Skip to content

Commit

Permalink
gcc: exclude malformed sys/mount.h from fixed headers directory
Browse files Browse the repository at this point in the history
Previously, builds such as `cmake` would fail with errors like this:

    In file included from /nix/store/injyphmxqgi028skp28fsmdvbdb57nvl-glibc-2.36-48-dev/include/linux/fs.h:19,
                     from /build/cmake-3.24.2/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c:56:
    /nix/store/injyphmxqgi028skp28fsmdvbdb57nvl-glibc-2.36-48-dev/include/linux/mount.h:95:6: error: redeclaration of 'enum fsconfig_command'
       95 | enum fsconfig_command {
          |      ^~~~~~~~~~~~~~~~

The reason behind that is that the kernel exports `linux/mount.h` via
kernel headers APIs that are also defined in `sys/mount.h` from glibc.
To avoid clashes, safeguards were implemented in glibc to prevent this
from happening[1][2].

However, these `#ifndef`-safeguards are removed by `fixincludes` during
gcc's build and the (broken) result is subsequently copied into
`include-fixed/sys/mount.h` which is added to each build via the
cc-wrapper. To work around this, I decided to simply drop the file: it
also exists in glibc's output and our gcc12 doesn't seem to expose this
anymore anyways.

[1] Commit bb1e8b0ca99b5cbedfae3e6245528a87d95ff3e2
[2] Commit 3bd3c612e98a53ce60ed972f5cd2b90628b3cba5
  • Loading branch information
Ma27 committed Oct 3, 2022
1 parent 515a89f commit 47b6539
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkgs/development/compilers/gcc/builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ postInstall() {
fi

# Get rid of some "fixed" header files
rm -rfv $out/lib/gcc/*/*/include-fixed/{root,linux}
rm -rfv $out/lib/gcc/*/*/include-fixed/{root,linux,sys/mount.h}

# Replace hard links for i686-pc-linux-gnu-gcc etc. with symlinks.
for i in $out/bin/*-gcc*; do
Expand Down

0 comments on commit 47b6539

Please sign in to comment.