gcc-8.3.0_2019_05_24.recipe revision 95e85ced
1SUMMARY="C/C++ compiler for target ${effectiveTargetMachineTriple}"
2DESCRIPTION="The standard compiler for non-legacy Haiku (i.e. for all \
3architectures other than x86_gcc2)."
4HOMEPAGE="https://gcc.gnu.org/"
5COPYRIGHT="1988-2019 Free Software Foundation, Inc."
6LICENSE="GNU GPL v3
7	GNU LGPL v3"
8REVISION="7"
9gccVersion="${portVersion%%_*}"
10SOURCE_URI="https://ftpmirror.gnu.org/gcc/gcc-$gccVersion/gcc-$gccVersion.tar.xz
11	https://ftp.gnu.org/gnu/gcc/gcc-$gccVersion/gcc-$gccVersion.tar.xz"
12CHECKSUM_SHA256="64baadfe6cc0f4947a84cb12d7f0dfaf45bb58b7e92461639596c21e02d97d2c"
13SOURCE_DIR="gcc-$gccVersion"
14PATCHES="gcc-$portVersion.patchset"
15
16ARCHITECTURES="!x86_gcc2 ?x86 x86_64 ?arm ?ppc"
17SECONDARY_ARCHITECTURES="x86"
18
19libatomicSoVersion="1"
20libatomicLibVersion="1.2.0"
21
22libgccSoVersion="1"
23libgccLibVersion="1"
24
25libgfortranSoVersion="5"
26libgfortranLibVersion="5.0.0"
27
28libgompSoVersion="1"
29libgompLibVersion="1.0.0"
30
31libquadmathSoVersion="0"
32libquadmathLibVersion="0.0.0"
33
34libsspSoVersion="0"
35libsspLibVersion="0.0.0"
36
37libstdcxxSoVersion="6"
38libstdcxxLibVersion="6.0.25"
39
40PROVIDES="
41	gcc$secondaryArchSuffix = $portVersion compat >= 7
42	cmd:c++$secondaryArchSuffix = $portVersion compat >= 7
43	cmd:cc$secondaryArchSuffix = $portVersion compat >= 7
44	cmd:cpp$secondaryArchSuffix = $portVersion compat >= 7
45	cmd:g++$secondaryArchSuffix = $portVersion compat >= 7
46	cmd:gcc$secondaryArchSuffix = $portVersion compat >= 7
47	cmd:gcc_ar$secondaryArchSuffix = $portVersion compat >= 7
48	cmd:gcc_nm$secondaryArchSuffix = $portVersion compat >= 7
49	cmd:gcc_ranlib$secondaryArchSuffix = $portVersion compat >= 7
50	cmd:gcov$secondaryArchSuffix = $portVersion compat >= 7
51	cmd:gcov_dump$secondaryArchSuffix = $portVersion compat >= 7
52	cmd:gcov_tool$secondaryArchSuffix = $portVersion compat >= 7
53	"
54REQUIRES="
55	haiku$secondaryArchSuffix
56	cmd:as$secondaryArchSuffix
57	lib:libgmp$secondaryArchSuffix
58	lib:libmpc$secondaryArchSuffix
59	lib:libmpfr$secondaryArchSuffix
60	lib:libz$secondaryArchSuffix
61	"
62
63SUMMARY_fortran="C/C++-runtime static libraries and C++ headers, needed for gfortran"
64DESCRIPTION_fortran="This package is not of general interest - it \
65contains the set of gcc's C/C++-runtime libraries and headers that is \
66required by gfortran to build fortran source code."
67PROVIDES_fortran="
68	gcc${secondaryArchSuffix}_fortran = $portVersion compat >= 7
69	cmd:gfortran$secondaryArchSuffix = $portVersion compat >= 7
70	cmd:f951$secondaryArchSuffix = $portVersion compat >= 7
71	devel:libgfortran$secondaryArchSuffix = $libgfortranLibVersion compat >= $libgfortranSoVersion
72	devel:libcaf_single$secondaryArchSuffix = $libgfortranLibVersion compat >= $libgfortranSoVersion
73	"
74REQUIRES_fortran="
75	haiku$secondaryArchSuffix
76	gcc${secondaryArchSuffix}_syslibs == $portVersion base
77	"
78
79SUMMARY_syslibs="C/C++-runtime shared libraries, needed to execute C/C++ programs"
80DESCRIPTION_syslibs="The C/C++-runtime libraries that are part of the gcc \
81distribution. This package contains the shared libraries for the runtime \
82loader, so it is required for executing most c/c++ programs."
83PROVIDES_syslibs="
84	gcc${secondaryArchSuffix}_syslibs = $portVersion compat >= 7
85	lib:libatomic$secondaryArchSuffix = $libatomicLibVersion compat >= $libatomicSoVersion
86	lib:libgcc_s$secondaryArchSuffix = $libgccLibVersion compat >= $libgccSoVersion
87	lib:libgfortran$secondaryArchSuffix = $libgfortranLibVersion compat >= $libgfortranSoVersion
88	lib:libgomp$secondaryArchSuffix = $libgompLibVersion compat >= $libgompSoVersion
89	lib:libquadmath$secondaryArchSuffix = $libquadmathLibVersion compat >= $libquadmathSoVersion
90	lib:libssp$secondaryArchSuffix = $libsspLibVersion compat >= $libsspSoVersion
91	lib:libstdc++$secondaryArchSuffix = $libstdcxxLibVersion compat >= $libstdcxxSoVersion
92	lib:libsupc++$secondaryArchSuffix = $portVersion compat >= 7
93	"
94REQUIRES_syslibs="
95	haiku$secondaryArchSuffix
96	lib:libz$secondaryArchSuffix
97	"
98
99SUMMARY_syslibs_devel="C/C++-runtime static libraries and C++ headers, needed to build Haiku"
100DESCRIPTION_syslibs_devel="This package is not of general interest - it \
101contains the set of gcc's C/C++-runtime libraries and headers that is \
102required by Haiku's build system when building Haiku."
103PROVIDES_syslibs_devel="
104	gcc${secondaryArchSuffix}_syslibs_devel = $portVersion compat >= 7
105	devel:libatomic$secondaryArchSuffix = $libatomicLibVersion compat >= $libatomicSoVersion
106	devel:libgcc$secondaryArchSuffix = $libgccLibVersion compat >= $libgccSoVersion
107	devel:libgcc_eh$secondaryArchSuffix = $libgccLibVersion compat >= $libgccSoVersion
108	devel:libgcc_eh_kernel$secondaryArchSuffix = $libgccLibVersion compat >= $libgccSoVersion
109	devel:libgcc_kernel$secondaryArchSuffix = $libgccLibVersion compat >= $libgccSoVersion
110	devel:libgcc_s$secondaryArchSuffix = $libgccLibVersion compat >= $libgccSoVersion
111	devel:libgfortran$secondaryArchSuffix = $libgfortranLibVersion compat >= $libgfortranSoVersion
112	devel:libgomp$secondaryArchSuffix = $libgompLibVersion compat >= $libgompSoVersion
113	devel:libquadmath$secondaryArchSuffix = $libquadmathLibVersion compat >= $libquadmathSoVersion
114	devel:libssp$secondaryArchSuffix = $libsspLibVersion compat >= $libsspSoVersion
115	devel:libssp_nonshared$secondaryArchSuffix = $libsspLibVersion
116	devel:libstdc++$secondaryArchSuffix = $libstdcxxLibVersion compat >= $libstdcxxSoVersion
117	devel:libstdc++fs$secondaryArchSuffix = $portVersion compat >= 7
118	devel:libsupc++$secondaryArchSuffix = $portVersion compat >= 7
119	devel:libsupc++_kernel$secondaryArchSuffix = $portVersion compat >= 7
120	"
121REQUIRES_syslibs_devel=""
122
123BUILD_REQUIRES="
124	haiku${secondaryArchSuffix}_devel
125	devel:libgmp$secondaryArchSuffix >= 10.3.0
126	devel:libmpc$secondaryArchSuffix >= 3.1.0
127	devel:libmpfr$secondaryArchSuffix >= 4.1.4
128	devel:libz$secondaryArchSuffix
129	"
130BUILD_PREREQUIRES="
131	cmd:autoconf
132	cmd:awk
133	cmd:find
134	cmd:flex
135	cmd:gcc$secondaryArchSuffix
136	cmd:ld$secondaryArchSuffix
137	cmd:make
138	cmd:makeinfo
139	cmd:sed
140	cmd:strip
141	cmd:tar
142	cmd:xargs
143	"
144
145relativeInstallDir="develop/tools$secondaryArchSubDir"
146installDir="$prefix/$relativeInstallDir"
147objectsDir=$sourceDir/../${portVersionedName}-obj
148gccLibDir=lib/gcc/$effectiveTargetMachineTriple/$gccVersion
149
150defineDebugInfoPackage gcc$secondaryArchSuffix \
151	"$gccLibDir"/cc1 \
152	"$gccLibDir"/cc1obj \
153	"$gccLibDir"/cc1plus \
154	"$gccLibDir"/collect2 \
155	"$gccLibDir"/lto1 \
156	"$gccLibDir"/lto-wrapper \
157	"$installDir/bin"/cpp \
158	"$installDir/bin"/g++ \
159	"$installDir/bin"/gcc \
160	"$installDir/bin"/gcc-ar \
161	"$installDir/bin"/gcc-nm \
162	"$installDir/bin"/gcc-ranlib \
163	"$installDir/bin"/gcov \
164	"$installDir/bin"/gcov-dump \
165	"$installDir/bin"/gcov-tool \
166	"$(getPackagePrefix fortran)/$relativeInstallDir"/bin/gfortran \
167	"$(getPackagePrefix fortran)/$relativeInstallDir/$gccLibDir"/f951 \
168	"$(getPackagePrefix syslibs)/$relativeLibDir"/libatomic.so.$libatomicLibVersion \
169	"$(getPackagePrefix syslibs)/$relativeLibDir"/libgcc_s.so.$libgccSoVersion \
170	"$(getPackagePrefix syslibs)/$relativeLibDir"/libgfortran.so.$libgfortranLibVersion \
171	"$(getPackagePrefix syslibs)/$relativeLibDir"/libgomp.so.$libgompLibVersion \
172	"$(getPackagePrefix syslibs)/$relativeLibDir"/libquadmath.so.$libquadmathLibVersion \
173	"$(getPackagePrefix syslibs)/$relativeLibDir"/libssp.so.$libsspLibVersion \
174	"$(getPackagePrefix syslibs)/$relativeLibDir"/libstdc++.so.$libstdcxxLibVersion \
175	"$(getPackagePrefix syslibs)/$relativeLibDir"/libsupc++.so
176
177BUILD()
178{
179	rm -rf $objectsDir
180
181	# Touch some files generated by bison, so that bison won't run to update
182	# them. Fixes issues with newer bison versions.
183	# And while at it, touch gperf target, too (as gperf may not be installed).
184	(cd $sourceDir/gcc; touch c-parse.c c-parse.h cexp.c cp/parse.c \
185		cp/parse.h c-gperf.h)
186
187	mkdir -p $objectsDir
188	cd $objectsDir
189
190	local additionalConfigureFlags
191	if [ -n "$secondaryArchSuffix" ]; then
192		additionalConfigureFlags="\
193			--with-hybrid-secondary=${effectiveTargetArchitecture}"
194	fi
195	local kernelCcFlags="-D_KERNEL_MODE"
196	if [ $effectiveTargetArchitecture == x86_64 ]; then
197		# disable multilib support, as x86_64 by default tries to build the
198		# 32-bit libraries, too, which fails as no 32-bit libroot is available
199		additionalConfigureFlags+=" --disable-multilib"
200
201		# deactivate red zone for x86_64
202		kernelCcFlags="$kernelCcFlags -mno-red-zone"
203	fi
204
205	"$sourceDir/configure" \
206		--build=$effectiveTargetMachineTriple \
207		--prefix=$installDir --libexecdir=$installDir/lib --mandir=$manDir \
208		--docdir=$docDir --enable-threads=posix \
209		--disable-nls --enable-shared --with-gnu-ld --with-gnu-as \
210		--enable-version-specific-runtime-libs \
211		--enable-languages=c,c++,fortran,objc --enable-lto \
212		--enable-frame-pointer \
213		--with-pkgversion=$(echo $portVersion | cut -d_ -f2-) \
214		--enable-__cxa-atexit --with-system-zlib --enable-checking=release \
215		--with-bug-url=http://dev.haiku-os.org/ \
216		--with-default-libstdcxx-abi=gcc4-compatible \
217		--enable-libssp \
218		$additionalConfigureFlags
219
220	make $jobArgs
221
222	echo "######################## building special libraries ################"
223
224	echo "### libgcc"
225
226	# build kernel versions of libgcc.a and libgcc_eh.a (no threads or TLS)
227	cd $objectsDir/$effectiveTargetMachineTriple/libgcc
228	mkdir -p saved
229	mv libgcc.a libgcc_eh.a libgcc_s* libgcov* saved/
230	make clean
231	ln -sfn "$sourceDir/libgcc/gthr-single.h" gthr-default.h
232	make CFLAGS="-O2 $kernelCcFlags" CXXFLAGS="-O2 $kernelCcFlags"
233	mv libgcc.a libgcc-kernel.a
234	mv libgcc_eh.a libgcc_eh-kernel.a
235	ln -sfn "$sourceDir/libgcc/gthr-posix.h" gthr-default.h
236	mv saved/* .
237	rmdir saved
238
239	# build kernel version of libsupc++.a (without threads or TLS)
240	cd $objectsDir/$effectiveTargetMachineTriple/libstdc++-v3/libsupc++
241	mkdir -p saved
242	mv .libs/libsupc++* saved/
243	cp "../include/$effectiveTargetMachineTriple/bits/gthr-default.h" \
244		"../config.h" \
245		"../include/$effectiveTargetMachineTriple/bits/c++config.h" \
246		saved/
247	make clean
248	cp "../include/$effectiveTargetMachineTriple/bits/gthr-single.h" \
249		"../include/$effectiveTargetMachineTriple/bits/gthr-default.h"
250	sed -i -e 's,#define _GLIBCXX_HAS_GTHREADS 1,/* #undef _GLIBCXX_HAS_GTHREADS */,' \
251		"../config.h"
252	sed -i -e 's,#define _GLIBCXX_HAVE_TLS 1,/* #undef _GLIBCXX_HAVE_TLS */,' \
253		"../include/$effectiveTargetMachineTriple/bits/c++config.h"
254	make CFLAGS="-O2 $kernelCcFlags" CXXFLAGS="-O2 $kernelCcFlags"
255	mv .libs/libsupc++.a .libs/libsupc++-kernel.a
256	mv saved/libsupc++* .libs/
257	mv saved/gthr-default.h "../include/$effectiveTargetMachineTriple/bits/"
258	mv saved/config.h ..
259	mv saved/c++config.h "../include/$effectiveTargetMachineTriple/bits/"
260	rmdir saved
261}
262
263INSTALL()
264{
265	cd $objectsDir
266
267	make install
268	make install-html
269
270	### HTML documentation ####################################
271
272	echo "Organizing HTML documentation..."
273	cd $docDir
274	for dir in libquadmath; do
275		mv ${dir}.html $dir
276		ln -s $dir/index.html ${dir}.html
277	done
278
279	### Libraries #############################################
280
281	echo "Moving libraries around"
282
283	# Move/copy libraries such that copies of the runtime (shared) libs exist
284	# in $libDir and copies of static libraries exist in $developLibDir. These
285	# are put into separate packages gcc_syslibs and gcc_syslibs_devel, which
286	# are both used by Haiku's build system.
287	mkdir -p $libDir
288	mkdir -p $developLibDir
289	cd $installDir
290
291	# libatomic
292	cp -d $gccLibDir/libatomic.so \
293		$gccLibDir/libatomic.so.$libatomicSoVersion \
294		$gccLibDir/libatomic.so.$libatomicLibVersion \
295		$libDir/
296	rm $gccLibDir/libatomic*.a
297
298	# libgfortran
299	cp -d $gccLibDir/libgfortran.so \
300		$gccLibDir/libgfortran.so.$libgfortranSoVersion \
301		$gccLibDir/libgfortran.so.$libgfortranLibVersion \
302		$libDir/
303	cp $gccLibDir/libgfortran*.a $developLibDir/
304
305	# libgomp
306	cp -d $gccLibDir/libgomp.so \
307		$gccLibDir/libgomp.so.$libgompSoVersion \
308		$gccLibDir/libgomp.so.$libgompLibVersion \
309		$libDir/
310	rm $gccLibDir/libgomp*.a
311
312	# libquadmath
313	cp -d $gccLibDir/libquadmath.so \
314		$gccLibDir/libquadmath.so.$libquadmathSoVersion \
315		$gccLibDir/libquadmath.so.$libquadmathLibVersion \
316		$libDir/
317	rm $gccLibDir/libquadmath*.a
318
319	# libssp
320	cp -d $gccLibDir/libssp.so \
321		$gccLibDir/libssp.so.$libsspSoVersion \
322		$gccLibDir/libssp.so.$libsspLibVersion \
323		$libDir/
324	rm $gccLibDir/libssp.a
325	cp $gccLibDir/libssp_nonshared.a $developLibDir
326
327	# libstdc++
328	cp -d $gccLibDir/libstdc++.so \
329		$gccLibDir/libstdc++.so.$libstdcxxSoVersion \
330		$gccLibDir/libstdc++.so.$libstdcxxLibVersion \
331		$libDir/
332	rm $gccLibDir/libstdc++.a
333	cp $gccLibDir/libstdc++fs.a $developLibDir
334
335	# libsupc++
336	libstdcxxDir=$objectsDir/$effectiveTargetMachineTriple/libstdc++-v3
337	cp $libstdcxxDir/libsupc++/.libs/libsupc++-kernel.a \
338		$gccLibDir/
339	ln -s libstdc++.so $libDir/libsupc++.so
340	cp $gccLibDir/libsupc++*.a $developLibDir/
341
342	# libgcc
343	cp $objectsDir/$effectiveTargetMachineTriple/libgcc/libgcc-kernel.a \
344		$objectsDir/$effectiveTargetMachineTriple/libgcc/libgcc_eh-kernel.a \
345		$gccLibDir/
346	cp -d $gccLibDir/libgcc_s.so \
347		$gccLibDir/libgcc_s.so.$libgccSoVersion \
348		$libDir/
349	cp $gccLibDir/libgcc*.a $developLibDir/
350
351	# gcc and c++ headers
352	mkdir -p $includeDir/gcc
353	cp -r $gccLibDir/include $includeDir/gcc/
354	cp -r $gccLibDir/include-fixed $includeDir/gcc/
355	mv $includeDir/gcc/include/c++ $includeDir/
356
357	### Strip #################################################
358
359	echo "Strip"
360
361	strip --strip-debug \
362		$gccLibDir/*.a \
363		$developLibDir/*.a
364
365	### Disable ASLR ##########################################
366
367	echo "Add SYS:ENV attribute to disable ASLR"
368
369	cd $installDir
370	for f in bin/*; do
371		if [ -r "$f" ]; then
372			addattr SYS:ENV DISABLE_ASLR=1 $f
373		fi
374	done
375	for f in cc1 cc1plus collect2 f951 lto1; do
376		addattr SYS:ENV DISABLE_ASLR=1 \
377			$gccLibDir/$f
378	done
379
380	### Symlinks ##############################################
381
382	echo "Creating required symlinks"
383
384	# create missing cc symlink
385	ln -sf gcc $installDir/bin/cc
386
387	# make all tools available via default paths
388	mkdir -p $binDir
389	for f in c++ cc cpp g++ gcc gcov gfortran gcc-ar gcc-nm gcc-ranlib; do
390		symlinkRelative -sfn $installDir/bin/$f $binDir
391	done
392
393	# symlink all libraries from libDir -> developLibDir
394	mkdir -p $developLibDir
395	for l in libatomic libgomp libquadmath libssp libgcc_s libstdc++ \
396			libsupc++; do
397		for f in $libDir/$l*; do
398			symlinkRelative -sfn $f $developLibDir/
399		done
400	done
401
402	### Cleanup ###############################################
403
404	echo "Cleanup"
405	rm -rf $installDir/info
406	rm -rf $installDir/share
407	rm -rf $installDir/$gccLibDir/*.la
408	rm -rf $installDir/$gccLibdir/libobjc.*
409	rm -rf $installDir/$gccLibdir/include/objc
410	rm -rf $includeDir/gcc/include/objc
411
412	### Sub Packages ##########################################
413
414	packageEntries "fortran" \
415		$relativeBinDir/gfortran \
416		$developDir/tools$secondaryArchSubDir/bin/*gfortran \
417		$installDir/$gccLibDir/f951 \
418		$installDir/$gccLibDir/finclude \
419		$installDir/$gccLibDir/libcaf_single.a \
420		$installDir/$gccLibDir/libgfortran.a \
421		$installDir/$gccLibDir/libgfortran.spec
422
423	rm -rf $installDir/$gccLibDir/{f951, finclude, libcaf_single*, libgfortran*}
424
425	packageEntries "syslibs" \
426		$relativeLibDir/libatomic.so \
427		$relativeLibDir/libatomic.so.$libatomicSoVersion \
428		$relativeLibDir/libatomic.so.$libatomicLibVersion \
429		$relativeLibDir/libgcc_s.so \
430		$relativeLibDir/libgcc_s.so.$libgccSoVersion \
431		$relativeLibDir/libgfortran.so \
432		$relativeLibDir/libgfortran.so.$libgfortranSoVersion \
433		$relativeLibDir/libgfortran.so.$libgfortranLibVersion \
434		$relativeLibDir/libgomp.so \
435		$relativeLibDir/libgomp.so.$libgompSoVersion \
436		$relativeLibDir/libgomp.so.$libgompLibVersion \
437		$relativeLibDir/libquadmath.so \
438		$relativeLibDir/libquadmath.so.$libquadmathSoVersion \
439		$relativeLibDir/libquadmath.so.$libquadmathLibVersion \
440		$relativeLibDir/libssp.so \
441		$relativeLibDir/libssp.so.$libsspSoVersion \
442		$relativeLibDir/libssp.so.$libsspLibVersion \
443		$relativeLibDir/libstdc++.so \
444		$relativeLibDir/libstdc++.so.$libstdcxxSoVersion \
445		$relativeLibDir/libstdc++.so.$libstdcxxLibVersion \
446		$relativeLibDir/libsupc++.so
447
448	packageEntries "syslibs_devel" \
449		$developLibDir/*.so* \
450		$developLibDir/libgcc.a \
451		$developLibDir/libgcc-kernel.a \
452		$developLibDir/libgcc_eh.a \
453		$developLibDir/libgcc_eh-kernel.a \
454		$developLibDir/libssp_nonshared.a \
455		$developLibDir/libstdc++fs.a \
456		$developLibDir/libsupc++.a \
457		$developLibDir/libsupc++-kernel.a \
458		$relativeIncludeDir
459
460	rm -rf $includeDir
461	rm -rf $developLibDir
462}
463