aboutsummaryrefslogblamecommitdiffstats
path: root/main/gcc/APKBUILD
blob: 48a6bbff9722c72eab569085de3810138a48a745 (plain) (tree)
1
2
3
4
5
6
7
8
9
                                                   
           
               
                  
                                                  

                                                                    
 
                          
        
                                     
                         
          
                                            
                        
                          
                                                                                                                
                                                                                                        
               
                                                          
                             
 





                         
 



               
 
                                   
                                          

                              
                             




                                                     

                          
                    


                        






                                                                  


                                      

                                         
                                    











                                                                  


                                      
 
                                                  
                       

                          
                    







                                              



                                                                  

                                                      

                                

    






                                                                   

                                                      
                          
                       

                                             

    
                                           



                                                                      
                                           
                                                         

  

                  
                                                                                 

                                    


                                                                                
                                                              
  
                   
                                                                               
                                     
  
                 
                                                                         
                                   
  
                      
                                                                                       

                                        
                  
                                                                               
                                    

                                                                                                      
  
                                                  
 


                                                                                               




                                                                                                


















                                                                       


















                                                                       
                                                           
         
 
                      
                             

                                                            
 

                     
 
             



                                         
                                                                    

                          
            
 







                                                     
                                                
 
 
         
                              


                                   
                       
 
                     
 
                          
                                                                                       
                                                                                                                                       
                                                                                                                                                        
                                                                                                                                                                                   



                                                                                                                                        
                                                                                                
                                                                                                                                                  
                                                                                                     
                                                                                                     
                                                                                                                                                 

            




                                                                        

                               
                                                                
                                                                                        
                                                                                         
                                                                                                               
                                            

                                             

            

                                                                                                        
 
                            

                                                                                            

            



                                                                                           
 




                                     

                                           
                                      
                                                


                                                          
                                                            

               

                                   


                                            

                                           


                                     
                                                    
                                           




                                         
                           
                                       
                                      
                                      
                                        
                                                
                                  


                                       
                                    
                                      
            


           
                       
                                          
 
                                      
 

                                     
                                              
                                        

                                      
 
                                                
                                                                                     
                                                               



                                                                               

                                                 
 
                          
                                                                       
          
                         
                                                                      
          

                    
                                                                         
                                             
 
                                             





                                                                                                
 
                                                


                               
                                                                                                         

                                                     

                    



                                                                          
                                                                                         

                                                                 


                                                                    
                                                               
                                             
                                                                           



                                                             

                                             
                                                  
         
                  

                      
                                                      



                                                                                
                           
   
                                                  
         
                  

                      
                                                
                                                                             


                        
                           

                                               



                                                                                   
          
 
 
             

                                    
                      
 
                                     
                                                                                      

 

                                                  
                
 




                                                                                          
 
                                     
                                                                                      


       
                                                       
                                                          
                                            
                                      

                                                               
 
                                                                    
                                                       
 


                                                                                                        

 
           
                                         
                       
                
                                     
                                                                                    
 
 


                                 
                                                        
 

                                                  
                                    
                                                                   
                                                                               
                                                                     
                                     

 
          

                                                  
 
                                     
                                                                                     
 
 



                                                                    
 
                                     
                                                                                    
 
 










                                                                    
                                                           
                                          
 

                                                     

                                      

                                                                           
                                         
                                                                


                                                                                

                                                                  



                                                      

                                            
                
 





                                                             
                                                 
 
                                            
                                      


                                                         

                                                        
                                                                



                                                                      


                                                
                                                   
                                     

 

                                                 
                
 



                                                                   


                                              
                
 



                                                                   

                                      
                                                   
                                                                
                      
 

                                            
                                      

                                                            

                                                  
                                     
                              

                                                          
                                             
          
                                                                   

                                                                      

 
           
                                                  
                
 




                                                             
                                     
                              
                                          

                                                                        

                                            



                                                                   

 






































                                                                                                                                                                                                 
                                                                                                                                                                                      
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=gcc
_pkgbase=10.2.1
pkgver=10.2.1_pre1
[ "$BOOTSTRAP" = "nolibc" ] && pkgname="gcc-pass2"
[ "$CBUILD" != "$CHOST" ] && _cross="-$CARCH" || _cross=""
[ "$CHOST" != "$CTARGET" ] && _target="-$CTARGET_ARCH" || _target=""

pkgname="$pkgname$_target"
pkgrel=3
pkgdesc="The GNU Compiler Collection"
url="https://gcc.gnu.org"
arch="all"
license="GPL-2.0-or-later LGPL-2.1-or-later"
_gccrel=$pkgver-r$pkgrel
depends="binutils$_target"
makedepends_build="gcc$_cross g++$_cross paxmark bison flex texinfo gawk zip gmp-dev mpfr-dev mpc1-dev zlib-dev"
makedepends_host="linux-headers gmp-dev mpfr-dev mpc1-dev isl-dev zlib-dev !gettext-dev libucontext-dev"
subpackages=" "
[ "$CHOST" = "$CTARGET" ] && subpackages="gcc-doc$_target"
replaces="libstdc++ binutils"

: "${LANG_CXX:=true}"
: "${LANG_D:=true}"
: "${LANG_OBJC:=true}"
: "${LANG_GO:=true}"
: "${LANG_FORTRAN:=true}"
: "${LANG_ADA:=true}"

_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_GO=false
	LANG_FORTRAN=false
	LANG_D=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_GO=false
	LANG_FORTRAN=false
	LANG_D=false

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

# GDC hasn't been ported to PowerPC
# See libphobos/configure.tgt in GCC sources for supported targets
[ "$CARCH" = ppc64le ] && LANG_D=false

# libitm has TEXTRELs in ARM build, so disable for now
case "$CTARGET_ARCH" in
arm*)		_libitm=false ;;
mips*)		_libitm=false ;;
esac

# Internal libffi fails to build on MIPS at the moment, need to
# investigate further.  We disable LANG_GO on mips64 as it requires
# the internal libffi.
case "$CTARGET_ARCH" in
mips*)		LANG_GO=false ;;
esac

# Fortran uses libquadmath if toolchain has __float128
# currently on x86, x86_64 and ia64
_libquadmath=$LANG_FORTRAN
case "$CTARGET_ARCH" in
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_D; then
	subpackages="$subpackages libgphobos::$CTARGET_ARCH gcc-gdc$_target:gdc"
	_languages="$_languages,d"
	makedepends_build="$makedepends_build libucontext-dev"
fi
if $LANG_OBJC; then
	subpackages="$subpackages libobjc::$CTARGET_ARCH gcc-objc$_target:objc"
	_languages="$_languages,objc"
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"
	[ "$CBUILD" = "$CTARGET" ] && makedepends_build="$makedepends_build gcc-gnat-bootstrap"
	[ "$CBUILD" != "$CTARGET" ] && makedepends_build="$makedepends_build gcc-gnat gcc-gnat$_cross"
fi
makedepends="$makedepends_build $makedepends_host"

# when using upstream releases, use this URI template
# https://gcc.gnu.org/pub/gcc/releases/gcc-${_pkgbase:-$pkgver}/gcc-${_pkgbase:-$pkgver}.tar.xz
#
# right now, we are using a git snapshot.
#
# PLEASE submit all patches to gcc to https://gitlab.alpinelinux.org/kaniini/alpine-gcc-patches,
# so that they can be properly tracked and easily rebased if needed.
source="https://dev.alpinelinux.org/~nenolod/gcc-${pkgver}.tar.xz
	0001-posix_memalign.patch
	0002-gcc-poison-system-directories.patch
	0003-Turn-on-Wl-z-relro-z-now-by-default.patch
	0004-Turn-on-D_FORTIFY_SOURCE-2-by-default-for-C-C-ObjC-O.patch
	0005-On-linux-targets-pass-as-needed-by-default-to-the-li.patch
	0006-Enable-Wformat-and-Wformat-security-by-default.patch
	0007-Enable-Wtrampolines-by-default.patch
	0008-Disable-ssp-on-nostdlib-nodefaultlibs-and-ffreestand.patch
	0009-Ensure-that-msgfmt-doesn-t-encounter-problems-during.patch
	0010-Don-t-declare-asprintf-if-defined-as-a-macro.patch
	0011-libiberty-copy-PIC-objects-during-build-process.patch
	0012-libitm-disable-FORTIFY.patch
	0013-libgcc_s.patch
	0014-nopie.patch
	0015-libffi-use-__linux__-instead-of-__gnu_linux__-for-mu.patch
	0016-dlang-update-zlib-binding.patch
	0017-dlang-fix-fcntl-on-mips-add-libucontext-dep.patch
	0018-ada-fix-shared-linking.patch
	0019-build-fix-CXXFLAGS_FOR_BUILD-passing.patch
	0020-add-fortify-headers-paths.patch
	0021-Alpine-musl-package-provides-libssp_nonshared.a.-We-.patch
	0022-DP-Use-push-state-pop-state-for-gold-as-well-when-li.patch
	0023-Pure-64-bit-MIPS.patch
	0024-use-pure-64-bit-configuration-where-appropriate.patch
	0025-always-build-libgcc_eh.a.patch
	0026-ada-libgnarl-compatibility-for-musl.patch
	0027-ada-musl-support-fixes.patch
	0028-gcc-go-Use-_off_t-type-instead-of-_loff_t.patch
	0029-gcc-go-Don-t-include-sys-user.h.patch
	0030-gcc-go-Fix-ucontext_t-on-PPC64.patch
	0031-gcc-go-Fix-handling-of-signal-34-on-musl.patch
	0032-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch
	0033-gcc-go-Fix-st_-a-m-c-tim-fields-in-generated-sysinfo.patch
	0034-gcc-go-signal-34-is-special-on-musl-libc.patch
	0035-gcc-go-Prefer-_off_t-over-_off64_t.patch
	0036-gcc-go-undef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch
	0037-gcc-go-link-to-libucontext.patch
	0038-gcc-go-Disable-printing-of-unaccessible-ppc64-struct.patch
	0040-CRuntime_Musl-Support-v1.2.0-for-32-bits.patch
	"

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

prepare() {
	cd "$_gccdir"

	_err=
	for i in $source; do
		case "$i" in
		*.patch)
			msg "Applying $i"
			patch -p1 -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

	echo ${_pkgbase:-$pkgver} > gcc/BASE-VER
}

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

	cd "$_gccdir"

	case "$CTARGET" in
	aarch64-*-*-*)		_arch_configure="--with-arch=armv8-a --with-abi=lp64";;
	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";;
	mips-*-*-*)		_arch_configure="--with-arch=mips32 --with-mips-plt --with-float=soft --with-abi=32";;
	mips64-*-*-*)		_arch_configure="--with-arch=mips3 --with-tune=mips64 --with-mips-plt --with-float=soft --with-abi=64";;
	mips64el-*-*-*)		_arch_configure="--with-arch=mips3 --with-tune=mips64 --with-mips-plt --with-float=soft --with-abi=64";;
	mipsel-*-*-*)		_arch_configure="--with-arch=mips32 --with-mips-plt --with-float=soft --with-abi=32";;
	powerpc-*-*-*)		_arch_configure="--enable-secureplt --enable-decimal-float=no";;
	powerpc64*-*-*-*)	_arch_configure="--with-abi=elfv2 --enable-secureplt --enable-decimal-float=no --enable-targets=powerpcle-linux";;
	i486-*-*-*)		_arch_configure="--with-arch=i486 --with-tune=generic --enable-cld";;
	i586-*-*-*)		_arch_configure="--with-arch=i586 --with-tune=generic --enable-cld";;
	s390x-*-*-*)		_arch_configure="--with-arch=z196 --with-tune=zEC12 --with-zarch --with-long-double-128 --enable-decimal-float";;
	esac

	case "$CTARGET_ARCH" in
	mips*)	_hash_style_configure="--with-linker-hash-style=sysv" ;;
	*)	_hash_style_configure="--with-linker-hash-style=gnu" ;;
	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
		# alpine musl provides libssp_nonshared.a, so we don't need libssp either
		_libc_configure="--disable-libssp --disable-libmpx --disable-libmudflap --disable-libsanitizer"
		_symvers="--disable-symvers"
		export libat_cv_have_ifunc=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_configure=$_hash_style_configure"
	echo ""

	export CFLAGS="$CFLAGS -O2"

	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="Alpine $pkgver" \
		--enable-checking=release \
		--disable-fixed-point \
		--disable-libstdcxx-pch \
		--disable-multilib \
		--disable-nls \
		--disable-werror \
		$_symvers \
		--enable-__cxa_atexit \
		--enable-default-pie \
		--enable-default-ssp \
		--enable-cloog-backend \
		--enable-languages=$_languages \
		$_arch_configure \
		$_libc_configure \
		$_cross_configure \
		$_bootstrap_configure \
		--with-system-zlib \
		$_hash_style_configure
	make
}

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 libgtkpeer.a \
		-o -name libgjsmalsa.a \
		-o -name libgij.a \) \
		-delete

	# strip debug info from some static libs
	find "$pkgdir" \( -name libgfortran.a -o -name libobjc.a -o -name libgomp.a \
		-o -name libgphobos.a -o -name libgdruntime.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 \
		-exec ${STRIP_FOR_TARGET} -g {} +

	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' -delete

	local gdblib=${_target:+$CTARGET/}lib
	if [ -d "$pkgdir"/usr/$gdblib/ ]; then
		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
	fi

	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
	else
		# add c89/c99 wrapper scripts
		cat >"$pkgdir"/usr/bin/c89 <<'EOF'
#!/bin/sh
_flavor="-std=c89"
for opt; do
	case "$opt" in
	-ansi|-std=c89|-std=iso9899:1990) _flavor="";;
	-std=*) echo "$(basename $0) called with non ANSI/ISO C option $opt" >&2
		exit 1;;
	esac
done
exec gcc $_flavor ${1+"$@"}
EOF
		cat >"$pkgdir"/usr/bin/c99 <<'EOF'
#!/bin/sh
_flavor="-std=c99"
for opt; do
	case "$opt" in
	-std=c99|-std=iso9899:1999) _flavor="";;
	-std=*) echo "$(basename $0) called with non ISO C99 option $opt" >&2
		exit 1;;
	esac
done
exec gcc $_flavor ${1+"$@"}
EOF
		chmod 755 "$pkgdir"/usr/bin/c?9

		# install lto plugin so regular binutils may use it
		mkdir -p "$pkgdir"/usr/lib/bfd-plugins
		ln -s /$_gcclibexec/liblto_plugin.so "$pkgdir/usr/lib/bfd-plugins/"
	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=

	if [ "$CHOST" = "$CTARGET" ]; then
		# verify that we are using clock_gettime rather than doing direct syscalls
		# so we dont break 32 bit arches due to time64.
		nm -D "$pkgdir"/usr/lib/libstdc++.so.* | grep clock_gettime
	fi

	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/$_gcclibexec" \
		"$subpkgdir"/$_gcclibdir/include \
		"$subpkgdir"/usr/lib
	mv "$pkgdir/$_gcclibexec/cc1obj" "$subpkgdir/$_gcclibexec/"
	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/
}

libgphobos() {
	pkgdesc="D programming language standard library for GCC"
	depends=

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

gdc() {
	pkgdesc="GCC-based D language compiler"
	depends="gcc=$_gccrel libgphobos=$_gccrel musl-dev"
	depends="$depends libucontext-dev"

	mkdir -p "$subpkgdir/$_gcclibexec" \
		"$subpkgdir"/$_gcclibdir/include/d/ \
		"$subpkgdir"/usr/lib \
		"$subpkgdir"/usr/bin
	# Copy: The installed '.d' files, the static lib, the binary itself
	# The shared libs are part of 'libgphobos' so one can run program
	# without installing the compiler
	mv "$pkgdir/$_gcclibexec/d21" "$subpkgdir/$_gcclibexec/"
	mv "$pkgdir"/$_gcclibdir/include/d/* "$subpkgdir"/$_gcclibdir/include/d/
	mv "$pkgdir"/usr/lib/libgdruntime.a "$subpkgdir"/usr/lib/
	mv "$pkgdir"/usr/lib/libgphobos.a "$subpkgdir"/usr/lib/
	mv "$pkgdir"/usr/lib/libgphobos.spec "$subpkgdir"/usr/lib/
	mv "$pkgdir"/usr/bin/$CTARGET-gdc "$subpkgdir"/usr/bin/
	mv "$pkgdir"/usr/bin/gdc "$subpkgdir"/usr/bin/
}


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 !go"

	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"/$_gcclibexec/buildid "$subpkgdir"/$_gcclibexec/
	mv "$pkgdir"/$_gcclibexec/test2json "$subpkgdir"/$_gcclibexec/
	mv "$pkgdir"/$_gcclibexec/vet "$subpkgdir"/$_gcclibexec/
	mv "$pkgdir"/usr/lib/libgo.a \
		"$pkgdir"/usr/lib/libgo.so \
		"$pkgdir"/usr/lib/libgobegin.a \
		"$pkgdir"/usr/lib/libgolibbegin.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"/$_gcclibdir/finclude "$subpkgdir"/$_gcclibdir/
	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"
	provides="$pkgname-gnat-bootstrap"
	[ "$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="172fd45e7274c36ebd22a7e12e44a7096ae3bf0e7f0b647da92cfd31ec406a69017df7ee6c1a6ee0822fbef4ff47855f83fab0a0cdb8f031713a14604af3900b  gcc-10.2.1_pre1.tar.xz
429a92934e1c507c0320741ed5cdd98ba96c73412447c8df0704077e3f0fa6ee4cc4056fadeaa6bb55d237416b555408e97a1c1d21f47b6f6812f153bc36f181  0001-posix_memalign.patch
a0a9445358f58a34ba0a605d142243d62873d4669ca811013a593e3d6e6640006b5ec23b7a5734ee72f71762d098d607749d6ecc98c85aa4f2074400aedd63ff  0002-gcc-poison-system-directories.patch
9fb636d1f2ef5b8225082f44da3086b9f196d1c045d7319cea148ee630b92c164e80a3e9a70a221e616a65fc00da761e733f87e23e8575634e498728bce2c48b  0003-Turn-on-Wl-z-relro-z-now-by-default.patch
e34086d5a46f963e43e9f2f9240e3fb4d935e49feb8edba5121a59192b5991103a8253a342fbc20cef8ac2aa4ae2bf9a7ceb62abf6676be16441fd2dbf3b05f2  0004-Turn-on-D_FORTIFY_SOURCE-2-by-default-for-C-C-ObjC-O.patch
ffd89376a743d29a16b4f38463076691cd3716bee2bca0dbb67c2c1da00773661fb362bcc4b2ffd94f57c6b4470ae7cf8f6abad95de5880e74adaa5c4da21426  0005-On-linux-targets-pass-as-needed-by-default-to-the-li.patch
e101b356589fb794f1c4224bba8d8c714a962bed7858a734badfe38a5d10f4e800155f1ed5edbae9da7134192dfd6a4d8a33a9dbe871becb9526810af535819c  0006-Enable-Wformat-and-Wformat-security-by-default.patch
e6fbe275e8f4b1257271118bfea5d6c05b041439dde560775a7ee1a9457f442c3e0c8b1113c68bd54502b7d44e6e4b76315613bf2972898a981119f384106fde  0007-Enable-Wtrampolines-by-default.patch
e2a6a0e3cb2c7a40f59432e0f633a3579bb320fc116290d4655766931c56fb78ce73b0f5e75a78c6aacf85155f3c508e84bfee259dba13cd36e77a601fd5d8f5  0008-Disable-ssp-on-nostdlib-nodefaultlibs-and-ffreestand.patch
0f802f8d9d794a6515a7df7b8588eadc0fa49fdb0b7a5148036fa6fc6e74f35c97d79ed1e4ad225f8f46cca6801f49cbc041258494e4fdbad77a6a7020024d7d  0009-Ensure-that-msgfmt-doesn-t-encounter-problems-during.patch
ff99bc1d02ab07ca7d4c45ff5bfec555096b9a9eb6ef5c02d7e18de72ff3a02505d5e3dca6681caa23b8993049a4acf6a07f5a2e8b4481c4778a7a982851970e  0010-Don-t-declare-asprintf-if-defined-as-a-macro.patch
cf4dc1bfe33250e4065d926d0a126eb87a43695e24a5efda1c383c4d78add0fa7884c378cd3fbb48d713503492d842758fed69c8b5e29774b3bc87c4abe65125  0011-libiberty-copy-PIC-objects-during-build-process.patch
93f244dda3fa55a6016d511f526abf902f7902e876a2d813980d0ad0bf527e4c0fd6258293c90085c1e59056d827bf92aab2b9b92c6f17f776e0068e507d731a  0012-libitm-disable-FORTIFY.patch
d6f409d8d9de3ff44e97046fed1b70ebbecebd5722e7c9bbb92d244ed37d43e77b5d398e39038c554945d022df6d2103b9d4c51fbe11e1d8a011bdfd9067b647  0013-libgcc_s.patch
d380dc2f57bb2065e0c6d80c0837113c3feee2b2290b5747e922aa7dbcbc4463f55f1c22b39a1dcf88653ef5bbae9d29adbfc0f1002d5eaa523a7a31f980b7ab  0014-nopie.patch
5db204edfcace211fd89eb16c358579d1534546a0245d2e11541078081d627e712a9ce372d838f152b4e361742696324929c4649d9b9ff6fb0678791bd898fca  0015-libffi-use-__linux__-instead-of-__gnu_linux__-for-mu.patch
bb76853e79fbeb5c57f52739dff132abf0b80fc551fe83d82238f598ab5ec153b7ebb45aa33b05b24750ff1895cd77a52375bcfb9295c1a44683996ac34bd381  0016-dlang-update-zlib-binding.patch
50916865c79d9a1305f2524f7051d04df46be925fc7385a3b3cb2c17f1becb8827de76c3e897d470ce1f3fc269f9051c9b478c4d022d7611bcf081782e8b4cba  0017-dlang-fix-fcntl-on-mips-add-libucontext-dep.patch
0de08138565d81d4b7bbd367f08e5a2bc637106c39736fbedc92401cf3c2cf18ff50c183c263354852bc03724f9353a9a357ed637b3f012ede2514d3c2ed3969  0018-ada-fix-shared-linking.patch
82aa21e25fddb6ba6a4e1424c88cf5989f62bf3fe088b43bfaf2e624df0381c830b1f0d1e7f10afb2ec6bff07a2558c0464229a997420fe0435321d1d2117372  0019-build-fix-CXXFLAGS_FOR_BUILD-passing.patch
97cb91e95afccfa7fd020d10f48421745cf7afcbe903f17256fc1df05f5f07eaa675576b7eb340da1b5aa97854df4f1f003cb648d8c2e64d9e9c067a0acd2243  0020-add-fortify-headers-paths.patch
3ffc3bbfbfd7ae3ddfef131d0731577aac0567c965d545a2ad7c9588430397748758990d2c449e4a4c66f11db6a3ea66fb3187d173c3581cda2093d25f3d90e6  0021-Alpine-musl-package-provides-libssp_nonshared.a.-We-.patch
fe3e098d71709bde04cc0a17dcf3bb6ce5bc14b51af1395db97afcb464ba5910dbf85be5d968beddf645e916241f9c6be243c24097c326d9bfebc58219f76118  0022-DP-Use-push-state-pop-state-for-gold-as-well-when-li.patch
7dc0c14cbdcab4aaa355568556e5263912ecc69301653602f99e7c70352d84431c6f931a27f4977de7bbd0d5a328c865f7717c8136e3ed6a12ef4448a107a1a6  0023-Pure-64-bit-MIPS.patch
e4bbd675aea5f09d4aaa32990a88597bd070273754656575e9be74a172afd244aa15e58c2d6878606b652d56457b053c94213f3c0bbf63ebe1ede5fcfdedca25  0024-use-pure-64-bit-configuration-where-appropriate.patch
f2bd09b05fb67544d0ef70ce14fd8ca2e2d21846d5396e4e53cdb95317ae122b3f121b8933e5784fc92e51e50d23812e4aa41f2fd07ae68ba1a21ca094a841ac  0025-always-build-libgcc_eh.a.patch
0d49f5104e89a1269a286f7021dd32d0ac4f7aa427b36f40133bc8616ca87e92144d6cc36f958b3ab4ec683e12f946c3658bceada8fcd5114bdb7c197992eb4a  0026-ada-libgnarl-compatibility-for-musl.patch
a09211cb007a9722ec95d046fbf317f63b362fb25f6d3ba285f278a33fe08ad5f5d51ba1e4ccf9ebe02c1ea3ca15f10b0721e7f65af5ced27ffc9380af7558b1  0027-ada-musl-support-fixes.patch
35c1ee71725042fffded7e3189d96ace6cb730d95d83cd49fd4d8527eba72eb344c11d563d1c751a3934627e5aaa44525c58afd4d01c0bb99bab3b6222fa3040  0028-gcc-go-Use-_off_t-type-instead-of-_loff_t.patch
26deab6006d46e2c8de4679cc7f598cfdd572b1b77c0595f0160fa693251669d324f47712c6faef481dc33a2c83878ec3fe385d54ab9bfd6fa2c576d84429d05  0029-gcc-go-Don-t-include-sys-user.h.patch
dd9cc5c3c5368a210276ce4396be9cf120c5acfc65cae88508aebd7d4430a28d21b26b362f7f7456ae64c87dd06dfe7a615cd0c7ca13740b683e3a59c1c7bc8d  0030-gcc-go-Fix-ucontext_t-on-PPC64.patch
c17f5088172babddbdb32830387487286f6106304cf07d49d0b2e59feacad62aa10a46bf1bf927f1f138fd1112da5bef7ae1227a26e7946082a6edc7f340b522  0031-gcc-go-Fix-handling-of-signal-34-on-musl.patch
db67b346f3def6c004639df27cef32a6c4e9b4661634f43b62f4f3be852f5ae6d5dadef85116f816d5fd88cbdd80001d8f81cc8d554b9094744402ca3ae14725  0032-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch
438c165b8e217142b64a002e99b112fbdac9b2c4ced7b0a8c8fe9cff42e6a5ea6d5939cb40905d5a8570fc890de447fd0f5b49c9ee43c3a6e33446efdf2229bf  0033-gcc-go-Fix-st_-a-m-c-tim-fields-in-generated-sysinfo.patch
85592117e6370ff8612a7a028194c6875c8df1f07299afa0188770bf9bdd82d9aeb322909ec980cf3bd10a54d90829fffb145c566d843027c11d49e78d3f0a9e  0034-gcc-go-signal-34-is-special-on-musl-libc.patch
abc2ae2ea2ff270226c45321508c3641011b23172d043c55239a52fee9ed8451e8e23a2a65612c5f3a0d2e4d1a601a7e9a2c1d6c07f926e6cdf42164d23cff34  0035-gcc-go-Prefer-_off_t-over-_off64_t.patch
21ff83b1f5f8c71c41e7c22ba59f194bc789c8e67a6be9e5185f215adf4ddb175551a261556e5c9bd57dd9c302e1f966de01ff90e097d7ace2c2e43208b6e0f9  0036-gcc-go-undef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch
5f0230f9e542bcbfa39f1a3da1f171229bd926971a924ec3e9f3ad8178645d3853659a58a89a48906ffdd77e9c5ff2af43dc54cfc4ac335a219267dddc4afad1  0037-gcc-go-link-to-libucontext.patch
08ffdce5d1ef722364faf5e824b62d0e58655acbba99b58f24c609abb1d90577432863e769fbe269e4151c997b8bbb0cbed29032752b6e6c3356f8fb3086d607  0038-gcc-go-Disable-printing-of-unaccessible-ppc64-struct.patch
81bcffde9635c9c4b3214afd8bb16048f15dc8c4ce82c5576b15ee552d6ca8eeee2c5444e2949fec3b938e69fc7a2a2259a07d437e004788ac232c43ae9a83d2  0040-CRuntime_Musl-Support-v1.2.0-for-32-bits.patch"