1 |
< |
### RPM external gcc 3.2.3 |
2 |
< |
## BUILDIF [ $(uname) != Darwin ] |
3 |
< |
Source: ftp://ftp.fu-berlin.de/unix/gnu/%n/%n-%v/%n-%v.tar.gz |
1 |
> |
### RPM external gcc 4.6.1 |
2 |
> |
## INITENV +PATH LD_LIBRARY_PATH %i/lib/32 |
3 |
> |
## INITENV +PATH LD_LIBRARY_PATH %i/lib64 |
4 |
> |
Source0: ftp://ftp.fu-berlin.de/unix/gnu/%n/%n-%realversion/%n-%realversion.tar.bz2 |
5 |
> |
# For gcc version >= 4.0.0, a number of additional sources are needed. |
6 |
> |
%define gmpVersion 5.0.2 |
7 |
> |
%define mpfrVersion 3.0.1 |
8 |
> |
%define mpcVersion 0.9 |
9 |
> |
Source1: ftp://ftp.gnu.org/gnu/gmp/gmp-%{gmpVersion}.tar.bz2 |
10 |
> |
Source2: http://www.mpfr.org/mpfr-%{mpfrVersion}/mpfr-%{mpfrVersion}.tar.bz2 |
11 |
> |
Source3: http://www.multiprecision.org/mpc/download/mpc-%{mpcVersion}.tar.gz |
12 |
> |
|
13 |
> |
# For gcc 4.5+ we need the additional tools ppl and cloog. |
14 |
> |
%define gcc_45plus %(echo %realversion | sed -e 's|4[.][5-9].*|true|') |
15 |
> |
%if "%{gcc_45plus}" == "true" |
16 |
> |
%define pplVersion 0.11.2 |
17 |
> |
%define cloogVersion 0.16.2 |
18 |
> |
Source4: http://www.cs.unipr.it/ppl/Download/ftp/releases/%{pplVersion}/ppl-%{pplVersion}.tar.bz2 |
19 |
> |
Source5: ftp://gcc.gnu.org/pub/gcc/infrastructure/cloog-%{cloogVersion}.tar.gz |
20 |
> |
%endif |
21 |
> |
|
22 |
> |
# On 64bit Scientific Linux build our own binutils. |
23 |
> |
%define use_custom_binutils %(echo %cmsos | sed -e 's|slc[0-9]*_amd64|true|') |
24 |
> |
%if "%use_custom_binutils" == "true" |
25 |
> |
%define bisonVersion 2.4 |
26 |
> |
Source6: http://ftp.gnu.org/gnu/bison/bison-%{bisonVersion}.tar.bz2 |
27 |
> |
%define binutilsv 2.21.53.0.2 |
28 |
> |
#Source7: http://ftp.gnu.org/gnu/binutils/binutils-%binutilsv.tar.bz2 |
29 |
> |
Source7: http://www.kernel.org/pub/linux/devel/binutils/binutils-%binutilsv.tar.bz2 |
30 |
> |
%endif |
31 |
> |
|
32 |
> |
# gcc 4.5+ link time optimization support requires libelf to work. However |
33 |
> |
# also rpm requires it. In order to have to duplicate dependencies we |
34 |
> |
# build it in gcc and we pick it up from there also for rpm. Notice that |
35 |
> |
# libelf does not work on Macosx however this is not a problem until |
36 |
> |
# we use the system compiler there. |
37 |
> |
%define isslc %(echo %cmsos | sed -e 's|slc.*|true|') |
38 |
> |
%define elfutilsVersion 0.131 |
39 |
> |
%if "%isslc" == "true" |
40 |
> |
Source8: ftp://sources.redhat.com/pub/systemtap/elfutils/elfutils-%{elfutilsVersion}.tar.gz |
41 |
> |
%endif |
42 |
> |
Patch0: gcc-4.6.1-ignore-arch-flags-macosx |
43 |
> |
|
44 |
> |
%prep |
45 |
> |
echo "use_custom_binutils: %use_custom_binutils" |
46 |
> |
%setup -T -b 0 -n gcc-%realversion |
47 |
> |
# Get the macosx build to accept -arch, -F options like the official Apple one. |
48 |
> |
# Notice that patch command have to stay on a single line. |
49 |
> |
case %cmsos in |
50 |
> |
osx*) |
51 |
> |
%patch0 -p1 |
52 |
> |
;; |
53 |
> |
esac |
54 |
> |
|
55 |
> |
case %cmsos in |
56 |
> |
slc*_amd64 ) |
57 |
> |
# Hack needed to align sections to 4096 bytes rather than 2MB on 64bit linux |
58 |
> |
# architectures. This is done to reduce the amount of address space wasted by |
59 |
> |
# relocating many libraries. This was done with a linker script before, but |
60 |
> |
# this approach seems to be more correct. |
61 |
> |
cat << \EOF_CONFIG_GCC >> gcc/config.gcc |
62 |
> |
# CMS patch to include gcc/config/i386/t-cms when building gcc |
63 |
> |
tm_file="$tm_file i386/cms.h" |
64 |
> |
EOF_CONFIG_GCC |
65 |
> |
|
66 |
> |
cat << \EOF_CMS_H > gcc/config/i386/cms.h |
67 |
> |
#undef LINK_SPEC |
68 |
> |
#define LINK_SPEC "%{" SPEC_64 ":-m elf_x86_64} %{" SPEC_32 ":-m elf_i386} \ |
69 |
> |
%{shared:-shared} \ |
70 |
> |
%{!shared: \ |
71 |
> |
%{!static: \ |
72 |
> |
%{rdynamic:-export-dynamic} \ |
73 |
> |
%{" SPEC_32 ":%{!dynamic-linker:-dynamic-linker " LINUX_DYNAMIC_LINKER32 "}} \ |
74 |
> |
%{" SPEC_64 ":%{!dynamic-linker:-dynamic-linker " LINUX_DYNAMIC_LINKER64 "}}} \ |
75 |
> |
%{static:-static}} -z common-page-size=4096 -z max-page-size=4096" |
76 |
> |
EOF_CMS_H |
77 |
> |
;; |
78 |
> |
esac |
79 |
> |
|
80 |
> |
%if "%{use_custom_binutils}" == "true" |
81 |
> |
%setup -D -T -b 6 -n bison-%{bisonVersion} |
82 |
> |
%setup -D -T -b 7 -n binutils-%binutilsv |
83 |
> |
%endif |
84 |
> |
|
85 |
> |
# These are required for any gcc 4.x build. |
86 |
> |
%setup -D -T -b 1 -n gmp-%{gmpVersion} |
87 |
> |
%setup -D -T -b 2 -n mpfr-%{mpfrVersion} |
88 |
> |
%setup -D -T -b 3 -n mpc-%{mpcVersion} |
89 |
> |
|
90 |
> |
# For gcc 4.5 and later we also need the following. |
91 |
> |
%if "%gcc_45plus" == "true" |
92 |
> |
%setup -D -T -b 4 -n ppl-%{pplVersion} |
93 |
> |
%setup -D -T -b 5 -n cloog-%{cloogVersion} |
94 |
> |
%endif |
95 |
> |
|
96 |
> |
# These are required by rpm as well, but only on linux. |
97 |
> |
%if "%isslc" == "true" |
98 |
> |
%setup -D -T -b 8 -n elfutils-%{elfutilsVersion} |
99 |
> |
%endif |
100 |
|
|
101 |
|
%build |
102 |
< |
# FIXME: --enable-__cxa_atexit can't be used with gcc 3.2.3 on RH 7.3, |
103 |
< |
# enabling it causes qt's uic to die with segmentation violation half |
104 |
< |
# way down the build of qt (projecsettings.ui or something like that; |
105 |
< |
# not the first or only call to uic). Disabling the flag removes the |
106 |
< |
# issue, so clearly the option does not work correctly on this |
107 |
< |
# platform combination. |
102 |
> |
# On mac we need to use gcc-proper, not gcc-llvm |
103 |
> |
case %{cmsos} in |
104 |
> |
osx*) |
105 |
> |
CC=/usr/bin/gcc-4.2 |
106 |
> |
CXX=/usr/bin/c++-4.2 |
107 |
> |
CPP=/usr/bin/cpp-4.2 |
108 |
> |
ADDITIONAL_LANGUAGES=,objc,obj-c++ |
109 |
> |
;; |
110 |
> |
*) |
111 |
> |
CC=gcc |
112 |
> |
CXX=c++ |
113 |
> |
CPP=cpp |
114 |
> |
;; |
115 |
> |
esac |
116 |
> |
|
117 |
> |
CC="$CC -fPIC" |
118 |
> |
CXX="$CXX -fPIC" |
119 |
> |
|
120 |
> |
# Whenever we build custom binutils we also enable the new linker "gold". |
121 |
> |
# We do so only if we are using the new gcc 4.5+ |
122 |
> |
if [ "X%use_custom_binutils:%gcc_45plus" = Xtrue:true ] ; then |
123 |
> |
CONF_BINUTILS_OPTS="--enable-gold=default --enable-lto --enable-plugins --enable-threads" |
124 |
> |
fi |
125 |
> |
|
126 |
> |
# Build libelf. |
127 |
> |
if [ "X%isslc" = Xtrue ]; then |
128 |
> |
cd ../elfutils-%{elfutilsVersion} |
129 |
> |
./configure --prefix=%i CC="$CC" CXX="$CXX" CPP="$CPP" |
130 |
> |
make %makeprocesses |
131 |
> |
make install |
132 |
> |
fi |
133 |
> |
|
134 |
> |
# If requested, build our own binutils. Currently the default is to use the |
135 |
> |
# system binutils on 32bit platforms and our own on 64 bit ones. |
136 |
> |
# FIXME: Notice that this copy is actually built using the system compiler, so |
137 |
> |
# we chances are we will need to rebuild it later on to make sure they get |
138 |
> |
# linked against our libstdc++ (required by gold). |
139 |
> |
if [ "X%use_custom_binutils" = Xtrue ] |
140 |
> |
then |
141 |
> |
cd ../bison-%{bisonVersion} |
142 |
> |
CC="$CC" ./configure --prefix=%i/tmp/bison |
143 |
> |
make %makeprocesses |
144 |
> |
make install |
145 |
> |
export PATH=%i/tmp/bison/bin:$PATH |
146 |
> |
cd ../binutils-%{binutilsv} |
147 |
> |
# Try to avoid dependency on makeinfo by forcing make not |
148 |
> |
# to build the documentation. |
149 |
> |
perl -p -i -e 's|SUBDIRS = .*|SUBDIRS =|' bfd/Makefile.in binutils/Makefile.in gas/Makefile.in |
150 |
> |
perl -p -i -e 's|all: info|all:|' etc/Makefile.in |
151 |
> |
perl -p -i -e 's|TEXINFOS =.*|TEXINFOS =|;s|INFO_DEPS =.*|INFO_DEPS =|' gprof/Makefile.in |
152 |
> |
perl -p -i -e 's|man_MANS =.*|man_MANS =|' gprof/Makefile.in |
153 |
> |
perl -p -i -e 's|INFO_DEPS =.*|INFO_DEPS =|' ld/Makefile.in |
154 |
> |
perl -p -i -e 's|INFOFILES =.*|INFOFILES =|' etc/Makefile.in |
155 |
> |
perl -p -i -e 's|DVIFILES =.*|DVIFILES =|' etc/Makefile.in |
156 |
> |
perl -p -i -e 's|PDFFILES =.*|PDFFILES =|' etc/Makefile.in |
157 |
> |
perl -p -i -e 's|HTMLFILES =.*|HTMLFILES =|' etc/Makefile.in |
158 |
> |
|
159 |
> |
./configure --prefix=%i ${CONF_BINUTILS_OPTS} --disable-werror \ |
160 |
> |
CC="$CC" CXX="$CXX" CPP="$CPP" CFLAGS="-I%i/include" \ |
161 |
> |
CXXFLAGS="-I%i/include" LDFLAGS="-L%i/lib" |
162 |
> |
make %makeprocesses |
163 |
> |
find . -name Makefile -exec perl -p -i -e 's|LN = ln|LN = cp -p|;s|ln ([^-])|cp -p $1|g' {} \; |
164 |
> |
make install |
165 |
> |
which ld |
166 |
> |
fi |
167 |
> |
|
168 |
> |
# Build GMP/MPFR/MPC |
169 |
> |
cd ../gmp-%{gmpVersion} |
170 |
> |
./configure --prefix=%i --enable-shared --disable-static --enable-cxx CC="$CC" CXX="$CXX" CPP="$CPP" |
171 |
> |
make %makeprocesses |
172 |
> |
make install |
173 |
> |
|
174 |
> |
cd ../mpfr-%{mpfrVersion} |
175 |
> |
./configure --prefix=%i --with-gmp=%i CC="$CC" CXX="$CXX" CPP="$CPP" |
176 |
> |
make %makeprocesses |
177 |
> |
make install |
178 |
> |
|
179 |
> |
cd ../mpc-%{mpcVersion} |
180 |
> |
./configure --prefix=%i --with-gmp=%i --with-mpfr=%i CC="$CC" CXX="$CXX" CPP="$CPP" |
181 |
> |
make %makeprocesses |
182 |
> |
make install |
183 |
> |
CONF_GCC_VERSION_OPTS="--with-gmp=%i --with-mpfr=%i --with-mpc=%i" |
184 |
> |
|
185 |
> |
# Build additional stuff for gcc 4.5+ |
186 |
> |
if [ "X%gcc_45plus" = Xtrue ]; then |
187 |
> |
cd ../ppl-%{pplVersion} |
188 |
> |
./configure --prefix=%i CC="$CC" CXX="$CXX" CPP="$CPP" |
189 |
> |
make %makeprocesses |
190 |
> |
make install |
191 |
> |
|
192 |
> |
cd ../cloog-%{cloogVersion} |
193 |
> |
./configure --prefix=%i --with-ppl=%i --with-gmp-prefix=%i CC="$CC" CXX="$CXX" CPP="$CPP" |
194 |
> |
make %makeprocesses |
195 |
> |
make install |
196 |
> |
|
197 |
> |
CONF_GCC_VERSION_OPTS="$CONF_GCC_VERSION_OPTS --with-ppl=%i --with-cloog=%i --enable-cloog-backend=isl" |
198 |
> |
fi |
199 |
> |
|
200 |
> |
# Build the compilers |
201 |
> |
cd ../gcc-%realversion |
202 |
|
mkdir -p obj |
203 |
|
cd obj |
204 |
< |
../configure --prefix=%i --enable-languages=c,c++,f77 \ |
205 |
< |
--enable-shared # --enable-__cxa_atexit |
204 |
> |
export LD_LIBRARY_PATH=%i/lib64:%i/lib:$LD_LIBRARY_PATH |
205 |
> |
../configure --prefix=%i \ |
206 |
> |
--enable-gold=yes --enable-lto --with-build-config=bootstrap-lto \ |
207 |
> |
--enable-languages=c,c++,fortran$ADDITIONAL_LANGUAGES \ |
208 |
> |
$CONF_GCC_VERSION_OPTS --enable-shared CC="$CC" CXX="$CXX" CPP="$CPP" |
209 |
> |
|
210 |
|
make %makeprocesses bootstrap |
211 |
+ |
make install |
212 |
|
|
213 |
|
%install |
214 |
< |
cd obj && make install |
214 |
> |
cd %_builddir/gcc-%{realversion}/obj && make install |
215 |
> |
|
216 |
|
ln -s gcc %i/bin/cc |
217 |
+ |
find %i/lib %i/lib64 -name '*.la' -exec rm -f {} \; || true |
218 |
+ |
# SCRAM ToolBox toolfile is now geneated by the gcc-toolfile.spec |
219 |
+ |
# so that everything works even in the case "--use-system-compiler" |
220 |
+ |
# option is specified. |