diff options
| author | Zach Cheung <zach.cheung@uber.com> | 2023-03-23 17:16:39 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-04-07 09:09:38 -0400 |
| commit | 1fdea551b22726783356c5bed90bce63706b550f (patch) | |
| tree | 22b8bd9b92578d7d03e38be8ece7d29662a640bf /src/main.zig | |
| parent | 086639630800fc52bd727163e85d174ec1ac1103 (diff) | |
| download | zig-1fdea551b22726783356c5bed90bce63706b550f.tar.gz zig-1fdea551b22726783356c5bed90bce63706b550f.zip | |
add linker -wrap flag
Diffstat (limited to 'src/main.zig')
| -rw-r--r-- | src/main.zig | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/main.zig b/src/main.zig index 76c43476ee..167bdfbafb 100644 --- a/src/main.zig +++ b/src/main.zig @@ -487,6 +487,7 @@ const usage_build_generic = \\ -fno-compiler-rt Prevent including compiler-rt symbols in output \\ -rdynamic Add all symbols to the dynamic symbol table \\ -rpath [path] Add directory to the runtime library search path + \\ -wrap [symbol] Override the symbol with the wrapped symbol definition \\ -feach-lib-rpath Ensure adding rpath for each used dynamic library \\ -fno-each-lib-rpath Prevent adding rpath for each used dynamic library \\ -fallow-shlib-undefined Allows undefined symbols in shared libraries @@ -874,6 +875,9 @@ fn buildOutputType( var rpath_list = std.ArrayList([]const u8).init(gpa); defer rpath_list.deinit(); + var wrap_list = std.ArrayList([]const u8).init(gpa); + defer wrap_list.deinit(); + var c_source_files = std.ArrayList(Compilation.CSourceFile).init(gpa); defer c_source_files.deinit(); @@ -1475,6 +1479,9 @@ fn buildOutputType( try system_libs.put(arg["-needed-l".len..], .{ .needed = true }); } else if (mem.startsWith(u8, arg, "-weak-l")) { try system_libs.put(arg["-weak-l".len..], .{ .weak = true }); + } else if (mem.eql(u8, arg, "-wrap")){ + try wrap_list.append(arg); + try wrap_list.append(args_iter.nextOrFatal()); } else if (mem.startsWith(u8, arg, "-D")) { try clang_argv.append(arg); } else if (mem.startsWith(u8, arg, "-I")) { @@ -2155,6 +2162,12 @@ fn buildOutputType( next_arg, }); }; + } else if (mem.eql(u8, arg, "-wrap")) { + i += 1; + if (i >= linker_args.items.len) { + fatal("expected linker arg after '{s}'", .{arg}); + } + try wrap_list.append(linker_args.items[i]); } else if (mem.startsWith(u8, arg, "/subsystem:")) { var split_it = mem.splitBackwards(u8, arg, ":"); subsystem = try parseSubSystem(split_it.first()); @@ -3039,6 +3052,7 @@ fn buildOutputType( .clang_argv = clang_argv.items, .lib_dirs = lib_dirs.items, .rpath_list = rpath_list.items, + .wrap_list = wrap_list.items, .c_source_files = c_source_files.items, .link_objects = link_objects.items, .framework_dirs = framework_dirs.items, |
