packaging: support aarch64 build
[platform/upstream/gcc48.git] / packaging / cross-armv7l-gcc48-icecream-backend.spec
1 #
2 # spec file for package gcc (Version 4.8.2)
3 #
4 # Copyright (c) 2005 SUSE Linux AG, Nuernberg, Germany.
5 # This file and all modifications and additions to the pristine
6 # package are under the same license as the package itself.
7 #
8 # Please submit bugfixes or comments via http://www.suse.de/feedback/
9 #
10
11 %define build_cp 1
12 %define build_ada 0
13 %define build_libjava 0
14 %define build_java 0
15 %define build_fortran 0
16 %define build_objc 0
17 %define build_objcp 0
18 %define build_nof 0
19 %define build_with_mudflap 0
20 %define gcc_target_arch armv7l-tizen-linux
21 %define gcc_icecream 1
22
23 %define binutils_target armv7l
24 %if %{binutils_target} == "armv7l" || %{binutils_target} == "armv7hl" || %{binutils_target} == "armv7el"
25 %define binutils_target arm
26 %endif
27 %if %{binutils_target} == "armv5el"
28 %define binutils_target arm
29 %endif
30 %define canonical_target %(echo %{binutils_target} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
31 %if %{binutils_target} == "arm"
32 %define canonical_target_abi -gnueabi
33 %endif
34
35 Name:         cross-armv7l-gcc48-icecream-backend
36 BuildRequires: cross-%{binutils_target}-binutils
37 BuildRequires: bison
38 BuildRequires: flex
39 BuildRequires: gettext-devel
40 BuildRequires: glibc-devel-32bit
41 BuildRequires: mpc-devel
42 BuildRequires: mpfr-devel
43 BuildRequires: perl
44 BuildRequires: makeinfo
45 BuildRequires: zlib-devel
46 %ifarch %ix86 x86_64  %arm
47 BuildRequires: cloog-devel
48 BuildRequires: ppl-devel
49 %endif
50 %ifarch ia64
51 BuildRequires: libunwind-devel
52 %endif
53 ExclusiveArch: ppc ppc64 %ix86 x86_64 ia64 
54 %define _binary_payload w.ufdio
55
56 %define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64
57
58 URL:          http://gcc.gnu.org/
59 Version: 4.8.2
60 Release:      1
61 %define gcc_dir_version 4.8
62 %define binsuffix -4.8
63 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
64 Source:         gcc-%{version}.tar.bz2
65 Source1:        change_spec
66 Source3:        gcc48-rpmlintrc
67 Source4:        ecj.jar
68 Source6:        baselibs.conf
69 Source1001: gcc.manifest
70
71
72 Group:          Development/Toolchain
73 Summary:        The GNU C Compiler and Support Files
74 License:        GPL-3.0+
75
76 %description
77 Core package for the GNU Compiler Collection, including the C language
78 frontend.
79
80 Language frontends other than C are split to different sub-packages,
81 namely gcc-ada, gcc-c++, gcc-fortran, gcc-java, gcc-objc and
82 gcc-obj-c++.
83
84
85
86
87 # Define the canonical target and host architecture
88 #   %gcc_target_arch  is supposed to be the full target triple
89 #   %TARGET_ARCH      is the canonicalized CPU part
90 #   %CONFIGURE_TARGET is the target triple used for --target=
91 %if 0%{?gcc_target_arch:1}
92 %define CONFIGURE_TARGET %{gcc_target_arch}
93 %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/;")
94 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "powerpc"
95 %define CONFIGURE_TARGET powerpc64-tizen-linux
96 %endif
97 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "powerpc64"
98 %define CONFIGURE_TARGET powerpc64-tizen-linux
99 %endif
100 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "i586"
101 %define CONFIGURE_TARGET i586-tizen-linux
102 %endif
103 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "armv7l"
104 %define CONFIGURE_TARGET armv7l-tizen-linux-gnueabi
105 %endif
106 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "armv7hl"
107 %define CONFIGURE_TARGET armv7hl-tizen-linux-gnueabi
108 %endif
109 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "armv5tel"
110 %define CONFIGURE_TARGET armv5tel-tizen-linux-gnueabi
111 %endif
112 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "aarch64"
113 %define CONFIGURE_TARGET aarch64-tizen-linux-gnueabi
114 %endif
115 %else
116 %define TARGET_ARCH %(echo %{_target_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
117 %endif
118 %define HOST_ARCH %(echo %{_host_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
119
120 %define biarch %(case " %{biarch_targets} " in (*" %{TARGET_ARCH} "*) echo 1;; (*) echo 0;; esac)
121
122 %ifarch ppc
123 %define GCCDIST powerpc64-tizen-linux
124 %else
125 %ifarch %sparc
126 %define GCCDIST sparc64-tizen-linux
127 %else
128 %ifarch %arm
129 %define GCCDIST %{HOST_ARCH}-tizen-linux-gnueabi
130 %else
131 %define GCCDIST %{HOST_ARCH}-tizen-linux
132 %endif
133 %endif
134 %endif
135
136 %define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
137 %define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
138
139
140 %prep
141 %setup -q -n gcc-%{version}
142 cp %{SOURCE1001} .
143
144
145 # We are configuring ppc as ppc64 but with switched multilibs.  Adjust
146 # the libstdc++ abi testsuite baseline files accordingly
147 %ifarch ppc
148 if [ -d libstdc++-v3/config/abi/post/powerpc64-linux-gnu ]; then
149   mkdir -p libstdc++-v3/config/abi/post/powerpc64-linux-gnu/64
150   mv libstdc++-v3/config/abi/post/powerpc64-linux-gnu/baseline_symbols.txt \
151         libstdc++-v3/config/abi/post/powerpc64-linux-gnu/64/
152   mv libstdc++-v3/config/abi/post/powerpc64-linux-gnu/32/baseline_symbols.txt \
153         libstdc++-v3/config/abi/post/powerpc64-linux-gnu/
154 fi
155 %endif
156
157 %build
158 # Avoid rebuilding of generated files
159 contrib/gcc_update --touch
160 # Avoid fucking up testsuite results with Java and indirect dispatch
161 export LD_AS_NEEDED=0
162 # Split version file into version used for directories (X.Y) and
163 # version to report with --version (X.Y.Z).
164 # See also gcc-dir-version.patch.
165 # Also decrement the patchlevel version by one
166 if test `cat gcc/DEV-PHASE` == "prerelease"; then
167   ( 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
168 else
169   mv gcc/BASE-VER gcc/FULL-VER
170 fi
171 cat gcc/FULL-VER | cut -d '.' -f 1-2 > gcc/BASE-VER
172
173 rm -rf obj-%{GCCDIST}
174 mkdir obj-%{GCCDIST}
175 cd obj-%{GCCDIST}
176 RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE"
177 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'`
178 %ifarch %ix86
179 # -mcpu is superceded by -mtune but -mtune is not supported by
180 # our bootstrap compiler.  -mcpu gives a warning that stops
181 # the build process, so remove it for now.  Also remove all other
182 # -march and -mtune flags.  They are superseeded by proper
183 # default compiler settings now.
184 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'`
185 %endif
186 %ifarch s390 s390x
187 RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'`
188 RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'`
189 %endif
190 %if 0%{?gcc_target_arch:1} && 0%{!?gcc_icecream:1}
191 # Kill all -march/tune/cpu because that screws building the target libs
192 RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'`
193 %endif
194 # Replace 2 spaces by one finally
195 RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/  / /g'`
196
197 languages=c
198 %if %{build_cp}
199 languages=$languages,c++
200 %endif
201 %if %{build_objc}
202 languages=$languages,objc
203 %endif
204 %if %{build_fortran}
205 languages=$languages,fortran
206 %endif
207 %if %{build_objcp}
208 languages=$languages,obj-c++
209 %endif
210 %if %{build_java}
211 languages=$languages,java
212 %endif
213 %if %{build_ada}
214 languages=$languages,ada
215 %endif
216
217 J=%{?jobs:%jobs}
218 if test -z "$J"; then
219   J=$(getconf _NPROCESSORS_CONF)
220   JL=$(($J * 2))
221 else
222   test 1 -gt "$J" && J=1
223   JL=$(($(getconf _NPROCESSORS_CONF)*2))
224 fi
225 if test "$J" == "0"; then
226   J=1
227 fi
228 if test "$JL" == "0"; then
229   JL=1
230 fi
231 PARALLEL="-j$J -l$JL"
232
233 # we don't want some miscompiles in the testsuite, or some fault in
234 # the compiler to kill the machine.  Hence we limit the amount of memory
235 # by the physical RAM plus half of swap
236 #MEM=$(free -m | awk '/^Mem:/ {print $2}')
237 #SWAP=$(free -m | awk '/^Swap:/ {print $2}')
238 #ulimit -v $(((MEM + SWAP/2)*1024))
239
240 # In general we want to ship release checking enabled compilers
241 # and run BETA with checking enabled.
242 #ENABLE_CHECKING="--enable-checking=yes"
243 ENABLE_CHECKING="--enable-checking=release"
244
245 # Work around tail/head -1 changes
246 export _POSIX2_VERSION=199209
247
248 # configure tries to parse include/features.h to detect
249 # if glibc supports SSP.  When cross compiling we would need
250 # to install a cross glibc, which we don't, or make the whole
251 # thing point to the native glibc, which is in /, hence the
252 # --with-build-sysroot=/
253
254 %if %{build_ada}
255 # Using the host gnatmake like
256 #   CC="gcc%{hostsuffix}" GNATBIND="gnatbind%{hostsuffix}"
257 #   GNATMAKE="gnatmake%{hostsuffix}"
258 # doesn't work due to PR33857, so an un-suffixed gnatmake has to be
259 # available
260 mkdir -p host-tools/bin
261 cp -a /usr/bin/gnatmake%{hostsuffix} host-tools/bin/gnatmake
262 cp -a /usr/bin/gnatlink%{hostsuffix} host-tools/bin/gnatlink
263 cp -a /usr/bin/gnatbind%{hostsuffix} host-tools/bin/gnatbind
264 cp -a /usr/bin/gcc%{hostsuffix} host-tools/bin/gcc
265 ln -sf /usr/%{_lib} host-tools/%{_lib}
266 export PATH="`pwd`/host-tools/bin:$PATH"
267 %endif
268 #%if 0%{?gcc_target_arch:1} && 0%{!?gcc_icecream:1}
269 #%else
270 #       --enable-threads=posix \
271 #%endif
272 #       --enable-shared \
273 %if "%{TARGET_ARCH}" == "armv7l" || "%{TARGET_ARCH}" == "armv7hl"
274 # temporary workaround for a miscompilation of hash functions in java code
275 GCJ_EXTRA_FLAGS="-marm"
276 %endif
277 CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \
278 TCFLAGS="$RPM_OPT_FLAGS" GCJFLAGS="$RPM_OPT_FLAGS $GCJ_EXTRA_FLAGS" \
279 ../configure \
280         --prefix=%{_prefix} \
281         --infodir=%{_infodir} \
282         --mandir=%{_mandir} \
283         --libdir=%{_libdir} \
284         --libexecdir=%{_libdir} \
285     --disable-bootstrap \
286         --enable-languages=$languages \
287         $ENABLE_CHECKING \
288         --with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \
289         --enable-ssp \
290         --disable-libssp \
291         --disable-plugin \
292         --with-bugurl="http://bugs.tizen.org/" \
293         --with-pkgversion="Tizen" \
294 %if !%{build_fortran}
295         --disable-libquadmath \
296 %endif
297 %if !%{build_libjava}
298         --disable-libgcj \
299 %else
300         --with-java-home=%{_libdir}/jvm/java-1.5.0-gcj%{binsuffix}-1.5.0.0/jre \
301         --with-ecj-jar=%{libsubdir}/ecj.jar \
302         --disable-java-awt \
303 %if !%{biarch_libjava}
304         --disable-libjava-multilib \
305 %endif
306 %endif
307 %if !%{build_with_mudflap}
308         --disable-libmudflap \
309 %endif
310         --with-slibdir=/%{_lib} \
311         --with-system-zlib \
312         --enable-__cxa_atexit \
313         --enable-libstdcxx-allocator=new \
314         --disable-libstdcxx-pch \
315         --enable-version-specific-runtime-libs \
316         --enable-linker-build-id \
317 %if 0%{?gcc_target_arch:1}
318 %if 0%{?gcc_icecream:1}
319         --with-sysroot=/ \
320         --with-gxx-include-dir=%{_prefix}/%{gcc_target_arch}%{?canonical_target_abi:%canonical_target_abi}/include/c++/%{gcc_dir_version} \
321         --enable-linux-futex \
322 %endif
323 %if 0%{?canonical_target:1}
324         --with-build-time-tools=/usr/%{canonical_target}-tizen-linux%{?canonical_target_abi:%canonical_target_abi}/bin \
325 %endif
326 %if 0%{?sysroot:1}
327         --with-sysroot=%sysroot \
328 %endif
329 %if 0%{?build_static:1}
330         --disable-shared \
331 %endif
332 %if "%{TARGET_ARCH}" == "spu"
333         --with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \
334         --with-newlib \
335 %endif
336         --disable-nls \
337         --target=%{CONFIGURE_TARGET} \
338 %else
339         --program-suffix=%{binsuffix} \
340         --enable-linux-futex \
341 %ifarch ia64
342         --with-system-libunwind \
343 %else
344         --without-system-libunwind \
345 %endif
346 %endif
347 %if "%{TARGET_ARCH}" == "armv5tel"
348         --with-arch=armv5te \
349         --with-float=soft \
350         --with-mode=arm \
351         --with-abi=aapcs-linux \
352         --disable-sjlj-exceptions \
353 %endif
354 %if "%{TARGET_ARCH}" == "armv7l" 
355         --with-arch=armv7-a \
356         --with-tune=cortex-a8 \
357         --with-float=softfp \
358         --with-fpu=vfpv3 \
359         --with-mode=thumb \
360         --disable-sjlj-exceptions \
361 %endif
362 %if  "%{TARGET_ARCH}" == "armv7hl"
363         --with-arch=armv7-a \
364         --with-tune=cortex-a9 \
365         --with-float=hard \
366         --with-abi=aapcs-linux \
367         --with-fpu=vfpv3-d16 \
368         --disable-sjlj-exceptions \
369 %endif
370 %if "%{TARGET_ARCH}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64"
371 %if "%{TARGET_ARCH}" == "powerpc"
372         --with-cpu=default32 \
373 %endif
374         --with-cpu-64=power4 \
375         --enable-secureplt \
376         --with-long-double-128 \
377 %endif
378 %if "%{TARGET_ARCH}" == "sparc64"
379         --with-cpu=ultrasparc \
380         --with-long-double-128 \
381 %endif
382 %if "%{TARGET_ARCH}" == "sparc"
383         --with-cpu=v8 \
384         --with-long-double-128 \
385 %endif
386 %if "%{TARGET_ARCH}" == "i586"
387         --with-arch-32=i586 \
388         --with-tune=generic \
389 %endif
390 %if "%{TARGET_ARCH}" == "x86_64"
391         --with-arch-32=i586 \
392         --with-tune=generic \
393 %endif
394 %if "%{TARGET_ARCH}" == "s390"
395         --with-tune=z196 --with-arch=z10 \
396         --with-long-double-128 \
397         --enable-decimal-float \
398 %endif
399 %if "%{TARGET_ARCH}" == "s390x"
400         --with-tune=z196 --with-arch=z10 \
401         --with-long-double-128 \
402         --enable-decimal-float \
403 %endif
404         --build=%{GCCDIST}
405
406
407 make %{?jobs:-j%jobs} all-gcc TARGET-gcc="cc1 cc1plus collect2 gcc-cross xg++ native"
408
409 %install
410 cd obj-%{GCCDIST}
411 rm -rf $RPM_BUILD_ROOT
412 make -C gcc DESTDIR=$RPM_BUILD_ROOT/inst install-driver install-common
413 make DESTDIR=$RPM_BUILD_ROOT/inst maybe-install-lto-plugin
414
415 # But the assembler comes from the cross-binutils, and hence is _not_
416 # named funnily, not even on ppc, so there we need the original target
417 install -s -D %{_prefix}/bin/%{canonical_target}-tizen-linux%{?canonical_target_abi:%canonical_target_abi}-as \
418         $RPM_BUILD_ROOT/env/usr/bin/as
419 install -s $RPM_BUILD_ROOT/inst%{_prefix}/bin/%{CONFIGURE_TARGET}-g++ \
420         $RPM_BUILD_ROOT/env/usr/bin/g++
421 install -s $RPM_BUILD_ROOT/inst%{_prefix}/bin/%{CONFIGURE_TARGET}-gcc \
422         $RPM_BUILD_ROOT/env/usr/bin/gcc
423
424 %define targetlibsubdir %{_libdir}/gcc/%{CONFIGURE_TARGET}/%{gcc_dir_version}
425 for back in cc1 cc1plus collect2; do 
426         install -s -D $RPM_BUILD_ROOT/inst%{targetlibsubdir}/$back \
427                 $RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
428 done
429 if test -f $RPM_BUILD_ROOT/inst%{targetlibsubdir}/liblto_plugin.so; then
430   install -s -D $RPM_BUILD_ROOT/inst%{targetlibsubdir}/liblto_plugin.so \
431                 $RPM_BUILD_ROOT/env%{targetlibsubdir}/liblto_plugin.so
432 fi
433
434 libs=`for bin in $RPM_BUILD_ROOT/env/usr/bin/* $RPM_BUILD_ROOT/env%{targetlibsubdir}/*; do \
435   ldd $bin | sed -n '\,^[^/]*\(/[^ ]*\).*,{ s//\1/; p; }'  ;\
436 done | sort -u `
437 for lib in $libs; do
438    # Check wether the same library also exists in the parent directory,
439    # and prefer that on the assumption that it is a more generic one.
440    baselib=`echo "$lib" | sed 's,/[^/]*\(/[^/]*\)$,\1,'`
441    test -f "$baselib" && lib=$baselib
442    install -s -D $lib $RPM_BUILD_ROOT/env$lib
443 done
444 rm -rf $RPM_BUILD_ROOT/inst
445 cd $RPM_BUILD_ROOT/env
446 tar cvzf ../%{name}_%{_arch}.tar.gz *
447 cd ..
448 mkdir -p usr/share/icecream-envs
449 mv %{name}_%{_arch}.tar.gz usr/share/icecream-envs
450 rpm -q --changelog glibc >  usr/share/icecream-envs/%{name}_%{_arch}.glibc
451 rpm -q --changelog binutils >  usr/share/icecream-envs/%{name}_%{_arch}.binutils
452 rm -r env
453 cd $RPM_BUILD_DIR
454
455 %clean
456 rm -rf $RPM_BUILD_ROOT
457
458 %files
459 %defattr(-,root,root)
460 /usr/share/icecream-envs
461
462 %changelog -n cross-armv7l-gcc48-icecream-backend