From af9628ad595e8015f74240ebdd501d2c9a671051 Mon Sep 17 00:00:00 2001 From: Roko <55251261+rokobekavac0@users.noreply.github.com> Date: Tue, 7 Apr 2026 08:50:45 +0200 Subject: [PATCH 1/2] pic --- build.zig | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build.zig b/build.zig index 31175f9..54266bd 100644 --- a/build.zig +++ b/build.zig @@ -63,6 +63,8 @@ pub fn addMultiVersion( /// creates a circular build dependency. Factor shared types into a /// separate module instead. imports: []const std.Build.Module.Import = &.{}, + /// Force PIC on multi-versioned objects (for shared libraries). + pic: ?bool = null, }, ) void { const b = compile.step.owner; @@ -92,10 +94,12 @@ pub fn addMultiVersion( query.cpu_model = .{ .explicit = cpuModelForLevel(level) }; const resolved = b.resolveTargetQuery(query); + const pic = options.pic orelse (compile.linkage == .dynamic); const user_mod = b.createModule(.{ .root_source_file = options.source, .target = resolved, .optimize = compile.root_module.optimize orelse .Debug, + .pic = pic, }); for (options.imports) |imp| user_mod.addImport(imp.name, imp.module); @@ -103,6 +107,7 @@ pub fn addMultiVersion( .root_source_file = wrapper_source, .target = resolved, .optimize = compile.root_module.optimize orelse .Debug, + .pic = pic, }); variant_mod.addImport("oma", oma_dep.module("oma")); variant_mod.addImport("_oma_source", user_mod); From 0dd9c3406ccc52506afc1ae8bfe6b910fa8fbf0b Mon Sep 17 00:00:00 2001 From: Anthony Templeton Date: Tue, 14 Apr 2026 20:00:15 -0400 Subject: [PATCH 2/2] fix: tweak pic for macOS --- build.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.zig b/build.zig index 54266bd..79bd177 100644 --- a/build.zig +++ b/build.zig @@ -94,7 +94,7 @@ pub fn addMultiVersion( query.cpu_model = .{ .explicit = cpuModelForLevel(level) }; const resolved = b.resolveTargetQuery(query); - const pic = options.pic orelse (compile.linkage == .dynamic); + const pic = options.pic orelse compile.root_module.pic; const user_mod = b.createModule(.{ .root_source_file = options.source, .target = resolved,