diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2022-07-05 14:42:45 +0200 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2022-07-22 16:58:20 +0200 |
| commit | 7ec9a4f382fb73950e4b4c5f7e005c154f6ec294 (patch) | |
| tree | 3f07e8ea27bd98eaa630eb5d3787c771841ddea4 /lib | |
| parent | 44ee42c6bc46b20b1dac1f0b3a44512a8ada9c93 (diff) | |
| download | zig-7ec9a4f382fb73950e4b4c5f7e005c154f6ec294.tar.gz zig-7ec9a4f382fb73950e4b4c5f7e005c154f6ec294.zip | |
cli: support --gc-sections and --no-gc-sections for Zig sources
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/std/build.zig | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/std/build.zig b/lib/std/build.zig index 2fb7b0258c..83e30b278f 100644 --- a/lib/std/build.zig +++ b/lib/std/build.zig @@ -1561,6 +1561,10 @@ pub const LibExeObjStep = struct { /// safely garbage-collected during the linking phase. link_function_sections: bool = false, + /// Remove functions and data that are unreachable by the entry point or + /// exported symbols. + link_gc_sections: ?bool = null, + linker_allow_shlib_undefined: ?bool = null, /// Permit read-only relocations in read-only segments. Disallowed by default. @@ -2705,6 +2709,9 @@ pub const LibExeObjStep = struct { if (self.link_function_sections) { try zig_args.append("-ffunction-sections"); } + if (self.link_gc_sections) |x| { + try zig_args.append(if (x) "--gc-sections" else "--no-gc-sections"); + } if (self.linker_allow_shlib_undefined) |x| { try zig_args.append(if (x) "-fallow-shlib-undefined" else "-fno-allow-shlib-undefined"); } |
