diff mbox series

[20/21] syslinux: Use -idirafter to add back path for system stdarg.h

Message ID 20250324-b4-musl-gcc15-v1-20-ca68c03c5b01@gmail.com
State Accepted, archived
Commit 40413233429ceb902d8eb30ccc56aa7a182db772
Headers show
Series musl/gcc-15: Fix packages to build with gcc15 on musl platforms | expand

Commit Message

Khem Raj March 24, 2025, 4:33 p.m. UTC
syslinux uses -nostdinc to build freestanding, which makes sense, however
it also tried to latch its own copy of stdarg.h to include system stdarg.h
via "include_next" compiler magic, so it poses to provide own stdarg.h but
then secretly include system version behind the scenes :)

It uses -nostdinc -iwithprefix include

hoping that gcc is uses and gcc has its include-fixed abstraction which
also contains stdarg.h so in the end it will find a version of stdarg.h
from system (even though it is from the compiler install ) and things will
work.

On musl, include-fixed is not expected and system includes are simplified
so that everyone can look into <sysroot>/usr/include to find them. This
can throw syslinux compilation into problems as now it does not find
the header from -iprefix and ends up with errors like

/mnt/b/yoe/master/sources/poky/build/tmp/work/core2-32-poky-linux-musl/syslinux/6.04-pre2/syslinux-6.04-pre2/com32/lib/../include/stdarg.h:9:15: fatal error: stdarg.h: No such file or directory
    9 | #include_next <stdarg.h>
      |               ^~~~~~~~~~
compilation terminated.

Therefore, we use -idirafter to point it into target sysroot as fallback
for system headers if it needs them, its added at the very last in search
order. It also keeps working with glibc based toolchains as usual and
also works with musl toolchains.

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 meta/recipes-devtools/syslinux/syslinux_6.04-pre2.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/meta/recipes-devtools/syslinux/syslinux_6.04-pre2.bb b/meta/recipes-devtools/syslinux/syslinux_6.04-pre2.bb
index fa7054bc54ffdc5d7249cc7904b7458695b3c4bb..7cf737170c3656a26f2d3f52ee15671c03558b1c 100644
--- a/meta/recipes-devtools/syslinux/syslinux_6.04-pre2.bb
+++ b/meta/recipes-devtools/syslinux/syslinux_6.04-pre2.bb
@@ -49,7 +49,7 @@  TARGET_LDFLAGS = ""
 SECURITY_LDFLAGS = ""
 LDFLAGS_SECTION_REMOVAL = ""
 
-CFLAGS += "-DNO_INLINE_FUNCS -Wno-error=implicit-function-declaration"
+CFLAGS += "-DNO_INLINE_FUNCS -Wno-error=implicit-function-declaration -idirafter ${STAGING_INCDIR}"
 
 EXTRA_OEMAKE = " \
 	BINDIR=${bindir} SBINDIR=${sbindir} LIBDIR=${libdir} \