From: q66 <q66@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: [PR PATCH] [RFC WIP] crosstoolchain build-style
Date: Fri, 25 Dec 2020 00:54:44 +0100 [thread overview]
Message-ID: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-27412@inbox.vuxu.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 1796 bytes --]
There is a new pull request by q66 against master on the void-packages repository
https://github.com/q66/void-packages cross-style
https://github.com/void-linux/void-packages/pull/27412
[RFC WIP] crosstoolchain build-style
This introduces a build-style for system crosstoolchains. It only works, and will only work, for toolchains targeting Void and one of its standard libraries. The none targets and stuff like mingw are explicitly a non-goal, to reduce the amount of magic we have to do.
This has a bunch of advantages:
- crosstoolchain templates can now be small and simple (also attached: proof of concept redoing of `cross-aarch64-linux-gnu`)
- crosstoolchains writen with this build-style will no longer mess up masterdirs like the existing ones do; you can safely build your stuff without `-t` and your `masterdir` will be pristine
- unification of options passed to `gcc`/libc/`binutils` configure, as much as possible
- reduced repeated boilerplate code between individual crosstoolchains
- `ccache` friendly
- easier upgrades, easier maintenance, etc
This is currently incomplete. These things are left to do:
- [ ] Add musl support
- [ ] Clean up the configure params, only keep the generic ones in the build-style, specific ones will go into individual crosstoolchains (this one is largely based on what the aarch64 one was doing)
- [ ] Rework the other templates to use this
- [ ] 64-bit cross on 32-bit hosts is probably actually fine in general, we just need to enable it
- [ ] Allow glibc crosstoolchains on musl (this needs `glibc` 2.32 though)
For now, posting for input.
@Duncaen @leahneukirchen @pullmoll @ericonr @void-linux/pkg-committers
[ci skip]
A patch file from https://github.com/void-linux/void-packages/pull/27412.patch is attached
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-cross-style-27412.patch --]
[-- Type: text/x-diff, Size: 24711 bytes --]
From 3141d48e68856161e0946abd6d41f1b943be487d Mon Sep 17 00:00:00 2001
From: q66 <daniel@octaforge.org>
Date: Fri, 25 Dec 2020 00:42:26 +0100
Subject: [PATCH 1/2] common/build-style: add void-cross
this introduces a new build-style void-cross, which can be used
to write system crosstoolchain templates; this is to reduce the
amount of maintenance, resolve existing problems with the cross
toolchain templates and remove repeated code
---
common/build-style/void-cross.sh | 421 +++++++++++++++++++
common/environment/build-style/void-cross.sh | 12 +
2 files changed, 433 insertions(+)
create mode 100644 common/build-style/void-cross.sh
create mode 100644 common/environment/build-style/void-cross.sh
diff --git a/common/build-style/void-cross.sh b/common/build-style/void-cross.sh
new file mode 100644
index 00000000000..94174da4347
--- /dev/null
+++ b/common/build-style/void-cross.sh
@@ -0,0 +1,421 @@
+#
+# This helper is for void system crosstoolchain templates.
+#
+# Mandatory variables:
+#
+# - cross_triplet - the target triplet (e.g. aarch64-linux-gnu)
+# - cross_wordsize - 32 or 64
+# - cross_libc - glibc or musl
+# - cross_binutils_version
+# - cross_gcc_version
+# - cross_linux_version
+# - cross_linux_arch - the source ARCH of the kernel (e.g. arm64)
+# - cross_glibc_version
+# - cross_musl_version
+#
+# Optional variables:
+#
+# - cross_binutils_configure_args
+# - cross_gcc_bootstrap_configure_args
+# - cross_glibc_cflags
+# - cross_glibc_ldflags
+# - cross_glibc_configure_args
+# - cross_musl_cflags
+# - cross_musl_ldflags
+# - cross_musl_configure_args
+#
+# configure_args is used for final gcc
+#
+
+_apply_patch() {
+ local args="$1" pname="$(basename $2)"
+ if [ ! -f ".${pname}_done" ]; then
+ patch -N $args -i $2
+ touch .${pname}_done
+ fi
+}
+
+_build_binutils() {
+ [ -f .binutils_done ] && return 0
+
+ msg_normal "Building binutils for ${cross_triplet}"
+
+ mkdir -p binutils_build
+ cd binutils_build
+
+ ../binutils-${cross_binutils_version}/configure \
+ --prefix=/usr \
+ --sbindir=/usr/bin \
+ --libdir=/usr/lib \
+ --libexecdir=/usr/lib \
+ --target=${cross_triplet} \
+ --with-sysroot=/usr/${cross_triplet} \
+ --disable-nls \
+ --disable-shared \
+ --disable-multilib \
+ --disable-werror \
+ --disable-gold \
+ --with-system-zlib \
+ ${cross_binutils_configure_args}
+
+ make configure-host
+ make ${makejobs}
+
+ make install DESTDIR=${wrksrc}/build_root
+
+ touch ${wrksrc}/.binutils_done
+}
+
+_build_bootstrap_gcc() {
+ [ -f .gcc_bootstrap_done ] && return 0
+
+ msg_normal "Patching GCC for ${cross_triplet}"
+
+ cd gcc-${cross_gcc_version}
+ for f in ${XBPS_SRCPKGDIR}/gcc/patches/*.patch; do
+ _apply_patch -p0 "$f"
+ done
+ cd ..
+
+ msg_normal "Building bootstrap GCC for ${cross_triplet}"
+
+ mkdir -p gcc_bootstrap
+ cd gcc_bootstrap
+
+ ../gcc-${cross_gcc_version}/configure \
+ --prefix=/usr \
+ --sbindir=/usr/bin \
+ --libdir=/usr/lib \
+ --libexecdir=/usr/lib \
+ --target=${cross_triplet} \
+ --without-headers \
+ --disable-nls \
+ --disable-multilib \
+ --disable-shared \
+ --disable-libquadmath \
+ --disable-decimal-float \
+ --disable-libgomp \
+ --disable-libmpx \
+ --disable-libmudflap \
+ --disable-libssp \
+ --disable-libitm \
+ --disable-libatomic \
+ --disable-threads \
+ --disable-sjlj-exceptions \
+ --enable-languages=c \
+ --with-gnu-ld \
+ --with-gnu-as \
+ ${cross_gcc_bootstrap_configure_args}
+
+ make ${makejobs}
+ make install DESTDIR=${wrksrc}/build_root
+
+ touch ${wrksrc}/.gcc_bootstrap_done
+}
+
+_build_kernel_headers() {
+ [ -f .linux_headers_done ] && return 0
+
+ msg_normal "Building Linux headers for ${cross_triplet}\n"
+
+ cd linux-${cross_linux_version}
+
+ make ARCH=$cross_linux_arch headers_check
+ make ARCH=$cross_linux_arch \
+ INSTALL_HDR_PATH=${wrksrc}/build_root/usr/${cross_triplet}/usr \
+ headers_install
+
+ touch ${wrksrc}/.linux_headers_done
+}
+
+_build_glibc_headers() {
+ [ -f .glibc_headers_done ] && return 0
+
+ local tgt=$cross_triplet
+
+ msg_normal "Patching glibc for ${cross_triplet}\n"
+
+ cd glibc-${cross_glibc_version}
+ if [ -d "${XBPS_SRCPKGDIR}/glibc/patches" ]; then
+ for f in ${XBPS_SRCPKGDIR}/glibc/patches/*.patch; do
+ _apply_patch -p1 "$f"
+ done
+ fi
+ cd ..
+
+ msg_normal "Building glibc headers for ${cross_triplet}\n"
+
+ mkdir -p glibc_headers
+ cd glibc_headers
+
+ echo "libc_cv_forced_unwind=yes" > config.cache
+ echo "libc_cv_c_cleanup=yes" >> config.cache
+
+ # we don't need any custom args here, it's just headers
+ CC="${tgt}-gcc" CXX="${tgt}-g++" CPP="${tgt}-cpp" LD="${tgt}-ld" \
+ AS="${tgt}-as" NM="${tgt}-nm" CFLAGS="-pipe" CXXFLAGS="" CPPFLAGS="" \
+ LDFLAGS="" \
+ ../glibc-${cross_glibc_version}/configure \
+ --prefix=/usr \
+ --host=${tgt} \
+ --with-headers=${wrksrc}/build_root/usr/${tgt}/usr/include \
+ --config-cache \
+ --enable-obsolete-rpc \
+ --enable-obsolete-nsl \
+ --enable-kernel=2.6.27
+
+ make -k install-headers cross_compiling=yes \
+ install_root=${wrksrc}/build_root/usr/${tgt}
+
+ touch ${wrksrc}/.glibc_headers_done
+}
+
+_build_glibc() {
+ [ -f .glibc_build_done ] && return 0
+
+ local tgt=$cross_triplet
+
+ msg_normal "Building glibc for ${tgt}\n"
+
+ mkdir -p glibc_build
+ cd glibc_build
+
+ echo "slibdir=/usr/lib${cross_wordsize}" > configparms
+
+ echo "libc_cv_forced_unwind=yes" > config.cache
+ echo "libc_cv_c_cleanup=yes" >> config.cache
+
+ CC="${tgt}-gcc" CXX="${tgt}-g++" CPP="${tgt}-cpp" LD="${tgt}-ld" \
+ AS="${tgt}-as" NM="${tgt}-nm" CFLAGS="-pipe ${cross_glibc_cflags}" \
+ CXXFLAGS="-pipe ${cross_glibc_cflags}" CPPFLAGS="${cross_glibc_cflags}" \
+ LDFLAGS="${cross_glibc_ldflags}" \
+ ../glibc-${cross_glibc_version}/configure \
+ --prefix=/usr \
+ --libdir=/usr/lib${cross_wordsize} \
+ --libexecdir=/usr/libexec \
+ --host=${tgt} \
+ --with-headers=${wrksrc}/build_root/usr/${tgt}/usr/include \
+ --config-cache \
+ --enable-obsolete-rpc \
+ --enable-obsolete-nsl \
+ --disable-profile \
+ --disable-werror \
+ --enable-kernel=2.6.27 \
+ ${cross_glibc_configure_args}
+
+ make ${makejobs}
+ make install_root=${wrksrc}/build_root/usr/${tgt} install
+
+ touch ${wrksrc}/.glibc_build_done
+}
+
+_build_gcc() {
+ [ -f .gcc_build_done ] && return 0
+
+ msg_normal "Building gcc for ${cross_triplet}\n"
+
+ mkdir -p gcc_build
+ cd gcc_build
+
+ ../gcc-${cross_gcc_version}/configure \
+ --prefix=/usr \
+ --sbindir=/usr/bin \
+ --libdir=/usr/lib \
+ --libexecdir=/usr/lib \
+ --target=${cross_triplet} \
+ --with-sysroot=/usr/${cross_triplet} \
+ --with-build-sysroot=${wrksrc}/build_root/usr/${cross_triplet} \
+ --enable-languages=c,c++,fortran,objc,obj-c++,ada,go,lto \
+ --disable-nls \
+ --disable-multilib \
+ --disable-sjlj-exceptions \
+ --disable-libquadmath \
+ --disable-libmudflap \
+ --disable-libssp \
+ --disable-libitm \
+ --disable-libvtv \
+ --disable-libsanitizer \
+ --disable-libcilkrts \
+ --disable-libstdcxx-pch \
+ --enable-shared \
+ --enable-threads=posix \
+ --enable-long-longx \
+ --enable-linker-build-id \
+ --enable-gnu-unique-object \
+ --enable-libada \
+ --enable-lto \
+ --enable-libstdcxx-time \
+ --enable-default-pie \
+ --enable-default-ssp \
+ --with-gnu-ld \
+ --with-gnu-as \
+ --with-linker-hash-style=gnu \
+ ${configure_args}
+
+ make ${makejobs}
+
+ touch ${wrksrc}/.gcc_build_done
+}
+
+do_build() {
+ # Verify toolchain versions
+
+ [ -z "$cross_binutils_version" ] && msg_error "Unknown binutils version\n"
+ [ -z "$cross_gcc_version" ] && msg_error "Unknown GCC version\n"
+ [ -z "$cross_linux_version" ] && msg_error "Unknown Linux version\n"
+
+ case "${cross_libc}" in
+ musl)
+ [ -z "$cross_musl_version" ] && msg_error "Unknown musl version\n"
+ ;;
+ glibc)
+ [ -z "$cross_glibc_version" ] && msg_error "Unknown glibc version\n"
+ ;;
+ *) msg_error "Unknown system libc: ${cross_libc}\n" ;;
+ esac
+
+ # Verify triplet
+ [ -z "$cross_triplet" ] && msg_error "Unknown target triplet\n"
+ [ -z "$cross_wordsize" ] && msg_error "Unknown target wordsize\n"
+ [ -z "$cross_linux_arch" ] && msg_error "Unknown kernel architecture\n"
+
+ local sysroot="/usr/${cross_triplet}"
+
+ # Prepare environment
+ cd ${wrksrc}
+
+ # Core directories for the build root
+ mkdir -p build_root/usr/{bin,lib,include,share}
+ mkdir -p build_root/usr/${cross_triplet}/usr/{bin,lib,include,share}
+
+ # Host root uses host wordsize
+ ln -sf usr/lib build_root/lib
+ ln -sf usr/lib build_root/lib${XBPS_TARGET_WORDSIZE}
+ ln -sf lib build_root/usr/lib${XBPS_TARGET_WORDSIZE}
+
+ # Target sysroot uses target wordsize
+ ln -sf usr/lib build_root/${sysroot}/lib
+ ln -sf usr/lib build_root/${sysroot}/lib${cross_wordsize}
+ ln -sf lib build_root/${sysroot}/usr/lib${cross_wordsize}
+ ln -sf lib build_root/${sysroot}/usr/libexec
+
+ # Build cross binutils
+ cd ${wrksrc}
+ if [ ! -d "binutils-${cross_binutils_version}" ]; then
+ msg_error "Binutils ${cross_binutils_version} does not exist\n"
+ fi
+
+ _build_binutils
+
+ # Prepare environment so we can use temporary prefix
+ local oldpath="$PATH"
+ local oldldlib="$LD_LIBRARY_PATH"
+
+ export PATH="${wrksrc}/build_root/usr/bin:$PATH"
+ export LD_LIBRARY_PATH="${wrksrc}/build_root/usr/lib:$PATH"
+
+ # Build bootstrap gcc
+ cd ${wrksrc}
+ if [ ! -d "gcc-${cross_gcc_version}" ]; then
+ msg_error "GCC ${cross_gcc_version} does not exist\n"
+ fi
+
+ _build_bootstrap_gcc
+
+ # Build kernel headers
+ cd ${wrksrc}
+ if [ ! -d "linux-${cross_linux_version}" ]; then
+ msg_error "Linux ${cross_linux_version} does not exist\n"
+ fi
+
+ _build_kernel_headers
+
+ # Build glibc
+ cd ${wrksrc}
+ if [ ! -d "glibc-${cross_glibc_version}" ]; then
+ msg_error "Glibc ${cross_glibc_version} does not exist\n"
+ fi
+
+ _build_glibc_headers
+ cd ${wrksrc}
+ _build_glibc
+
+ # Build gcc
+ cd ${wrksrc}
+ _build_gcc
+
+ # restore this stuff in case later hooks depend on it
+ export PATH="$oldpath"
+ export LD_LIBRARY_PATH="$oldldlib"
+}
+
+do_install() {
+ # We need to be able to access binutils in the root
+ local oldpath="$PATH"
+ local oldldlib="$LD_LIBRARY_PATH"
+ export PATH="${wrksrc}/build_root/usr/bin:$PATH"
+ export LD_LIBRARY_PATH="${wrksrc}/build_root/usr/lib:$PATH"
+
+ local sysroot="/usr/${cross_triplet}"
+
+ # Core directories for the sysroot
+ #
+ # libexec is created for sysroot but not for dest, since in sysroot
+ # we configure glibc with separate libexec, elsewhere it's just lib
+ # and we want to delete the libexec from glibc afterwards to save space
+ mkdir -p ${DESTDIR}/${sysroot}/usr/{bin,lib,libexec,include,share}
+ # Sysroot base symlinks
+ ln -sf usr/lib ${DESTDIR}/${sysroot}/lib
+ ln -sf usr/lib ${DESTDIR}/${sysroot}/lib${cross_wordsize}
+ ln -sf lib ${DESTDIR}/${sysroot}/usr/lib${cross_wordsize}
+
+ # Install binutils
+ cd ${wrksrc}/binutils_build
+ make install DESTDIR=${DESTDIR}
+
+ # Install final gcc
+ cd ${wrksrc}/gcc_build
+ make install DESTDIR=${DESTDIR}
+
+ # Move libcc1.so* to the sysroot
+ mv ${DESTDIR}/usr/lib/libcc1.so* ${DESTDIR}/${sysroot}/usr/lib
+
+ # Install Linux headers
+ cd ${wrksrc}/linux-${cross_linux_version}
+ make ARCH=${cross_linux_arch} \
+ INSTALL_HDR_PATH=${DESTDIR}/${sysroot}/usr headers_install
+ rm -f $(find ${DESTDIR}/${sysroot}/usr/include \
+ -name .install -or -name ..install.cmd)
+ rm -rf ${DESTDIR}/${sysroot}/usr/include/drm
+
+ # Install glibc
+ cd ${wrksrc}/glibc_build
+ make install_root=${DESTDIR}/${sysroot} install install-headers
+
+ # Symlinks for gnarl and gnat shared libraries
+ local majorver=${cross_gcc_version%.*.*}
+ local adalib=usr/lib/gcc/${_triplet}/${_gcc_version}/adalib
+ mv ${DESTDIR}/${adalib}/libgnarl-${majorver}.so \
+ ${DESTDIR}/${sysroot}/usr/lib
+ mv ${DESTDIR}/${adalib}/libgnat-${majorver}.so \
+ ${DESTDIR}/${sysroot}/usr/lib
+ ln -sf libgnarl-${majorver}.so ${DESTDIR}/${sysroot}/usr/lib/libgnarl.so
+ ln -sf libgnat-${majorver}.so ${DESTDIR}/${sysroot}/usr/lib/libgnat.so
+ rm -vf ${DESTDIR}/${adalib}/libgna{rl,t}.so
+
+ # Remove unnecessary libatomic which is only built for gccgo
+ rm -rf ${DESTDIR}/${sysroot}/usr/lib/libatomic.*
+
+ # Remove leftover symlinks
+ rm -f ${DESTDIR}/usr/lib${XBPS_TARGET_WORDSIZE}
+ rm -f ${DESTDIR}/lib*
+ rm -f ${DESTDIR}/*bin
+ # Remove unnecessary stuff
+ rm -rf ${DESTDIR}/${sysroot}/{sbin,etc,var,libexec}
+ rm -rf ${DESTDIR}/${sysroot}/usr/{sbin,share,libexec}
+ rm -rf ${DESTDIR}/usr/share
+ rm -f ${DESTDIR}/usr/lib*/libiberty.a
+
+ export PATH="$oldpath"
+ export LD_LIBRARY_PATH="$oldldlib"
+}
diff --git a/common/environment/build-style/void-cross.sh b/common/environment/build-style/void-cross.sh
new file mode 100644
index 00000000000..216125cc144
--- /dev/null
+++ b/common/environment/build-style/void-cross.sh
@@ -0,0 +1,12 @@
+lib32disabled=yes
+nocross=yes
+nopie=yes
+create_wrksrc=yes
+
+if [ "$cross_libc" = "glibc" -a "$XBPS_TARGET_LIBC" != "glibc" ]; then
+ broken="glibc crosstoolchains are only available on glibc hosts for now"
+fi
+
+if [ "cross_wordsize" = "64" -a "$XBPS_TARGET_WORDSIZE" != "64" ]; then
+ broken="64-bit crosstoolchains are not available on 32-bit hosts"
+fi
From 0d8d09a15986c158befe1f076712757893cb21c2 Mon Sep 17 00:00:00 2001
From: q66 <daniel@octaforge.org>
Date: Fri, 25 Dec 2020 00:43:48 +0100
Subject: [PATCH 2/2] cross-aarch64-linux-gnu: redo with void-cross build-style
---
srcpkgs/cross-aarch64-linux-gnu/template | 366 ++---------------------
1 file changed, 20 insertions(+), 346 deletions(-)
diff --git a/srcpkgs/cross-aarch64-linux-gnu/template b/srcpkgs/cross-aarch64-linux-gnu/template
index b0122c8ec4a..330dc0db045 100644
--- a/srcpkgs/cross-aarch64-linux-gnu/template
+++ b/srcpkgs/cross-aarch64-linux-gnu/template
@@ -1,21 +1,20 @@
-# Template build file for 'cross-aarch64-linux-gnu'
-#
+# Template file for 'cross-aarch64-linux-gnu'
+_triplet=aarch64-linux-gnu
_binutils_version=2.32
_gcc_version=9.3.0
_glibc_version=2.30
_linux_version=4.19
-
-_triplet=aarch64-linux-gnu
-_archflags="-march=armv8-a"
-_sysroot="/usr/${_triplet}"
-
pkgname=cross-${_triplet}
version=0.33
-revision=3
+revision=4
+build_style=void-cross
+hostmakedepends="tar gcc-objc gcc-go flex perl python3"
+makedepends="isl15-devel libmpc-devel zlib-devel"
+depends="${pkgname}-libc-${version}_${revision}"
short_desc="GNU Cross toolchain for the ${_triplet} LE target (binutils/gcc/glibc)"
maintainer="Leah Neukirchen <leah@vuxu.org>"
-homepage="https://www.voidlinux.org/"
license="GPL-2.0-or-later, GPL-3.0-or-later, LGPL-2.1-or-later"
+homepage="https://www.voidlinux.org/"
distfiles="
${GNU_SITE}/binutils/binutils-${_binutils_version}.tar.xz
${GNU_SITE}/gcc/gcc-${_gcc_version}/gcc-${_gcc_version}.tar.xz
@@ -26,349 +25,24 @@ checksum="0ab6c55dd86a92ed561972ba15b9b70a8b9f75557f896446c82e8b36e473ee04
e2c4114e569afbe7edbc29131a43be833850ab9a459d81beb2588016d2bbb8af
0c68f5655528aed4f99dae71a5b259edc93239fa899e2df79c055275c21749a1"
-lib32disabled=yes
-nocross=yes
-nopie=yes
-create_wrksrc=yes
-hostmakedepends="tar gcc-objc gcc-go flex perl python3"
-makedepends="isl15-devel libmpc-devel zlib-devel"
-depends="${pkgname}-libc-${version}_${revision}"
+cross_triplet=${_triplet}
+cross_wordsize=64
+cross_libc=glibc
+cross_binutils_version=${_binutils_version}
+cross_gcc_version=${_gcc_version}
+cross_glibc_version=${_glibc_version}
+cross_linux_version=${_linux_version}
+cross_linux_arch=arm64
+cross_wordsize=64
+cross_glibc_cflags="-O2 -march=armv8-a"
+
nostrip_files="libcaf_single.a libgcc.a libgcov.a libgcc_eh.a
libgnarl_pic.a libgnarl.a libgnat_pic.a libgnat.a libgmem.a"
-if [ "$XBPS_TARGET_LIBC" != "glibc" ]; then
- broken="glibc crosstoolchain only available on glibc"
-fi
-
-if [ "$XBPS_TARGET_WORDSIZE" != "64" ]; then
- broken="64-bit crosstoolchain only available on 64-bit host"
-fi
-
if [ "$XBPS_TARGET_MACHINE" = "aarch64" ]; then
broken="Can't build crosstoolchain to itself"
fi
-_apply_patch() {
- local args="$1" pname="$(basename $2)"
-
- if [ ! -f ".${pname}_done" ]; then
- patch -N $args -i $2
- touch .${pname}_done
- fi
-}
-
-_linux_headers() {
- [ -f ${wrksrc}/.linux_build_done ] && return 0
-
- cd ${wrksrc}
- msg_normal "Building Linux API headers for ARM\n"
-
- cd linux-${_linux_version}
-
- make ARCH=arm64 headers_check
- make ARCH=arm64 INSTALL_HDR_PATH=${_sysroot}/usr headers_install
-
- touch ${wrksrc}/.linux_build_done
-}
-
-_binutils_build() {
- local _args
-
- [ -f ${wrksrc}/.binutils_build_done ] && return 0
-
- cd ${wrksrc}
- msg_normal "Building cross binutils\n"
- [ ! -d binutils-build ] && mkdir binutils-build
- cd binutils-build
-
- _args="--prefix=/usr"
- _args+=" --target=${_triplet}"
- _args+=" --with-sysroot=${_sysroot}"
- _args+=" --disable-nls"
- _args+=" --disable-shared"
- _args+=" --disable-multilib"
- _args+=" --disable-werror"
- _args+=" --disable-gold"
- _args+=" --with-system-zlib"
- ../binutils-${_binutils_version}/configure ${_args}
-
- make configure-host && make ${makejobs}
- make install
-
- touch ${wrksrc}/.binutils_build_done
-}
-
-_gcc_bootstrap() {
- local _args
-
- [ -f ${wrksrc}/.gcc_bootstrap_done ] && return 0
-
- cd ${wrksrc}/gcc-${_gcc_version}
- for f in ${XBPS_SRCPKGDIR}/gcc/patches/*.patch; do
- _apply_patch -p0 "$f"
- done
-
- msg_normal "Building cross gcc bootstrap\n"
-
- [ ! -d ../gcc-bootstrap ] && mkdir ../gcc-bootstrap
- cd ../gcc-bootstrap
-
- _args="--prefix=/usr"
- _args+=" --target=${_triplet}"
- _args+=" --without-headers"
- _args+=" --disable-nls"
- _args+=" --disable-shared"
- _args+=" --disable-libquadmath"
- _args+=" --disable-decimal-float"
- _args+=" --disable-libgomp"
- _args+=" --disable-libmpx"
- _args+=" --disable-libmudflap"
- _args+=" --disable-libssp"
- _args+=" --disable-libitm"
- _args+=" --disable-libatomic"
- _args+=" --disable-threads"
- _args+=" --enable-languages=c"
- _args+=" --disable-sjlj-exceptions"
- _args+=" --disable-multilib"
- _args+=" --with-gnu-ld"
- _args+=" --with-gnu-as"
-
- ../gcc-${_gcc_version}/configure ${_args}
-
- make ${makejobs}
- make install
-
- touch ${wrksrc}/.gcc_bootstrap_done
-}
-
-_glibc_headers() {
- local _args f
-
- [ -f ${wrksrc}/.glibc_headers_done ] && return 0
-
- cd ${wrksrc}/glibc-${_glibc_version}
- if [ -d "${XBPS_SRCPKGDIR}/glibc/patches" ]; then
- for f in ${XBPS_SRCPKGDIR}/glibc/patches/*.patch; do
- _apply_patch -p1 "$f"
- done
- fi
-
- cd ${wrksrc}
- msg_normal "Building cross glibc headers\n"
-
- [ ! -d glibc-headers ] && mkdir glibc-headers
- cd glibc-headers
-
- echo "libc_cv_forced_unwind=yes" > config.cache
- echo "libc_cv_c_cleanup=yes" >> config.cache
-
- export CC="${_triplet}-gcc" LD="${_triplet}-ld" \
- AS="${_triplet}-as" CPP="${_triplet}-cpp" \
- NM="${_triplet}-nm"
-
- _args="--prefix=/usr"
- _args+=" --host=${_triplet}"
- _args+=" --with-headers=${_sysroot}/usr/include"
- _args+=" --config-cache"
- _args+=" --enable-obsolete-rpc"
- _args+=" --enable-obsolete-nsl"
- _args+=" --enable-kernel=2.6.27"
-
- ../glibc-${_glibc_version}/configure ${_args}
-
- make -k install-headers cross_compiling=yes \
- install_root=${_sysroot}
-
- touch ${wrksrc}/.glibc_headers_done
-}
-
-_glibc_build() {
- local _args
-
- [ -f ${wrksrc}/.glibc_build_done ] && return 0
-
- cd ${wrksrc}
- msg_normal "Building cross glibc\n"
-
- [ ! -d glibc-build ] && mkdir glibc-build
- cd glibc-build
-
- echo "slibdir=/usr/lib64" > configparms
-
- echo "libc_cv_forced_unwind=yes" > config.cache
- echo "libc_cv_c_cleanup=yes" >> config.cache
-
- export CC="${_triplet}-gcc" CXX="${_triplet}-g++" LD="${_triplet}-ld" \
- AS="${_triplet}-as" CPP="${_triplet}-cpp" \
- NM="${_triplet}-nm"
- export CFLAGS="-O1 -pipe ${_archflags}"
-
- _args="--prefix=/usr"
- _args+=" --libdir=/usr/lib64"
- _args+=" --host=${_triplet}"
- _args+=" --with-headers=${_sysroot}/usr/include"
- _args+=" --config-cache"
- _args+=" --enable-obsolete-rpc"
- _args+=" --enable-obsolete-nsl"
- _args+=" --disable-profile"
- _args+=" --enable-kernel=2.6.27"
- _args+=" --disable-werror"
-
- ../glibc-${_glibc_version}/configure ${_args}
-
- make ${makejobs}
- make install_root=${_sysroot} install
-
- touch ${wrksrc}/.glibc_build_done
-}
-
-_gcc_build() {
- local _args
-
- [ -f ${wrksrc}/.gcc_build_done ] && return 0
-
- cd ${wrksrc}
- msg_normal "Building cross gcc final\n"
-
- [ ! -d gcc-build ] && mkdir gcc-build
- cd gcc-build
-
- export CC="gcc" CXX="g++" CFLAGS="-Os -pipe"
- unset LD AS
-
- # Make this link to target libs.
- if [ ! -f .sed_subst_done ]; then
- sed -e "s, /lib/, ${_sysroot}/lib/,g;s, /usr/lib/, ${_sysroot}/usr/lib/,g" \
- -i ${_sysroot}/lib/libc.so
- sed -e "s, /lib64/, ${_sysroot}/lib64/,g;s, /usr/lib64/, ${_sysroot}/usr/lib64/,g" \
- -i ${_sysroot}/lib/libc.so
- touch .sed_subst_done
- fi
-
- _args="--prefix=/usr"
- _args+=" --libexecdir=/usr/lib"
- _args+=" --target=${_triplet}"
- _args+=" --with-sysroot=${_sysroot}"
- _args+=" --enable-languages=c,ada,c++,objc,obj-c++,go,fortran,lto"
- _args+=" --with-gnu-as"
- _args+=" --with-gnu-ld"
- _args+=" --disable-multilib"
- _args+=" --disable-nls"
- _args+=" --disable-sjlj-exceptions"
- _args+=" --enable-threads=posix"
- _args+=" --enable-long-longx"
- _args+=" --enable-shared"
- _args+=" --enable-linker-build-id"
- _args+=" --enable-gnu-unique-object"
- _args+=" --enable-libada"
- _args+=" --enable-lto"
- _args+=" --enable-default-pie"
- _args+=" --enable-default-ssp"
- _args+=" --disable-libquadmath"
- _args+=" --disable-libssp"
- _args+=" --disable-libmudflap"
- _args+=" --disable-libsanitizer"
- _args+=" --disable-libcilkrts"
- _args+=" --disable-libitm"
- _args+=" --disable-libvtv"
- _args+=" --disable-libstdcxx-pch"
- _args+=" --enable-libstdcxx-time"
- _args+=" --with-linker-hash-style=gnu"
-
- ../gcc-${_gcc_version}/configure ${_args}
-
- make ${makejobs}
-
- touch ${wrksrc}/.gcc_build_done
-}
-
-do_build() {
- unset LDFLAGS
- export CFLAGS="-Os" CXXFLAGS="-Os"
-
- for f in include lib libexec bin sbin; do
- if [ ! -d ${_sysroot}/usr/${f} ]; then
- mkdir -p ${_sysroot}/usr/${f}
- fi
- if [ ! -h ${_sysroot}/${f} ]; then
- ln -sfr ${_sysroot}/usr/${f} ${_sysroot}/${f}
- fi
- done
- ln -sf lib ${_sysroot}/usr/lib64
- ln -sf usr/lib ${_sysroot}/lib64
-
- _binutils_build
- _gcc_bootstrap
- _linux_headers
- _glibc_headers
- _glibc_build
- _gcc_build
-}
-
-do_install() {
- for f in include lib libexec bin sbin; do
- if [ ! -d ${DESTDIR}/${_sysroot}/usr/${f} ]; then
- mkdir -p ${DESTDIR}/${_sysroot}/usr/${f}
- fi
- if [ ! -h ${DESTDIR}/${_sysroot}/${f} ]; then
- ln -sfr ${DESTDIR}/${_sysroot}/usr/${f} \
- ${DESTDIR}/${_sysroot}/${f}
- fi
- done
- ln -sf lib ${DESTDIR}/${_sysroot}/usr/lib64
- ln -sf usr/lib ${DESTDIR}/${_sysroot}/lib64
-
- # install cross binutils
- cd ${wrksrc}/binutils-build
- make DESTDIR=${DESTDIR} install
-
- # install cross gcc
- cd ${wrksrc}/gcc-build
- make DESTDIR=${DESTDIR} install
-
- # move libcc1.so* to the sysroot
- mv ${DESTDIR}/usr/lib/libcc1.so* ${DESTDIR}/${_sysroot}/usr/lib
-
- # install linux API headers for ARM64
- cd ${wrksrc}/linux-${_linux_version}
- make ARCH=arm64 INSTALL_HDR_PATH=${DESTDIR}/${_sysroot}/usr headers_install
- rm -f $(find ${DESTDIR}/${_sysroot}/usr/include -name .install -or -name ..install.cmd)
- rm -rf ${DESTDIR}/${_sysroot}/usr/include/drm
-
- # install glibc for target
- cd ${wrksrc}/glibc-build
- make install_root=${DESTDIR}/${_sysroot} install install-headers
-
- # symlinks for gnarl and gnat shared libraries
- _majorver=${_gcc_version%.*.*}
- _adalib=usr/lib/gcc/${_triplet}/${_gcc_version}/adalib
- mv -v ${DESTDIR}/${_adalib}/libgnarl-${_majorver}.so ${DESTDIR}/${_sysroot}/usr/lib
- mv -v ${DESTDIR}/${_adalib}/libgnat-${_majorver}.so ${DESTDIR}/${_sysroot}/usr/lib
- ln -svf libgnarl-${_majorver}.so libgnarl.so
- ln -svf libgnat-${_majorver}.so libgnat.so
- rm -vf ${DESTDIR}/${_adalib}/libgna{rl,t}.so
-
- # We need to build libatomic in target gcc as gccgo needs it to
- # build... but it's not needed at runtime, so remove it from the
- # destdir so it doesn't conflict with the libatomic package
- rm -f ${DESTDIR}/${_sysroot}/usr/lib/libatomic.*
-
- # Remove unnecessary stuff
- rm -f ${DESTDIR}/usr/lib*/libiberty.a
- rm -rf ${DESTDIR}/usr/share
- rm -rf ${DESTDIR}/${_sysroot}/{sbin,etc,var}
- rm -rf ${DESTDIR}/${_sysroot}/usr/{sbin,share,libexec}
- rm -f ${DESTDIR}/${_sysroot}/libexec
-}
-
-do_clean() {
- # Remove temporary stuff from masterdir
- rm -rf ${_sysroot}
- rm -f /usr/bin/${_triplet}*
- rm -rf /usr/lib/gcc/${_triplet}
- rm -rf /usr/libexec/gcc/${_triplet}
-}
-
cross-aarch64-linux-gnu-libc_package() {
short_desc+=" - glibc files"
nostrip=yes
@@ -376,6 +50,6 @@ cross-aarch64-linux-gnu-libc_package() {
noverifyrdeps=yes
pkg_install() {
- vmove ${_sysroot}
+ vmove usr/${cross_triplet}
}
}
next reply other threads:[~2020-12-24 23:54 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-24 23:54 q66 [this message]
2020-12-25 13:49 ` [PR REVIEW] " pullmoll
2020-12-25 13:49 ` pullmoll
2020-12-25 13:51 ` pullmoll
2020-12-25 14:04 ` q66
2020-12-25 14:36 ` sgn
2020-12-25 14:36 ` sgn
2020-12-25 15:41 ` q66
2020-12-25 15:42 ` q66
2020-12-25 15:50 ` [PR PATCH] [Updated] " q66
2020-12-25 15:51 ` q66
2020-12-25 16:46 ` [PR PATCH] [Updated] " q66
2020-12-25 17:10 ` [PR REVIEW] " q66
2020-12-25 17:11 ` [PR PATCH] [Updated] " q66
2020-12-25 17:25 ` q66
2020-12-25 19:10 ` pullmoll
2020-12-25 19:11 ` pullmoll
2020-12-25 19:12 ` [PR PATCH] [Updated] " q66
2020-12-25 19:15 ` q66
2020-12-25 19:16 ` q66
2020-12-25 19:16 ` pullmoll
2020-12-25 19:18 ` pullmoll
2020-12-25 19:20 ` q66
2020-12-25 19:21 ` q66
2020-12-25 19:22 ` q66
2020-12-25 19:24 ` pullmoll
2020-12-25 19:25 ` pullmoll
2020-12-25 19:28 ` q66
2020-12-25 20:32 ` [PR PATCH] [Updated] " q66
2020-12-25 20:39 ` q66
2020-12-25 23:14 ` q66
2020-12-25 23:29 ` [PR REVIEW] " ericonr
2020-12-25 23:29 ` ericonr
2020-12-26 0:13 ` [PR PATCH] [Updated] " q66
2020-12-26 1:22 ` q66
2020-12-26 18:17 ` q66
2020-12-27 4:27 ` q66
2020-12-27 4:30 ` q66
2020-12-27 4:50 ` [PR PATCH] [Updated] " q66
2020-12-27 13:01 ` [PR REVIEW] " pullmoll
2020-12-27 17:13 ` [PR PATCH] [Updated] " q66
2020-12-28 12:53 ` [PR REVIEW] " pullmoll
2020-12-28 12:54 ` pullmoll
2020-12-28 12:56 ` pullmoll
2020-12-28 13:46 ` [PR PATCH] [Updated] " q66
2020-12-28 13:47 ` q66
2020-12-28 13:53 ` [PR PATCH] [Updated] " q66
2020-12-28 14:09 ` [PR REVIEW] " sgn
2020-12-28 14:22 ` sgn
2020-12-28 14:24 ` sgn
2020-12-28 14:26 ` sgn
2020-12-28 19:01 ` pullmoll
2020-12-28 19:43 ` pullmoll
2020-12-28 20:05 ` pullmoll
2020-12-28 20:18 ` pullmoll
2020-12-28 20:24 ` pullmoll
2020-12-28 20:48 ` ericonr
2020-12-29 11:20 ` pullmoll
2020-12-29 11:22 ` pullmoll
2020-12-29 22:10 ` pullmoll
2020-12-29 22:48 ` q66
2020-12-29 23:24 ` pullmoll
2020-12-29 23:26 ` [PR PATCH] [Updated] " q66
2020-12-29 23:29 ` q66
2020-12-29 23:42 ` [PR PATCH] [Updated] " q66
2020-12-29 23:44 ` q66
2020-12-31 0:35 ` fosslinux
2020-12-31 22:48 ` [PR PATCH] [Merged]: " q66
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-27412@inbox.vuxu.org \
--to=q66@users.noreply.github.com \
--cc=ml@inbox.vuxu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).