From dbfcebf8d88b91c5a85366da09a4ce69c0bb5dc6 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Sat, 11 Dec 2021 00:26:50 +0100 Subject: 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. --- src/main.zig | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/main.zig') 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}); } -- cgit v1.2.3