-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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 relies too much on /usr/bin/env
to detect dynamic-linker path
#14577
Comments
related IRC transcript
key takeaways
|
The code attempts to fall back to a reasonable default with |
Hi, I've been admiring Zig from afar for the last couple of years and am now finally giving it some real time -- thanks for all the hard work. For the last week I've been bringing-up zig-0.11.0 on illumos (specifically OmniOS). I ran into a similar issue as described in this ticket. illumos runs a multi-lib environment, and currently Coming back to this issue today my plan is to write a patch to hard-code the for (all_abis) |abi| {
// This may be a nonsensical parameter. We detect this with
// error.UnknownDynamicLinkerPath and skip adding it to `ld_info_list`.
const target: Target = .{
.cpu = cpu,
.os = os,
.abi = abi,
.ofmt = ofmt,
};
const ld = target.standardDynamicLinkerPath();
if (ld.get() == null) continue;
ld_info_list_buffer[ld_info_list_len] = .{
.ld = ld,
.abi = abi,
};
ld_info_list_len += 1;
} The problem is that the comment above the |
Seems like the code goes returns the value of zig/lib/std/zig/system/NativeTargetInfo.zig Line 362 in 402468b
break statement, the same statically linked /usr/bin/env file is passed to abiAndDynamicLinkerFromFile , which somehow concludes that the target does need a .interp entry
|
@ifreund Is it a sensible fix to make |
@rzezeski Seems like the But in this particular case, it eventually boils down to there being no portable and non-hacky way to determine at runtime whether zig's actual "native" is musl or glibc.. hmm |
That sounds very reasonable to me. |
The "-target native" argument causes Zig to call detectAbiAndDynamicLinker() and determine the dynamic-linker from the ELF data of `/usr/bin/env`. Problem is, `env` is a 32-bit executable, and the zig binary is 64-bit. One other person hit this same issue but in this case their `/usr/bin/env` was a link to a statically built busybox, meaning there was no interpreter to find. ziglang#14577 The real fix is probably to just have detectAbiAndDynamicLinker() use hard-coded defaults on the `solaris` tag. But for now I'm going to try to make progress by setting the target explicitly.
The last commit didn't work. Let's try this temporary work-around based on the solution in the zig#14577. ziglang#14577
Zig Version
0.11.0-dev.1580+a5b34a61a
Steps to Reproduce and Observed Behavior
/usr/bin/env
try to producehello.zig
executable linked with-lc
-dynamic-linker /lib/ld-musl-x86_64.so.1
Expected Behavior
-dynamic-linker /lib/ld-musl-x86_64.so.1
The text was updated successfully, but these errors were encountered: