Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -92,17 +94,20 @@ pub fn addMultiVersion(
query.cpu_model = .{ .explicit = cpuModelForLevel(level) };
const resolved = b.resolveTargetQuery(query);

const pic = options.pic orelse compile.root_module.pic;
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);

const variant_mod = b.createModule(.{
.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);
Expand Down