void-packages

Void Source Packages
git clone git://ezup.dev/void-packages.git
Log | Files | Refs | README | LICENSE

void-cross.sh (16752B)


      1#
      2# This helper is for void system crosstoolchain templates.
      3#
      4# Optional variables:
      5#
      6# - cross_gcc_skip_go - do not build gccgo support
      7# - cross_binutils_configure_args
      8# - cross_gcc_bootstrap_configure_args
      9# - cross_gcc_configure_args
     10# - cross_glibc_cflags
     11# - cross_glibc_ldflags
     12# - cross_glibc_configure_args
     13# - cross_musl_cflags
     14# - cross_musl_ldflags
     15# - cross_musl_configure_args
     16#
     17# configure_args is passed to both bootstrap gcc and final gcc
     18# if you need to pass some to one and not the other, use the
     19# respective cross_ variables for final gcc and bootstrap gcc
     20#
     21
     22_void_cross_apply_patch() {
     23	local args="$1" pname="$(basename $2)"
     24	if [ ! -f ".${pname}_done" ]; then
     25		patch -N $args -i $2
     26		touch .${pname}_done
     27	fi
     28}
     29
     30_void_cross_build_binutils() {
     31	[ -f ${wrksrc}/.binutils_done ] && return 0
     32
     33	local tgt=$1
     34	local ver=$2
     35
     36	msg_normal "Patching binutils for ${tgt}\n"
     37
     38	cd ${wrksrc}/binutils-${ver}
     39	if [ -d "${XBPS_SRCPKGDIR}/binutils/patches" ]; then
     40		for f in ${XBPS_SRCPKGDIR}/binutils/patches/*.patch; do
     41			_void_cross_apply_patch -p1 "$f"
     42		done
     43	fi
     44	cd ..
     45
     46	msg_normal "Building binutils for ${tgt}\n"
     47
     48	mkdir -p ${wrksrc}/binutils_build
     49	cd ${wrksrc}/binutils_build
     50
     51	../binutils-${ver}/configure \
     52		--prefix=/usr \
     53		--sbindir=/usr/bin \
     54		--libdir=/usr/lib \
     55		--libexecdir=/usr/lib \
     56		--target=${tgt} \
     57		--with-sysroot=/usr/${tgt} \
     58		--disable-nls \
     59		--disable-shared \
     60		--disable-multilib \
     61		--disable-werror \
     62		--disable-gold \
     63		--enable-relro \
     64		--enable-plugins \
     65		--enable-64-bit-bfd \
     66		--enable-deterministic-archives \
     67		--enable-default-hash-style=gnu \
     68		--with-system-zlib \
     69		--with-mmap \
     70		--with-pic \
     71		${cross_binutils_configure_args}
     72
     73	make configure-host
     74	make ${makejobs}
     75
     76	make install DESTDIR=${wrksrc}/build_root
     77
     78	touch ${wrksrc}/.binutils_done
     79}
     80
     81_void_cross_build_bootstrap_gcc() {
     82	[ -f ${wrksrc}/.gcc_bootstrap_done ] && return 0
     83
     84	local tgt=$1
     85	local ver=$2
     86
     87	msg_normal "Patching GCC for ${tgt}\n"
     88
     89	cd ${wrksrc}/gcc-${ver}
     90
     91	# Do not run fixincludes
     92	sed -i 's@./fixinc.sh@-c true@' Makefile.in
     93
     94	for f in ${XBPS_SRCPKGDIR}/gcc/patches/*.patch; do
     95		_void_cross_apply_patch -p0 "$f"
     96	done
     97	if [ -f ${wrksrc}/.musl_version ]; then
     98		for f in ${XBPS_SRCPKGDIR}/gcc/files/*-musl.patch; do
     99			_void_cross_apply_patch -p0 "$f"
    100		done
    101	fi
    102	cd ..
    103
    104	msg_normal "Building bootstrap GCC for ${tgt}\n"
    105
    106	mkdir -p gcc_bootstrap
    107	cd gcc_bootstrap
    108
    109	local extra_args
    110	if [ -f ${wrksrc}/.musl_version ]; then
    111		extra_args+=" --with-newlib"
    112		extra_args+=" --disable-symvers"
    113		extra_args+=" libat_cv_have_ifunc=no"
    114	else
    115		extra_args+=" --without-headers"
    116	fi
    117
    118	../gcc-${ver}/configure \
    119		--prefix=/usr \
    120		--sbindir=/usr/bin \
    121		--libdir=/usr/lib \
    122		--libexecdir=/usr/lib \
    123		--target=${tgt} \
    124		--disable-nls \
    125		--disable-multilib \
    126		--disable-shared \
    127		--disable-libquadmath \
    128		--disable-decimal-float \
    129		--disable-libgomp \
    130		--disable-libmpx \
    131		--disable-libmudflap \
    132		--disable-libssp \
    133		--disable-libitm \
    134		--disable-libatomic \
    135		--disable-threads \
    136		--disable-sjlj-exceptions \
    137		--enable-languages=c \
    138		--with-gnu-ld \
    139		--with-gnu-as \
    140		${extra_args} \
    141		${configure_args} \
    142		${cross_gcc_bootstrap_configure_args}
    143
    144	make ${makejobs}
    145	make install DESTDIR=${wrksrc}/build_root
    146
    147	local ptrs=$(${tgt}-gcc -dM -E - < /dev/null | \
    148		grep __SIZEOF_POINTER__)
    149	local ws=${ptrs##* }
    150
    151	case ${ws} in
    152		8) echo 64 > ${wrksrc}/.gcc_wordsize ;;
    153		4) echo 32 > ${wrksrc}/.gcc_wordsize ;;
    154		*) msg_error "Unknown word size: ${ws}\n" ;;
    155	esac
    156
    157	touch ${wrksrc}/.gcc_bootstrap_done
    158}
    159
    160_void_cross_build_kernel_headers() {
    161	[ -f ${wrksrc}/.linux_headers_done ] && return 0
    162
    163	local tgt=$1
    164	local ver=$2
    165	local arch
    166
    167	msg_normal "Patching Linux headers for ${tgt}\n"
    168
    169	cd ${wrksrc}/linux-${ver}
    170	for f in ${XBPS_SRCPKGDIR}/kernel-libc-headers/patches/*.patch; do
    171		_void_cross_apply_patch -p0 $f
    172	done
    173	cd ..
    174
    175	msg_normal "Building Linux headers for ${tgt}\n"
    176
    177	cd linux-${ver}
    178
    179	case "$tgt" in
    180		x86_64*|i686*) arch=x86 ;;
    181		powerpc*) arch=powerpc ;;
    182		mips*) arch=mips ;;
    183		aarch64*) arch=arm64 ;;
    184		arm*) arch=arm ;;
    185		riscv*) arch=riscv ;;
    186		s390*) arch=s390 ;;
    187		*) msg_error "Unknown Linux arch for ${tgt}\n" ;;
    188	esac
    189
    190	make ARCH=${arch} headers
    191	find usr/include -name '.*' -delete
    192	rm usr/include/Makefile
    193	rm -r usr/include/drm
    194	cp -a usr/include ${wrksrc}/build_root/usr/${tgt}/usr
    195
    196	touch ${wrksrc}/.linux_headers_done
    197}
    198
    199_void_cross_build_glibc_headers() {
    200	[ -f ${wrksrc}/.glibc_headers_done ] && return 0
    201
    202	local tgt=$1
    203	local ver=$2
    204
    205	msg_normal "Patching glibc for ${tgt}\n"
    206
    207	cd ${wrksrc}/glibc-${ver}
    208	if [ -d "${XBPS_SRCPKGDIR}/glibc/patches" ]; then
    209		for f in ${XBPS_SRCPKGDIR}/glibc/patches/*.patch; do
    210			_void_cross_apply_patch -p1 "$f"
    211		done
    212	fi
    213	cd ..
    214
    215	msg_normal "Building glibc headers for ${tgt}\n"
    216
    217	mkdir -p glibc_headers
    218	cd glibc_headers
    219
    220	echo "libc_cv_forced_unwind=yes" > config.cache
    221	echo "libc_cv_c_cleanup=yes" >> config.cache
    222
    223	# we don't need any custom args here, it's just headers
    224	CC="${tgt}-gcc" CXX="${tgt}-g++" CPP="${tgt}-cpp" LD="${tgt}-ld" \
    225	AS="${tgt}-as" NM="${tgt}-nm" CFLAGS="-pipe" CXXFLAGS="" CPPFLAGS="" \
    226	LDFLAGS="" \
    227	../glibc-${ver}/configure \
    228		--prefix=/usr \
    229		--host=${tgt} \
    230		--with-headers=${wrksrc}/build_root/usr/${tgt}/usr/include \
    231		--config-cache \
    232		--enable-kernel=2.6.27 \
    233		${cross_glibc_configure_args}
    234
    235	make -k install-headers cross_compiling=yes \
    236		install_root=${wrksrc}/build_root/usr/${tgt}
    237
    238	touch ${wrksrc}/.glibc_headers_done
    239}
    240
    241_void_cross_build_glibc() {
    242	[ -f ${wrksrc}/.glibc_build_done ] && return 0
    243
    244	local tgt=$1
    245	local ver=$2
    246
    247	msg_normal "Building glibc for ${tgt}\n"
    248
    249	mkdir -p ${wrksrc}/glibc_build
    250	cd ${wrksrc}/glibc_build
    251
    252	local ws=$(cat ${wrksrc}/.gcc_wordsize)
    253
    254	echo "slibdir=/usr/lib${ws}" > configparms
    255
    256	echo "libc_cv_forced_unwind=yes" > config.cache
    257	echo "libc_cv_c_cleanup=yes" >> config.cache
    258
    259	CC="${tgt}-gcc" CXX="${tgt}-g++" CPP="${tgt}-cpp" LD="${tgt}-ld" \
    260	AR="${tgt}-ar" AS="${tgt}-as" NM="${tgt}-nm" \
    261	CFLAGS="-pipe ${cross_glibc_cflags}" \
    262	CXXFLAGS="-pipe ${cross_glibc_cflags}" \
    263	CPPFLAGS="${cross_glibc_cflags}" \
    264	LDFLAGS="${cross_glibc_ldflags}" \
    265	../glibc-${ver}/configure \
    266		--prefix=/usr \
    267		--libdir=/usr/lib${ws} \
    268		--libexecdir=/usr/libexec \
    269		--host=${tgt} \
    270		--with-headers=${wrksrc}/build_root/usr/${tgt}/usr/include \
    271		--config-cache \
    272		--disable-profile \
    273		--disable-werror \
    274		--enable-kernel=2.6.27 \
    275		${cross_glibc_configure_args}
    276
    277	make ${makejobs}
    278	make install_root=${wrksrc}/build_root/usr/${tgt} install
    279
    280	touch ${wrksrc}/.glibc_build_done
    281}
    282
    283_void_cross_build_musl() {
    284	[ -f ${wrksrc}/.musl_build_done ] && return 0
    285
    286	local tgt=$1
    287	local ver=$2
    288
    289	msg_normal "Patching musl for ${tgt}\n"
    290
    291	cd ${wrksrc}/musl-${ver}
    292	if [ -d "${XBPS_SRCPKGDIR}/musl/patches" ]; then
    293		for f in ${XBPS_SRCPKGDIR}/musl/patches/*.patch; do
    294			_void_cross_apply_patch -p0 "$f"
    295		done
    296	fi
    297	cd ..
    298
    299	msg_normal "Building musl for ${tgt}\n"
    300
    301	mkdir -p musl_build
    302	cd musl_build
    303
    304	CC="${tgt}-gcc" CXX="${tgt}-g++" CPP="${tgt}-cpp" LD="${tgt}-ld" \
    305	AR="${tgt}-ar" AS="${tgt}-as" NM="${tgt}-nm" \
    306	CFLAGS="-pipe -fPIC ${cross_musl_cflags}" \
    307	CPPFLAGS="${cross_musl_cflags}" LDFLAGS="${cross_musl_ldflags}" \
    308	../musl-${ver}/configure \
    309		--prefix=/usr \
    310		--host=${tgt} \
    311		${cross_musl_configure_args}
    312
    313	make ${makejobs}
    314	make DESTDIR=${wrksrc}/build_root/usr/${tgt} install
    315
    316	touch ${wrksrc}/.musl_build_done
    317}
    318
    319_void_cross_build_libucontext() {
    320	[ -n "$cross_gcc_skip_go" ] && return 0
    321	[ -f ${wrksrc}/.libucontext_build_done ] && return 0
    322
    323	local tgt=$1
    324	local ver=$2
    325	local arch incpath
    326
    327	msg_normal "Building libucontext for ${tgt}\n"
    328
    329	case "$tgt" in
    330		x86_64*) arch=x86_64 ;;
    331		i686*) arch=x86 ;;
    332		powerpc64*) arch=ppc64 ;;
    333		powerpc*) arch=ppc ;;
    334		mips*64*) arch=mips64 ;;
    335		mips*) arch=mips ;;
    336		aarch64*) arch=aarch64 ;;
    337		arm*) arch=arm ;;
    338		riscv64*) arch=riscv64 ;;
    339		s390x*) arch=s390x ;;
    340		*) msg_error "Unknown libucontext arch for ${tgt}\n" ;;
    341	esac
    342
    343	cd ${wrksrc}/libucontext-${ver}
    344	# a terrible hack but seems to work for now
    345	# we build a static-only library to prevent linking to a runtime
    346	# since it's tiny it can be linked into libgo and we don't have
    347	# to keep it around (which would possibly conflict with crossdeps)
    348	incpath="${wrksrc}/build_root/usr/${tgt}/usr/include"
    349	CC="${tgt}-gcc" AS="${tgt}-as" AR="${tgt}-ar" \
    350	make ARCH=$arch libucontext.a \
    351		CFLAGS="${cross_musl_cflags} -g0 -nostdinc -isystem ${incpath}"
    352
    353	cp libucontext.a ${wrksrc}/build_root/usr/${tgt}/usr/lib
    354
    355	touch ${wrksrc}/.libucontext_build_done
    356}
    357
    358_void_cross_build_gcc() {
    359	[ -f ${wrksrc}/.gcc_build_done ] && return 0
    360
    361	local tgt=$1
    362	local ver=$2
    363
    364	msg_normal "Building gcc for ${tgt}\n"
    365
    366	mkdir -p ${wrksrc}/gcc_build
    367	cd ${wrksrc}/gcc_build
    368
    369	local langs="c,c++,fortran,objc,obj-c++,ada,lto"
    370	if [ -z "$cross_gcc_skip_go" ]; then
    371		langs+=",go"
    372	fi
    373
    374	local extra_args
    375	if [ -f ${wrksrc}/.musl_version ]; then
    376		# otherwise glibc hosts get confused and use the gnu impl
    377		extra_args+=" --enable-clocale=generic"
    378		extra_args+=" --disable-symvers"
    379		extra_args+=" --disable-gnu-unique-object"
    380		extra_args+=" libat_cv_have_ifunc=no"
    381	else
    382		extra_args+=" --enable-gnu-unique-object"
    383	fi
    384
    385	# note on --disable-libquadmath:
    386	# on some platforms the library is actually necessary for the
    387	# fortran frontend to build, but still disable it because it
    388	# should not be in the resulting packages; it conflicts with
    389	# the libquadmath you can install into the cross root
    390	#
    391	# platforms where this is a problem should explicitly force
    392	# libquadmath to be on via cross_gcc_configure_args, the
    393	# do_install in this build-style automatically removes it
    394	#
    395	../gcc-${ver}/configure \
    396		--prefix=/usr \
    397		--sbindir=/usr/bin \
    398		--libdir=/usr/lib \
    399		--libexecdir=/usr/lib \
    400		--target=${tgt} \
    401		--with-sysroot=/usr/${tgt} \
    402		--with-build-sysroot=${wrksrc}/build_root/usr/${tgt} \
    403		--enable-languages=${langs} \
    404		--disable-nls \
    405		--disable-multilib \
    406		--disable-sjlj-exceptions \
    407		--disable-libquadmath \
    408		--disable-libmudflap \
    409		--disable-libitm \
    410		--disable-libvtv \
    411		--disable-libsanitizer \
    412		--disable-libstdcxx-pch \
    413		--enable-shared \
    414		--enable-threads=posix \
    415		--enable-__cxa_atexit \
    416		--enable-linker-build-id \
    417		--enable-libada \
    418		--enable-lto \
    419		--enable-default-pie \
    420		--enable-default-ssp \
    421		--enable-libssp \
    422		--with-gnu-ld \
    423		--with-gnu-as \
    424		--with-linker-hash-style=gnu \
    425		${extra_args} \
    426		${configure_args} \
    427		${cross_gcc_configure_args}
    428
    429	make ${makejobs}
    430
    431	touch ${wrksrc}/.gcc_build_done
    432}
    433
    434_void_cross_test_ver() {
    435	local proj=$1
    436	local noerr=$2
    437	local ver cver
    438	for p in ${proj}-*; do
    439		cver=${p#${proj}-}
    440		if [ -z "$noerr" -a -n "$ver" ]; then
    441			msg_error "multiple versions of ${proj} found: ${ver}, ${cver}"
    442		fi
    443		ver=${cver}
    444	done
    445	if [ -d "${proj}-${ver}" ]; then
    446		echo ${ver} > ${wrksrc}/.${proj}_version
    447		return
    448	fi
    449	if [ -z "$noerr" ]; then
    450		msg_error "project ${proj} not available for build\n"
    451	fi
    452}
    453
    454do_build() {
    455	# Verify toolchain versions
    456	cd ${wrksrc}
    457
    458	local binutils_ver linux_ver gcc_ver libc_ver libucontext_ver
    459	local tgt=${sourcepkg/cross-}
    460
    461	_void_cross_test_ver binutils
    462	_void_cross_test_ver linux
    463	_void_cross_test_ver gcc
    464
    465	binutils_ver=$(cat .binutils_version)
    466	linux_ver=$(cat .linux_version)
    467	gcc_ver=$(cat .gcc_version)
    468
    469	_void_cross_test_ver musl noerr
    470	if [ ! -f .musl_version ]; then
    471		_void_cross_test_ver glibc
    472		libc_ver=$(cat .glibc_version)
    473	else
    474		libc_ver=$(cat .musl_version)
    475		if [ -z "$cross_gcc_skip_go" ]; then
    476			_void_cross_test_ver libucontext
    477			libucontext_ver=$(cat .libucontext_version)
    478		fi
    479	fi
    480
    481	local sysroot="/usr/${tgt}"
    482
    483	# Prepare environment
    484	cd ${wrksrc}
    485
    486	# Core directories for the build root
    487	mkdir -p build_root/usr/{bin,lib,include,share}
    488	mkdir -p build_root/usr/${tgt}/usr/{bin,lib,include,share}
    489
    490	# Host root uses host wordsize
    491	ln -sf usr/lib build_root/lib
    492	ln -sf usr/lib build_root/lib${XBPS_TARGET_WORDSIZE}
    493	ln -sf lib build_root/usr/lib${XBPS_TARGET_WORDSIZE}
    494
    495	# Prepare target sysroot
    496	ln -sf usr/lib build_root/${sysroot}/lib
    497	ln -sf lib build_root/${sysroot}/usr/libexec
    498
    499	_void_cross_build_binutils ${tgt} ${binutils_ver}
    500
    501	# Prepare environment so we can use temporary prefix
    502	local oldpath="$PATH"
    503	local oldldlib="$LD_LIBRARY_PATH"
    504
    505	export PATH="${wrksrc}/build_root/usr/bin:$PATH"
    506	export LD_LIBRARY_PATH="${wrksrc}/build_root/usr/lib:$PATH"
    507
    508	_void_cross_build_bootstrap_gcc ${tgt} ${gcc_ver}
    509	_void_cross_build_kernel_headers ${tgt} ${linux_ver}
    510
    511	local ws=$(cat ${wrksrc}/.gcc_wordsize)
    512
    513	# Now that we know the target wordsize, prepare symlinks
    514	ln -sf usr/lib ${wrksrc}/build_root/${sysroot}/lib${ws}
    515	ln -sf lib ${wrksrc}/build_root/${sysroot}/usr/lib${ws}
    516
    517	if [ -f ${wrksrc}/.musl_version ]; then
    518		_void_cross_build_musl ${tgt} ${libc_ver}
    519		_void_cross_build_libucontext ${tgt} ${libucontext_ver}
    520	else
    521		_void_cross_build_glibc_headers ${tgt} ${libc_ver}
    522		_void_cross_build_glibc ${tgt} ${libc_ver}
    523	fi
    524
    525	_void_cross_build_gcc ${tgt} ${gcc_ver}
    526
    527	# restore this stuff in case later hooks depend on it
    528	export PATH="$oldpath"
    529	export LD_LIBRARY_PATH="$oldldlib"
    530}
    531
    532do_install() {
    533	# We need to be able to access binutils in the root
    534	local oldpath="$PATH"
    535	local oldldlib="$LD_LIBRARY_PATH"
    536	export PATH="${wrksrc}/build_root/usr/bin:$PATH"
    537	export LD_LIBRARY_PATH="${wrksrc}/build_root/usr/lib:$PATH"
    538
    539	local tgt=${sourcepkg/cross-}
    540	local sysroot="/usr/${tgt}"
    541	local ws=$(cat ${wrksrc}/.gcc_wordsize)
    542
    543	# Core directories for the sysroot
    544	#
    545	# libexec is created for sysroot but not for dest, since in sysroot
    546	# we configure glibc with separate libexec, elsewhere it's just lib
    547	# and we want to delete the libexec from glibc afterwards to save space
    548	mkdir -p ${DESTDIR}/${sysroot}/usr/{bin,lib,libexec,include,share}
    549	# Sysroot base symlinks
    550	ln -sf usr/bin ${DESTDIR}/${sysroot}/bin
    551	ln -sf usr/lib ${DESTDIR}/${sysroot}/lib
    552	ln -sf usr/lib ${DESTDIR}/${sysroot}/lib${ws}
    553	ln -sf lib ${DESTDIR}/${sysroot}/usr/lib${ws}
    554	ln -sf usr/include ${DESTDIR}/${sysroot}/include
    555
    556	# Install Linux headers
    557	cd ${wrksrc}/linux-$(cat ${wrksrc}/.linux_version)
    558	cp -a usr/include ${DESTDIR}/${sysroot}/usr
    559
    560	# Install binutils
    561	cd ${wrksrc}/binutils_build
    562	make install DESTDIR=${DESTDIR}
    563
    564	# Install final gcc
    565	cd ${wrksrc}/gcc_build
    566	make install DESTDIR=${DESTDIR}
    567
    568	# Move libcc1.so* to the sysroot
    569	mv ${DESTDIR}/usr/lib/libcc1.so* ${DESTDIR}/${sysroot}/usr/lib
    570
    571	local gcc_ver=$(cat ${wrksrc}/.gcc_version)
    572	local gcc_patch=${gcc_ver/_*}
    573	local gcc_minor=${gcc_patch%.*}
    574	local gcc_major=${gcc_minor%.*}
    575
    576	if [ -f ${wrksrc}/.musl_version ]; then
    577		# Install musl
    578		cd ${wrksrc}/musl_build
    579		make DESTDIR=${DESTDIR}/${sysroot} install
    580
    581		# Remove useless headers
    582		rm -rf ${DESTDIR}/usr/lib/gcc/${tgt}/*/include-fixed
    583
    584		# Make ld-musl.so symlinks relative
    585		for f in ${DESTDIR}/${sysroot}/usr/lib/ld-musl-*.so.*; do
    586			ln -sf libc.so ${f}
    587		done
    588	else
    589		# Install glibc
    590		cd ${wrksrc}/glibc_build
    591		make install_root=${DESTDIR}/${sysroot} install install-headers
    592
    593		# Remove bad header
    594		rm -f ${DESTDIR}/usr/lib/gcc/${tgt}/${gcc_patch}/include-fixed/bits/statx.h
    595	fi
    596
    597	# minor-versioned symlinks
    598	mv ${DESTDIR}/usr/lib/gcc/${tgt}/${gcc_patch} \
    599		${DESTDIR}/usr/lib/gcc/${tgt}/${gcc_minor}
    600	ln -sfr ${DESTDIR}/usr/lib/gcc/${tgt}/${gcc_minor} \
    601		${DESTDIR}/usr/lib/gcc/${tgt}/${gcc_patch}
    602
    603	# ditto for c++ headers
    604	mv ${DESTDIR}/${sysroot}/usr/include/c++/${gcc_patch} \
    605		${DESTDIR}/${sysroot}/usr/include/c++/${gcc_minor}
    606	ln -sfr ${DESTDIR}/${sysroot}/usr/include/c++/${gcc_minor} \
    607		${DESTDIR}/${sysroot}/usr/include/c++/${gcc_patch}
    608
    609	# Symlinks for gnarl and gnat shared libraries
    610	local adalib=usr/lib/gcc/${tgt}/${gcc_patch}/adalib
    611	mv ${DESTDIR}/${adalib}/libgnarl-${gcc_major}.so \
    612		${DESTDIR}/${sysroot}/usr/lib
    613	mv ${DESTDIR}/${adalib}/libgnat-${gcc_major}.so \
    614		${DESTDIR}/${sysroot}/usr/lib
    615	ln -sf libgnarl-${gcc_major}.so ${DESTDIR}/${sysroot}/usr/lib/libgnarl.so
    616	ln -sf libgnat-${gcc_major}.so ${DESTDIR}/${sysroot}/usr/lib/libgnat.so
    617	rm -vf ${DESTDIR}/${adalib}/libgna{rl,t}.so
    618
    619	# Remove unnecessary libatomic which is only built for gccgo
    620	rm -rf ${DESTDIR}/${sysroot}/usr/lib/libatomic.*
    621
    622	# If libquadmath was forced (needed for gfortran on some platforms)
    623	# then remove it because it conflicts with libquadmath package
    624	rm -rf ${DESTDIR}/${sysroot}/usr/lib/libquadmath.*
    625
    626	# Remove leftover symlinks
    627	rm -f ${DESTDIR}/usr/lib${XBPS_TARGET_WORDSIZE}
    628	rm -f ${DESTDIR}/lib*
    629	rm -f ${DESTDIR}/*bin
    630	# Remove unnecessary stuff
    631	rm -rf ${DESTDIR}/${sysroot}/{sbin,etc,var,libexec}
    632	rm -rf ${DESTDIR}/${sysroot}/usr/{sbin,share,libexec}
    633	rm -rf ${DESTDIR}/usr/share
    634	rm -f ${DESTDIR}/usr/lib*/libiberty.a
    635
    636	export PATH="$oldpath"
    637	export LD_LIBRARY_PATH="$oldldlib"
    638}