1 |
davidlt |
1.107 |
### RPM external gcc 4.7.2
|
2 |
eulisse |
1.16 |
## INITENV +PATH LD_LIBRARY_PATH %i/lib64
|
3 |
eulisse |
1.102 |
#Source0: ftp://gcc.gnu.org/pub/gcc/snapshots/4.7.0-RC-20120302/gcc-4.7.0-RC-20120302.tar.bz2
|
4 |
|
|
# Use the svn repository for fetching the sources. This gives us more control while developing
|
5 |
|
|
# a new platform so that we can compile yet to be released versions of the compiler.
|
6 |
davidlt |
1.106 |
%define gccRevision 191558
|
7 |
eulisse |
1.102 |
%define gccBranch gcc-%(echo %realversion | cut -f1,2 -d. | tr . _)-branch
|
8 |
|
|
Source0: svn://gcc.gnu.org/svn/gcc/branches/%gccBranch?module=gcc-%gccBranch-%gccRevision&revision=%gccRevision&output=/gcc-%gccBranch-%gccRevision.tar.gz
|
9 |
eulisse |
1.83 |
|
10 |
|
|
%define keep_archives true
|
11 |
|
|
|
12 |
muzaffar |
1.94 |
# For gcc version >= 4.0.0, a number of additional sources are needed.
|
13 |
davidlt |
1.107 |
%define gmpVersion 5.0.5
|
14 |
|
|
%define mpfrVersion 3.1.1
|
15 |
|
|
%define mpcVersion 1.0.1
|
16 |
eulisse |
1.46 |
Source1: ftp://ftp.gnu.org/gnu/gmp/gmp-%{gmpVersion}.tar.bz2
|
17 |
|
|
Source2: http://www.mpfr.org/mpfr-%{mpfrVersion}/mpfr-%{mpfrVersion}.tar.bz2
|
18 |
elmer |
1.56 |
Source3: http://www.multiprecision.org/mpc/download/mpc-%{mpcVersion}.tar.gz
|
19 |
eulisse |
1.63 |
|
20 |
|
|
# For gcc 4.5+ we need the additional tools ppl and cloog.
|
21 |
|
|
%define gcc_45plus %(echo %realversion | sed -e 's|4[.][5-9].*|true|')
|
22 |
|
|
%if "%{gcc_45plus}" == "true"
|
23 |
davidlt |
1.107 |
%define pplVersion 1.0
|
24 |
|
|
%define cloogVersion 0.17.0
|
25 |
lat |
1.87 |
Source4: http://bugseng.com/products/ppl/download/ftp/releases/%{pplVersion}/ppl-%{pplVersion}.tar.bz2
|
26 |
elmer |
1.67 |
Source5: ftp://gcc.gnu.org/pub/gcc/infrastructure/cloog-%{cloogVersion}.tar.gz
|
27 |
eulisse |
1.63 |
%endif
|
28 |
eulisse |
1.18 |
|
29 |
eulisse |
1.63 |
# On 64bit Scientific Linux build our own binutils.
|
30 |
eulisse |
1.93 |
# Notice that since we don't support building 32bit nor slc4 anymore.
|
31 |
|
|
%define use_custom_binutils %(case %cmsos in (slc*) echo true ;; (*) echo false ;; esac)
|
32 |
eulisse |
1.63 |
%if "%use_custom_binutils" == "true"
|
33 |
davidlt |
1.107 |
%define bisonVersion 2.6.2
|
34 |
elmer |
1.60 |
Source6: http://ftp.gnu.org/gnu/bison/bison-%{bisonVersion}.tar.bz2
|
35 |
eulisse |
1.102 |
%define binutilsv 2.22
|
36 |
lat |
1.80 |
Source7: http://ftp.gnu.org/gnu/binutils/binutils-%binutilsv.tar.bz2
|
37 |
|
|
#Source7: http://cmsrep.cern.ch/cmssw/binutils-mirror/binutils-%binutilsv.tar.bz2
|
38 |
|
|
#Source7: http://www.kernel.org/pub/linux/devel/binutils/binutils-%binutilsv.tar.bz2
|
39 |
elmer |
1.57 |
%endif
|
40 |
|
|
|
41 |
eulisse |
1.65 |
# gcc 4.5+ link time optimization support requires libelf to work. However
|
42 |
|
|
# also rpm requires it. In order to have to duplicate dependencies we
|
43 |
|
|
# build it in gcc and we pick it up from there also for rpm. Notice that
|
44 |
|
|
# libelf does not work on Macosx however this is not a problem until
|
45 |
|
|
# we use the system compiler there.
|
46 |
eulisse |
1.93 |
%define isslc %(case %cmsos in (slc*) echo true ;; (*) echo false ;; esac)
|
47 |
davidlt |
1.107 |
%define elfutilsVersion 0.155
|
48 |
eulisse |
1.65 |
%if "%isslc" == "true"
|
49 |
eulisse |
1.84 |
Source8: https://fedorahosted.org/releases/e/l/elfutils/%{elfutilsVersion}/elfutils-%{elfutilsVersion}.tar.bz2
|
50 |
eulisse |
1.65 |
%endif
|
51 |
davidlt |
1.107 |
Patch2: https://fedorahosted.org/releases/e/l/elfutils/%{elfutilsVersion}/elfutils-portability.patch
|
52 |
eulisse |
1.65 |
|
53 |
eulisse |
1.16 |
%prep
|
54 |
eulisse |
1.63 |
echo "use_custom_binutils: %use_custom_binutils"
|
55 |
eulisse |
1.102 |
%setup -T -b 0 -n gcc-%gccBranch-%gccRevision
|
56 |
dlange |
1.15 |
|
57 |
elmer |
1.43 |
case %cmsos in
|
58 |
eulisse |
1.99 |
slc*_gcc4[0-6]*)
|
59 |
eulisse |
1.63 |
# Hack needed to align sections to 4096 bytes rather than 2MB on 64bit linux
|
60 |
|
|
# architectures. This is done to reduce the amount of address space wasted by
|
61 |
|
|
# relocating many libraries. This was done with a linker script before, but
|
62 |
|
|
# this approach seems to be more correct.
|
63 |
eulisse |
1.62 |
cat << \EOF_CONFIG_GCC >> gcc/config.gcc
|
64 |
|
|
# CMS patch to include gcc/config/i386/t-cms when building gcc
|
65 |
|
|
tm_file="$tm_file i386/cms.h"
|
66 |
|
|
EOF_CONFIG_GCC
|
67 |
|
|
|
68 |
|
|
cat << \EOF_CMS_H > gcc/config/i386/cms.h
|
69 |
|
|
#undef LINK_SPEC
|
70 |
|
|
#define LINK_SPEC "%{" SPEC_64 ":-m elf_x86_64} %{" SPEC_32 ":-m elf_i386} \
|
71 |
|
|
%{shared:-shared} \
|
72 |
|
|
%{!shared: \
|
73 |
|
|
%{!static: \
|
74 |
|
|
%{rdynamic:-export-dynamic} \
|
75 |
|
|
%{" SPEC_32 ":%{!dynamic-linker:-dynamic-linker " LINUX_DYNAMIC_LINKER32 "}} \
|
76 |
|
|
%{" SPEC_64 ":%{!dynamic-linker:-dynamic-linker " LINUX_DYNAMIC_LINKER64 "}}} \
|
77 |
|
|
%{static:-static}} -z common-page-size=4096 -z max-page-size=4096"
|
78 |
|
|
EOF_CMS_H
|
79 |
|
|
;;
|
80 |
eulisse |
1.99 |
slc*)
|
81 |
|
|
# Hack needed to align sections to 4096 bytes rather than 2MB on 64bit linux
|
82 |
|
|
# architectures. This is done to reduce the amount of address space wasted by
|
83 |
|
|
# relocating many libraries. This was done with a linker script before, but
|
84 |
|
|
# this approach seems to be more correct.
|
85 |
|
|
cat << \EOF_CONFIG_GCC >> gcc/config.gcc
|
86 |
|
|
# CMS patch to include gcc/config/i386/t-cms when building gcc
|
87 |
|
|
tm_file="$tm_file i386/cms.h"
|
88 |
|
|
EOF_CONFIG_GCC
|
89 |
|
|
|
90 |
|
|
cat << \EOF_CMS_H > gcc/config/i386/cms.h
|
91 |
|
|
#undef LINK_SPEC
|
92 |
|
|
#define LINK_SPEC "%{" SPEC_64 ":-m elf_x86_64} %{" SPEC_32 ":-m elf_i386} \
|
93 |
|
|
%{shared:-shared} \
|
94 |
|
|
%{!shared: \
|
95 |
|
|
%{!static: \
|
96 |
|
|
%{rdynamic:-export-dynamic} \
|
97 |
|
|
%{" SPEC_32 ":%{!dynamic-linker:-dynamic-linker " GNU_USER_DYNAMIC_LINKER32 "}} \
|
98 |
|
|
%{" SPEC_64 ":%{!dynamic-linker:-dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "}}} \
|
99 |
|
|
%{static:-static}} -z common-page-size=4096 -z max-page-size=4096"
|
100 |
|
|
EOF_CMS_H
|
101 |
|
|
;;
|
102 |
elmer |
1.43 |
esac
|
103 |
dlange |
1.15 |
|
104 |
eulisse |
1.93 |
case %cmsos in
|
105 |
|
|
slc*_corei7)
|
106 |
|
|
cat << \EOF_CMS_H >> gcc/config/i386/cms.h
|
107 |
|
|
#undef ASM_SPEC
|
108 |
|
|
#define ASM_SPEC "%%{v:-V} %%{Qy:} %%{!Qn:-Qy} %%{n} %%{T} %%{Ym,*} %%{Yd,*} %%{Wa,*:%%*} -march=corei7 -mtune=corei7"
|
109 |
|
|
#undef CC1_SPEC
|
110 |
|
|
#define CC1_SPEC "%%(cc1_cpu) %%{profile:-p} -march=corei7 -mtune=corei7"
|
111 |
|
|
#undef CC1PLUS_SPEC
|
112 |
|
|
#define CC1PLUS_SPEC "-march=corei7"
|
113 |
|
|
EOF_CMS_H
|
114 |
|
|
;;
|
115 |
|
|
esac
|
116 |
|
|
|
117 |
eulisse |
1.63 |
%if "%{use_custom_binutils}" == "true"
|
118 |
elmer |
1.60 |
%setup -D -T -b 6 -n bison-%{bisonVersion}
|
119 |
|
|
%setup -D -T -b 7 -n binutils-%binutilsv
|
120 |
eulisse |
1.46 |
%endif
|
121 |
|
|
|
122 |
eulisse |
1.63 |
# These are required for any gcc 4.x build.
|
123 |
eulisse |
1.46 |
%setup -D -T -b 1 -n gmp-%{gmpVersion}
|
124 |
|
|
%setup -D -T -b 2 -n mpfr-%{mpfrVersion}
|
125 |
elmer |
1.56 |
%setup -D -T -b 3 -n mpc-%{mpcVersion}
|
126 |
eulisse |
1.63 |
|
127 |
|
|
# For gcc 4.5 and later we also need the following.
|
128 |
|
|
%if "%gcc_45plus" == "true"
|
129 |
elmer |
1.57 |
%setup -D -T -b 4 -n ppl-%{pplVersion}
|
130 |
elmer |
1.67 |
%setup -D -T -b 5 -n cloog-%{cloogVersion}
|
131 |
eulisse |
1.63 |
%endif
|
132 |
eulisse |
1.65 |
|
133 |
|
|
# These are required by rpm as well, but only on linux.
|
134 |
|
|
%if "%isslc" == "true"
|
135 |
|
|
%setup -D -T -b 8 -n elfutils-%{elfutilsVersion}
|
136 |
eulisse |
1.85 |
%patch2 -p1
|
137 |
eulisse |
1.65 |
%endif
|
138 |
|
|
|
139 |
eulisse |
1.63 |
%build
|
140 |
eulisse |
1.77 |
# On mac we need to use gcc-proper, not gcc-llvm
|
141 |
eulisse |
1.63 |
case %{cmsos} in
|
142 |
eulisse |
1.95 |
osx10[0-6]*)
|
143 |
davidlt |
1.98 |
CC='/usr/bin/gcc-4.2'
|
144 |
|
|
CXX='/usr/bin/c++-4.2'
|
145 |
|
|
CPP='/usr/bin/cpp-4.2'
|
146 |
|
|
CXXCPP='/usr/bin/c++-4.2 -E'
|
147 |
eulisse |
1.77 |
ADDITIONAL_LANGUAGES=,objc,obj-c++
|
148 |
lat |
1.80 |
|
149 |
|
|
# Apparently must emulate apple compiler even if we build
|
150 |
|
|
# full chain ourselves, as things come in via system libs.
|
151 |
|
|
# - http://newartisans.com/2009/10/a-c-gotcha-on-snow-leopard/
|
152 |
|
|
# - http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41645
|
153 |
|
|
# - http://trac.macports.org/ticket/25205 (and 22234)
|
154 |
|
|
CONF_GCC_OS_SPEC=--enable-fully-dynamic-string
|
155 |
eulisse |
1.77 |
;;
|
156 |
eulisse |
1.95 |
osx*)
|
157 |
davidlt |
1.105 |
CC='clang'
|
158 |
|
|
CXX='clang++'
|
159 |
|
|
CPP='clang -E'
|
160 |
|
|
CXXCPP='clang++ -E'
|
161 |
eulisse |
1.95 |
ADDITIONAL_LANGUAGES=,objc,obj-c++
|
162 |
davidlt |
1.98 |
|
163 |
|
|
# Disable for Lion (10.7.X) otherwise ld will fail on libgfortran.la
|
164 |
|
|
#CONF_GCC_OS_SPEC=--enable-fully-dynamic-string
|
165 |
eulisse |
1.95 |
;;
|
166 |
eulisse |
1.63 |
*)
|
167 |
eulisse |
1.77 |
CC=gcc
|
168 |
|
|
CXX=c++
|
169 |
|
|
CPP=cpp
|
170 |
davidlt |
1.98 |
CXXCPP='c++ -E'
|
171 |
lat |
1.80 |
CONF_GCC_OS_SPEC=
|
172 |
eulisse |
1.77 |
;;
|
173 |
eulisse |
1.20 |
esac
|
174 |
eulisse |
1.59 |
|
175 |
eulisse |
1.77 |
CC="$CC -fPIC"
|
176 |
|
|
CXX="$CXX -fPIC"
|
177 |
|
|
|
178 |
eulisse |
1.63 |
# Whenever we build custom binutils we also enable the new linker "gold".
|
179 |
|
|
# We do so only if we are using the new gcc 4.5+
|
180 |
|
|
if [ "X%use_custom_binutils:%gcc_45plus" = Xtrue:true ] ; then
|
181 |
elmer |
1.75 |
CONF_BINUTILS_OPTS="--enable-gold=default --enable-lto --enable-plugins --enable-threads"
|
182 |
lat |
1.86 |
CONF_GCC_WITH_LTO="--enable-gold=yes --enable-lto" # --with-build-config=bootstrap-lto
|
183 |
eulisse |
1.63 |
fi
|
184 |
|
|
|
185 |
eulisse |
1.65 |
# Build libelf.
|
186 |
|
|
if [ "X%isslc" = Xtrue ]; then
|
187 |
|
|
cd ../elfutils-%{elfutilsVersion}
|
188 |
eulisse |
1.102 |
./configure --disable-static --without-zlib \
|
189 |
|
|
--without-bzlib --without-lzma \
|
190 |
|
|
--prefix=%i CC="$CC" CXX="$CXX -Wno-strict-aliasing" CPP="$CPP" CXXCPP="$CXXCPP"
|
191 |
eulisse |
1.65 |
make %makeprocesses
|
192 |
|
|
make install
|
193 |
|
|
fi
|
194 |
|
|
|
195 |
eulisse |
1.63 |
# If requested, build our own binutils. Currently the default is to use the
|
196 |
|
|
# system binutils on 32bit platforms and our own on 64 bit ones.
|
197 |
|
|
# FIXME: Notice that this copy is actually built using the system compiler, so
|
198 |
|
|
# we chances are we will need to rebuild it later on to make sure they get
|
199 |
|
|
# linked against our libstdc++ (required by gold).
|
200 |
|
|
if [ "X%use_custom_binutils" = Xtrue ]
|
201 |
|
|
then
|
202 |
|
|
cd ../bison-%{bisonVersion}
|
203 |
eulisse |
1.77 |
CC="$CC" ./configure --prefix=%i/tmp/bison
|
204 |
eulisse |
1.63 |
make %makeprocesses
|
205 |
|
|
make install
|
206 |
|
|
export PATH=%i/tmp/bison/bin:$PATH
|
207 |
|
|
cd ../binutils-%{binutilsv}
|
208 |
eulisse |
1.74 |
# Try to avoid dependency on makeinfo by forcing make not
|
209 |
|
|
# to build the documentation.
|
210 |
|
|
perl -p -i -e 's|SUBDIRS = .*|SUBDIRS =|' bfd/Makefile.in binutils/Makefile.in gas/Makefile.in
|
211 |
eulisse |
1.73 |
perl -p -i -e 's|all: info|all:|' etc/Makefile.in
|
212 |
eulisse |
1.74 |
perl -p -i -e 's|TEXINFOS =.*|TEXINFOS =|;s|INFO_DEPS =.*|INFO_DEPS =|' gprof/Makefile.in
|
213 |
|
|
perl -p -i -e 's|man_MANS =.*|man_MANS =|' gprof/Makefile.in
|
214 |
|
|
perl -p -i -e 's|INFO_DEPS =.*|INFO_DEPS =|' ld/Makefile.in
|
215 |
|
|
perl -p -i -e 's|INFOFILES =.*|INFOFILES =|' etc/Makefile.in
|
216 |
|
|
perl -p -i -e 's|DVIFILES =.*|DVIFILES =|' etc/Makefile.in
|
217 |
|
|
perl -p -i -e 's|PDFFILES =.*|PDFFILES =|' etc/Makefile.in
|
218 |
|
|
perl -p -i -e 's|HTMLFILES =.*|HTMLFILES =|' etc/Makefile.in
|
219 |
eulisse |
1.73 |
|
220 |
eulisse |
1.79 |
./configure --disable-static --prefix=%i ${CONF_BINUTILS_OPTS} --disable-werror \
|
221 |
davidlt |
1.98 |
CC="$CC" CXX="$CXX" CPP="$CPP" CXXCPP="$CXXCPP" CFLAGS="-I%i/include" \
|
222 |
eulisse |
1.65 |
CXXFLAGS="-I%i/include" LDFLAGS="-L%i/lib"
|
223 |
eulisse |
1.63 |
make %makeprocesses
|
224 |
|
|
find . -name Makefile -exec perl -p -i -e 's|LN = ln|LN = cp -p|;s|ln ([^-])|cp -p $1|g' {} \;
|
225 |
|
|
make install
|
226 |
|
|
which ld
|
227 |
|
|
fi
|
228 |
eulisse |
1.16 |
|
229 |
eulisse |
1.63 |
# Build GMP/MPFR/MPC
|
230 |
eulisse |
1.19 |
cd ../gmp-%{gmpVersion}
|
231 |
davidlt |
1.98 |
./configure --disable-static --prefix=%i --enable-shared --disable-static --enable-cxx \
|
232 |
|
|
CC="$CC" CXX="$CXX" CPP="$CPP" CXXCPP="$CXXCPP"
|
233 |
eulisse |
1.19 |
make %makeprocesses
|
234 |
eulisse |
1.20 |
make install
|
235 |
eulisse |
1.19 |
|
236 |
|
|
cd ../mpfr-%{mpfrVersion}
|
237 |
davidlt |
1.98 |
./configure --disable-static --prefix=%i --with-gmp=%i CC="$CC" CXX="$CXX" CPP="$CPP" CXXCPP="$CXXCPP"
|
238 |
eulisse |
1.19 |
make %makeprocesses
|
239 |
eulisse |
1.31 |
make install
|
240 |
elmer |
1.56 |
|
241 |
|
|
cd ../mpc-%{mpcVersion}
|
242 |
davidlt |
1.98 |
./configure --disable-static --prefix=%i --with-gmp=%i --with-mpfr=%i CC="$CC" CXX="$CXX" \
|
243 |
|
|
CPP="$CPP" CXXCPP="$CXXCPP"
|
244 |
elmer |
1.56 |
make %makeprocesses
|
245 |
|
|
make install
|
246 |
eulisse |
1.63 |
CONF_GCC_VERSION_OPTS="--with-gmp=%i --with-mpfr=%i --with-mpc=%i"
|
247 |
elmer |
1.56 |
|
248 |
eulisse |
1.63 |
# Build additional stuff for gcc 4.5+
|
249 |
|
|
if [ "X%gcc_45plus" = Xtrue ]; then
|
250 |
|
|
cd ../ppl-%{pplVersion}
|
251 |
eulisse |
1.102 |
./configure --disable-static --with-gmp=%i --with-cxxflags="-I%i/include" \
|
252 |
davidlt |
1.98 |
--enable-interfaces=c --prefix=%i CC="$CC" CXX="$CXX" CPP="$CPP" CXXCPP="$CXXCPP" \
|
253 |
|
|
LDFLAGS="-L%i/lib"
|
254 |
eulisse |
1.63 |
make %makeprocesses
|
255 |
|
|
make install
|
256 |
|
|
|
257 |
elmer |
1.67 |
cd ../cloog-%{cloogVersion}
|
258 |
davidlt |
1.98 |
./configure --disable-static --prefix=%i --with-ppl=%i --with-gmp-prefix=%i CC="$CC" \
|
259 |
|
|
CXX="$CXX" CPP="$CPP" CXXCPP="$CXXCPP"
|
260 |
eulisse |
1.63 |
make %makeprocesses
|
261 |
|
|
make install
|
262 |
elmer |
1.57 |
|
263 |
elmer |
1.67 |
CONF_GCC_VERSION_OPTS="$CONF_GCC_VERSION_OPTS --with-ppl=%i --with-cloog=%i --enable-cloog-backend=isl"
|
264 |
eulisse |
1.63 |
fi
|
265 |
eulisse |
1.19 |
|
266 |
eulisse |
1.20 |
# Build the compilers
|
267 |
eulisse |
1.102 |
cd ../gcc-%gccBranch-%gccRevision
|
268 |
eulisse |
1.18 |
mkdir -p obj
|
269 |
|
|
cd obj
|
270 |
eulisse |
1.59 |
export LD_LIBRARY_PATH=%i/lib64:%i/lib:$LD_LIBRARY_PATH
|
271 |
lat |
1.80 |
../configure --prefix=%i --disable-multilib --disable-nls \
|
272 |
eulisse |
1.77 |
--enable-languages=c,c++,fortran$ADDITIONAL_LANGUAGES \
|
273 |
lat |
1.80 |
$CONF_GCC_OS_SPEC $CONF_GCC_WITH_LTO $CONF_GCC_VERSION_OPTS \
|
274 |
davidlt |
1.98 |
--enable-shared CC="$CC" CXX="$CXX" CPP="$CPP" CXXCPP="$CXXCPP"
|
275 |
eulisse |
1.18 |
|
276 |
|
|
make %makeprocesses bootstrap
|
277 |
eulisse |
1.63 |
make install
|
278 |
eulisse |
1.16 |
|
279 |
argiro |
1.1 |
%install
|
280 |
eulisse |
1.102 |
cd %_builddir/gcc-%gccBranch-%gccRevision/obj && make install
|
281 |
eulisse |
1.51 |
|
282 |
argiro |
1.1 |
ln -s gcc %i/bin/cc
|
283 |
eulisse |
1.77 |
find %i/lib %i/lib64 -name '*.la' -exec rm -f {} \; || true
|
284 |
eulisse |
1.79 |
|
285 |
eulisse |
1.83 |
# Remove unneeded documentation, temporary areas, unneeded files.
|
286 |
|
|
%define drop_files %i/share/{man,info,doc,locale} %i/tmp %i/lib*/{libstdc++.a,libsupc++.a}
|
287 |
eulisse |
1.79 |
# Strip things people will most likely never debug themself.
|
288 |
eulisse |
1.83 |
%define more_strip %i/bin/*{c++,g++,gcc,gfortran,gcov,ppl,cloog,cpp}*
|
289 |
lat |
1.86 |
%define strip_files %i/libexec/*/*/*/{cc1,cc1plus,f951,lto1,collect2} %i/x86_64*/bin %i/lib/lib{mpfr,ppl,gmp,cloog}* %more_strip
|
290 |
eulisse |
1.83 |
%define keep_archives yes
|
291 |
eulisse |
1.79 |
# This avoids having a dependency on the system pkg-config.
|
292 |
|
|
rm -rf %i/lib/pkg-config
|