Skip to content

Commit

Permalink
fix(lang-js): fix Nix pkg by only linking the single ld-linux program
Browse files Browse the repository at this point in the history
This fixes an issue where a Nix build phase now detects broken symlinks.
This was happening by design as we were creating a symlink for both
x86_64-linux and aarch64-linux systems no matter which system package
was being built.

The error was:

```
lang-js> ERROR: noBrokenSymlinks: the symlink /nix/store/yc5yb3cdvjyqzykwf4nz1w1aj9vxxxs9-lang-js/lib/ld-linux-x86-64.so.2 points to a missing target /nix/store
/4j0ghmjl1hia5h4fx9szjz0zzlr4ck9b-glibc-2.40-66/lib/ld-linux-x86-64.so.2
lang-js> ERROR: noBrokenSymlinks: found 1 dangling symlinks and 0 reflexive symlinks
error: builder for '/nix/store/qkdscpxj0ig5njnh39sbcwgyipiaxx1b-lang-js.drv' failed with exit code 1
```

The fix provided here computes the appropriate file name for the given
system and uses that when creating the symlink.

Signed-off-by: Fletcher Nichol <[email protected]>
  • Loading branch information
fnichol committed Feb 14, 2025
1 parent 5fabcc6 commit 86218be
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@
darwin.apple_sdk.frameworks.CoreFoundation
];

# The file name of the program interpreter/dynamic linker. We're primarily
# interested in the Linux system values.
interpreterName =
{
"x86_64-linux" = "ld-linux-x86-64.so.2";
"aarch64-linux" = "ld-linux-aarch64.so.1";
"x86_64-darwin" = "/dev/null";
"aarch64-darwin" = "/dev/null";
}
.${system};

# This isn't an exact science, but confirmed the system interpreter by
# running `ldd /bin/sh` in Docker containers running:
# - debian:9-slim
Expand Down Expand Up @@ -301,11 +312,8 @@
# /lib64/ld-linux-x86-64.so.2 -> /nix/store/*/ld-linux-x86-64.20.2
mkdir -p $out/lib64
ln -sf \
"${pkgs.glibc}/lib/ld-linux-x86-64.so.2" \
"$out/lib64/ld-linux-x86-64.so.2"
ln -sf \
"${pkgs.glibc}/lib/ld-linux-aarch64.so.1" \
"$out/lib64/ld-linux-aarch64.so.1"
"${pkgs.glibc}/lib/${interpreterName}" \
"$out/lib64/${interpreterName}"
wrapProgram $out/bin/lang-js \
--set LD_LIBRARY_PATH "${pkgs.lib.makeLibraryPath [
Expand Down

0 comments on commit 86218be

Please sign in to comment.