aboutsummaryrefslogblamecommitdiffstats
path: root/main/gcc/APKBUILD
blob: a673112b289c76baec1a32feb6cedf937e5d031f (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_pre0
[ "$BOOTSTRAP" = "nolibc" ] && pkgname="gcc-pass2"
[ "$CBUILD" != "$CHOST" ] && _cross="-$CARCH" || _cross=""
[ "$CHOST" != "$CTARGET" ] && _target="-$CTARGET_ARCH" || _target=""

pkgname="$pkgname$_target"
pkgrel=0
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
source="https://dev.alpinelinux.org/~nenolod/gcc-10.2.1.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-libstdc-futex-add-time64-compatibility.patch
	0021-add-fortify-headers-paths.patch
	0022-Alpine-musl-package-provides-libssp_nonshared.a.-We-.patch
	0023-DP-Use-push-state-pop-state-for-gold-as-well-when-li.patch
	0024-Pure-64-bit-MIPS.patch
	0025-use-pure-64-bit-configuration-where-appropriate.patch
	0026-always-build-libgcc_eh.a.patch
	0027-ada-libgnarl-compatibility-for-musl.patch
	0028-ada-musl-support-fixes.patch
	0029-gcc-go-Use-_off_t-type-instead-of-_loff_t.patch
	0030-gcc-go-Don-t-include-sys-user.h.patch
	0031-gcc-go-Fix-ucontext_t-on-PPC64.patch
	0032-gcc-go-Fix-handling-of-signal-34-on-musl.patch
	0033-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch
	0034-gcc-go-Fix-st_-a-m-c-tim-fields-in-generated-sysinfo.patch
	0035-gcc-go-signal-34-is-special-on-musl-libc.patch
	0036-gcc-go-Prefer-_off_t-over-_off64_t.patch
	0037-gcc-go-undef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch
	0038-gcc-go-link-to-libucontext.patch
	0039-gcc-go-Disable-printing-of-unaccessible-ppc64-struct.patch
	"

#	gcc-4.8-build-args.patch

# we build out-of-tree
_gccdir="$srcdir"/gcc-${_pkgbase:-$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="30c3e36c6e001d172b6219dbf5f0383655d29cbed8a197e1d6139213aacbfdb7cbca63553eedf3a4b35bd445a87ee0f555838d8b2cd7a46ab6bba7951a6b60c5  gcc-10.2.1.tar.xz
571e689369e1fd8a9281fed29f9ce5d35cdb6f892f5118216b2b171c5cd16ba5ab1f8f25f8438760bd26bc649b8f4703cc4e7a0918c250933398a37132fb3266  0001-posix_memalign.patch
2ca7d07543105955525e28a899f9cfbafa3f4f58cce8ae9931c20ddebe1126119a5001b8654e3ff7762f84de882dd609ae87f987b31a53dba6d6f5c7b6374a81  0002-gcc-poison-system-directories.patch
772b1bbae7c12cecef87d696603c523d5ea94a6c27f020f5873e6011479e43af735690a1137d4ec2a086946460ce4d411d5a9f00491015a73b04df39942d6dcd  0003-Turn-on-Wl-z-relro-z-now-by-default.patch
5d785525371fdfe89c5c36edf8c694083fc5d25870ef529473386de51e1db2f846d55a48087099230028acc1d076ad29c159603249aedc695cdf14844e2b26c7  0004-Turn-on-D_FORTIFY_SOURCE-2-by-default-for-C-C-ObjC-O.patch
f467e975f904c01339696f27113ddccac321ef205db4855d46a2a7e9f4ec93e5ab5f9adc19e36a4ef6f61e87fcf9b089ea0727f3ea9736561fb4e9eec4bbf9b0  0005-On-linux-targets-pass-as-needed-by-default-to-the-li.patch
49919bcbd59aea56be90e209d299ddb7b7a295d1db438a769279f4fe57ccf7a028a68227e31a22c1370037a4946a4c7c9ed5ac5044c163fb0f3795d3a2dc26cd  0006-Enable-Wformat-and-Wformat-security-by-default.patch
8374eaa22ef5f26d63226ded57042a8d7d2b69b415e3ff87ec2fc5046404dc062e2e096f329062d047d4e741ed2c5b58b6e1695cf070308f36c9558c6098fdcc  0007-Enable-Wtrampolines-by-default.patch
6be0db2455f5f678d37506773e4493a3cbaefd951486edb3374803813c749c2e6064218950cdc1c06f491fd95d4bd6ae9cbdf83148b332d172c20903eca03aa1  0008-Disable-ssp-on-nostdlib-nodefaultlibs-and-ffreestand.patch
d1d1a87177623439a929b42af57a997b48d9e1f6a4ff06b4f84c5f027fc461473dd36145671d2d61b50c0acfcf028d3361be9c95b3340e6e336b012de84f4252  0009-Ensure-that-msgfmt-doesn-t-encounter-problems-during.patch
167cc80faa6a9daca1a990e87bfc268f27cb620fcd488405f24e397b9a1d6f51a0238d85be4a87f2db93fc1e06ff05d569ce0a2e2fe4db65ec44e15dfb66b994  0010-Don-t-declare-asprintf-if-defined-as-a-macro.patch
85327918c409bf982c0dc13895324d6fc9cef1c68a3969ba5cf0a9450f2a04e3fa858af5ef7e432fc578cf6b0631cec55921bdcd361724c928eea943b4b5b2f3  0011-libiberty-copy-PIC-objects-during-build-process.patch
f65784f4eebec688f51598a306b9d034ba7feb0c6ac35a45e4f59585097fff820b3de90613941603985cdb5ee1a4c630381146bf2ee8429ffe80f0ffd5aa22c1  0012-libitm-disable-FORTIFY.patch
c489306880b493c92796e145dad372976ff90e42d8a97211e91db59bc75ca20244c96456dc806fd30f878f95878a37f4211f58b0f527b5808467a245186a0e14  0013-libgcc_s.patch
67a045fb5588eeb6776a98fbc0280a97e8b06e26909cab3e55346f6c81d87cf9ed7515afa3648b92ddd455e182fd5e44f6094e44f701676817f9d6fc3aad319e  0014-nopie.patch
b559a0f380065bd62d69359813e855819950a82c2361aa85771081de68bfe5d652936fbe5ad762f029016c643ffc8d62c0bf0e90460bd7d62a1c0f89ddcb5491  0015-libffi-use-__linux__-instead-of-__gnu_linux__-for-mu.patch
a42d56b0346208adb4a9f8575d53519c6303ead4eb498bed2ff36b9c20d904d9e1ba5996ec8ee35fb39ba91f30be28a6ab6c3c537a21078670c3ae88762b9a5b  0016-dlang-update-zlib-binding.patch
72313fd4829c8d153b8f4654863ff959597ac25fe657d641cfb5eafb42ae58662dd8581ac7a09eb6dadd2797e3585376fdd1f0207f23c061febdc37a85ea1ba1  0017-dlang-fix-fcntl-on-mips-add-libucontext-dep.patch
8f695b5f60d2effca4144373fb0e2d3f1ce4a0c4465669ffb3dd771794b0e18da73b2c3e3644403e91c786ad0c42b54bfeac22543280d40c1a1c2b441c434410  0018-ada-fix-shared-linking.patch
c6800ce569e2da9a379bbb94f1f064833ba66ea1e4dc555e66c45f4ab9e83f40264ca0d06d161df469449b05ddf04907f890b39a1fa8a2bc3e530777d4896371  0019-build-fix-CXXFLAGS_FOR_BUILD-passing.patch
5557ec2a754cd64451a8f186397ff79c509d5781a3e32ba11e6ea45356b13d28ba0b959663540d25725e4bd20934c029a90343bed03b2c0bd143ea73c7f47281  0020-libstdc-futex-add-time64-compatibility.patch
1844d044b1eb3cc72ef72c7efb0623d08d62bbb059dcc254524a378bcc37193126eb52894f6acfea31240457e51c435e28573346d3a19d3d045d12846c07ff8d  0021-add-fortify-headers-paths.patch
210b6a16411c1e5fd00c96c06472c3b7713417ef6f48ea8d127482664d63db8ff5226be2cb2b93420e5f153d96b48e02ba4937d2ad7172c6a0e52ac91a050a2d  0022-Alpine-musl-package-provides-libssp_nonshared.a.-We-.patch
4a1daeb55c1103b9b52061eb08a3782307e4c9e1a72f4fc20aaa1ecca02931a9678d6a71cbcf8aaf8898da4c95ad639f8d04de07f169d95c16fc58d0db31602e  0023-DP-Use-push-state-pop-state-for-gold-as-well-when-li.patch
80729605dac33f225eebecbcf6c319e2839c6924483a13bc186092f15f325bf3e972f68328546e394d9e216de0b00e6601ba768b0bb2633ff8c3c0747bb7b1fd  0024-Pure-64-bit-MIPS.patch
ba222bd9ceb95ea9aa729618b95ee81299d20dd5a7840bff47a046d92247e1ea9e2f65d192b1570724da5898fa950a0b8692d505b5c27005d4b143301fd86a52  0025-use-pure-64-bit-configuration-where-appropriate.patch
67e4426be0aeab6b62d7b5e72443f4ea71e4f3fab096b734d656601ad47d44120ef1d9fc87dfef6af2808b39d21cc161cf3d3e45744bd79b56a1071bef5cde94  0026-always-build-libgcc_eh.a.patch
1f9a62459a511a97620147b357a8d1129d1f33a45b3db3a16e049e33b62c23886c37b10152254e84a86d0d2736de06e68e029cf96fa607cf52f15d58e4925b94  0027-ada-libgnarl-compatibility-for-musl.patch
d610a309aebc1aa3a13ce57a69a185b129b02e34cac0f25d7ea3b1dde28551de5e0acc8952b7c877d1f63cbf8f245fb78555d41fee6a55d4d5f68fe92b6a3037  0028-ada-musl-support-fixes.patch
dfa4e5da6206793c63cffef67cf02a443116e63649e6b0466d3c6e24082e5f14eb2640fb9b1b433d2cc4d4755804a360b1b4c572f50638f27169c9f2ef271bdc  0029-gcc-go-Use-_off_t-type-instead-of-_loff_t.patch
22aec9116a2dc32add10efcf6bdc502933a318c668aaa9f01d9e7d6aebc1221fd8e6858abd610c556582f9cad0bc15ff7fbb08ca6c7fbe483c481cec3f361712  0030-gcc-go-Don-t-include-sys-user.h.patch
274b227d5d28e9c1d90ce1e29d5d88f938ea775cdd536bd51c8941a55994103ffb37222e395ab36b2fe4676aef106bb63bd510f73590e2ae434f4c6904454363  0031-gcc-go-Fix-ucontext_t-on-PPC64.patch
3c06cf909d3b07a7de89c67afa6596fdc4ed4445ddc299d3b037dab8cb08828726aa7136576ba6b36f4c8b80451215bc356c8f9141b1e1420010f1ad5444943f  0032-gcc-go-Fix-handling-of-signal-34-on-musl.patch
f0b6f30c6d934c751ab5d58f3656ab80e02ceac12954a124600b09f2de350ad5a2081a09c2eb5c046fe1969af5022ac27b3bc0c0652cd1986b402334825ca92d  0033-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch
7800ae263f8510341cfc4b0daf5771e309f8ac1df9b8b9ad199eb6c792a13d1550f59584a89eda396514692e43940f5f52039cdef64f49a3e1b9ef40282d81be  0034-gcc-go-Fix-st_-a-m-c-tim-fields-in-generated-sysinfo.patch
33ae7f190b29667d2740e5f8edb6e69946f5601c3d87e2874cb7314bdfaef798223c018006a1d1932a547d1139ebbce08c3cb8b5f563413eb2ae64b9b8668a1e  0035-gcc-go-signal-34-is-special-on-musl-libc.patch
5f56cecf4b1a00c47c58d75ac8390009d80c8733e63cda90483cbbcb2e89d4e63778e475292378df77e6d2b81603dc43f27b8bb9a36ea384a429f501e6e88eed  0036-gcc-go-Prefer-_off_t-over-_off64_t.patch
a4d3396a34e88723740fe52451992082974ddd2336257d173726f08955806349cbee9ddf1d9ec634365d374a0d61f6b28496ca326fba007b151bc3bed3097fa6  0037-gcc-go-undef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch
85e1f94113cf9e6be00be810b484b2098913ddb6b9f088351e0ae4d96afe5782d7c8687dacda1db8ee7487d14f67ef836bcfe890e94221b6c112c587e373afe0  0038-gcc-go-link-to-libucontext.patch
d332bf5b2af982776aacee359737145b636eaf373214fc58f66666ec6add5032ae1d2cbff6380c0791a0a8010f3c73a68407cd8908385a9bb2ba0295ea3e2370  0039-gcc-go-Disable-printing-of-unaccessible-ppc64-struct.patch"