Skip to content

Commit

Permalink
Workaround build problem with linking to gcc_eh
Browse files Browse the repository at this point in the history
Trying to use the llvm clang toolchain, targeting static musl, failed with:
```
/nix/store/fnw7g7s8z6wmaank060jpqppl0hiqbal-x86_64-unknown-linux-musl-binutils-2.38/bin/x86_64-unknown-linux-musl-ld: cannot find -lgcc_eh: No such file or directory
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)
```
See NixOS/nixpkgs#177129
  • Loading branch information
avdv committed Jun 20, 2022
1 parent b2477db commit 8e320ec
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@
mkShell = pkgsStatic.mkShell.override { stdenv = stdenvStatic; };

nativeBuildInputs = with pkgs; [ git which ];

empty-gcc-eh = pkgs.runCommand "empty-gcc-eh" { } ''
if $CC -Wno-unused-command-line-argument -x c - -o /dev/null <<< 'int main() {}'; then
echo "linking succeeded; please remove empty-gcc-eh workaround" >&2
exit 3
fi
mkdir -p $out/lib
${pkgs.binutils-unwrapped}/bin/ar r $out/lib/libgcc_eh.a
'';
in
rec {
packages = rec {
Expand All @@ -42,6 +51,7 @@
buildPhase = ''
export CLANG_PATH="$NIX_CC/bin/$CC"
export CLANGPP_PATH="$NIX_CC/bin/$CXX"
export NIX_LDFLAGS="$NIX_LDFLAGS -L${empty-gcc-eh}/lib"
sbt scalalsNative/nativeLink
'';
Expand Down Expand Up @@ -82,6 +92,7 @@
shellHook = ''
export CLANG_PATH="$NIX_CC/bin/$CC"
export CLANGPP_PATH="$NIX_CC/bin/$CXX"
export NIX_LDFLAGS="$NIX_LDFLAGS -L${empty-gcc-eh}/lib"
${checks.pre-commit-check.shellHook}
'';
Expand Down

0 comments on commit 8e320ec

Please sign in to comment.