Skip to content

NIX_LIB64_IN_SELF_RPATH leaks through to cross-builds #221350

@eliasnaur

Description

@eliasnaur

Describe the bug

lib64 directories are added to linker rpath flags for cross-compilation to platforms that don't need them.

Steps To Reproduce

Steps to reproduce the behavior:

  1. nix build -L github:eliasnaur/nix-lib64-rpath on a x86_64-linux system

output:

...
demonstrate-lib64-rpath-armv6l-unknown-linux-gnueabihf> CC armv6l-unknown-linux-gnueabihf-gcc
demonstrate-lib64-rpath-armv6l-unknown-linux-gnueabihf> NIX_LDFLAGS: -rpath /nix/store/lskdn4fvvjlz53dxkbkgb1x2dy4zkf7k-demonstrate-lib64-rpath-armv6l-unknown-linux-gnueabihf/lib64 -rpath /nix/store/lskdn4fvvjlz53dxkbkgb1x2dy4zkf7k-demonstrate-lib64-rpath-armv6l-unknown-linux-gnueabihf/lib
...

Note the lib64 directory added to NIX_LDFLAGS.

See full build log at https://github.com/eliasnaur/nix-lib64-rpath/actions/runs/4428890865/jobs/7768605092.

Running the same command on a aarch64-darwin configuration (with a aarch64-linux builder configured):

% nix build -L
...
demonstrate-lib64-rpath-armv6l-unknown-linux-gnueabihf> CC armv6l-unknown-linux-gnueabihf-gcc
demonstrate-lib64-rpath-armv6l-unknown-linux-gnueabihf> NIX_LDFLAGS: -rpath /nix/store/sw8ymyqpavw0v4hl01q0xb9c9wr50v9z-demonstrate-lib64-rpath-armv6l-unknown-linux-gnueabihf/lib
...

Note that NIX_LDFLAGS doesn't contain a lib64 directory.

Expected behavior

NIX_LDFLAGS should not contain lib64 directories when cross-compiling for non-x86_64-linux platforms.

Additional context

Adding lib64 to NIX_LDFLAGS is generally benign, except that I'm trying to achieve bit-for-bit reproducible builds. The extra lib64 entries end up in slightly larger ELF sections that can't be saved by careful use of patchelf.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions