Skip to content

Commit e527e3f

Browse files
committed
build: make the Zig static lib position-independent (PIC)
The static lib's code had absolute relocations (R_X86_64_32S against character_map), so linking it into a PIE executable failed on Linux ('can not be used when making a PIE object') — which broke test-ffi-cli on Garnix and would break any Linux FFI consumer building a default PIE binary. Set .pic = true on the static-lib module. (Masked on darwin by its reloc model.)
1 parent 29f27fb commit e527e3f

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

build.zig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ pub fn build(b: *std.Build) void {
2121
.root_source_file = b.path("src/zig/printable_binary.zig"),
2222
.target = target,
2323
.optimize = optimize,
24+
// Position-independent so the static lib links into PIE executables
25+
// (the default on modern Linux) — required by FFI consumers.
26+
.pic = true,
2427
});
2528
static_lib_mod.addAnonymousImport("character_map.txt", .{ .root_source_file = b.path("character_map.txt") });
2629

0 commit comments

Comments
 (0)