1 %define pkgname cross-x86_64-gcc49
2 %define cross_arch x86_64
3 %define gcc_target_arch x86_64-tizen-linux
6 # spec file for package gcc (Version 4.8.2)
8 # Copyright (c) 2005 SUSE Linux AG, Nuernberg, Germany.
9 # This file and all modifications and additions to the pristine
10 # package are under the same license as the package itself.
12 # Please submit bugfixes or comments via http://www.suse.de/feedback/
17 %define build_libjava 0
20 %define build_fortran 0
24 %define gcc_target_arch x86_64-tizen-linux
26 %define binutils_target %{cross_arch}
27 %if %{cross_arch} == "armv7l" || %{cross_arch} == "armv7hl"
28 %define binutils_target arm
30 %if %{cross_arch} == "armv6l" || %{cross_arch} == "armv6hl"
31 %define binutils_target arm
33 %if %{cross_arch} == "armv5tel"
34 %define binutils_target arm
36 %define canonical_target %(echo %{binutils_target} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
37 %if %{binutils_target} == "arm"
38 %define canonical_target_abi -gnueabi
41 %if 0%{?gcc_icecream:1}
42 %define build_sysroot /
47 ExcludeArch: %{cross_arch}
48 BuildRequires: cross-%{binutils_target}-binutils
49 BuildRequires: gcc-c++
52 BuildRequires: gettext-devel
53 BuildRequires: glibc-devel-32bit
54 BuildRequires: mpc-devel
55 BuildRequires: mpfr-devel
57 BuildRequires: makeinfo
58 BuildRequires: zlib-devel
59 %ifarch %ix86 x86_64 ppc ppc64 s390 s390x ia64 %sparc hppa %arm
60 BuildRequires: cloog-devel
61 BuildRequires: ppl-devel
64 BuildRequires: libunwind-devel
66 %if 0%{!?gcc_icecream:1}
67 BuildRequires: cross-%cross_arch-glibc-devel
70 %define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64
72 URL: http://gcc.gnu.org/
75 %define gcc_dir_version 4.9
76 %define binsuffix -4.9
77 BuildRoot: %{_tmppath}/%{name}-%{version}-build
78 Source: gcc-%{version}.tar.bz2
80 Source2: libffi49-rpmlintrc
81 Source3: gcc49-rpmlintrc
83 Source5: baselibs.conf
84 Source6: libgcj49-rpmlintrc
86 Group: Development/Building
87 Summary: The GNU C Compiler and Support Files
91 Core package for the GNU Compiler Collection, including the C language
94 Language frontends other than C are split to different sub-packages,
95 namely gcc-ada, gcc-c++, gcc-fortran, gcc-java, gcc-objc and
101 # Define the canonical target and host architecture
102 # %gcc_target_arch is supposed to be the full target triple
103 # %TARGET_ARCH is the canonicalized CPU part
104 # %CONFIGURE_TARGET is the target triple used for --target=
105 %if 0%{?gcc_target_arch:1}
106 %define CONFIGURE_TARGET %{gcc_target_arch}
107 %define TARGET_ARCH %(echo %{gcc_target_arch} | cut -d - -f 1 | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
108 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "powerpc"
109 %define CONFIGURE_TARGET powerpc64-tizen-linux
111 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "powerpc64"
112 %define CONFIGURE_TARGET powerpc64-tizen-linux
114 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "i586"
115 %define CONFIGURE_TARGET i586-tizen-linux
117 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "aarch64"
118 %define CONFIGURE_TARGET aarch64-tizen-linux
120 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "armv7l"
121 %define CONFIGURE_TARGET armv7l-tizen-linux-gnueabi
123 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "armv7hl"
124 %define CONFIGURE_TARGET armv7hl-tizen-linux-gnueabi
126 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "armv5tel"
127 %define CONFIGURE_TARGET armv5tel-tizen-linux-gnueabi
130 %define TARGET_ARCH %(echo %{_target_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
132 %define biarch %(case " %{biarch_targets} " in (*" %{TARGET_ARCH} "*) echo 1;; (*) echo 0;; esac)
134 %define HOST_ARCH %(echo %{_host_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
136 %define GCCDIST powerpc64-tizen-linux
139 %define GCCDIST sparc64-tizen-linux
142 %define GCCDIST %{HOST_ARCH}-tizen-linux-gnueabi
144 %define GCCDIST %{HOST_ARCH}-tizen-linux
149 %define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
150 %define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
154 %setup -q -n gcc-%{version}
156 # We are configuring ppc as ppc64 but with switched multilibs. Adjust
157 # the libstdc++ abi testsuite baseline files accordingly
159 if [ -d libstdc++-v3/config/abi/post/powerpc64-linux-gnu ]; then
160 mkdir -p libstdc++-v3/config/abi/post/powerpc64-linux-gnu/64
161 mv libstdc++-v3/config/abi/post/powerpc64-linux-gnu/baseline_symbols.txt \
162 libstdc++-v3/config/abi/post/powerpc64-linux-gnu/64/
163 mv libstdc++-v3/config/abi/post/powerpc64-linux-gnu/32/baseline_symbols.txt \
164 libstdc++-v3/config/abi/post/powerpc64-linux-gnu/
169 # Avoid rebuilding of generated files
170 contrib/gcc_update --touch
171 # Avoid fucking up testsuite results with Java and indirect dispatch
172 export LD_AS_NEEDED=0
173 # Split version file into version used for directories (X.Y) and
174 # version to report with --version (X.Y.Z).
175 # See also gcc-dir-version.patch.
176 # Also decrement the patchlevel version by one if possible and remove
177 # the 'prerelease' tagging in this case
178 if test `cat gcc/DEV-PHASE` == "prerelease"; then
179 if test `cat gcc/BASE-VER | cut -d '.' -f 3` != "0"; then
182 ( cat gcc/BASE-VER | cut -d '.' -f 1-2 | tr -d '\n'; echo -n .; cat gcc/BASE-VER | cut -d '.' -f 3 | tr '0123456789' '0012345678' ) > gcc/FULL-VER
184 mv gcc/BASE-VER gcc/FULL-VER
186 cat gcc/FULL-VER | cut -d '.' -f 1-2 > gcc/BASE-VER
188 rm -rf obj-%{GCCDIST}
191 RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g' -e 's/-fexceptions//' -e 's/\([[:space:]]\+.*-D_FORTIFY_SOURCE=\)[[:alnum:]]\+/\10/g'
192 RPM_OPT_FLAGS="$RPM_OPT_FLAGS -D__USE_FORTIFY_LEVEL=0"`
194 # -mcpu is superceded by -mtune but -mtune is not supported by
195 # our bootstrap compiler. -mcpu gives a warning that stops
196 # the build process, so remove it for now. Also remove all other
197 # -march and -mtune flags. They are superseeded by proper
198 # default compiler settings now.
199 RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'`
202 RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'`
203 RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'`
205 %if 0%{?gcc_target_arch:1} && 0%{!?gcc_icecream:1}
206 # Kill all -march/tune/cpu because that screws building the target libs
207 RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'`
209 # Replace 2 spaces by one finally
210 RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'`
214 languages=$languages,c++
217 languages=$languages,objc
220 languages=$languages,fortran
223 languages=$languages,obj-c++
226 languages=$languages,java
229 languages=$languages,ada
232 languages=$languages,go
236 if test -z "$J"; then
237 J=$(getconf _NPROCESSORS_CONF)
240 test 1 -gt "$J" && J=1
241 JL=$(($(getconf _NPROCESSORS_CONF)*2))
243 if test "$J" == "0"; then
246 if test "$JL" == "0"; then
249 PARALLEL="-j$J -l$JL"
251 # we don't want some miscompiles in the testsuite, or some fault in
252 # the compiler to kill the machine. Hence we limit the amount of memory
253 # by the physical RAM plus half of swap
254 #MEM=$(free -m | awk '/^Mem:/ {print $2}')
255 #SWAP=$(free -m | awk '/^Swap:/ {print $2}')
256 #ulimit -v $(((MEM + SWAP/2)*1024))
258 # In general we want to ship release checking enabled compilers
259 # and run BETA with checking enabled.
260 #ENABLE_CHECKING="--enable-checking=yes"
261 ENABLE_CHECKING="--enable-checking=release"
263 # Work around tail/head -1 changes
264 export _POSIX2_VERSION=199209
267 # Using the host gnatmake like
268 # CC="gcc%{hostsuffix}" GNATBIND="gnatbind%{hostsuffix}"
269 # GNATMAKE="gnatmake%{hostsuffix}"
270 # doesn't work due to PR33857, so an un-suffixed gnatmake has to be
272 mkdir -p host-tools/bin
273 cp -a /usr/bin/gnatmake%{hostsuffix} host-tools/bin/gnatmake
274 cp -a /usr/bin/gnatlink%{hostsuffix} host-tools/bin/gnatlink
275 cp -a /usr/bin/gnatbind%{hostsuffix} host-tools/bin/gnatbind
276 cp -a /usr/bin/gcc%{hostsuffix} host-tools/bin/gcc
277 ln -sf /usr/%{_lib} host-tools/%{_lib}
278 export PATH="`pwd`/host-tools/bin:$PATH"
280 #%if 0%{?gcc_target_arch:1} && 0%{!?gcc_icecream:1}
282 # --enable-threads=posix \
285 %if "%{TARGET_ARCH}" == "armv7l" || "%{TARGET_ARCH}" == "armv7hl"
286 # temporary workaround for a miscompilation of hash functions in java code
287 GCJ_EXTRA_FLAGS="-marm"
290 CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \
291 TCFLAGS="$RPM_OPT_FLAGS" GCJFLAGS="$RPM_OPT_FLAGS $GCJ_EXTRA_FLAGS" \
293 --prefix=%{_prefix} \
294 --infodir=%{_infodir} \
295 --mandir=%{_mandir} \
296 --libdir=%{_libdir} \
297 --libexecdir=%{_libdir} \
298 --enable-languages=$languages \
300 --with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \
303 --disable-bootstrap \
304 %if 0%{!?build_libvtv:1}
308 --with-bugurl="http://bugs.tizen.org/" \
309 --with-pkgversion="Tizen" \
310 %if !%{build_fortran}
311 --disable-libquadmath \
313 %if !%{build_libjava}
316 --with-java-home=%{_libdir}/jvm/java-1.5.0-gcj%{binsuffix}-1.5.0.0/jre \
317 --with-ecj-jar=%{libsubdir}/ecj.jar \
319 %if !%{biarch_libjava}
320 --disable-libjava-multilib \
323 --with-slibdir=/%{_lib} \
325 --enable-__cxa_atexit \
326 --enable-libstdcxx-allocator=new \
327 --disable-libstdcxx-pch \
328 --enable-version-specific-runtime-libs \
329 --enable-linker-build-id \
330 --enable-linux-futex \
331 --program-suffix=%{binsuffix} \
332 %if 0%{!?gcc_target_arch:1}
334 --with-system-libunwind \
336 --without-system-libunwind \
339 %if 0%{?gcc_target_arch:1}
340 --program-prefix=%{gcc_target_arch}- \
341 --target=%{gcc_target_arch} \
344 --with-sysroot=%sysroot \
346 --with-sysroot=%{_prefix}/%{gcc_target_arch} \
348 %if 0%{?build_sysroot:1}
349 --with-build-sysroot=%{build_sysroot} \
352 --with-build-sysroot=%{sysroot} \
354 --with-build-sysroot=%{_prefix}/%{gcc_target_arch} \
357 %if 0%{?canonical_target:1}
358 --with-build-time-tools=/usr/%{canonical_target}-tizen-linux%{?canonical_target_abi:%canonical_target_abi}/bin \
360 %if "%{TARGET_ARCH}" == "spu"
361 --with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \
365 %if "%{TARGET_ARCH}" == "armv5tel"
366 --with-arch=armv5te \
369 --with-abi=aapcs-linux \
370 --disable-sjlj-exceptions \
372 %if "%{TARGET_ARCH}" == "armv7l"
373 --with-arch=armv7-a \
374 --with-tune=cortex-a8 \
375 --with-float=softfp \
378 --disable-sjlj-exceptions \
380 %if "%{TARGET_ARCH}" == "armv7hl"
381 --with-arch=armv7-a \
382 --with-tune=cortex-a9 \
384 --with-abi=aapcs-linux \
385 --with-fpu=vfpv3-d16 \
386 --disable-sjlj-exceptions \
388 %if "%{TARGET_ARCH}" == "aarch64"
389 --with-arch=armv8-a \
390 --disable-sjlj-exceptions \
392 %if "%{TARGET_ARCH}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64"
393 %if "%{TARGET_ARCH}" == "powerpc"
394 --with-cpu=default32 \
396 %if "%{TARGET_ARCH}" == "powerpc64le"
399 --with-cpu-64=power4 \
402 --with-long-double-128 \
403 %if "%{TARGET_ARCH}" == "powerpc64le"
407 %if "%{TARGET_ARCH}" == "sparc64"
408 --with-cpu=ultrasparc \
409 --with-long-double-128 \
411 %if "%{TARGET_ARCH}" == "sparc"
413 --with-long-double-128 \
415 %if "%{TARGET_ARCH}" == "i586"
416 --with-arch-32=i586 \
417 --with-tune=generic \
419 %if "%{TARGET_ARCH}" == "x86_64"
420 --with-arch-32=i586 \
421 --with-tune=generic \
424 %if "%{TARGET_ARCH}" == "s390"
425 --with-tune=zEC12 --with-arch=z196 \
426 --with-long-double-128 \
427 --enable-decimal-float \
429 %if "%{TARGET_ARCH}" == "s390x"
430 --with-tune=zEC12 --with-arch=z196 \
431 --with-long-double-128 \
432 --enable-decimal-float \
434 %if "%{TARGET_ARCH}" == "m68k"
441 %if 0%{!?gcc_icecream:1}
442 make %{?jobs:-j%jobs}
444 make %{?jobs:-j%jobs} all-host
447 %package -n cross-%cross_arch-gcc49-icecream-backend
448 Summary: Icecream backend for the GNU C Compiler
449 Group: Development/Languages/C and C++
451 %description -n cross-%cross_arch-gcc49-icecream-backend
452 This package contains the icecream environment for the GNU C Compiler
455 %define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version}
460 # install and fixup host parts
461 make DESTDIR=$RPM_BUILD_ROOT install-host
462 # with the present setup fixincludes are for the build includes which
463 # is wrong - get rid of them
464 rm -rf $RPM_BUILD_ROOT/%{targetlibsubdir}/include-fixed
465 rm -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.la
467 rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a
469 # remove docs and disable automated generation
471 %define disable_docs_package 1
473 # install and fixup target parts
474 # ??? don't do this - debugedit is not prepared for this and crashes
475 # so expect the sysroot to be populated from natively built binaries
477 #make DESTDIR=$RPM_BUILD_ROOT/%{sysroot} install-target
479 #make DESTDIR=$RPM_BUILD_ROOT/%{_prefix}/%{gcc_target_arch} install-target
483 # Build an icecream environment
484 # The assembler comes from the cross-binutils, and hence is _not_
485 # named funnily, not even on ppc, so there we need the original target
486 install -s -D %{_prefix}/bin/%{canonical_target}-tizen-linux%{?canonical_target_abi:%canonical_target_abi}-as $RPM_BUILD_ROOT/env/usr/bin/as
487 install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix} $RPM_BUILD_ROOT/env/usr/bin/g++
488 install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} $RPM_BUILD_ROOT/env/usr/bin/gcc
490 for back in cc1 cc1plus; do
491 install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/$back $RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
493 if test -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so; then
494 install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so $RPM_BUILD_ROOT/env%{targetlibsubdir}/liblto_plugin.so
497 # Make sure to also pull in all shared library requirements for the
498 # binaries we put into the environment which is operated by chrooting
499 # into it and execing the compiler
500 libs=`for bin in $RPM_BUILD_ROOT/env/usr/bin/* $RPM_BUILD_ROOT/env%{targetlibsubdir}/*; do ldd $bin | sed -n '\,^[^/]*\(/[^ ]*\).*,{ s//\1/; p; }' ;done | sort -u`
502 # Check wether the same library also exists in the parent directory,
503 # and prefer that on the assumption that it is a more generic one.
504 baselib=`echo "$lib" | sed 's,/[^/]*\(/[^/]*\)$,\1,'`
505 test -f "$baselib" && lib=$baselib
506 install -s -D $lib $RPM_BUILD_ROOT/env$lib
509 cd $RPM_BUILD_ROOT/env
510 %if 0%{?gcc_icecream:1}
511 tar cvzf ../%{name}-icecream-backend_%{_arch}.tar.gz *
513 tar cvzf ../%{name}_%{_arch}.tar.gz *
516 mkdir -p usr/share/icecream-envs
517 %if 0%{?gcc_icecream:1}
518 mv %{name}-icecream-backend_%{_arch}.tar.gz usr/share/icecream-envs
520 mv %{name}_%{_arch}.tar.gz usr/share/icecream-envs
522 rpm -q --changelog glibc > usr/share/icecream-envs/%{name}_%{_arch}.glibc
523 rpm -q --changelog binutils > usr/share/icecream-envs/%{name}_%{_arch}.binutils
527 %defattr(-,root,root)
529 %dir %{targetlibsubdir}
530 %dir %{_libdir}/gcc/%{gcc_target_arch}
533 %files -n cross-%cross_arch-gcc49-icecream-backend
534 %defattr(-,root,root)
535 /usr/share/icecream-envs