Skip to content

gcc's include order differs between glibc and musl #142066

@trofi

Description

@trofi

In https://lists.gnu.org/archive/html/bug-gnulib/2021-10/msg00045.html I noticed the following:

  • gcc+glibc uses include order: gcc's, then glibc's
  • gcc+musl uses include order: musl's, then gcc's

Is it intended? Here is an executable (ish) example:

glibc:

$ nix-shell '<nixpkgs>' --pure -A bison --run 'gcc -v -x c -E - </dev/null' |& unnix

 /<<NIX>>/gcc-10.3.0/lib/gcc/x86_64-unknown-linux-gnu/10.3.0/include
 /<<NIX>>/gcc-10.3.0/include
 /<<NIX>>/gcc-10.3.0/lib/gcc/x86_64-unknown-linux-gnu/10.3.0/include-fixed
 /<<NIX>>/glibc-2.33-50-dev/include

musl:

$ nix-shell '<nixpkgs>' --pure -A pkgsMusl.bison --run 'gcc -v -x c -E - </dev/null' |& unnix

 /<<NIX>>/gcc-10.3.0/include
 /<<NIX>>/musl-1.2.2-dev/include
 /<<NIX>>/gcc-10.3.0/lib/gcc/x86_64-unknown-linux-musl/10.3.0/include
 /<<NIX>>/gcc-10.3.0/lib/gcc/x86_64-unknown-linux-musl/10.3.0/include-fixed

In case of gnulib's bug above stdarg.h is present in both gcc's version-specific headers and musl's headers. gnulib expects to find headers in musl's copy and fails when gcc's is used.

Is it a reasonable assumption? Should we make glibc's incude order as musl's? Or the other way around? I think "gcc, then libc" is more natural given that gcc places it's headers for namespace cleanup reasons.

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bugSomething is broken6.topic: muslRunning or building packages with musl libc
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions