summaryrefslogblamecommitdiff
path: root/system/gcc/APKBUILD
blob: aebf3b6662ca94fb1242403b5c6ace9f6664bd7e (plain) (tree)
1
2
3
4
5
6
7
8
9







                                                                        
        


                                     
                                


                                                                                                           
                                                                                           
               
                                                                           
                             
                                              





                       
                    































































                                                                  
                                                      
                                                                  

                               
                                              





                                                      
                                                    
















































































                                                                                                   


                                           


                                       
                         













































                                                                        
                                                                                                                                                     


                                                                                                                                                                                   
                                                                                          















                                                                                                                                                              
                                                                                              

                                             
                                            












































                                                                                                        









































































































































































                                                                                                             
                                                                         









                                                                            


                                                         






























                                                                             


                                                                              




















                                                             

                                                        
                                                                
                                                                


                                                

                                                   



































































































                                                                                                                                                                                  

                                                                                                                                                                     
                                                                                                                                                      

                                                                                                                                                                 
# Maintainer: Adelie Platform Group <adelie-devel@lists.adelielinux.org>
pkgname=gcc
pkgver=6.4.0
[ "$BOOTSTRAP" = "nolibc" ] && pkgname="gcc-pass2"
[ "$CBUILD" != "$CHOST" ] && _cross="-$CARCH" || _cross=""
[ "$CHOST" != "$CTARGET" ] && _target="-$CTARGET_ARCH" || _target=""

pkgname="$pkgname$_target"
pkgrel=9
pkgdesc="The GNU Compiler Collection"
url="http://gcc.gnu.org"
arch="all"
license="GPL-3.0+ AND LGPL-2.1+"
_gccrel=$pkgver-r$pkgrel
depends="binutils$_target isl"
makedepends_build="gcc$_cross g++$_cross paxmark bison flex texinfo zip gmp-dev mpfr-dev mpc1-dev zlib-dev"
makedepends_host="linux-headers gmp-dev mpfr-dev mpc1-dev isl-dev zlib-dev libucontext-dev"
subpackages=" "
[ "$CHOST" = "$CTARGET" ] && subpackages="gcc-doc$_target gcc-lang$_target"
replaces="libstdc++ binutils"
options="$options !check !dbg strip toolchain"

: ${LANG_CXX:=true}
: ${LANG_OBJC:=true}
: ${LANG_JAVA:=true}
: ${LANG_GO:=true}
: ${LANG_FORTRAN:=true}
: ${LANG_ADA:=false}

LIBGOMP=true
LIBGCC=true
LIBATOMIC=true
LIBITM=true

if [ "$CHOST" != "$CTARGET" ]; then
	if [ "$BOOTSTRAP" = nolibc ]; then
		LANG_CXX=false
		LANG_ADA=false
		LIBGCC=false
		_builddir="$srcdir/build-cross-pass2"
	else
		_builddir="$srcdir/build-cross-final"
	fi
	LANG_OBJC=false
	LANG_JAVA=false
	LANG_GO=false
	LANG_FORTRAN=false
	LIBGOMP=false
	LIBATOMIC=false
	LIBITM=false

	# reset target flags (should be set in crosscreate abuild)
	# fixup flags. seems gcc treats CPPFLAGS as global without
	# _FOR_xxx variants. wrap it in CFLAGS and CXXFLAGS.
	export CFLAGS="$CPPFLAGS $CFLAGS"
	export CXXFLAGS="$CPPFLAGS $CXXFLAGS"
	unset CPPFLAGS
	export CFLAGS_FOR_TARGET=" "
	export CXXFLAGS_FOR_TARGET=" "
	export LDFLAGS_FOR_TARGET=" "

	STRIP_FOR_TARGET="$CTARGET-strip"
elif [ "$CBUILD" != "$CHOST" ]; then
	# fixup flags. seems gcc treats CPPFLAGS as global without
	# _FOR_xxx variants. wrap it in CFLAGS and CXXFLAGS.
	export CFLAGS="$CPPFLAGS $CFLAGS"
	export CXXFLAGS="$CPPFLAGS $CXXFLAGS"
	unset CPPFLAGS

	# reset flags and cc for build
	export CC_FOR_BUILD="gcc"
	export CXX_FOR_BUILD="g++"
	export CFLAGS_FOR_BUILD=" "
	export CXXFLAGS_FOR_BUILD=" "
	export LDFLAGS_FOR_BUILD=" "
	export CFLAGS_FOR_TARGET=" "
	export CXXFLAGS_FOR_TARGET=" "
	export LDFLAGS_FOR_TARGET=" "

	# Languages that do not need bootstrapping
	LANG_OBJC=false
	LANG_JAVA=false
	LANG_GO=false
	LANG_FORTRAN=false

	STRIP_FOR_TARGET=${CROSS_COMPILE}strip
	_builddir="$srcdir/build-cross-native"
else
	STRIP_FOR_TARGET=${CROSS_COMPILE}strip
	_builddir="$srcdir/build"
fi

# libitm has TEXTRELs in ARM build, so disable for now
# gcc itself has TEXTRELs in m68k; until this is fixed, we need it
case "$CTARGET_ARCH" in
arm*)		LIBITM=false ;;
m68k)		options="$options textrels" ;;
esac

# Fortran uses libquadmath if toolchain has __float128
# currently on x86, x86_64 and ia64
LIBQUADMATH=$LANG_FORTRAN
case "$CTARGET_ARCH" in
pmmx | x86 | x86_64)	LIBQUADMATH=$LANG_FORTRAN ;;
*)			LIBQUADMATH=false ;;
esac

# libatomic is a dependency for openvswitch
$LIBATOMIC && subpackages="$subpackages libatomic::$CTARGET_ARCH"
$LIBGCC && subpackages="$subpackages libgcc::$CTARGET_ARCH"
$LIBQUADMATH && subpackages="$subpackages libquadmath::$CTARGET_ARCH"
if $LIBGOMP; then
	depends="$depends libgomp=$_gccrel"
	subpackages="$subpackages libgomp::$CTARGET_ARCH"
fi

_languages=c
if $LANG_CXX; then
	subpackages="$subpackages libstdc++:libcxx:$CTARGET_ARCH g++$_target:gpp"
	_languages="$_languages,c++"
fi
if $LANG_OBJC; then
	subpackages="$subpackages libobjc::$CTARGET_ARCH gcc-objc$_target:objc"
	_languages="$_languages,objc"
fi
if $LANG_JAVA; then
	subpackages="$subpackages libgcj::$CTARGET_ARCH gcc-java$_target:java"
	_languages="$_languages,java"
fi
if $LANG_GO; then
	subpackages="$subpackages libgo::$CTARGET_ARCH gcc-go$_target:go"
	_languages="$_languages,go"
fi
if $LANG_FORTRAN; then
	subpackages="$subpackages libgfortran::$CTARGET_ARCH gfortran$_target:gfortran"
	_languages="$_languages,fortran"
fi
if $LANG_ADA; then
	subpackages="$subpackages libgnat::$CTARGET_ARCH gcc-gnat$_target:gnat"
	_languages="$_languages,ada"
	makedepends_build="$makedepends_build gcc-gnat gcc-gnat$_cross"
fi
makedepends="$makedepends_build $makedepends_host"

source="ftp://gcc.gnu.org/pub/gcc/releases/gcc-${_pkgbase:-$pkgver}/gcc-${_pkgbase:-$pkgver}.tar.xz
	ftp://sourceware.org/pub/java/ecj-4.9.jar

	001_all_default-ssp-strong.patch
	002_all_default-relro.patch
	003_all_default-fortify-source.patch
	005_all_default-as-needed.patch
	011_all_default-warn-format-security.patch
	012_all_default-warn-trampolines.patch
	020_all_msgfmt-libstdc++-link.patch
	050_all_libiberty-asprintf.patch
	051_all_libiberty-pic.patch
	053_all_libitm-no-fortify-source.patch
	067_all_gcc-poison-system-directories.patch
	090_all_pr55930-dependency-tracking.patch

	201-cilkrts.patch
	203-libgcc_s.patch
	204-linux_libc_has_function.patch
	205-nopie.patch
	207-static-pie.patch

	libgcc-always-build-gcceh.a.patch
	gcc-4.9-musl-fortify.patch
	gcc-6.1-musl-libssp.patch
	boehm-gc-musl.patch
	gcc-pure64.patch
	fix-gcj-stdgnu14-link.patch
	fix-gcj-musl.patch
	fix-gcj-iconv-musl.patch

	gcc-4.8-build-args.patch
	fix-cxxflags-passing.patch
	ada-fixes.patch
	ada-shared.patch
	ada-musl.patch
	ada-aarch64-multiarch.patch

	300-main-gcc-add-musl-s390x-dynamic-linker.patch
	310-build-gcj-s390x.patch
	320-libffi-gnulinux.patch
	330-gccgo-link-to-ucontext.patch
	331-gccgo-use-real-off_t-type.patch
	332-gccgo-remove-ustat.patch

	fix-rs6000-pie.patch
	add-classic_table-support.patch
	lra-pentium.patch
	"

# we build out-of-tree
_gccdir="$srcdir"/gcc-${_pkgbase:-$pkgver}
_gcclibdir=/usr/lib/gcc/${CTARGET}/$pkgver
_gcclibexec=/usr/libexec/gcc/${CTARGET}/$pkgver

prepare() {
	cd "$_gccdir"

	_err=
	for i in $source; do
		case "$i" in
		*.patch)
			msg "Applying $i"
			patch -p1 -F3 -i "$srcdir"/$i || _err="$_err $i"
			;;
		esac
	done

	if [ -n "$_err" ]; then
		error "The following patches failed:"
		for i in $_err; do
			echo "  $i"
		done
		return 1
	fi

	# see http://gcc.gnu.org/ml/java/2008-04/msg00027.html
	mv "$srcdir"/ecj-*.jar ecj.jar

	echo ${pkgver} > gcc/BASE-VER
	echo "UNSUPPORTED=1" > libcilkrts/configure.tgt
}

build() {
	local _arch_configure=
	local _libc_configure=
	local _cross_configure=
	local _bootstrap_configure=
	local _hash_style=gnu
	local _symvers=

	cd "$_gccdir"

	case "$CTARGET" in
	aarch64-*-*-*)		_arch_configure="--with-arch=armv8-a --with-abi=lp64 --enable-fix-cortex-a53-835769 --enable-fix-cortex-a53-843419";;
	armv5-*-*-*eabi)	_arch_configure="--with-arch=armv5te --with-tune=arm926ej-s --with-float=soft --with-abi=aapcs-linux";;
	armv6-*-*-*eabihf)	_arch_configure="--with-arch=armv6zk --with-tune=arm1176jzf-s --with-fpu=vfp --with-float=hard --with-abi=aapcs-linux";;
	armv7-*-*-*eabihf)	_arch_configure="--with-arch=armv7-a --with-tune=generic-armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-abi=aapcs-linux --with-mode=thumb";;
	m68k-*-*-*)		_arch_configure="--with-arch=68020 --with-tune=68020-40";;
	mipsel-*-*-*)		_arch_configure="--with-arch-32=mips2 --with-tune-32=mips32 --with-fp-32=32 --with-mips-plt --with-float=hard --with-abi=32";;
	mips-*-*-*)		_arch_configure="--with-arch=mips3 --with-mips-plt --with-abi=32"; _hash_style="sysv";;
	mips32el-*-*-*)		_arch_configure="--with-arch=mips32 --with-mips-plt --with-abi=32"; _hash_style="sysv";;
	powerpc-*-*-*)		_arch_configure="--enable-secureplt --enable-decimal-float=no";;
	powerpc64*-*-*-*)	_arch_configure="--with-abi=elfv2 --enable-secureplt --enable-decimal-float=no";;
	powerpc64le*-*-*-*)	_arch_configure="--with-abi=elfv2 --enable-secureplt --enable-decimal-float=no";;
	i486-*-*-*)		_arch_configure="--with-arch=i486 --with-tune=generic --enable-cld";;
	i586-*-*-*)		_arch_configure="--with-arch=i586 --with-tune=pentium2 --enable-cld --enable-mmx";;
	pentium3-*-*-*)		_arch_configure="--with-arch=pentium3 --with-tune=pentium-m";;
	s390x-*-*-*)		_arch_configure="--with-arch=z196 --with-tune=zEC12 --with-zarch --with-long-double-128 --enable-decimal-float";;
	esac

	case "$CTARGET_LIBC" in
	musl)
		# musl does not support mudflap, or libsanitizer
		# libmpx uses secure_getenv and struct _libc_fpstate not present in musl
		_libc_configure="--disable-libmpx --disable-libmudflap --disable-libsanitizer"
		_symvers="--disable-symvers"
		export libat_cv_have_ifunc=no
		export ac_cv_type_off64_t=no
		;;
	esac

	[ "$CBUILD" != "$CHOST"   ] && _cross_configure="--disable-bootstrap"
	[ "$CHOST"  != "$CTARGET" ] && _cross_configure="--disable-bootstrap --with-sysroot=$CBUILDROOT"

	case "$BOOTSTRAP" in
	nolibc)	_bootstrap_configure="--with-newlib --disable-shared --enable-threads=no" ;;
	*)	_bootstrap_configure="--enable-shared --enable-threads --enable-tls" ;;
	esac

	$LIBGOMP	|| _bootstrap_configure="$_bootstrap_configure --disable-libgomp"
	$LIBATOMIC	|| _bootstrap_configure="$_bootstrap_configure --disable-libatomic"
	$LIBITM		|| _bootstrap_configure="$_bootstrap_configure --disable-libitm"
	$LIBQUADMATH	|| _arch_configure="$_arch_configure --disable-libquadmath"

	msg "Building the following:"
	echo ""
	echo "  CBUILD=$CBUILD"
	echo "  CHOST=$CHOST"
	echo "  CTARGET=$CTARGET"
	echo "  CTARGET_ARCH=$CTARGET_ARCH"
	echo "  CTARGET_LIBC=$CTARGET_LIBC"
	echo "  languages=$_languages"
	echo "  arch_configure=$_arch_configure"
	echo "  libc_configure=$_libc_configure"
	echo "  cross_configure=$_cross_configure"
	echo "  bootstrap_configure=$_bootstrap_configure"
	echo "  hash_style=$_hash_style"
	echo ""

	mkdir -p "$_builddir"
	cd "$_builddir"
	"$_gccdir"/configure --prefix=/usr \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--build=${CBUILD} \
		--host=${CHOST} \
		--target=${CTARGET} \
		--with-pkgversion="Adelie ${pkgver}" \
		--with-bugurl="http://bts.adelielinux.org/" \
		--enable-checking=release \
		--disable-fixed-point \
		--disable-libstdcxx-pch \
		--disable-multilib \
		--disable-werror \
		$_symvers \
		--enable-__cxa_atexit \
		--enable-default-pie \
		--enable-cloog-backend \
		--enable-languages=$_languages \
		$_arch_configure \
		$_libc_configure \
		$_cross_configure \
		$_bootstrap_configure \
		--with-system-zlib \
		--with-linker-hash-style=$_hash_style
	make
}

check() {
	cd "$_builddir"
	make check
}

package() {
	cd "$_builddir"
	make -j1 DESTDIR="${pkgdir}" install

	ln -s gcc "$pkgdir"/usr/bin/cc

	# we dont support gcj -static
	# and saving 35MB is not bad.
	find "$pkgdir" -name libgcj.a -o -name libgtkpeer.a \
		-o -name libgjsmalsa.a -o -name libgcj-tools.a \
		-o -name libjvm.a -o -name libgij.a -o -name libgcj_bc.a \
		-o -name libjavamath.a \
		| xargs rm -f

	# strip debug info from some static libs
	${STRIP_FOR_TARGET} -g `find "$pkgdir" \( -name libgfortran.a -o -name libobjc.a -o -name libgomp.a \
		-o -name libmudflap.a -o -name libmudflapth.a \
		-o -name libgcc.a -o -name libgcov.a -o -name libquadmath.a \
		-o -name libitm.a -o -name libgo.a -o -name libcaf\*.a \
		-o -name libatomic.a -o -name libasan.a -o -name libtsan.a \) \
		-a -type f`

	if $LANG_JAVA; then
		sed -i -e 's/lib: /&%{static:%eJava programs cannot be linked statically}/' \
			"$pkgdir"/usr/lib/libgcj.spec
	fi

	if $LIBGOMP; then
		mv "$pkgdir"/usr/lib/libgomp.spec "$pkgdir"/$_gcclibdir
	fi
	if $LIBITM; then
		mv "$pkgdir"/usr/lib/libitm.spec "$pkgdir"/$_gcclibdir
	fi

	# remove ffi
	rm -f "$pkgdir"/usr/lib/libffi* "$pkgdir"/usr/share/man/man3/ffi*
	find "$pkgdir" -name 'ffi*.h' | xargs rm -f

	local gdblib=${_target:+$CTARGET/}lib
	for i in $(find "$pkgdir"/usr/$gdblib/ -type f -maxdepth 1 -name "*-gdb.py" ); do
		mkdir -p "$pkgdir"/usr/share/gdb/python/auto-load/usr/$gdblib
		mv "$i" "$pkgdir"/usr/share/gdb/python/auto-load/usr/$gdblib/
	done

	paxmark -pmrs "$pkgdir"/$_gcclibexec/cc1

	# move ada runtime libs
	if $LANG_ADA; then
		for i in $(find "$pkgdir"/$_gcclibdir/adalib/ -type f -maxdepth 1 -name "libgna*.so"); do
			mv "$i" "$pkgdir"/usr/lib/
			ln -s ../../../../${i##*/} $i
		done
	fi

	if [ "$CHOST" != "$CTARGET" ]; then
		# cross-gcc: remove any files that would conflict with the
		# native gcc package
		rm -rf "$pkgdir"/usr/bin/cc "$pkgdir"/usr/include "$pkgdir"/usr/share
		# libcc1 does not depend on target, don't ship it
		rm -rf "$pkgdir"/usr/lib/libcc1.so*

		# fixup gcc library symlinks to be linker scripts so
		# linker finds the libs from relocated sysroot
		for so in "$pkgdir"/usr/$CTARGET/lib/*.so; do
			if [ -h "$so" ]; then
				local _real=$(basename $(readlink "$so"))
				rm -f "$so"
				echo "GROUP ($_real)" > "$so"
			fi
		done
	fi
}

libatomic() {
	pkgdesc="GCC Atomic library"
	depends=
	replaces="gcc"

	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/${_target:+$CTARGET/}lib/libatomic.so.* "$subpkgdir"/usr/lib/
}

libcxx() {
	pkgdesc="GNU C++ standard runtime library"
	depends=

	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/${_target:+$CTARGET/}lib/libstdc++.so.* "$subpkgdir"/usr/lib/
}

gpp() {
	pkgdesc="GNU C++ standard library and compiler"
	depends="libstdc++=$_gccrel gcc=$_gccrel libc-dev"
	mkdir -p "$subpkgdir/$_gcclibexec" \
		"$subpkgdir"/usr/bin \
		"$subpkgdir"/usr/${_target:+$CTARGET/}include \
		"$subpkgdir"/usr/${_target:+$CTARGET/}lib \

	mv "$pkgdir/$_gcclibexec/cc1plus" "$subpkgdir/$_gcclibexec/"
	paxmark -pmrs "$subpkgdir/$_gcclibexec/cc1plus"

	mv "$pkgdir"/usr/${_target:+$CTARGET/}lib/*++* "$subpkgdir"/usr/${_target:+$CTARGET/}lib/
	mv "$pkgdir"/usr/${_target:+$CTARGET/}include/c++ "$subpkgdir"/usr/${_target:+$CTARGET/}include/
	mv "$pkgdir"/usr/bin/*++ "$subpkgdir"/usr/bin/
}

libobjc() {
	pkgdesc="GNU Objective-C runtime"
	replaces="objc"
	depends=
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/${_target:+$CTARGET/}lib/libobjc.so.* "$subpkgdir"/usr/lib/
}

objc() {
	pkgdesc="GNU Objective-C"
	replaces="gcc"
	depends="libc-dev gcc=$_gccrel libobjc=$_gccrel"

	mkdir -p "$subpkgdir"/$_gcclibdir/include \
		"$subpkgdir"/usr/lib
	mv "$pkgdir"/$_gcclibdir/include/objc "$subpkgdir"/$_gcclibdir/include/
	mv "$pkgdir"/usr/lib/libobjc.so "$pkgdir"/usr/lib/libobjc.a \
		"$subpkgdir"/usr/lib/
}

libgcc() {
	pkgdesc="GNU C compiler runtime libraries"
	depends=

	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/${_target:+$CTARGET/}lib/libgcc_s.so.* "$subpkgdir"/usr/lib/
}

libgomp() {
	pkgdesc="GCC shared-memory parallel programming API library"
	depends=
	replaces="gcc"

	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/${_target:+$CTARGET/}lib/libgomp.so.* "$subpkgdir"/usr/lib/
}

java() {
	pkgdesc="Java support for GCC"
	depends="zlib-dev gcc=$_gccrel libgcj=$_gccrel"

	paxmark -pm "$pkgdir"/$_gcclibexec/ecj1
	mkdir -p "$subpkgdir"/usr/bin "$subpkgdir"/usr/lib "$subpkgdir"/$_gcclibdir/
	cd "$pkgdir"/usr/bin
	mv *gcj *gcj-dbtool *gjavah *gcjh *jcf-dump "$subpkgdir"/usr/bin/
	cd "$pkgdir"
	for i in $(find usr/ -name ecj1 -o -name jc1 -o -name jvgenmain); do
		mkdir -p "$subpkgdir"/${i%/*}
		mv "$pkgdir"/$i "$subpkgdir"/$i
	done
	for i in "$pkgdir"/usr/lib/libgcj*.so; do
		if [ -L "$i" ]; then
			mv "$i" "$subpkgdir"/usr/lib/
		fi
	done
	mkdir -p "$subpkgdir"/usr/share/gcc-6.4.0/python
	mv "$pkgdir"/usr/share/gcc-6.4.0/python/libjava \
		"$subpkgdir"/usr/share/gcc-6.4.0/python
	mv "$pkgdir"/usr/lib/libgij.so "$subpkgdir"/usr/lib/
	mv "$pkgdir"/usr/lib/libgcj.spec "$subpkgdir"/$_gcclibdir/
}

libgcj() {
	pkgdesc="Java runtime library for gcc"
	# libgcj_bc.so moved from gcc-java to libgcj
	replaces="gcc-java"
	depends=

	mkdir -p "$subpkgdir"/usr/bin
	cd "$pkgdir"/usr/bin
	paxmark -pmse "$pkgdir"/usr/bin/gij
	mv aot-compile gappletviewer gc-analyze gij gjar gjarsigner gkeytool\
		gnative2ascii gorbd grmic grmid grmiregistry gserialver \
		gtnameserv jv-convert rebuild-gcj-db \
		"$subpkgdir"/usr/bin/
	cd "$pkgdir"
	for i in $(find usr/lib -name jc1 -o -name jvgenmain); do
		mkdir -p "$subpkgdir"/${i%/*}
		mv "$pkgdir"/$i "$subpkgdir"/$i
	done
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/gcj-* \
		"$pkgdir"/usr/lib/libgcj_bc.so \
		"$pkgdir"/usr/lib/libgcj*.so.* \
		"$pkgdir"/usr/lib/libgij.so.* \
		"$pkgdir"/usr/lib/logging.properties \
		"$pkgdir"/usr/lib/security \
		"$subpkgdir"/usr/lib/

	mkdir -p "$subpkgdir"/usr/lib/pkgconfig
	mv "$pkgdir"/usr/lib/pkgconfig/libgcj* "$subpkgdir"/usr/lib/pkgconfig/

	mkdir -p "$subpkgdir"/usr/share/
	mv "$pkgdir"/usr/share/java "$subpkgdir"/usr/share/
}

libgo() {
	pkgdesc="Go runtime library for GCC"
	depends=

	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libgo.so.* "$subpkgdir"/usr/lib/
}

go() {
	pkgdesc="Go support for GCC"
	depends="gcc=$_gccrel libgo=$_gccrel"

	mkdir -p "$subpkgdir"/$_gcclibexec \
		"$subpkgdir"/usr/lib \
		"$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/lib/go "$subpkgdir"/usr/lib/
	mv "$pkgdir"/usr/bin/*gccgo "$subpkgdir"/usr/bin/
	mv "$pkgdir"/usr/bin/*go "$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/bin/*gofmt "$subpkgdir"/usr/bin
	mv "$pkgdir"/$_gcclibexec/go1 "$subpkgdir"/$_gcclibexec/
	mv "$pkgdir"/$_gcclibexec/cgo "$subpkgdir"/$_gcclibexec/
	mv "$pkgdir"/usr/lib/libgo.a \
		"$pkgdir"/usr/lib/libgo.so \
		"$pkgdir"/usr/lib/libgobegin.a \
		"$pkgdir"/usr/lib/libgolibbegin.a \
		"$pkgdir"/usr/lib/libnetgo.a \
		"$subpkgdir"/usr/lib/
}

libgfortran() {
	pkgdesc="Fortran runtime library for GCC"
	depends=

	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libgfortran.so.* "$subpkgdir"/usr/lib/
}

libquadmath() {
	replaces="gcc"
	pkgdesc="128-bit math library for GCC"
	depends=

	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libquadmath.so.* "$subpkgdir"/usr/lib/
}

gfortran() {
	pkgdesc="GNU Fortran Compiler"
	depends="gcc=$_gccrel libgfortran=$_gccrel"
	$LIBQUADMATH && depends="$depends libquadmath=$_gccrel"
	replaces="gcc"

	mkdir -p "$subpkgdir"/$_gcclibexec \
		"$subpkgdir"/$_gcclibdir \
		"$subpkgdir"/usr/lib \
		"$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/bin/*gfortran "$subpkgdir"/usr/bin/
	mv "$pkgdir"/usr/lib/libgfortran.a \
		"$pkgdir"/usr/lib/libgfortran.so \
		"$subpkgdir"/usr/lib/
	if $LIBQUADMATH; then
		mv "$pkgdir"/usr/lib/libquadmath.a \
			"$pkgdir"/usr/lib/libquadmath.so \
			"$subpkgdir"/usr/lib/
	fi
	mv "$pkgdir"/$_gcclibexec/f951 "$subpkgdir"/$_gcclibexec
	mv "$pkgdir"/usr/lib/libgfortran.spec "$subpkgdir"/$_gcclibdir
}

libgnat() {
	pkgdesc="GNU Ada runtime shared libraries"
	depends=

	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libgna*.so "$subpkgdir"/usr/lib/
}

gnat() {
	pkgdesc="Ada support for GCC"
	depends="gcc=$_gccrel"
	[ "$CHOST" = "$CTARGET" ] && depends="$depends libgnat=$_gccrel"

	mkdir -p "$subpkgdir"/$_gcclibexec \
		"$subpkgdir"/$_gcclibdir \
		"$subpkgdir"/usr/bin
	mv "$pkgdir"/$_gcclibexec/*gnat* "$subpkgdir"/$_gcclibexec/
	mv "$pkgdir"/$_gcclibdir/*ada* "$subpkgdir"/$_gcclibdir/
	mv "$pkgdir"/usr/bin/*gnat* "$subpkgdir"/usr/bin/
}

sha512sums="02c60e54527c7adf584798d5251f8a0b80c93d5deafce82501b2c28e6692e0bd783927bbfc4bc527a863c0cccc025150a34740a9e29badb02d4b48e56a8aba90  gcc-6.4.0.tar.xz
28f8c6fdbcb19e950b1d0bafb3bcc7a8cba87bc673aa6027cece116599cdee80f0cf5e95a1440544890239f5c754e8a93ab46d9daedd937faef445d7ea33b226  ecj-4.9.jar
a1335adc2fbee98e36c4437ff2587771b98ed4180726779020f65039498235626a411cdb0100dbd20cd19d12f0d94f9a21af179ff624676c28cead9d60598b5d  001_all_default-ssp-strong.patch
e36e95b81489163abd6fe9d58f7867bdca43e61143afacbfb17f4698c0b16ec5fd0061d8fab7b2ae615540bebd721c2e2227f80401b4e7fc253da9da62e6b513  002_all_default-relro.patch
f86466c62b8291fac46f9c250c7ad8fa5ab7b1cce2504442fd07ddc4543665b317ae28951f244e39aba29aeaf3fff252ec4f6a147aa16adb2b7aed747dd89188  003_all_default-fortify-source.patch
51282fea54c7e616367bbeb2479ba13fec6f24eb47bd04e2071907b3b36273b2ff24676f46ef8d22f241c8ab4857307861eee076eab66797c3a50a8ecaa1809a  005_all_default-as-needed.patch
3398386dd1e079d6545dd9799adc799c6b80e3984fac6899d0e1a7ee21b66d0c7e53cddf17a65d590c883db750f9f79aaedd857355a8b9f7fb9476c906237919  011_all_default-warn-format-security.patch
9adb0d2b9b67dd957df6c609b8714c7c078efb52cd88770905c37c67827be8fc83d1125037b9c29d77db21ce78756aa2bb0bacdb0b98d869ac126da76a298e21  012_all_default-warn-trampolines.patch
d35a3ac7e13a4446921a90e1ff3eec1079840c845f9d523c868e24ae21f94cf69ba041de5341ebef96432a6f57598e223381d4286e8fb8baaa25906707f29fbd  020_all_msgfmt-libstdc++-link.patch
840070a3c423e6206aaa6e63e1d9a0fcd6efd53626cd1240a193f0b60aa5d84216acc4a2a4fa8bce74549b07e6a316b01d638f20cea13dc62473491a302fb3d6  050_all_libiberty-asprintf.patch
0a0bc72b9366158f5d23fff1928e756fdd212433bac6ab1f00d632f241382820db8db5d475ddf11ea020eaf7e2e71b12fb9b1c3c870cf84adf6c2b16f15aabca  051_all_libiberty-pic.patch
e7a2eb1b1870e199d6fd753d065781575656fa12baa264f96c5d179689d88c31b8a3f92a5dae96088c05e96aa2bda138364ad7dbcc79e1819a102f192cbb7bab  053_all_libitm-no-fortify-source.patch
e87da18aa7ab92b02b06168658c63b42a6c73a08fad2a30f81ef6296100fdbe3c3a91548fd0cb24eaf591e862bb08e4b67249bc4b977b07da33523aee0c686bc  067_all_gcc-poison-system-directories.patch
4a328d1e1a56c20166307edcfa322068915784d9c08025b7f81cf69714da48fc266b6d34f77b9135c2f10da830d9df408276a1b78d1fd218637c2823506593c2  090_all_pr55930-dependency-tracking.patch
ef052d0c3c9642fcb5ed570069c5a49c8ef523c47ac8ce3f201a801766f72ae4ff7c3725a70ee66e52c0fb559621e35fe0cf5b88b901d71ceadd381f49653a08  201-cilkrts.patch
808e206f5e107084156fba333d4e091dcbd62f5d7756142bc292d4b0a52619f8c2aaca3617defc2f5b6552ba0439aebd33f4141329d88eab6ddf2dd637d92c08  203-libgcc_s.patch
fc0de05b36613b732a0222ea005c90653c6a40d6761b6894af2419272f4e74875f37e26af33a9b9940669ef89269c44c46d17ca5bcd54b5cd1176e5eaf2992c1  204-linux_libc_has_function.patch
98473bcaa77903a223ca9b0d2087c0921b287a2816d308cc32c8fe009e6cbf5dd1ae7fba27794ab8d9c09e117fe534413d91a464d1218474fc123ce0adfdc2c1  205-nopie.patch
3287d5b443bea8ec64132bcabe869c738ae98ea8f1a86df1c5d18c927f8816edbfcefeefc47792dbbb2bcacf50319af00e01b3735d34525913b64350770ad453  207-static-pie.patch
d08d7ead2de0429e5c9055d5b029ec2be9a8c821d22cecaf9b51f633652c493333f98963d9267fa2fa63850c50ae5eefd5f59e5910ec10d20044dac082182a8b  libgcc-always-build-gcceh.a.patch
600fe5098dc54edaa9808fd5717af9dec058953f9ad37d49cfba1db4f7e9a7a8f02019342f75157fc575946fa693259422184de27b7ecc8386d9f3ecc0f7cc5d  gcc-4.9-musl-fortify.patch
dbe0ee917fc7668571722364ab7c806731e3a31e8bfa30b4941b28b16b877d2a32b4a3897ef533399a28f82d43cac9b28e92de0493f0e779046db56584e07fa4  gcc-6.1-musl-libssp.patch
bda845a6aa1854d2c883910b115f79ccfa93dfc2b5eac69a3a236d83eb34cadc140731d616ffc24698c7abc8878dd15f231bcc5119f1860e575a120b311706c7  boehm-gc-musl.patch
fa62556719449caec6b2b434355bfbcaa5ae55ffe017b3e1f827f66a2aae21b79c571ee7a4ce723ea69169bc3a6447e73650991a200cc372adf2f102677518d7  gcc-pure64.patch
2253941f3d19b6d08801d3782f5f5ed56c3b73fbc9d3561a8f01c702963ac4fab91599c686076e7081eb6a80c37ccd33591ae978996d6eee1dc0ce0f1c50259a  fix-gcj-stdgnu14-link.patch
f89ddeb21bc8f97e6a850a6b70b4501a8f3e49a4bc8cc82897488decda5d98ad01cb7f6c8b392d452e9579924a523bc75da6e0648c1c976d42e40af48b10343b  fix-gcj-musl.patch
54d67cc008b735e47771314171930c5d8b8f5f5dc97fcf4214824c105c808f3e75d22d5a4fdf5068ed0457fa0d46c60cfb442e276259a4a5e9b8722a027d18e6  fix-gcj-iconv-musl.patch
abe9aaf9aa956058d0386a4396a511d176a46bb3906b90e952383646cdc158cbeb0a5dc616a1ccb1ca7d49fd0b5e351532aa15a3b13362abbf1ca4266f54a687  gcc-4.8-build-args.patch
35d6d59f0b7b968f282f56767c9e0823a7bdc5aa0d450aca50fbd802649a7ca608b47671244a3faa208a9b0d6832cabb5a22724157dc817b2c0ad63d09f93282  fix-cxxflags-passing.patch
9016b257abd8fa981de44a49512e35db814d1cbb47c1a87cd31c12d4ae20b13e9e149fe41691a7ec3c95bbcfde8a79194a8d2eaf547ceade3a246fad67c47dd8  ada-fixes.patch
3f5bc334d9f73d06f5f7c876738d02356acdd08958bea0e4d2095ebf15c2c2ec4e411abdae0297505ae9a1699ca01b17338e853184e84663203b192b0d35fc19  ada-shared.patch
631d4bdef6d8bde34df7978bb53ec28c3c909cf1f87139e5f148138d0f09adc58b41ecf0148bbf50fb4bc916c411e9bf8a2b6c046c75c0e77d754d8c35bcd4d7  ada-musl.patch
fa44c8158111627aa0e91c43e7cc3aa38642c2041c96532dd4f0932dae4d6f92ea2850b683abcf10e7e120299d42ea6b69adc00002a514c76be8e39e99fa052b  ada-aarch64-multiarch.patch
4b4a0ff306a8ef34ff6e3284fbfca869012164a47ba7cb099085c1dd03e6ca0cdd462f82710e08c9a02895adc7484e4c5eef17b5aa264cf5d978fe8ad78eea93  300-main-gcc-add-musl-s390x-dynamic-linker.patch
385bc2fa50204f678964e5148c6170f572701dab920fbec8301f505bda34d182cde0adb7da042fee71719e12fb59f59181897f9b1bb4f4716ff59aad46ca1998  310-build-gcj-s390x.patch
f4ef08454e28c8732db69115e4998ec153399e8d229dd27f923dbdcf57b68128a65640d026cc7f45b58ba8764ab1eb575d4eb6d6dfc550a87a183f8b94e76181  320-libffi-gnulinux.patch
8efd028febb962ae100be32f72f7450c4f77d67ad96a5f47072136cdf47043f9d54835a87c7ab5aaa0fa0108c4c7a97ba2d7732d5aaf2efce70fe1f7e1c39d6e  330-gccgo-link-to-ucontext.patch
24c8708f64b9b7945b3f07e9bbecf17ab8bcde2524f49cbd694ca2f6146ccc3f13bb027db282f326525ea79d50a2868fa3fa2b0d688a914b5ea77bbfd7e5cbe4  331-gccgo-use-real-off_t-type.patch
01c71cd5881fc07ea3b9b980697e89b3ca0fe98502958ceafc3fca18b2604c844e2f457feab711baf8e03f00a5383b0e38aac7eb954034e306f43d4a37f165ed  fix-rs6000-pie.patch
1860593584f629d24d5b6db14b0a3412e9f93449b663aaa4981301a0923db0159314905e694f27366fbfef72dce06636ab6df86862b7e9e9564847e03bee82c1  add-classic_table-support.patch
4e1b421ed72668b66ecbcb0a34afa99d2a34cb2ea9ee51c4aad605fc8a0e94e3bfbabae4ebe236efc5ec86fc01a472cbe93f36fe25cf579714939d8102a9b84a  lra-pentium.patch"