1 %define pkgname cross-x86_64-gcc49
2 %define cross_arch x86_64
3 %define gcc_target_arch x86_64-tizen-linux
8 # call this via pre_checkin.sh
10 # 2005-05-09, jw@suse.de
12 test -z "$cross_arch" && echo 1>&2 "Error: $0 needs environment variable 'cross_arch'"
13 test -z "$outfile" && echo 1>&2 "Error: $0 needs environment variable 'outfile'"
14 cross_arch_cpu=`echo $cross_arch | sed -e 's/\([^-]*\)-\?.*/\1/'`
18 # spec file for package gcc (Version 4.8.2)
20 # Copyright (c) 2005 SUSE Linux AG, Nuernberg, Germany.
21 # This file and all modifications and additions to the pristine
22 # package are under the same license as the package itself.
24 # Please submit bugfixes or comments via http://www.suse.de/feedback/
29 %define build_libjava 0
32 %define build_fortran 0
36 %define gcc_target_arch $cross_arch
38 %define binutils_target %{cross_arch}
39 %if %{cross_arch} == "armv7l" || %{cross_arch} == "armv7hl"
40 %define binutils_target arm
42 %if %{cross_arch} == "armv6l" || %{cross_arch} == "armv6hl"
43 %define binutils_target arm
45 %if %{cross_arch} == "armv5tel"
46 %define binutils_target arm
48 %if %{cross_arch} == "aarch64"
49 %define binutils_target arm
51 %define canonical_target %(echo %{binutils_target} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
52 %if %{binutils_target} == "arm"
53 %define canonical_target_abi -gnueabi
56 %if 0%{?gcc_icecream:1}
57 %define build_sysroot /
62 BuildRequires: cross-%{binutils_target}-binutils
63 BuildRequires: gcc-c++
66 BuildRequires: gettext-devel
67 BuildRequires: glibc-devel-32bit
68 BuildRequires: mpc-devel
69 BuildRequires: mpfr-devel
71 BuildRequires: makeinfo
72 BuildRequires: zlib-devel
73 %ifarch %ix86 x86_64 ppc ppc64 s390 s390x ia64 %sparc hppa %arm
74 BuildRequires: cloog-devel
75 BuildRequires: ppl-devel
77 BuildRequires: cross-$cross_arch_cpu-binutils
79 BuildRequires: libunwind-devel
81 %if 0%{!?gcc_icecream:1}
82 BuildRequires: cross-%cross_arch-glibc-devel
85 %define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64
87 URL: http://gcc.gnu.org/
90 %define gcc_dir_version 4.9
91 %define binsuffix -4.9
92 BuildRoot: %{_tmppath}/%{name}-%{version}-build
93 Source: gcc-%{version}.tar.bz2
95 Source2: gcc49-rpmlintrc
97 Source4: baselibs.conf
99 Group: Development/Building
100 Summary: The GNU C Compiler and Support Files
104 Core package for the GNU Compiler Collection, including the C language
107 Language frontends other than C are split to different sub-packages,
108 namely gcc-ada, gcc-c++, gcc-fortran, gcc-java, gcc-objc and
114 # Define the canonical target and host architecture
115 # %gcc_target_arch is supposed to be the full target triple
116 # %TARGET_ARCH is the canonicalized CPU part
117 # %CONFIGURE_TARGET is the target triple used for --target=
118 %if 0%{?gcc_target_arch:1}
119 %define CONFIGURE_TARGET %{gcc_target_arch}
120 %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/;")
121 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "powerpc"
122 %define CONFIGURE_TARGET powerpc64-tizen-linux
124 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "powerpc64"
125 %define CONFIGURE_TARGET powerpc64-tizen-linux
127 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "i586"
128 %define CONFIGURE_TARGET i586-tizen-linux
130 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "aarch64"
131 %define CONFIGURE_TARGET aarch64-tizen-linux
133 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "armv7l"
134 %define CONFIGURE_TARGET armv7l-tizen-linux-gnueabi
136 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "armv7hl"
137 %define CONFIGURE_TARGET armv7hl-tizen-linux-gnueabi
139 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "armv5tel"
140 %define CONFIGURE_TARGET armv5tel-tizen-linux-gnueabi
143 %define TARGET_ARCH %(echo %{_target_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
145 %define biarch %(case " %{biarch_targets} " in (*" %{TARGET_ARCH} "*) echo 1;; (*) echo 0;; esac)
147 %define HOST_ARCH %(echo %{_host_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
149 %define GCCDIST powerpc64-tizen-linux
152 %define GCCDIST sparc64-tizen-linux
155 %define GCCDIST %{HOST_ARCH}-tizen-linux-gnueabi
157 %define GCCDIST %{HOST_ARCH}-tizen-linux
162 %define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
163 %define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
167 %setup -q -n gcc-%{version}
169 # We are configuring ppc as ppc64 but with switched multilibs. Adjust
170 # the libstdc++ abi testsuite baseline files accordingly
172 if [ -d libstdc++-v3/config/abi/post/powerpc64-linux-gnu ]; then
173 mkdir -p libstdc++-v3/config/abi/post/powerpc64-linux-gnu/64
174 mv libstdc++-v3/config/abi/post/powerpc64-linux-gnu/baseline_symbols.txt \
175 libstdc++-v3/config/abi/post/powerpc64-linux-gnu/64/
176 mv libstdc++-v3/config/abi/post/powerpc64-linux-gnu/32/baseline_symbols.txt \
177 libstdc++-v3/config/abi/post/powerpc64-linux-gnu/
182 # Avoid rebuilding of generated files
183 contrib/gcc_update --touch
184 # Avoid fucking up testsuite results with Java and indirect dispatch
185 export LD_AS_NEEDED=0
186 # Split version file into version used for directories (X.Y) and
187 # version to report with --version (X.Y.Z).
188 # See also gcc-dir-version.patch.
189 # Also decrement the patchlevel version by one if possible and remove
190 # the 'prerelease' tagging in this case
191 if test `cat gcc/DEV-PHASE` == "prerelease"; then
192 if test `cat gcc/BASE-VER | cut -d '.' -f 3` != "0"; then
195 ( 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
197 mv gcc/BASE-VER gcc/FULL-VER
199 cat gcc/FULL-VER | cut -d '.' -f 1-2 > gcc/BASE-VER
201 rm -rf obj-%{GCCDIST}
204 RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE"
205 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//'`
207 # -mcpu is superceded by -mtune but -mtune is not supported by
208 # our bootstrap compiler. -mcpu gives a warning that stops
209 # the build process, so remove it for now. Also remove all other
210 # -march and -mtune flags. They are superseeded by proper
211 # default compiler settings now.
212 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'`
215 RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'`
216 RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'`
218 %if 0%{?gcc_target_arch:1} && 0%{!?gcc_icecream:1}
219 # Kill all -march/tune/cpu because that screws building the target libs
220 RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'`
222 # Replace 2 spaces by one finally
223 RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'`
227 languages=$languages,c++
230 languages=$languages,objc
233 languages=$languages,fortran
236 languages=$languages,obj-c++
239 languages=$languages,java
242 languages=$languages,ada
245 languages=$languages,go
249 if test -z "$J"; then
250 J=$(getconf _NPROCESSORS_CONF)
253 test 1 -gt "$J" && J=1
254 JL=$(($(getconf _NPROCESSORS_CONF)*2))
256 if test "$J" == "0"; then
259 if test "$JL" == "0"; then
262 PARALLEL="-j$J -l$JL"
264 # we don't want some miscompiles in the testsuite, or some fault in
265 # the compiler to kill the machine. Hence we limit the amount of memory
266 # by the physical RAM plus half of swap
267 #MEM=$(free -m | awk '/^Mem:/ {print $2}')
268 #SWAP=$(free -m | awk '/^Swap:/ {print $2}')
269 #ulimit -v $(((MEM + SWAP/2)*1024))
271 # In general we want to ship release checking enabled compilers
272 # and run BETA with checking enabled.
273 #ENABLE_CHECKING="--enable-checking=yes"
274 ENABLE_CHECKING="--enable-checking=release"
276 # Work around tail/head -1 changes
277 export _POSIX2_VERSION=199209
280 # Using the host gnatmake like
281 # CC="gcc%{hostsuffix}" GNATBIND="gnatbind%{hostsuffix}"
282 # GNATMAKE="gnatmake%{hostsuffix}"
283 # doesn't work due to PR33857, so an un-suffixed gnatmake has to be
285 mkdir -p host-tools/bin
286 cp -a /usr/bin/gnatmake%{hostsuffix} host-tools/bin/gnatmake
287 cp -a /usr/bin/gnatlink%{hostsuffix} host-tools/bin/gnatlink
288 cp -a /usr/bin/gnatbind%{hostsuffix} host-tools/bin/gnatbind
289 cp -a /usr/bin/gcc%{hostsuffix} host-tools/bin/gcc
290 ln -sf /usr/%{_lib} host-tools/%{_lib}
291 export PATH="`pwd`/host-tools/bin:$PATH"
293 #%if 0%{?gcc_target_arch:1} && 0%{!?gcc_icecream:1}
295 # --enable-threads=posix \
298 %if "%{TARGET_ARCH}" == "armv7l" || "%{TARGET_ARCH}" == "armv7hl"
299 # temporary workaround for a miscompilation of hash functions in java code
300 GCJ_EXTRA_FLAGS="-marm"
303 export RPM_OPT_FLAGS="`echo $RPM_OPT_FLAGS | sed -e "s/ -Wp,-D_FORTIFY_SOURCE=2 / /g"`"
305 CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \
306 TCFLAGS="$RPM_OPT_FLAGS" GCJFLAGS="$RPM_OPT_FLAGS $GCJ_EXTRA_FLAGS" \
308 --prefix=%{_prefix} \
309 --infodir=%{_infodir} \
310 --mandir=%{_mandir} \
311 --libdir=%{_libdir} \
312 --libexecdir=%{_libdir} \
313 --enable-languages=$languages \
315 --with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \
318 %if 0%{!?build_libvtv:1}
322 --with-bugurl="http://bugs.tizen.org/" \
323 --with-pkgversion="Tizen" \
324 %if !%{build_fortran}
325 --disable-libquadmath \
327 %if !%{build_libjava}
330 --with-java-home=%{_libdir}/jvm/java-1.5.0-gcj%{binsuffix}-1.5.0.0/jre \
331 --with-ecj-jar=%{libsubdir}/ecj.jar \
333 %if !%{biarch_libjava}
334 --disable-libjava-multilib \
337 --with-slibdir=/%{_lib} \
339 --enable-__cxa_atexit \
340 --enable-libstdcxx-allocator=new \
341 --disable-libstdcxx-pch \
342 --enable-version-specific-runtime-libs \
343 --enable-linker-build-id \
344 --enable-linux-futex \
345 --program-suffix=%{binsuffix} \
346 %if 0%{!?gcc_target_arch:1}
348 --with-system-libunwind \
350 --without-system-libunwind \
353 %if 0%{?gcc_target_arch:1}
354 --program-prefix=%{gcc_target_arch}- \
355 --target=%{gcc_target_arch} \
358 --with-sysroot=%sysroot \
360 --with-sysroot=%{_prefix}/%{gcc_target_arch} \
362 %if 0%{?build_sysroot:1}
363 --with-build-sysroot=%{build_sysroot} \
366 --with-build-sysroot=%{sysroot} \
368 --with-build-sysroot=%{_prefix}/%{gcc_target_arch} \
371 %if 0%{?canonical_target:1}
372 --with-build-time-tools=/usr/%{canonical_target}-tizen-linux%{?canonical_target_abi:%canonical_target_abi}/bin \
374 %if "%{TARGET_ARCH}" == "spu"
375 --with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \
379 %if "%{TARGET_ARCH}" == "armv5tel"
380 --with-arch=armv5te \
383 --with-abi=aapcs-linux \
384 --disable-sjlj-exceptions \
386 %if "%{TARGET_ARCH}" == "armv7l"
387 --with-arch=armv7-a \
388 --with-tune=cortex-a8 \
389 --with-float=softfp \
392 --disable-sjlj-exceptions \
394 %if "%{TARGET_ARCH}" == "armv7hl"
395 --with-arch=armv7-a \
396 --with-tune=cortex-a9 \
398 --with-abi=aapcs-linux \
399 --with-fpu=vfpv3-d16 \
400 --disable-sjlj-exceptions \
402 %if "%{TARGET_ARCH}" == "aarch64"
403 --with-arch=armv8-a \
404 --disable-sjlj-exceptions \
406 %if "%{TARGET_ARCH}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64"
407 %if "%{TARGET_ARCH}" == "powerpc"
408 --with-cpu=default32 \
410 %if "%{TARGET_ARCH}" == "powerpc64le"
413 --with-cpu-64=power4 \
416 --with-long-double-128 \
417 %if "%{TARGET_ARCH}" == "powerpc64le"
421 %if "%{TARGET_ARCH}" == "sparc64"
422 --with-cpu=ultrasparc \
423 --with-long-double-128 \
425 %if "%{TARGET_ARCH}" == "sparc"
427 --with-long-double-128 \
429 %if "%{TARGET_ARCH}" == "i586"
430 --with-arch-32=i586 \
431 --with-tune=generic \
433 %if "%{TARGET_ARCH}" == "x86_64"
434 --with-arch-32=i586 \
435 --with-tune=generic \
438 %if "%{TARGET_ARCH}" == "s390"
439 --with-tune=zEC12 --with-arch=z196 \
440 --with-long-double-128 \
441 --enable-decimal-float \
443 %if "%{TARGET_ARCH}" == "s390x"
444 --with-tune=zEC12 --with-arch=z196 \
445 --with-long-double-128 \
446 --enable-decimal-float \
448 %if "%{TARGET_ARCH}" == "m68k"
455 %if 0%{!?gcc_icecream:1}
456 make %{?jobs:-j%jobs}
458 make %{?jobs:-j%jobs} all-host
461 %define _prefix /opt/cross
463 %package -n cross-%cross_arch-gcc49-icecream-backend
464 Summary: Icecream backend for the GNU C Compiler
465 Group: Development/Languages/C and C++
467 %description -n cross-%cross_arch-gcc49-icecream-backend
468 This package contains the icecream environment for the GNU C Compiler
471 %define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version}
476 # install and fixup host parts
477 make DESTDIR=$RPM_BUILD_ROOT install-host
478 # with the present setup fixincludes are for the build includes which
479 # is wrong - get rid of them
480 rm -rf $RPM_BUILD_ROOT/%{targetlibsubdir}/include-fixed
481 rm -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.la
483 rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a
485 rm -rf $RPM_BUILD_ROOT%{_mandir}
486 rm -rf $RPM_BUILD_ROOT%{_infodir}
489 # install and fixup target parts
490 # ??? don't do this - debugedit is not prepared for this and crashes
491 # so expect the sysroot to be populated from natively built binaries
493 #make DESTDIR=$RPM_BUILD_ROOT/%{sysroot} install-target
495 #make DESTDIR=$RPM_BUILD_ROOT/%{_prefix}/%{gcc_target_arch} install-target
499 # Build an icecream environment
500 # The assembler comes from the cross-binutils, and hence is _not_
501 # named funnily, not even on ppc, so there we need the original target
502 install -s -D %{_prefix}/bin/%{canonical_target}-tizen-linux%{?canonical_target_abi:%canonical_target_abi}-as \
503 $RPM_BUILD_ROOT/env/usr/bin/as
504 install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix} \
505 $RPM_BUILD_ROOT/env/usr/bin/g++
506 install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} \
507 $RPM_BUILD_ROOT/env/usr/bin/gcc
509 for back in cc1 cc1plus; do
510 install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/$back \
511 $RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
513 if test -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so; then
514 install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so \
515 $RPM_BUILD_ROOT/env%{targetlibsubdir}/liblto_plugin.so
518 # Make sure to also pull in all shared library requirements for the
519 # binaries we put into the environment which is operated by chrooting
520 # into it and execing the compiler
521 libs=`for bin in $RPM_BUILD_ROOT/env/usr/bin/* $RPM_BUILD_ROOT/env%{targetlibsubdir}/*; do \
522 ldd $bin | sed -n '\,^[^/]*\(/[^ ]*\).*,{ s//\1/; p; }' ;\
525 # Check wether the same library also exists in the parent directory,
526 # and prefer that on the assumption that it is a more generic one.
527 baselib=`echo "$lib" | sed 's,/[^/]*\(/[^/]*\)$,\1,'`
528 test -f "$baselib" && lib=$baselib
529 install -s -D $lib $RPM_BUILD_ROOT/env$lib
532 cd $RPM_BUILD_ROOT/env
533 tar cvzf ../%{name}_%{_arch}.tar.gz *
535 mkdir -p usr/share/icecream-envs
536 mv %{name}_%{_arch}.tar.gz usr/share/icecream-envs
537 rpm -q --changelog glibc > usr/share/icecream-envs/%{name}_%{_arch}.glibc
538 rpm -q --changelog binutils > usr/share/icecream-envs/%{name}_%{_arch}.binutils
542 %defattr(-,root,root)
544 %dir %{targetlibsubdir}
545 %dir %{_libdir}/gcc/%{gcc_target_arch}
548 %files -n cross-%cross_arch-gcc49-icecream-backend
549 %defattr(-,root,root)
550 /usr/share/icecream-envs