zig
zig copied to clipboard
CompileStep.addRPath always generates absolute paths
Zig Version
0.11.0-dev.3295+7cb2e653a
Steps to Reproduce and Observed Behavior
- Start a new project using
zig init-exe
- Make a slight modification to build.zig:
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const exe = b.addExecutable(.{
.name = "xx",
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
});
b.installArtifact(exe);
// link to any installed library, doesn't matter
exe.linkSystemLibrary("ssl");
// specify a relative rpath
exe.addRPath("lib");
const run_cmd = b.addRunArtifact(exe);
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
}
- Build the project using
zig build
- Inspect the run path:
$ readelf --dynamic zig-out/bin/test | grep RUNPATH
0x000000000000001d (RUNPATH) Library runpath: [/home/user/code/test/lib:/usr/lib/x86_64-linux-gnu:/lib/x86_64-linux-gnu]
build-exe
works as expected:
$ zig build-exe src/main.zig --name test -lssl -rpath lib
$ readelf --dynamic test | grep RUNPATH
0x000000000000001d (RUNPATH) Library runpath: [lib:/usr/lib/x86_64-linux-gnu:/lib/x86_64-linux-gnu]
Expected Behavior
The relative path should be preserved. build-exe and build.zig should be consistent with each other.