forked from cms-sw/cmsdist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgcc.spec
284 lines (246 loc) · 9.75 KB
/
gcc.spec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
### RPM external gcc 10.3.0
## USE_COMPILER_VERSION
## INITENV +PATH LD_LIBRARY_PATH %{i}/lib64
# Use the git repository for fetching the sources. This gives us more control while developing
# a new platform so that we can compile yet to be released versions of the compiler.
# See: https://gcc.gnu.org/viewcvs/gcc/branches/gcc-8-branch/?view=log
%define gccTag f00b5710a30f22efc3171c393e56aeb335c3cd39
%define gccBranch releases/gcc-10
%define moduleName %{n}-%{realversion}
Source0: git+https://github.com/gcc-mirror/%{n}.git?obj=%{gccBranch}/%{gccTag}&export=%{moduleName}&output=/%{n}-%{realversion}-%{gccTag}.tgz
%define keep_archives true
%define gmpVersion 6.2.1
%define mpfrVersion 4.1.0
%define mpcVersion 1.2.1
%define islVersion 0.24
%define zlibVersion 1.2.11
Source1: https://gmplib.org/download/gmp/gmp-%{gmpVersion}.tar.bz2
Source2: http://www.mpfr.org/mpfr-%{mpfrVersion}/mpfr-%{mpfrVersion}.tar.bz2
Source3: https://ftp.gnu.org/gnu/mpc/mpc-%{mpcVersion}.tar.gz
Source4: http://isl.gforge.inria.fr/isl-%{islVersion}.tar.bz2
Source12: http://zlib.net/zlib-%{zlibVersion}.tar.gz
%ifos linux
%define bisonVersion 3.7.6
%define binutilsVersion 2.36.1
%define elfutilsVersion 0.183
%define m4Version 1.4.19
%define flexVersion 2.6.4
Source7: http://ftp.gnu.org/gnu/bison/bison-%{bisonVersion}.tar.gz
Source8: https://sourceware.org/pub/binutils/releases/binutils-%{binutilsVersion}.tar.bz2
Source9: https://sourceware.org/pub/elfutils/%{elfutilsVersion}/elfutils-%{elfutilsVersion}.tar.bz2
Source10: http://ftp.gnu.org/gnu/m4/m4-%{m4Version}.tar.gz
Source11: https://github.com/westes/flex/releases/download/v%{flexVersion}/flex-%{flexVersion}.tar.gz
%endif
Patch0: gcc-flex-nonfull-path-m4
Patch1: gcc-flex-disable-doc
Patch2: gcc-103-substitution-bug-fix
%prep
%setup -T -b 0 -n %{moduleName}
%patch2 -p1
# Filter out private stuff from RPM requires headers.
cat << \EOF > %{name}-req
#!/bin/sh
%{__find_requires} $* | \
sed -e '/GLIBC_PRIVATE/d'
EOF
%global __find_requires %{_builddir}/%{moduleName}/%{name}-req
chmod +x %{__find_requires}
%ifos linux
%ifarch x86_64
# Hack needed to align sections to 4096 bytes rather than 2MB on 64bit linux
# architectures. This is done to reduce the amount of address space wasted by
# relocating many libraries. This was done with a linker script before, but
# this approach seems to be more correct.
cat << \EOF_CONFIG_GCC >> gcc/config.gcc
# CMS patch to include gcc/config/i386/cms.h when building gcc
tm_file="$tm_file i386/cms.h"
EOF_CONFIG_GCC
cat << \EOF_CMS_H > gcc/config/i386/cms.h
#undef LINK_SPEC
#define LINK_SPEC "%{" SPEC_64 ":-m elf_x86_64} %{" SPEC_32 ":-m elf_i386} \
%{shared:-shared} \
%{!shared: \
%{!static: \
%{rdynamic:-export-dynamic} \
%{" SPEC_32 ":%{!dynamic-linker:-dynamic-linker " GNU_USER_DYNAMIC_LINKER32 "}} \
%{" SPEC_64 ":%{!dynamic-linker:-dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "}}} \
%{static:-static}} -z common-page-size=4096 -z max-page-size=4096"
EOF_CMS_H
%endif
%endif
cat << \EOF_CONFIG_GCC >> gcc/config.gcc
# CMS patch to include gcc/config/general-cms.h when building gcc
tm_file="$tm_file general-cms.h"
EOF_CONFIG_GCC
cat << \EOF_CMS_H > gcc/config/general-cms.h
#undef CC1PLUS_SPEC
#define CC1PLUS_SPEC "-fabi-version=0"
EOF_CMS_H
# GCC prerequisites
%setup -D -T -b 1 -n gmp-%{gmpVersion}
%setup -D -T -b 2 -n mpfr-%{mpfrVersion}
%setup -D -T -b 3 -n mpc-%{mpcVersion}
%setup -D -T -b 4 -n isl-%{islVersion}
%setup -D -T -b 12 -n zlib-%{zlibVersion}
%ifos linux
%setup -D -T -b 7 -n bison-%{bisonVersion}
%setup -D -T -b 8 -n binutils-%{binutilsVersion}
%setup -D -T -b 9 -n elfutils-%{elfutilsVersion}
%setup -D -T -b 10 -n m4-%{m4Version}
%setup -D -T -b 11 -n flex-%{flexVersion}
%patch0 -p1
%patch1 -p1
%endif
%build
%ifarch darwin
CC='clang'
CXX='clang++'
CPP='clang -E'
CXXCPP='clang++ -E'
ADDITIONAL_LANGUAGES=,objc,obj-c++
CONF_GCC_OS_SPEC=
%else
CC=gcc
CXX=c++
CPP=cpp
CXXCPP='c++ -E'
CONF_GCC_OS_SPEC=
%endif
CC="$CC -fPIC"
CXX="$CXX -fPIC"
mkdir -p %{i}/tmp/sw
export PATH=%{i}/tmp/sw/bin:$PATH
# Build zlib (required for compressed debug information)
cd ../zlib-%{zlibVersion}
CONF_FLAGS="-fPIC -O3 -DUSE_MMAP -DUNALIGNED_OK -D_LARGEFILE64_SOURCE=1"
%ifarch x86_64
CONF_FLAGS="${CONF_FLAGS} -msse3"
%endif
CFLAGS="${CONF_FLAGS}" ./configure --static --prefix=%{i}/tmp/sw
make %{makeprocesses}
make install
%ifos linux
CONF_BINUTILS_OPTS="--enable-ld=default --enable-lto --enable-plugins --enable-threads"
CONF_GCC_WITH_LTO="--enable-ld=default --enable-lto"
CONF_BINUTILS_OPTS="$CONF_BINUTILS_OPTS --enable-gold=yes"
CONF_GCC_WITH_LTO="$CONF_GCC_WITH_LTO --enable-gold=yes"
# Build M4 (for building)
cd ../m4-%{m4Version}
./configure --prefix=%{i}/tmp/sw \
--build=%{_build} --host=%{_host} \
CC="$CC"
make %{makeprocesses}
make install
hash -r
# Build Bison (for building)
cd ../bison-%{bisonVersion}
./configure --build=%{_build} --host=%{_host} \
--prefix=%{i}/tmp/sw CC="$CC"
make %{makeprocesses}
make install
hash -r
# Build Flex (for building)
cd ../flex-%{flexVersion}
./configure --disable-nls --prefix=%{i}/tmp/sw \
--build=%{_build} --host=%{_host} \
CC="$CC" CXX="$CXX"
make %{makeprocesses}
make install
hash -r
# Build Flex
cd ../flex-%{flexVersion}
./configure --disable-nls --prefix=%{i} \
--build=%{_build} --host=%{_host} \
CC="$CC" CXX="$CXX"
make %{makeprocesses}
make install
# Build elfutils
cd ../elfutils-%{elfutilsVersion}
./configure --disable-static --with-zlib --without-bzlib --without-lzma \
--disable-libdebuginfod --enable-libdebuginfod=dummy --disable-debuginfod \
--build=%{_build} --host=%{_host} --program-prefix='eu-' --disable-silent-rules \
--prefix=%{i} CC="gcc" \
CPPFLAGS="-I%{i}/tmp/sw/include" LDFLAGS="-L%{i}/tmp/sw/lib"
make %{makeprocesses}
make install
%ifarch ppc64le
CONF_BINUTILS_OPTS="${CONF_BINUTILS_OPTS} --enable-targets=spu --enable-targets=powerpc-linux"
%endif
# Build binutils
cd ../binutils-%{binutilsVersion}
./configure --disable-static --prefix=%{i} ${CONF_BINUTILS_OPTS} --disable-werror --enable-deterministic-archives \
--build=%{_build} --host=%{_host} --disable-nls --with-system-zlib --enable-64-bit-bfd \
CC="$CC" CXX="$CXX" CPP="$CPP" CXXCPP="$CXXCPP" CFLAGS="-I%{i}/include -I%{i}/tmp/sw/include" \
CXXFLAGS="-I%{i}/include -I%{i}/tmp/sw/include" LDFLAGS="-L%{i}/lib -L%{i}/tmp/sw/lib"
make %{makeprocesses}
find . -name Makefile -exec perl -p -i -e 's|LN = ln|LN = cp -p|;s|ln ([^-])|cp -p $1|g' {} \;
make install
%endif
# Build GMP
cd ../gmp-%{gmpVersion}
./configure --disable-static --prefix=%{i} --enable-shared --disable-static --enable-cxx \
--build=%{_build} --host=%{_host} \
CC="$CC" CXX="$CXX" CPP="$CPP" CXXCPP="$CXXCPP"
make %{makeprocesses}
make install
# Build MPFR
cd ../mpfr-%{mpfrVersion}
./configure --disable-static --prefix=%{i} --with-gmp=%{i} \
--build=%{_build} --host=%{_host} \
CC="$CC" CXX="$CXX" CPP="$CPP" CXXCPP="$CXXCPP"
make %{makeprocesses}
make install
# Build MPC
cd ../mpc-%{mpcVersion}
./configure --disable-static --prefix=%{i} --with-gmp=%{i} --with-mpfr=%{i} \
--build=%{_build} --host=%{_host} \
CC="$CC" CXX="$CXX" CPP="$CPP" CXXCPP="$CXXCPP"
make %{makeprocesses}
make install
# Build ISL
cd ../isl-%{islVersion}
./configure --disable-static --with-gmp-prefix=%i --prefix=%{i} \
--build=%{_build} --host=%{_host} \
CC="$CC" CXX="$CXX" CPP="$CPP" CXXCPP="$CXXCPP"
make %{makeprocesses}
make install
CONF_GCC_ARCH_SPEC=
%ifarch aarch64
CONF_GCC_ARCH_SPEC="$CONF_GCC_ARCH_SPEC \
--enable-threads=posix --enable-initfini-array --disable-libmpx"
%endif
%ifarch ppc64le
CONF_GCC_ARCH_SPEC="$CONF_GCC_ARCH_SPEC \
--enable-threads=posix --enable-initfini-array \
--enable-targets=powerpcle-linux --enable-secureplt --with-long-double-128 \
--with-cpu=power8 --with-tune=power8 --disable-libmpx"
%endif
# Build GCC
cd ../%{moduleName}
rm gcc/DEV-PHASE
touch gcc/DEV-PHASE
mkdir -p obj
cd obj
export LD_LIBRARY_PATH=%{i}/lib64:%{i}/lib:$LD_LIBRARY_PATH
../configure --prefix=%{i} --disable-multilib --disable-nls --disable-dssi \
--enable-languages=c,c++,fortran$ADDITIONAL_LANGUAGES --enable-gnu-indirect-function \
--enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object \
--enable-plugin --with-linker-hash-style=gnu --enable-linker-build-id \
$CONF_GCC_OS_SPEC $CONF_GCC_WITH_LTO --with-gmp=%{i} --with-mpfr=%{i} --enable-bootstrap \
--with-mpc=%{i} --with-isl=%{i} --enable-checking=release \
--build=%{_build} --host=%{_host} --enable-libstdcxx-time=rt $CONF_GCC_ARCH_SPEC \
--enable-shared --disable-libgcj CC="$CC" CXX="$CXX" CPP="$CPP" CXXCPP="$CXXCPP" \
CFLAGS="-I%{i}/tmp/sw/include" CXXFLAGS="-I%{i}/tmp/sw/include" LDFLAGS="-L%{i}/tmp/sw/lib"
make %{makeprocesses} profiledbootstrap
%install
cd %_builddir/%{moduleName}/obj && make install
ln -s gcc %{i}/bin/cc
find %{i}/lib %{i}/lib64 -name '*.la' -exec rm -f {} \; || true
# Remove unneeded documentation, temporary areas, unneeded files.
%define drop_files %{i}/share/{man,info,doc,locale} %{i}/tmp %{i}/lib*/{libstdc++.a,libsupc++.a}
# Strip things people will most likely never debug themself.
%define more_strip %{i}/bin/*{c++,g++,gcc,gfortran,gcov,cpp}*
%define strip_files %{i}/libexec/*/*/*/{cc1,cc1plus,f951,lto1,collect2} %{i}/x86_64*/bin %{i}/lib/lib{mpfr,gmp}* %{more_strip}
%define keep_archives yes
# This avoids having a dependency on the system pkg-config.
rm -rf %{i}/lib/pkg-config