scripts/gcc: Add extra include dir with -idirafter

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 <joakim@nohlgard.se>
This commit is contained in:
Joakim Nohlgård 2022-12-01 09:47:43 +01:00 committed by Chris Packham
parent e04351d666
commit 16f6112327

View File

@ -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}"