NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.36k stars 13.59k forks source link

cuneiform broken on aarch64-linux due to incomplete RUNPATH #54793

Open erikarvstedt opened 5 years ago

erikarvstedt commented 5 years ago

Preliminaries

To run aarch64-linux binaries and builds on foreign architectures, add this snippet to your NixOS config:

{
  imports = let
    repo = builtins.fetchTarball {
      url = "https://github.com/cleverca22/nixos-configs/archive/738e551c261fce79869c92723ded657b0346e0e1.tar.gz";
      sha256 = "0scscnrmasxqssp2a7vxvgx491w1bhqx7pljlr8arjjnk5w5938f";
    };
  in
    [ "${repo}/qemu.nix" ];

  qemu-user.aarch64 = true;
}

Reproduce

cu_arm=$(nix-build '<nixpkgs>' --no-out-link --argstr system aarch64-linux -A cuneiform)
cu_x64=$(nix-build '<nixpkgs>' --no-out-link --argstr system x64_64-linux  -A cuneiform)

$cu_arm/bin/cuneiform
# Result:
# error while loading shared libraries: libcuneiform.so.0: cannot open shared object file: No such file or directory

Inspecting the binaries reveals that ${cuniform}/lib is missing from RUNPATH:

# Lib path is present on x64
readelf -d $cu_x64/bin/cuneiform | grep RUNPATH
# [/nix/store/924dyc20kzy3mzj2196lxds3l3cly9vq-cuneiform-1.1.0/lib64:...]

# But missing on ARM
readelf -d $cu_arm/bin/cuneiform | grep RUNPATH
# [/nix/store/yxsr5jyl15h90bcwin47gprndyic5svj-glibc-2.27/lib:/nix/store/imyp31s6wg3wsgdxrj0gwfidsh5llf9b-gcc-7.4.0-lib/lib]

Manually setting the library path fixes it:

LD_LIBRARY_PATH=$cu_arm/lib $cu_arm/bin/cuneiform

cc: @matthewbauer, @7c6f434c

7c6f434c commented 5 years ago

Weird, don't we add "$out/lib" ro RPATH by default??

matthewbauer commented 5 years ago

Probably something weird with the CMake. This looks suspicious:

https://bazaar.launchpad.net/~jpakkane/cuneiform-linux/trunk/view/head:/install_files.cmake#L6

7c6f434c commented 5 years ago

https://bazaar.launchpad.net/~jpakkane/cuneiform-linux/trunk/view/head:/install_files.cmake#L6

This shouldn't distinguish 64-bit platforms, one could hope…

stale[bot] commented 4 years ago

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.