diff mbox series

gcc: fix local include path for nativesdk-gcc

Message ID 20250910113802.1331526-1-gregor.herburger@ew.tq-group.com
State New
Headers show
Series gcc: fix local include path for nativesdk-gcc | expand

Commit Message

Gregor Herburger Sept. 10, 2025, 11:38 a.m. UTC
By default GCC uses /usr/local/include as the local include prefix.
When building the nativesdk-gcc package, this makes gcc look in the
hosts /usr/local/include and may use non-SDK headers.

Example from current poky:
$# x86_64-pokysdk-linux-gcc -v -E - </dev/null
 #include <...> search starts here:
  /opt/poky/5.2.99+snapshot/sysroots/x86_64-pokysdk-linux/usr/lib/gcc/x86_64-pokysdk-linux/15.2.0/include
  /usr/local/include
  /opt/poky/5.2.99+snapshot/sysroots/x86_64-pokysdk-linux/usr/include
  /opt/poky/5.2.99+snapshot/sysroots/x86_64-pokysdk-linux/usr/lib/gcc/x86_64-pokysdk-linux/15.2.0/include-fixed

Define LOCAL_INCLUDE_DIR along with the other include directories in
defaults.h to set the local include directory to the directory in the
sysroot.

Signed-off-by: Gregor Herburger <gregor.herburger@ew.tq-group.com>
---
 meta/recipes-devtools/gcc/gcc-configure-common.inc | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/meta/recipes-devtools/gcc/gcc-configure-common.inc b/meta/recipes-devtools/gcc/gcc-configure-common.inc
index 50ff0d2e820a..f152ae55555d 100644
--- a/meta/recipes-devtools/gcc/gcc-configure-common.inc
+++ b/meta/recipes-devtools/gcc/gcc-configure-common.inc
@@ -72,6 +72,7 @@  CPPFLAGS = ""
 SYSTEMHEADERS = "${target_includedir}"
 SYSTEMLIBS = "${target_base_libdir}/"
 SYSTEMLIBS1 = "${target_libdir}/"
+SYSTEMLOCALHEADERS = "${target_prefix}/local/include"
 
 do_configure:prepend () {
 	# teach gcc to find correct target includedir when checking libc ssp support
@@ -83,6 +84,7 @@  do_configure:prepend () {
 #define STANDARD_STARTFILE_PREFIX_1 "${SYSTEMLIBS}"
 #define STANDARD_STARTFILE_PREFIX_2 "${SYSTEMLIBS1}"
 #define SYSTEMLIBS_DIR "${SYSTEMLIBS}"
+#define LOCAL_INCLUDE_DIR "${SYSTEMLOCALHEADERS}"
 #endif /* ! GCC_DEFAULTS_H */
 _EOF
 	mv ${B}/gcc/defaults.h.new ${B}/gcc/defaults.h