authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-07-02 08:45:33+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-07-22 16:58:20+02:00
log44ee42c6bc46b20b1dac1f0b3a44512a8ada9c93
tree699e713d9a9e0e5b7c97656d8baee9ed1a4cf88a
parent8e75ba653b03477229cf72211e8a8bfe7b071254

cli: parse -dead_strip MachO linker flag


2 files changed, 12 insertions(+), 0 deletions(-)

src/link/MachO.zig+7
......@@ -565,6 +565,7 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No
565565 man.hash.addOptional(self.base.options.search_strategy);
566566 man.hash.addOptional(self.base.options.headerpad_size);
567567 man.hash.add(self.base.options.headerpad_max_install_names);
568 man.hash.add(self.base.options.gc_sections orelse false);
568569 man.hash.add(self.base.options.dead_strip_dylibs);
569570 man.hash.addListOfBytes(self.base.options.lib_dirs);
570571 man.hash.addListOfBytes(self.base.options.framework_dirs);
......@@ -1003,6 +1004,12 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No
10031004 try argv.append("-headerpad_max_install_names");
10041005 }
10051006
1007 if (self.base.options.gc_sections) |is_set| {
1008 if (is_set) {
1009 try argv.append("-dead_strip");
1010 }
1011 }
1012
10061013 if (self.base.options.dead_strip_dylibs) {
10071014 try argv.append("-dead_strip_dylibs");
10081015 }
src/main.zig+5
......@@ -463,6 +463,7 @@ const usage_build_generic =
463463 \\ -search_dylibs_first (Darwin) search `libx.dylib` in each dir in library search paths, then `libx.a`
464464 \\ -headerpad [value] (Darwin) set minimum space for future expansion of the load commands in hexadecimal notation
465465 \\ -headerpad_max_install_names (Darwin) set enough space as if all paths were MAXPATHLEN
466 \\ -dead_strip (Darwin) remove function and data that are unreachable by the entry point of exported symbols
466467 \\ -dead_strip_dylibs (Darwin) remove dylibs that are unreachable by the entry point or exported symbols
467468 \\ --import-memory (WebAssembly) import memory from the environment
468469 \\ --import-table (WebAssembly) import function table from the host environment
......@@ -969,6 +970,8 @@ fn buildOutputType(
969970 };
970971 } else if (mem.eql(u8, arg, "-headerpad_max_install_names")) {
971972 headerpad_max_install_names = true;
973 } else if (mem.eql(u8, arg, "-dead_strip")) {
974 linker_gc_sections = true;
972975 } else if (mem.eql(u8, arg, "-dead_strip_dylibs")) {
973976 dead_strip_dylibs = true;
974977 } else if (mem.eql(u8, arg, "-T") or mem.eql(u8, arg, "--script")) {
......@@ -1764,6 +1767,8 @@ fn buildOutputType(
17641767 };
17651768 } else if (mem.eql(u8, arg, "-headerpad_max_install_names")) {
17661769 headerpad_max_install_names = true;
1770 } else if (mem.eql(u8, arg, "-dead_strip")) {
1771 linker_gc_sections = true;
17671772 } else if (mem.eql(u8, arg, "-dead_strip_dylibs")) {
17681773 dead_strip_dylibs = true;
17691774 } else if (mem.eql(u8, arg, "--gc-sections")) {