-
-
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
Segmentation fault by default due to a wrong dynamic linker on KissLinux #21963
Comments
Please try this with a nightly build from https://ziglang.org/download as there have been multiple changes to |
Unfortunately I get the same issue with the latest nightly build |
I guess it's similar reason as in #21941 (comment) :
In $ file usr/bin/env
usr/bin/env: symbolic link to busybox
$ file usr/bin/busybox
usr/bin/busybox: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, stripped
$ file usr/bin/x86_64-pc-linux-musl-gcc
usr/bin/x86_64-pc-linux-musl-gcc: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-x86_64.so.1, stripped So if you start pub const abi = std.Target.Abi.musl;
// ...
pub const os = std.Target.Os{
.tag = .linux,
.version_range = .{ .linux = .{
.range = .{
.min = .{
.major = 6,
.minor = 11,
.patch = 5,
},
.max = .{
.major = 6,
.minor = 11,
.patch = 5,
},
},
.glibc = .{
.major = 2,
.minor = 28,
.patch = 0,
},
}},
};
pub const target: std.Target = .{
.cpu = cpu,
.os = os,
.abi = abi,
.ofmt = object_format,
.dynamic_linker = std.Target.DynamicLinker.none,
}; But if I replace pub const target: std.Target = .{
.cpu = cpu,
.os = os,
.abi = abi,
.ofmt = object_format,
.dynamic_linker = std.Target.DynamicLinker.init("/lib/ld-musl-x86_64.so.1"),
}; I assume result above is what you want? |
Yes, this is exactly what I want, a workaround for this issue is to simply manually set the const std = @import("std");
pub fn build(b: *std.Build) void {
b.host.query.dynamic_linker = std.Target.DynamicLinker.init("/usr/lib/ld-musl-x86_64.so.1");
const exe = b.addExecutable(.{
.name = "hello",
.root_source_file = b.path("main.zig"),
.target = b.host,
.optimize = .Debug,
});
exe.linkLibC();
b.installArtifact(exe);
} |
As an easier alternative, you can pass |
Zig Version
0.13.0
Steps to Reproduce and Observed Behavior
On KissLinux:
gdb output

After digging a little bit I realized that the linking stage was failing but still outputs the executable:

By taking the exact build command and removing the

listen=-
argument and adding--dynamic-linker /usr/lib/ld-musl-x86_64.so.1
the executable get successfully linked and works as expectedWhat can be the cause of this issue ?
Expected Behavior
The executable gets linked successfully
The text was updated successfully, but these errors were encountered: