summaryrefslogtreecommitdiff
path: root/manualPorts/gcc/Pkgfile
blob: f4903dace3f57e7704d27a53b35436a13a8aef0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Description: The GNU Compiler Collection
# URL: https://gcc.gnu.org
# Contributor: CRUX System Team, core-ports at crux dot nu
# Maintainer: Erich Eckner, crux at eckner dot net
# Depends on: libmpc zlib zstd

# You can use http://mirrors.cdn.adacore.com/art/591c6d80c7a447af2deed1d7
# to bootstrap (then you only need core/gcc installed). Run
# > find $install_dir \( -name ld -o -name -as \) -delete
# and
# export PATH="$install_dir/bin:$PATH"
# before compiling ($install_dir should be the directory into which you
# temporarily installed gnat-gpl).

name=gcc
version=12.4.0
release=1
source=(https://sourceware.org/pub/gcc/releases/gcc-$version/$name-$version.tar.xz
	$name-nocheck-fixincludes.patch $name-4.7.3-multilib-dirs.patch)

build() {
	# fix libasan.a
	sed -e '/static.*SIGSTKSZ/d' \
		-e 's/return kAltStackSize/return SIGSTKSZ * 4/' \
		-i $name-$version/libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cpp

	patch -d $name-$version -p1 -i $SRC/$name-nocheck-fixincludes.patch
	patch -d $name-$version -p1 -i $SRC/$name-4.7.3-multilib-dirs.patch

	# pipe fails tests
	CFLAGS=${CFLAGS/-pipe/}
	CXXFLAGS=${CXXFLAGS/-pipe/}

	mkdir build
	cd build
	../$name-$version/configure \
		--prefix=/usr \
		--libexecdir=/usr/lib \
		--enable-languages=ada,c,c++,lto \
		--enable-threads=posix \
		--enable-__cxa_atexit \
		--enable-clocale=gnu \
		--enable-shared \
		--enable-lto \
		--with-x=no \
		--enable-multilib \
		--enable-plugin \
		--enable-default-pie \
		--enable-default-ssp \
		--with-pkgversion="CRUX-x86_64-multilib" \
		--with-system-zlib \
		--disable-nls
	make bootstrap
	make -j1 DESTDIR=$PKG install

	install -d $PKG/lib
	ln -sf ../usr/bin/cpp $PKG/lib/cpp
	ln -sf gcc $PKG/usr/bin/cc
	ln -sf g++ $PKG/usr/bin/c++

	mv $PKG/usr/lib/gcc/*/$version/include-fixed/{limits.h,syslimits.h} $PKG/usr/lib/gcc/*/$version/include/
	rm -r $PKG/usr/share/{info,$name-$version}
	rm -r $PKG/usr/bin/*-linux-gnu-*
	rm -r $PKG/usr/lib/gcc/*/$version/{install-tools,include-fixed}

	for D in lib{,32}; do
		install -d -m 0755 $PKG/usr/share/gdb/auto-load/usr/${D}
		mv $PKG/usr/${D}/libstdc++.so.*-gdb.py $PKG/usr/share/gdb/auto-load/usr/${D}
	done

	sed -i "s|-L$SRC[^ ]* ||g" $PKG/usr/lib{,32}/{libstdc++.la,libsupc++.la}
}