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.
This commit is contained in:
2026-08-03 19:15:20 +03:00
parent f4363142b1
commit d9b408d7de
+8
View File
@@ -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/}"