From 16f611232701d6d370210e6af3a3dac8fafaee5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Nohlg=C3=A5rd?= Date: Thu, 1 Dec 2022 09:47:43 +0100 Subject: [PATCH] scripts/gcc: Add extra include dir with -idirafter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes Canadian cross builds failing with missing include file 'stdio.h' when building libstdc++ for a companion libc with system libc set to LIBC_NONE. Signed-off-by: Joakim NohlgÄrd --- scripts/build/cc/gcc.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/scripts/build/cc/gcc.sh b/scripts/build/cc/gcc.sh index 8cf03cbd..1d7fc065 100644 --- a/scripts/build/cc/gcc.sh +++ b/scripts/build/cc/gcc.sh @@ -295,7 +295,6 @@ do_gcc_core_backend() { exec_prefix="${CT_PREFIX_DIR}/${libstdcxx_name}" fi extra_config+=( "${CT_CC_SYSROOT_ARG[@]}" ) - extra_config+=( "--with-headers=${header_dir}" ) extra_user_config=( "${CT_CC_GCC_EXTRA_CONFIG_ARRAY[@]}" ) log_txt="libstdc++ ${libstdcxx_name} library" # to inhibit the libiberty and libgcc tricks later on @@ -554,6 +553,13 @@ do_gcc_core_backend() { fi fi + # Add an extra system include dir if we have one. This is especially useful + # when building libstdc++ with a libc other than the system libc (e.g. + # picolibc) + if [ -n "${header_dir}" ]; then + cflags_for_target="${cflags_for_target} -idirafter ${header_dir}" + fi + # For non-sysrooted toolchain, GCC doesn't search except at the installation # prefix; in core stage we use a temporary installation prefix - but # we may have installed something into the final prefix. This is less than ideal: @@ -1200,6 +1206,13 @@ do_gcc_backend() { fi fi + # Add an extra system include dir if we have one. This is especially useful + # when building libstdc++ with a libc other than the system libc (e.g. + # picolibc) + if [ -n "${header_dir}" ]; then + cflags_for_target="${cflags_for_target} -idirafter ${header_dir}" + fi + # Assume '-O2' by default for building target libraries. cflags_for_target="-g -O2 ${cflags_for_target}"