Static build is broken because clang in nixpkgs is broken for static libgcc #527

Closed
opened 2024-09-18 03:37:32 +00:00 by jade · 1 comment
Owner

This is a truly ridiculous bug.

There is one bug that is easy to fix:

diff --git a/package.nix b/package.nix
index 23ebc3a82..f794c4572 100644
--- a/package.nix
+++ b/package.nix
@@ -100,7 +100,7 @@
         (lib.enableFeature (ncurses != null) "termcap")
       ];

-      nativeBuildInputs = (prev.nativeBuildInputs or [ ]) ++ [ ncurses ];
+      buildInputs = (prev.buildInputs or [ ]) ++ [ ncurses ];
     });

     build-release-notes = callPackage ./maintainers/build-release-notes.nix { };

After fixing this we have another worse bug:

Builds fail with meson.build:341:9: ERROR: Dependency lookup for toml11 with method 'cmake' failed: Dependency toml11 not found: Unable to obtain CMake system information.

Looking at the meson log, we find:

  The C++ compiler

    "/nix/store/zixyk51n5qhd6ibj8mwjc9x34fh30ig2-x86_64-unknown-linux-musl-clang-wrapper-17.0.6/bin/x86_64-unknown-linux-musl-clang++"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: '/build/source/build/meson-private/cmake_toml11/CMakeFiles/CMakeScratch/TryCompile-j6kYOp'
    
    Run Build Command(s): /nix/store/mk7637n6h4d437gl5cplxvd3k2l66awd-cmake-3.29.2/bin/cmake -E env VERBOSE=1 /nix/store/3hnf34qxi3h6c62dw95crgxdxvibasml-gnumake-4.4.
1/bin/make -f Makefile cmTC_52de2/fast
    /nix/store/3hnf34qxi3h6c62dw95crgxdxvibasml-gnumake-4.4.1/bin/make  -f CMakeFiles/cmTC_52de2.dir/build.make CMakeFiles/cmTC_52de2.dir/build
    make[1]: Entering directory '/build/source/build/meson-private/cmake_toml11/CMakeFiles/CMakeScratch/TryCompile-j6kYOp'
    Building CXX object CMakeFiles/cmTC_52de2.dir/testCXXCompiler.cxx.o
    /nix/store/zixyk51n5qhd6ibj8mwjc9x34fh30ig2-x86_64-unknown-linux-musl-clang-wrapper-17.0.6/bin/x86_64-unknown-linux-musl-clang++    -MD -MT CMakeFiles/cmTC_52de2.
dir/testCXXCompiler.cxx.o -MF CMakeFiles/cmTC_52de2.dir/testCXXCompiler.cxx.o.d -o CMakeFiles/cmTC_52de2.dir/testCXXCompiler.cxx.o -c /build/source/build/meson-privat
e/cmake_toml11/CMakeFiles/CMakeScratch/TryCompile-j6kYOp/testCXXCompiler.cxx
    Linking CXX executable cmTC_52de2
    /nix/store/mk7637n6h4d437gl5cplxvd3k2l66awd-cmake-3.29.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_52de2.dir/link.txt --verbose=1
    /nix/store/zixyk51n5qhd6ibj8mwjc9x34fh30ig2-x86_64-unknown-linux-musl-clang-wrapper-17.0.6/bin/x86_64-unknown-linux-musl-clang++ CMakeFiles/cmTC_52de2.dir/testCXX
Compiler.cxx.o -o cmTC_52de2
    /nix/store/fmc9d0xbcgfcwg8fyw9w9908wca58y9k-x86_64-unknown-linux-musl-binutils-2.41/bin/x86_64-unknown-linux-musl-ld: cannot find -lgcc_eh: No such file or direct
ory
    clang++: error: linker command failed with exit code 1 (use -v to see invocation)
    make[1]: *** [CMakeFiles/cmTC_52de2.dir/build.make:100: cmTC_52de2] Error 1
    make[1]: Leaving directory '/build/source/build/meson-private/cmake_toml11/CMakeFiles/CMakeScratch/TryCompile-j6kYOp'
    make: *** [Makefile:127: cmTC_52de2/fast] Error 2

This is because clang is busted and requires a shared build of libgcc to be able to compile anything (libgcc_eh.a only exists on --enable-shared builds of libgcc). 135d92f903/clang/lib/Driver/ToolChains/CommonArgs.cpp (L2055-L2066)

Which then lands back at nixpkgs with https://github.com/NixOS/nixpkgs/issues/177129

This isn't acceptable to ship in a release, so this is a 2.92 release blocker.

This is a truly ridiculous bug. There is one bug that is easy to fix: ``` diff --git a/package.nix b/package.nix index 23ebc3a82..f794c4572 100644 --- a/package.nix +++ b/package.nix @@ -100,7 +100,7 @@ (lib.enableFeature (ncurses != null) "termcap") ]; - nativeBuildInputs = (prev.nativeBuildInputs or [ ]) ++ [ ncurses ]; + buildInputs = (prev.buildInputs or [ ]) ++ [ ncurses ]; }); build-release-notes = callPackage ./maintainers/build-release-notes.nix { }; ``` After fixing this we have another worse bug: Builds fail with `meson.build:341:9: ERROR: Dependency lookup for toml11 with method 'cmake' failed: Dependency toml11 not found: Unable to obtain CMake system information`. Looking at the meson log, we find: ``` The C++ compiler "/nix/store/zixyk51n5qhd6ibj8mwjc9x34fh30ig2-x86_64-unknown-linux-musl-clang-wrapper-17.0.6/bin/x86_64-unknown-linux-musl-clang++" is not able to compile a simple test program. It fails with the following output: Change Dir: '/build/source/build/meson-private/cmake_toml11/CMakeFiles/CMakeScratch/TryCompile-j6kYOp' Run Build Command(s): /nix/store/mk7637n6h4d437gl5cplxvd3k2l66awd-cmake-3.29.2/bin/cmake -E env VERBOSE=1 /nix/store/3hnf34qxi3h6c62dw95crgxdxvibasml-gnumake-4.4. 1/bin/make -f Makefile cmTC_52de2/fast /nix/store/3hnf34qxi3h6c62dw95crgxdxvibasml-gnumake-4.4.1/bin/make -f CMakeFiles/cmTC_52de2.dir/build.make CMakeFiles/cmTC_52de2.dir/build make[1]: Entering directory '/build/source/build/meson-private/cmake_toml11/CMakeFiles/CMakeScratch/TryCompile-j6kYOp' Building CXX object CMakeFiles/cmTC_52de2.dir/testCXXCompiler.cxx.o /nix/store/zixyk51n5qhd6ibj8mwjc9x34fh30ig2-x86_64-unknown-linux-musl-clang-wrapper-17.0.6/bin/x86_64-unknown-linux-musl-clang++ -MD -MT CMakeFiles/cmTC_52de2. dir/testCXXCompiler.cxx.o -MF CMakeFiles/cmTC_52de2.dir/testCXXCompiler.cxx.o.d -o CMakeFiles/cmTC_52de2.dir/testCXXCompiler.cxx.o -c /build/source/build/meson-privat e/cmake_toml11/CMakeFiles/CMakeScratch/TryCompile-j6kYOp/testCXXCompiler.cxx Linking CXX executable cmTC_52de2 /nix/store/mk7637n6h4d437gl5cplxvd3k2l66awd-cmake-3.29.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_52de2.dir/link.txt --verbose=1 /nix/store/zixyk51n5qhd6ibj8mwjc9x34fh30ig2-x86_64-unknown-linux-musl-clang-wrapper-17.0.6/bin/x86_64-unknown-linux-musl-clang++ CMakeFiles/cmTC_52de2.dir/testCXX Compiler.cxx.o -o cmTC_52de2 /nix/store/fmc9d0xbcgfcwg8fyw9w9908wca58y9k-x86_64-unknown-linux-musl-binutils-2.41/bin/x86_64-unknown-linux-musl-ld: cannot find -lgcc_eh: No such file or direct ory clang++: error: linker command failed with exit code 1 (use -v to see invocation) make[1]: *** [CMakeFiles/cmTC_52de2.dir/build.make:100: cmTC_52de2] Error 1 make[1]: Leaving directory '/build/source/build/meson-private/cmake_toml11/CMakeFiles/CMakeScratch/TryCompile-j6kYOp' make: *** [Makefile:127: cmTC_52de2/fast] Error 2 ``` This is because clang is busted and requires a shared build of libgcc to be able to compile anything (`libgcc_eh.a` only exists on `--enable-shared` builds of libgcc). https://github.com/llvm/llvm-project/blob/135d92f903161e66ff82ab846acfbc5015ef3096/clang/lib/Driver/ToolChains/CommonArgs.cpp#L2055-L2066 Which then lands back at nixpkgs with https://github.com/NixOS/nixpkgs/issues/177129 This isn't acceptable to ship in a release, so this is a 2.92 release blocker.
jade added the
release-blocker
bug
Area/build-packaging
labels 2024-09-18 03:37:32 +00:00
Member

This issue was mentioned on Gerrit on the following CLs:

  • commit message in cl/1921 ("package.nix: fix cross for editline")
  • commit message in cl/2149 ("fix: make static build work again")
<!-- GERRIT_LINKBOT: {"cls": [{"backlink": "https://gerrit.lix.systems/c/lix/+/1921", "number": 1921, "kind": "commit message"}, {"backlink": "https://gerrit.lix.systems/c/lix/+/2149", "number": 2149, "kind": "commit message"}], "cl_meta": {"1921": {"change_title": "package.nix: fix cross for editline"}, "2149": {"change_title": "fix: make static build work again"}}} --> This issue was mentioned on Gerrit on the following CLs: * commit message in [cl/1921](https://gerrit.lix.systems/c/lix/+/1921) ("package.nix: fix cross for editline") * commit message in [cl/2149](https://gerrit.lix.systems/c/lix/+/2149) ("fix: make static build work again")
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#527
No description provided.