From a555d8112132f9b5ea8f3210433a5281828cfd46 Mon Sep 17 00:00:00 2001 From: Andre Heider Date: Mon, 24 Feb 2025 20:55:30 +0100 Subject: [PATCH 1/2] use a distinct sysroot per toolchain Using one for all yields all sorts of issues: build/gcc-aarch64-14.2.0/.x86_64-linux-gnu/./gcc/xgcc -Bbuild/gcc-aarch64-14.2.0/.x86_64-linux-gnu/./gcc/ -Btoolchain/aarch64-none-elf/bin/ -Btoolchain/aarch64-none-elf/lib/ -isystem toolchain/aarch64-none-elf/include -isystem toolchain/aarch64-none-elf/sys-include -g -O2 -O2 -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector -Dinhibit_libc -I. -I. -I../.././gcc -Ibuild/gcc-aarch64-14.2.0/libgcc -Ibuild/gcc-aarch64-14.2.0/libgcc/. -Ibuild/gcc-aarch64-14.2.0/libgcc/../gcc -Ibuild/gcc-aarch64-14.2.0/libgcc/../include -DHAVE_CC_TLS -o cpuinfo.o -MT cpuinfo.o -MD -MP -MF cpuinfo.dep -c build/gcc-aarch64-14.2.0/libgcc/config/aarch64/cpuinfo.c -fvisibility=hidden -DHIDE_EXPORTS In file included from toolchain/armv8a-libreelec-linux-gnueabihf/sysroot/usr/include/features.h:548, from toolchain/armv8a-libreelec-linux-gnueabihf/sysroot/usr/include/bits/libc-header-start.h:33, from toolchain/armv8a-libreelec-linux-gnueabihf/sysroot/usr/include/stdint.h:26, from build/gcc-aarch64-14.2.0/.x86_64-linux-gnu/gcc/include/stdint.h:9, from toolchain/armv8a-libreelec-linux-gnueabihf/sysroot/usr/include/elf.h:24, from toolchain/armv8a-libreelec-linux-gnueabihf/sysroot/usr/include/sys/auxv.h:22, from build/gcc-aarch64-14.2.0/libgcc/config/aarch64/cpuinfo.c:28: toolchain/armv8a-libreelec-linux-gnueabihf/sysroot/usr/include/gnu/stubs.h:7:11: fatal error: gnu/stubs-soft.h: No such file or directory 7 | # include | ^~~~~~~~~~~~~~~~~~ compilation terminated. Notice the mix of paths from two architectures. Additionally the armv8a fpu config leaks into aarch64. --- packages/devel/binutils-aarch64/package.mk | 7 +------ packages/devel/binutils-arm-none-eabi/package.mk | 6 +----- packages/devel/binutils-bpf/package.mk | 6 +----- packages/devel/binutils-or1k/package.mk | 5 +---- packages/lang/gcc-aarch64/package.mk | 9 ++++++++- packages/lang/gcc-arm-none-eabi/package.mk | 9 ++++++++- packages/lang/gcc-bpf/package.mk | 9 ++++++++- packages/lang/gcc-or1k/package.mk | 9 ++++++++- 8 files changed, 36 insertions(+), 24 deletions(-) diff --git a/packages/devel/binutils-aarch64/package.mk b/packages/devel/binutils-aarch64/package.mk index 6dc677e0dd..3c11c28f22 100644 --- a/packages/devel/binutils-aarch64/package.mk +++ b/packages/devel/binutils-aarch64/package.mk @@ -12,8 +12,7 @@ PKG_DEPENDS_UNPACK+=" binutils" PKG_PATCH_DIRS+=" $(get_pkg_directory binutils)/patches" PKG_CONFIGURE_OPTS_HOST="--target=aarch64-none-elf \ - --with-sysroot=${SYSROOT_PREFIX} \ - --with-lib-path=${SYSROOT_PREFIX}/lib:${SYSROOT_PREFIX}/usr/lib \ + --with-sysroot=${TOOLCHAIN}/aarch64-none-elf/sysroot \ --without-ppl \ --enable-static \ --without-cloog \ @@ -47,9 +46,5 @@ make_host() { } makeinstall_host() { - cp -v ../include/libiberty.h ${SYSROOT_PREFIX}/usr/include - make -C libsframe install # bfd is reliant on libsframe - make -C bfd install # fix parallel build with libctf requiring bfd - # override the makeinfo binary with true - this does not build the documentation make MAKEINFO=true install } diff --git a/packages/devel/binutils-arm-none-eabi/package.mk b/packages/devel/binutils-arm-none-eabi/package.mk index e2d7af56d8..9242ef8847 100644 --- a/packages/devel/binutils-arm-none-eabi/package.mk +++ b/packages/devel/binutils-arm-none-eabi/package.mk @@ -12,8 +12,7 @@ PKG_DEPENDS_UNPACK+=" binutils" PKG_PATCH_DIRS+=" $(get_pkg_directory binutils)/patches" PKG_CONFIGURE_OPTS_HOST="--target=arm-none-eabi \ - --with-sysroot=${SYSROOT_PREFIX} \ - --with-lib-path=${SYSROOT_PREFIX}/lib:${SYSROOT_PREFIX}/usr/lib \ + --with-sysroot=${TOOLCHAIN}/arm-none-eabi/sysroot \ --without-ppl \ --enable-static \ --without-cloog \ @@ -47,9 +46,6 @@ make_host() { } makeinstall_host() { - cp -v ../include/libiberty.h ${SYSROOT_PREFIX}/usr/include - make -C libsframe install # bfd is reliant on libsframe - make -C bfd install # fix parallel build with libctf requiring bfd # override the makeinfo binary with true - this does not build the documentation make MAKEINFO=true install } diff --git a/packages/devel/binutils-bpf/package.mk b/packages/devel/binutils-bpf/package.mk index 9b970370ea..a607f5e771 100644 --- a/packages/devel/binutils-bpf/package.mk +++ b/packages/devel/binutils-bpf/package.mk @@ -12,8 +12,7 @@ PKG_DEPENDS_UNPACK+=" binutils" PKG_PATCH_DIRS+=" $(get_pkg_directory binutils)/patches" PKG_CONFIGURE_OPTS_HOST="--target=bpf \ - --with-sysroot=${SYSROOT_PREFIX} \ - --with-lib-path=${SYSROOT_PREFIX}/lib:${SYSROOT_PREFIX}/usr/lib \ + --with-sysroot=${TOOLCHAIN}/bpf/sysroot \ --without-ppl \ --enable-static \ --without-cloog \ @@ -47,9 +46,6 @@ make_host() { } makeinstall_host() { - cp -v ../include/libiberty.h ${SYSROOT_PREFIX}/usr/include - make -C libsframe install # bfd is reliant on libsframe - make -C bfd install # fix parallel build with libctf requiring bfd # override the makeinfo binary with true - this does not build the documentation make MAKEINFO=true install } diff --git a/packages/devel/binutils-or1k/package.mk b/packages/devel/binutils-or1k/package.mk index c5e0e17391..1ba2357131 100644 --- a/packages/devel/binutils-or1k/package.mk +++ b/packages/devel/binutils-or1k/package.mk @@ -12,8 +12,7 @@ PKG_DEPENDS_UNPACK+=" binutils" PKG_PATCH_DIRS+=" $(get_pkg_directory binutils)/patches" PKG_CONFIGURE_OPTS_HOST="--target=or1k-none-elf \ - --with-sysroot=${SYSROOT_PREFIX} \ - --with-lib-path=${SYSROOT_PREFIX}/lib:${SYSROOT_PREFIX}/usr/lib \ + --with-sysroot=${TOOLCHAIN}/or1k-none-elf/sysroot \ --without-ppl \ --enable-static \ --without-cloog \ @@ -47,8 +46,6 @@ make_host() { } makeinstall_host() { - cp -v ../include/libiberty.h ${SYSROOT_PREFIX}/usr/include - make -C bfd install # fix parallel build with libctf requiring bfd # override the makeinfo binary with true - this does not build the documentation make MAKEINFO=true install } diff --git a/packages/lang/gcc-aarch64/package.mk b/packages/lang/gcc-aarch64/package.mk index f439aad402..e59f6ec993 100644 --- a/packages/lang/gcc-aarch64/package.mk +++ b/packages/lang/gcc-aarch64/package.mk @@ -16,7 +16,7 @@ if [ "${MOLD_SUPPORT}" = "yes" ]; then fi PKG_CONFIGURE_OPTS_HOST="--target=aarch64-none-elf \ - --with-sysroot=${SYSROOT_PREFIX} \ + --with-sysroot=${TOOLCHAIN}/aarch64-none-elf/sysroot \ --with-gmp=${TOOLCHAIN} \ --with-mpfr=${TOOLCHAIN} \ --with-mpc=${TOOLCHAIN} \ @@ -57,6 +57,13 @@ unpack() { tar --strip-components=1 -xf ${SOURCES}/gcc/gcc-${PKG_VERSION}.tar.xz -C ${PKG_BUILD} } +pre_configure_host() { + unset CPPFLAGS + unset CFLAGS + unset CXXFLAGS + unset LDFLAGS +} + post_makeinstall_host() { PKG_GCC_PREFIX="${TOOLCHAIN}/bin/aarch64-none-elf-" GCC_VERSION=$(${PKG_GCC_PREFIX}gcc -dumpversion) diff --git a/packages/lang/gcc-arm-none-eabi/package.mk b/packages/lang/gcc-arm-none-eabi/package.mk index 5fb2868cc5..aad5f341b5 100644 --- a/packages/lang/gcc-arm-none-eabi/package.mk +++ b/packages/lang/gcc-arm-none-eabi/package.mk @@ -16,7 +16,7 @@ if [ "${MOLD_SUPPORT}" = "yes" ]; then fi PKG_CONFIGURE_OPTS_HOST="--target=arm-none-eabi \ - --with-sysroot=${SYSROOT_PREFIX} \ + --with-sysroot=${TOOLCHAIN}/arm-none-eabi/sysroot \ --with-gmp=${TOOLCHAIN} \ --with-mpfr=${TOOLCHAIN} \ --with-mpc=${TOOLCHAIN} \ @@ -56,6 +56,13 @@ unpack() { tar --strip-components=1 -xf ${SOURCES}/gcc/gcc-${PKG_VERSION}.tar.xz -C ${PKG_BUILD} } +pre_configure_host() { + unset CPPFLAGS + unset CFLAGS + unset CXXFLAGS + unset LDFLAGS +} + post_makeinstall_host() { PKG_GCC_PREFIX="${TOOLCHAIN}/bin/arm-none-eabi-" GCC_VERSION=$(${PKG_GCC_PREFIX}gcc -dumpversion) diff --git a/packages/lang/gcc-bpf/package.mk b/packages/lang/gcc-bpf/package.mk index 875a4706fc..e479eebeab 100644 --- a/packages/lang/gcc-bpf/package.mk +++ b/packages/lang/gcc-bpf/package.mk @@ -16,7 +16,7 @@ if [ "${MOLD_SUPPORT}" = "yes" ]; then fi PKG_CONFIGURE_OPTS_HOST="--target=bpf \ - --with-sysroot=${SYSROOT_PREFIX} \ + --with-sysroot=${TOOLCHAIN}/bpf/sysroot \ --with-gmp=${TOOLCHAIN} \ --with-mpfr=${TOOLCHAIN} \ --with-mpc=${TOOLCHAIN} \ @@ -56,3 +56,10 @@ unpack() { mkdir -p ${PKG_BUILD} tar --strip-components=1 -xf ${SOURCES}/gcc/gcc-${PKG_VERSION}.tar.xz -C ${PKG_BUILD} } + +pre_configure_host() { + unset CPPFLAGS + unset CFLAGS + unset CXXFLAGS + unset LDFLAGS +} diff --git a/packages/lang/gcc-or1k/package.mk b/packages/lang/gcc-or1k/package.mk index 0730a4c8bb..83213edb47 100644 --- a/packages/lang/gcc-or1k/package.mk +++ b/packages/lang/gcc-or1k/package.mk @@ -16,7 +16,7 @@ if [ "${MOLD_SUPPORT}" = "yes" ]; then fi PKG_CONFIGURE_OPTS_HOST="--target=or1k-none-elf \ - --with-sysroot=${SYSROOT_PREFIX} \ + --with-sysroot=${TOOLCHAIN}/or1k-none-elf/sysroot \ --with-gmp=${TOOLCHAIN} \ --with-mpfr=${TOOLCHAIN} \ --with-mpc=${TOOLCHAIN} \ @@ -57,6 +57,13 @@ unpack() { tar --strip-components=1 -xf ${SOURCES}/gcc/gcc-${PKG_VERSION}.tar.xz -C ${PKG_BUILD} } +pre_configure_host() { + unset CPPFLAGS + unset CFLAGS + unset CXXFLAGS + unset LDFLAGS +} + post_makeinstall_host() { PKG_GCC_PREFIX="${TOOLCHAIN}/bin/or1k-none-elf-" GCC_VERSION=$(${PKG_GCC_PREFIX}gcc -dumpversion) From 0d53201a5c3907059241600196121d90f91b4d96 Mon Sep 17 00:00:00 2001 From: Andre Heider Date: Mon, 24 Feb 2025 20:58:12 +0100 Subject: [PATCH 2/2] atf: fix build This is a target package, and as such config/functions set all sorts of "target compiler" options, but atf needs to be build with the "kernel compiler", e.g. aarch64 and not armv8a. So unset all the wrong envvars from the wrong toolchain to not confuse the atf build system. --- packages/tools/atf/package.mk | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/tools/atf/package.mk b/packages/tools/atf/package.mk index 213b04c097..293ab2fcaa 100644 --- a/packages/tools/atf/package.mk +++ b/packages/tools/atf/package.mk @@ -21,12 +21,13 @@ fi make_target() { # As of atf 2.11.0 - the supported compile for .S is gcc (not as.) - unset AS + unset AR AS CC CPP CXX LD NM OBJCOPY OBJDUMP STRIP RANLIB + unset CPPFLAGS CFLAGS CXXFLAGS LDFLAGS if [ "${ATF_PLATFORM}" = "imx8mq" ]; then - CROSS_COMPILE="${TARGET_KERNEL_PREFIX}" LDFLAGS="" CFLAGS="" make PLAT=${ATF_PLATFORM} LOG_LEVEL=0 bl31 + CROSS_COMPILE="${TARGET_KERNEL_PREFIX}" make PLAT=${ATF_PLATFORM} LOG_LEVEL=0 bl31 else # as of atf 2.12.0 - sun50i_a64 builds use LTO, include -ffat-lto-objects to support this - CROSS_COMPILE="${TARGET_KERNEL_PREFIX}" LDFLAGS="" CFLAGS="-ffat-lto-objects" make PLAT=${ATF_PLATFORM} bl31 + CROSS_COMPILE="${TARGET_KERNEL_PREFIX}" CFLAGS="-ffat-lto-objects" make PLAT=${ATF_PLATFORM} bl31 fi }