1 %define pkgname cross-aarch64-gcc49
2 %define cross_arch aarch64
3 %define gcc_target_arch aarch64-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: libffi49-rpmlintrc
96 Source3: gcc49-rpmlintrc
98 Source5: baselibs.conf
99 Source6: libgcj49-rpmlintrc
101 Group: Development/Building
102 Summary: The GNU C Compiler and Support Files
106 Core package for the GNU Compiler Collection, including the C language
109 Language frontends other than C are split to different sub-packages,
110 namely gcc-ada, gcc-c++, gcc-fortran, gcc-java, gcc-objc and
116 # Define the canonical target and host architecture
117 # %gcc_target_arch is supposed to be the full target triple
118 # %TARGET_ARCH is the canonicalized CPU part
119 # %CONFIGURE_TARGET is the target triple used for --target=
120 %if 0%{?gcc_target_arch:1}
121 %define CONFIGURE_TARGET %{gcc_target_arch}
122 %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/;")
123 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "powerpc"
124 %define CONFIGURE_TARGET powerpc64-tizen-linux
126 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "powerpc64"
127 %define CONFIGURE_TARGET powerpc64-tizen-linux
129 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "i586"
130 %define CONFIGURE_TARGET i586-tizen-linux
132 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "aarch64"
133 %define CONFIGURE_TARGET aarch64-tizen-linux
135 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "armv7l"
136 %define CONFIGURE_TARGET armv7l-tizen-linux-gnueabi
138 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "armv7hl"
139 %define CONFIGURE_TARGET armv7hl-tizen-linux-gnueabi
141 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "armv5tel"
142 %define CONFIGURE_TARGET armv5tel-tizen-linux-gnueabi
145 %define TARGET_ARCH %(echo %{_target_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
147 %define biarch %(case " %{biarch_targets} " in (*" %{TARGET_ARCH} "*) echo 1;; (*) echo 0;; esac)
149 %define HOST_ARCH %(echo %{_host_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
151 %define GCCDIST powerpc64-tizen-linux
154 %define GCCDIST sparc64-tizen-linux
157 %define GCCDIST %{HOST_ARCH}-tizen-linux-gnueabi
159 %define GCCDIST %{HOST_ARCH}-tizen-linux
164 %define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
165 %define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
169 %setup -q -n gcc-%{version}
171 # We are configuring ppc as ppc64 but with switched multilibs. Adjust
172 # the libstdc++ abi testsuite baseline files accordingly
174 if [ -d libstdc++-v3/config/abi/post/powerpc64-linux-gnu ]; then
175 mkdir -p libstdc++-v3/config/abi/post/powerpc64-linux-gnu/64
176 mv libstdc++-v3/config/abi/post/powerpc64-linux-gnu/baseline_symbols.txt \
177 libstdc++-v3/config/abi/post/powerpc64-linux-gnu/64/
178 mv libstdc++-v3/config/abi/post/powerpc64-linux-gnu/32/baseline_symbols.txt \
179 libstdc++-v3/config/abi/post/powerpc64-linux-gnu/
184 # Avoid rebuilding of generated files
185 contrib/gcc_update --touch
186 # Avoid fucking up testsuite results with Java and indirect dispatch
188 # Split version file into version used for directories (X.Y) and
189 # version to report with --version (X.Y.Z).
190 # See also gcc-dir-version.patch.
191 # Also decrement the patchlevel version by one if possible and remove
192 # the 'prerelease' tagging in this case
193 if test `cat gcc/DEV-PHASE` == "prerelease"; then
194 if test `cat gcc/BASE-VER | cut -d '.' -f 3` != "0"; then
197 ( 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
199 mv gcc/BASE-VER gcc/FULL-VER
201 cat gcc/FULL-VER | cut -d '.' -f 1-2 > gcc/BASE-VER
203 rm -rf obj-%{GCCDIST}
206 RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE"
207 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'`
209 # -mcpu is superceded by -mtune but -mtune is not supported by
210 # our bootstrap compiler. -mcpu gives a warning that stops
211 # the build process, so remove it for now. Also remove all other
212 # -march and -mtune flags. They are superseeded by proper
213 # default compiler settings now.
214 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'`
217 RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'`
218 RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'`
220 %if 0%{?gcc_target_arch:1} && 0%{!?gcc_icecream:1}
221 # Kill all -march/tune/cpu because that screws building the target libs
222 RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'`
224 # Replace 2 spaces by one finally
225 RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'`
229 languages=$languages,c++
232 languages=$languages,objc
235 languages=$languages,fortran
238 languages=$languages,obj-c++
241 languages=$languages,java
244 languages=$languages,ada
247 languages=$languages,go
251 if test -z "$J"; then
252 J=$(getconf _NPROCESSORS_CONF)
255 test 1 -gt "$J" && J=1
256 JL=$(($(getconf _NPROCESSORS_CONF)*2))
258 if test "$J" == "0"; then
261 if test "$JL" == "0"; then
264 PARALLEL="-j$J -l$JL"
266 # we don't want some miscompiles in the testsuite, or some fault in
267 # the compiler to kill the machine. Hence we limit the amount of memory
268 # by the physical RAM plus half of swap
269 #MEM=$(free -m | awk '/^Mem:/ {print $2}')
270 #SWAP=$(free -m | awk '/^Swap:/ {print $2}')
271 #ulimit -v $(((MEM + SWAP/2)*1024))
273 # In general we want to ship release checking enabled compilers
274 # and run BETA with checking enabled.
275 #ENABLE_CHECKING="--enable-checking=yes"
276 ENABLE_CHECKING="--enable-checking=release"
278 # Work around tail/head -1 changes
279 export _POSIX2_VERSION=199209
282 # Using the host gnatmake like
283 # CC="gcc%{hostsuffix}" GNATBIND="gnatbind%{hostsuffix}"
284 # GNATMAKE="gnatmake%{hostsuffix}"
285 # doesn't work due to PR33857, so an un-suffixed gnatmake has to be
287 mkdir -p host-tools/bin
288 cp -a /usr/bin/gnatmake%{hostsuffix} host-tools/bin/gnatmake
289 cp -a /usr/bin/gnatlink%{hostsuffix} host-tools/bin/gnatlink
290 cp -a /usr/bin/gnatbind%{hostsuffix} host-tools/bin/gnatbind
291 cp -a /usr/bin/gcc%{hostsuffix} host-tools/bin/gcc
292 ln -sf /usr/%{_lib} host-tools/%{_lib}
293 export PATH="`pwd`/host-tools/bin:$PATH"
295 #%if 0%{?gcc_target_arch:1} && 0%{!?gcc_icecream:1}
297 # --enable-threads=posix \
300 %if "%{TARGET_ARCH}" == "armv7l" || "%{TARGET_ARCH}" == "armv7hl"
301 # temporary workaround for a miscompilation of hash functions in java code
302 GCJ_EXTRA_FLAGS="-marm"
305 export RPM_OPT_FLAGS="`echo $RPM_OPT_FLAGS | sed -e "s/ -Wp,-D_FORTIFY_SOURCE=2 / /g"`"
307 CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \
308 TCFLAGS="$RPM_OPT_FLAGS" GCJFLAGS="$RPM_OPT_FLAGS $GCJ_EXTRA_FLAGS" \
310 --prefix=%{_prefix} \
311 --infodir=%{_infodir} \
312 --mandir=%{_mandir} \
313 --libdir=%{_libdir} \
314 --libexecdir=%{_libdir} \
315 --disable-bootstrap \
316 --enable-languages=$languages \
318 --with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \
321 %if 0%{!?build_libvtv:1}
325 --with-bugurl="http://bugs.tizen.org/" \
326 --with-pkgversion="Tizen" \
327 %if !%{build_fortran}
328 --disable-libquadmath \
330 %if !%{build_libjava}
333 --with-java-home=%{_libdir}/jvm/java-1.5.0-gcj%{binsuffix}-1.5.0.0/jre \
334 --with-ecj-jar=%{libsubdir}/ecj.jar \
336 %if !%{biarch_libjava}
337 --disable-libjava-multilib \
340 --with-slibdir=/%{_lib} \
342 --enable-__cxa_atexit \
343 --enable-libstdcxx-allocator=new \
344 --disable-libstdcxx-pch \
345 --enable-version-specific-runtime-libs \
346 --enable-linker-build-id \
347 --enable-linux-futex \
348 --program-suffix=%{binsuffix} \
349 %if 0%{!?gcc_target_arch:1}
351 --with-system-libunwind \
353 --without-system-libunwind \
356 %if 0%{?gcc_target_arch:1}
357 --program-prefix=%{gcc_target_arch}- \
358 --target=%{gcc_target_arch} \
361 --with-sysroot=%sysroot \
363 --with-sysroot=%{_prefix}/%{gcc_target_arch} \
365 %if 0%{?build_sysroot:1}
366 --with-build-sysroot=%{build_sysroot} \
369 --with-build-sysroot=%{sysroot} \
371 --with-build-sysroot=%{_prefix}/%{gcc_target_arch} \
374 %if 0%{?canonical_target:1}
375 --with-build-time-tools=/usr/%{canonical_target}-tizen-linux%{?canonical_target_abi:%canonical_target_abi}/bin \
377 %if "%{TARGET_ARCH}" == "spu"
378 --with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \
382 %if "%{TARGET_ARCH}" == "armv5tel"
383 --with-arch=armv5te \
386 --with-abi=aapcs-linux \
387 --disable-sjlj-exceptions \
389 %if "%{TARGET_ARCH}" == "armv7l"
390 --with-arch=armv7-a \
391 --with-tune=cortex-a8 \
392 --with-float=softfp \
395 --disable-sjlj-exceptions \
397 %if "%{TARGET_ARCH}" == "armv7hl"
398 --with-arch=armv7-a \
399 --with-tune=cortex-a9 \
401 --with-abi=aapcs-linux \
402 --with-fpu=vfpv3-d16 \
403 --disable-sjlj-exceptions \
405 %if "%{TARGET_ARCH}" == "aarch64"
406 --with-arch=armv8-a \
407 --disable-sjlj-exceptions \
409 %if "%{TARGET_ARCH}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64"
410 %if "%{TARGET_ARCH}" == "powerpc"
411 --with-cpu=default32 \
413 %if "%{TARGET_ARCH}" == "powerpc64le"
416 --with-cpu-64=power4 \
419 --with-long-double-128 \
420 %if "%{TARGET_ARCH}" == "powerpc64le"
424 %if "%{TARGET_ARCH}" == "sparc64"
425 --with-cpu=ultrasparc \
426 --with-long-double-128 \
428 %if "%{TARGET_ARCH}" == "sparc"
430 --with-long-double-128 \
432 %if "%{TARGET_ARCH}" == "i586"
433 --with-arch-32=i586 \
434 --with-tune=generic \
436 %if "%{TARGET_ARCH}" == "x86_64"
437 --with-arch-32=i586 \
438 --with-tune=generic \
441 %if "%{TARGET_ARCH}" == "s390"
442 --with-tune=zEC12 --with-arch=z196 \
443 --with-long-double-128 \
444 --enable-decimal-float \
446 %if "%{TARGET_ARCH}" == "s390x"
447 --with-tune=zEC12 --with-arch=z196 \
448 --with-long-double-128 \
449 --enable-decimal-float \
451 %if "%{TARGET_ARCH}" == "m68k"
458 %if 0%{!?gcc_icecream:1}
459 make %{?jobs:-j%jobs}
461 make %{?jobs:-j%jobs} all-host
464 %define _prefix /opt/cross
466 %package -n cross-%cross_arch-gcc49-icecream-backend
467 Summary: Icecream backend for the GNU C Compiler
468 Group: Development/Languages/C and C++
470 %description -n cross-%cross_arch-gcc49-icecream-backend
471 This package contains the icecream environment for the GNU C Compiler
474 %define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version}
479 # install and fixup host parts
480 make DESTDIR=$RPM_BUILD_ROOT install-host
481 # with the present setup fixincludes are for the build includes which
482 # is wrong - get rid of them
483 rm -rf $RPM_BUILD_ROOT/%{targetlibsubdir}/include-fixed
484 rm -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.la
486 rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a
488 rm -rf $RPM_BUILD_ROOT%{_mandir}
489 rm -rf $RPM_BUILD_ROOT%{_infodir}
492 # install and fixup target parts
493 # ??? don't do this - debugedit is not prepared for this and crashes
494 # so expect the sysroot to be populated from natively built binaries
496 #make DESTDIR=$RPM_BUILD_ROOT/%{sysroot} install-target
498 #make DESTDIR=$RPM_BUILD_ROOT/%{_prefix}/%{gcc_target_arch} install-target
502 # Build an icecream environment
503 # The assembler comes from the cross-binutils, and hence is _not_
504 # named funnily, not even on ppc, so there we need the original target
505 install -s -D %{_prefix}/bin/%{canonical_target}-tizen-linux%{?canonical_target_abi:%canonical_target_abi}-as \
506 $RPM_BUILD_ROOT/env/usr/bin/as
507 install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix} \
508 $RPM_BUILD_ROOT/env/usr/bin/g++
509 install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} \
510 $RPM_BUILD_ROOT/env/usr/bin/gcc
512 for back in cc1 cc1plus; do
513 install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/$back \
514 $RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
516 if test -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so; then
517 install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so \
518 $RPM_BUILD_ROOT/env%{targetlibsubdir}/liblto_plugin.so
521 # Make sure to also pull in all shared library requirements for the
522 # binaries we put into the environment which is operated by chrooting
523 # into it and execing the compiler
524 libs=`for bin in $RPM_BUILD_ROOT/env/usr/bin/* $RPM_BUILD_ROOT/env%{targetlibsubdir}/*; do \
525 ldd $bin | sed -n '\,^[^/]*\(/[^ ]*\).*,{ s//\1/; p; }' ;\
528 # Check wether the same library also exists in the parent directory,
529 # and prefer that on the assumption that it is a more generic one.
530 baselib=`echo "$lib" | sed 's,/[^/]*\(/[^/]*\)$,\1,'`
531 test -f "$baselib" && lib=$baselib
532 install -s -D $lib $RPM_BUILD_ROOT/env$lib
535 cd $RPM_BUILD_ROOT/env
536 tar cvzf ../%{name}_%{_arch}.tar.gz *
538 mkdir -p usr/share/icecream-envs
539 mv %{name}_%{_arch}.tar.gz usr/share/icecream-envs
540 rpm -q --changelog glibc > usr/share/icecream-envs/%{name}_%{_arch}.glibc
541 rpm -q --changelog binutils > usr/share/icecream-envs/%{name}_%{_arch}.binutils
545 %defattr(-,root,root)
547 %dir %{targetlibsubdir}
548 %dir %{_libdir}/gcc/%{gcc_target_arch}
551 %files -n cross-%cross_arch-gcc49-icecream-backend
552 %defattr(-,root,root)
553 /usr/share/icecream-envs