Message ID | 20240606071005.884909-1-raj.khem@gmail.com |
---|---|
State | New |
Headers | show |
Series | gcc: Fix wrong order of gcc include paths on musl systems | expand |
On Thu, 2024-06-06 at 00:10 -0700, Khem Raj via lists.openembedded.org wrote: > musl does not use gcc private system headers, however, the path gets > prepended since gcc driver passes -iprefix option to cc1 based on its > installation location. This starts to prefer these headers instead of > musl provided equivalent system headers which is not as per musl's > design. This patch switches prepend to append for musl systems. > > Signed-off-by: Khem Raj <raj.khem@gmail.com> > --- > meta/recipes-devtools/gcc/gcc-14.1.inc | 1 + > ...te-include-paths-on-musl-instead-of-.patch | 35 +++++++++++++++++++ > 2 files changed, 36 insertions(+) > create mode 100644 meta/recipes-devtools/gcc/gcc/0026-Append-GCC-private-include-paths-on-musl-instead-of-.patch > > diff --git a/meta/recipes-devtools/gcc/gcc-14.1.inc b/meta/recipes-devtools/gcc/gcc-14.1.inc > index b057e570f3b..c4bc4c72664 100644 > --- a/meta/recipes-devtools/gcc/gcc-14.1.inc > +++ b/meta/recipes-devtools/gcc/gcc-14.1.inc > @@ -68,6 +68,7 @@ SRC_URI = "${BASEURI} \ > file://0023-Fix-install-path-of-linux64.h.patch \ > file://0024-Avoid-hardcoded-build-paths-into-ppc-libgcc.patch \ > file://0025-gcc-testsuite-tweaks-for-mips-OE.patch \ > + file://0026-Append-GCC-private-include-paths-on-musl-instead-of-.patch \ > " > > S = "${TMPDIR}/work-shared/gcc-${PV}-${PR}/${SOURCEDIR}" > diff --git a/meta/recipes-devtools/gcc/gcc/0026-Append-GCC-private-include-paths-on-musl-instead-of-.patch b/meta/recipes-devtools/gcc/gcc/0026-Append-GCC-private-include-paths-on-musl-instead-of-.patch > new file mode 100644 > index 00000000000..1bcff39aa7c > --- /dev/null > +++ b/meta/recipes-devtools/gcc/gcc/0026-Append-GCC-private-include-paths-on-musl-instead-of-.patch > @@ -0,0 +1,35 @@ > +From 30f1229a8b663ee4dc35d389acf60241a4536fb8 Mon Sep 17 00:00:00 2001 > +From: Khem Raj <raj.khem@gmail.com> > +Date: Wed, 5 Jun 2024 22:56:12 -0700 > +Subject: [PATCH] Append GCC private include paths on musl instead of > + prepending > + > +Musl does not need gcc private compiler headers, therefore use them > +after standard system header search paths. > + > +This fixes packages like python builds to detect the musl systems > +correclty, as it looks for musl specific stuff in stdarg.h system > +header, which is wrongly picked from gcc private headers in OE > + > +Upstream-Status: Submitted [https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115368] > +Signed-off-by: Khem Raj <raj.khem@gmail.com> > +--- > + gcc/gcc.cc | 4 ++++ > + 1 file changed, 4 insertions(+) > + > +diff --git a/gcc/gcc.cc b/gcc/gcc.cc > +index 01968001c44..d0d5c35cf83 100644 > +--- a/gcc/gcc.cc > ++++ b/gcc/gcc.cc > +@@ -6589,7 +6589,11 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part) > + > + if (gcc_exec_prefix) > + { > ++#if DEFAULT_LIBC == LIBC_MUSL > ++ do_spec_1 ("-idirafter", 1, NULL); > ++#else > + do_spec_1 ("-iprefix", 1, NULL); > ++#endif > + /* Make this a separate argument. */ > + do_spec_1 (" ", 0, NULL); > + do_spec_1 (gcc_exec_prefix, 1, NULL); > The trouble is we build one cross compiler for both glibc and musl so this will fix musl and break glibc. It would need to change this depending upon the target at runtime. I suspect upstream gcc will say the same thing :/ Cheers, Richard
diff --git a/meta/recipes-devtools/gcc/gcc-14.1.inc b/meta/recipes-devtools/gcc/gcc-14.1.inc index b057e570f3b..c4bc4c72664 100644 --- a/meta/recipes-devtools/gcc/gcc-14.1.inc +++ b/meta/recipes-devtools/gcc/gcc-14.1.inc @@ -68,6 +68,7 @@ SRC_URI = "${BASEURI} \ file://0023-Fix-install-path-of-linux64.h.patch \ file://0024-Avoid-hardcoded-build-paths-into-ppc-libgcc.patch \ file://0025-gcc-testsuite-tweaks-for-mips-OE.patch \ + file://0026-Append-GCC-private-include-paths-on-musl-instead-of-.patch \ " S = "${TMPDIR}/work-shared/gcc-${PV}-${PR}/${SOURCEDIR}" diff --git a/meta/recipes-devtools/gcc/gcc/0026-Append-GCC-private-include-paths-on-musl-instead-of-.patch b/meta/recipes-devtools/gcc/gcc/0026-Append-GCC-private-include-paths-on-musl-instead-of-.patch new file mode 100644 index 00000000000..1bcff39aa7c --- /dev/null +++ b/meta/recipes-devtools/gcc/gcc/0026-Append-GCC-private-include-paths-on-musl-instead-of-.patch @@ -0,0 +1,35 @@ +From 30f1229a8b663ee4dc35d389acf60241a4536fb8 Mon Sep 17 00:00:00 2001 +From: Khem Raj <raj.khem@gmail.com> +Date: Wed, 5 Jun 2024 22:56:12 -0700 +Subject: [PATCH] Append GCC private include paths on musl instead of + prepending + +Musl does not need gcc private compiler headers, therefore use them +after standard system header search paths. + +This fixes packages like python builds to detect the musl systems +correclty, as it looks for musl specific stuff in stdarg.h system +header, which is wrongly picked from gcc private headers in OE + +Upstream-Status: Submitted [https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115368] +Signed-off-by: Khem Raj <raj.khem@gmail.com> +--- + gcc/gcc.cc | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/gcc/gcc.cc b/gcc/gcc.cc +index 01968001c44..d0d5c35cf83 100644 +--- a/gcc/gcc.cc ++++ b/gcc/gcc.cc +@@ -6589,7 +6589,11 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part) + + if (gcc_exec_prefix) + { ++#if DEFAULT_LIBC == LIBC_MUSL ++ do_spec_1 ("-idirafter", 1, NULL); ++#else + do_spec_1 ("-iprefix", 1, NULL); ++#endif + /* Make this a separate argument. */ + do_spec_1 (" ", 0, NULL); + do_spec_1 (gcc_exec_prefix, 1, NULL);
musl does not use gcc private system headers, however, the path gets prepended since gcc driver passes -iprefix option to cc1 based on its installation location. This starts to prefer these headers instead of musl provided equivalent system headers which is not as per musl's design. This patch switches prepend to append for musl systems. Signed-off-by: Khem Raj <raj.khem@gmail.com> --- meta/recipes-devtools/gcc/gcc-14.1.inc | 1 + ...te-include-paths-on-musl-instead-of-.patch | 35 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 meta/recipes-devtools/gcc/gcc/0026-Append-GCC-private-include-paths-on-musl-instead-of-.patch