Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zig NativeTargetInfo's hardcoded /usr/bin/env is not Nix-friendly #15898

Open
mitchellh opened this issue May 29, 2023 · 3 comments
Open

Zig NativeTargetInfo's hardcoded /usr/bin/env is not Nix-friendly #15898

mitchellh opened this issue May 29, 2023 · 3 comments
Labels
bug Observed behavior contradicts documented or intended behavior os-linux
Milestone

Comments

@mitchellh
Copy link
Contributor

Zig Version

0.11.0-dev.1836+28364166e (but it doesn't matter)

Steps to Reproduce and Observed Behavior

The Zig package on Nix requires this patch: https://github.com/NixOS/nixpkgs/blame/e6e389917a8c778be636e67a67ec958f511cc55d/pkgs/development/compilers/zig/0.10.nix#L48-L51

If I use a precompiled zig without that patch, then the dynamic linker used for built binaries is wrong, which leads to GLIBC mismatches (see mitchellh/zig-overlay#21).

Expected Behavior

It should use the correct dynamic linker, see the patch.

I'm not sure what the right generic answer to this is. An environment variable to override the path to env (or any binary to inspect) would work, but is clunky. Detecting NixOS is also an option, in which case you could inspect a different binary. I just wanted to get a tracking issue up because I couldn't find one.

@mitchellh mitchellh added the bug Observed behavior contradicts documented or intended behavior label May 29, 2023
@andrewrk andrewrk added this to the 0.12.0 milestone May 29, 2023
@BratishkaErik
Copy link
Contributor

BratishkaErik commented May 29, 2023

TBH I'm still in favor of using getconf GNU_LIBC_VERSION directly, it's an utility specifically for getting this information.
BTW can you please check output of this command on your Nix system? It should be like this:
glibc 2.35
If it does not have version of selected glibc (I guess? sorry, IDK Niz terminology), then it's not so „guaranteed to work” as I thought and will finally throw this path (in my mind) away.

@kknives
Copy link

kknives commented Jul 10, 2023

@BratishkaErik getconf GNU_LIBC_VERSION does indeed work with nix shells:

$ getconf GNU_LIBC_VERSION
glibc 2.35 # host glibc
$ nix develop
$ getconf GNU_LIBC_VERSION
glibc 2.37 # nix glibc

@erikarvstedt
Copy link
Contributor

erikarvstedt commented Apr 19, 2024

The dynamic linker is now configurable via standardTargetOptions.
Usage: nix build -Ddynamic-linker=...

This option is also exposed to Zig's cmake build (usage example with Nix).

Edit: What's missing for this issue to be resolved is removing the hardcoded env path (accepted solution).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior os-linux
Projects
None yet
Development

No branches or pull requests

5 participants