From c64500d94be92ed1bcdfdef911048a14e216a5e1 Mon Sep 17 00:00:00 2001 From: Dimitar Dimitrov Date: Sat, 9 Mar 2024 12:14:46 +0200 Subject: gnuprumcu: Pass host sysroot to build toolchain In canadian builds, the target toolchain running on the build machine is not compiling and installing target Newlib. Thus it cannot by itself link target executables. This results in errors for gnuprumcu package when its configure script attempts to test the compiler: .../ld: cannot find crt0.o: No such file or directory configure:3738: error: C compiler cannot create executables Fix by passing the host toolchains's sysroot in target CFLAGS. While at it, also add a missing passing of target LDFLAGS. Successfully tested the following canadian builds: x86_64-unknown-linux-gnu,pru x86_64-w64-mingw32,pru arm-unknown-linux-gnueabihf,pru Signed-off-by: Dimitar Dimitrov --- scripts/build/companion_libs/400-gnuprumcu.sh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/build/companion_libs/400-gnuprumcu.sh b/scripts/build/companion_libs/400-gnuprumcu.sh index bba85748..7d17853c 100644 --- a/scripts/build/companion_libs/400-gnuprumcu.sh +++ b/scripts/build/companion_libs/400-gnuprumcu.sh @@ -19,6 +19,22 @@ do_gnuprumcu_extract() { do_gnuprumcu_for_target() { local -a gnuprumcu_opts + local -a cflags + + cflags=${CT_ALL_TARGET_CFLAGS} + + # When building a canadian, newlib is installed + # only in the host' sysroot. Thus the build toolchain + # lacks CRT0 and LibC objects. Consequently the + # gnuprumcu configure script fails with: + # .../ld: cannot find crt0.o: No such file or directory + # configure:3738: error: C compiler cannot create executables + # + # Fix by pointing the build toolchain to the host sysroot, + # where the necessary target runtime files are available. + case "${CT_TOOLCHAIN_TYPE}" in + canadian) cflags="${cflags} --sysroot=${CT_SYSROOT_DIR}";; + esac CT_DoStep INFO "Installing gnuprumcu for the target" CT_mkdir_pushd "${CT_BUILD_DIR}/build-gnuprumcu-target-${CT_TARGET}" @@ -26,7 +42,8 @@ do_gnuprumcu_for_target() { gnuprumcu_opts+=( "destdir=${CT_SYSROOT_DIR}" ) gnuprumcu_opts+=( "host=${CT_TARGET}" ) - gnuprumcu_opts+=( "cflags=${CT_ALL_TARGET_CFLAGS}" ) + gnuprumcu_opts+=( "cflags=${cflags}" ) + gnuprumcu_opts+=( "ldflags=${CT_ALL_TARGET_LDFLAGS}" ) gnuprumcu_opts+=( "prefix=${CT_PREFIX_DIR}" ) do_gnuprumcu_backend "${gnuprumcu_opts[@]}" -- cgit v1.2.3