aboutsummaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2021-12-11 00:26:50 +0100
committerJakub Konka <kubkon@jakubkonka.com>2021-12-12 00:32:03 +0100
commitdbfcebf8d88b91c5a85366da09a4ce69c0bb5dc6 (patch)
treee8f255a5277c428a2f598a6352a1d3b04f6c19ea /src/main.zig
parentefdb94486b78fa143f8d684609cb4c5d3de10124 (diff)
downloadzig-dbfcebf8d88b91c5a85366da09a4ce69c0bb5dc6.tar.gz
zig-dbfcebf8d88b91c5a85366da09a4ce69c0bb5dc6.zip
macho: allow undefined symbols in dylibs
We now respect both `-fallow-shlib-undefined` and `-Wl,"-undefined=dynamic_lookup"` flags. This is the first step towards solving issues #8180 and #3000. We currently do not expose any other ld64 equivalent flag for `-undefined` flag - we basically throw an error should the user specify a different flag. Support for those is conditional on closing #8180. As a result of this change, it is now possible to generate a valid native Node.js addon with Zig for macOS.
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/main.zig b/src/main.zig
index c29a272660..761935c897 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -1703,6 +1703,16 @@ fn buildOutputType(
}
emit_implib = .{ .yes = linker_args.items[i] };
emit_implib_arg_provided = true;
+ } else if (mem.eql(u8, arg, "-undefined")) {
+ i += 1;
+ if (i >= linker_args.items.len) {
+ fatal("expected linker arg after '{s}'", .{arg});
+ }
+ if (mem.eql(u8, "dynamic_lookup", linker_args.items[i])) {
+ linker_allow_shlib_undefined = true;
+ } else {
+ fatal("unsupported -undefined option '{s}'", .{linker_args.items[i]});
+ }
} else {
warn("unsupported linker arg: {s}", .{arg});
}