From d9b408d7de252d0252de7e469141adc09bbbeda4 Mon Sep 17 00:00:00 2001 From: vasilito Date: Mon, 3 Aug 2026 19:15:20 +0300 Subject: [PATCH] gcc-native: put GCC's own include/ ahead of the sysroot for getopt.h libiberty compiles getopt1.c against GCC's include/getopt.h, which declares the GNU-internal _getopt_internal. relibc ships a getopt.h that does not declare it and was shadowing GCC's: getopt1.c:71: error: implicit declaration of function '_getopt_internal' Same shape as the cpuid.h shadowing already handled in recipes/dev/gcc13. Verified: _getopt_internal errors 5 -> 0. STILL FAILING, on a new and different phase: the HOST libstdc++ headers are being pulled into the build -- /usr/include/c++/16/x86_64-pc-linux-gnu/bits/os_defines.h:44: error: missing binary operator before token '(' which is __GLIBC_PREREQ evaluated where there is no glibc. That is a host/target header leak, not a continuation of the getopt problem, and it is unrelated to this commit's change. --- local/recipes/dev/gcc-native/recipe.toml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/local/recipes/dev/gcc-native/recipe.toml b/local/recipes/dev/gcc-native/recipe.toml index b0f46cb8db..0a58d035ca 100644 --- a/local/recipes/dev/gcc-native/recipe.toml +++ b/local/recipes/dev/gcc-native/recipe.toml @@ -50,6 +50,14 @@ DYNAMIC_INIT # gcc/config/i386/i386.h:1722: error: unknown type name 'bool' # Drop the pin for this recipe so the compiler builds at the standard its own # sources are written in. +# GCC's own include/ must precede the sysroot. libiberty compiles getopt1.c +# against GCC's include/getopt.h, which declares the GNU-internal +# _getopt_internal; relibc ships a getopt.h that does not, and it otherwise +# shadows GCC's: +# getopt1.c:71: error: implicit declaration of function '_getopt_internal' +# Same shape as the cpuid.h shadowing in recipes/dev/gcc13. +export CPPFLAGS="-I${COOKBOOK_SOURCE}/include ${CPPFLAGS}" + export CFLAGS="${CFLAGS//-std=gnu17/}" export CXXFLAGS="${CXXFLAGS//-std=gnu17/}"