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...@@ -565,6 +565,7 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No
565 man.hash.addOptional(self.base.options.search_strategy);565 man.hash.addOptional(self.base.options.search_strategy);
566 man.hash.addOptional(self.base.options.headerpad_size);566 man.hash.addOptional(self.base.options.headerpad_size);
567 man.hash.add(self.base.options.headerpad_max_install_names);567 man.hash.add(self.base.options.headerpad_max_install_names);
568 man.hash.add(self.base.options.gc_sections orelse false);
568 man.hash.add(self.base.options.dead_strip_dylibs);569 man.hash.add(self.base.options.dead_strip_dylibs);
569 man.hash.addListOfBytes(self.base.options.lib_dirs);570 man.hash.addListOfBytes(self.base.options.lib_dirs);
570 man.hash.addListOfBytes(self.base.options.framework_dirs);571 man.hash.addListOfBytes(self.base.options.framework_dirs);
...@@ -1003,6 +1004,12 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No...@@ -1003,6 +1004,12 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No
1003 try argv.append("-headerpad_max_install_names");1004 try argv.append("-headerpad_max_install_names");
1004 }1005 }
10051006
1007 if (self.base.options.gc_sections) |is_set| {
1008 if (is_set) {
1009 try argv.append("-dead_strip");
1010 }
1011 }
1012
1006 if (self.base.options.dead_strip_dylibs) {1013 if (self.base.options.dead_strip_dylibs) {
1007 try argv.append("-dead_strip_dylibs");1014 try argv.append("-dead_strip_dylibs");
1008 }1015 }
src/main.zig+5
...@@ -463,6 +463,7 @@ const usage_build_generic =...@@ -463,6 +463,7 @@ const usage_build_generic =
463 \\ -search_dylibs_first (Darwin) search `libx.dylib` in each dir in library search paths, then `libx.a`463 \\ -search_dylibs_first (Darwin) search `libx.dylib` in each dir in library search paths, then `libx.a`
464 \\ -headerpad [value] (Darwin) set minimum space for future expansion of the load commands in hexadecimal notation464 \\ -headerpad [value] (Darwin) set minimum space for future expansion of the load commands in hexadecimal notation
465 \\ -headerpad_max_install_names (Darwin) set enough space as if all paths were MAXPATHLEN465 \\ -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
466 \\ -dead_strip_dylibs (Darwin) remove dylibs that are unreachable by the entry point or exported symbols467 \\ -dead_strip_dylibs (Darwin) remove dylibs that are unreachable by the entry point or exported symbols
467 \\ --import-memory (WebAssembly) import memory from the environment468 \\ --import-memory (WebAssembly) import memory from the environment
468 \\ --import-table (WebAssembly) import function table from the host environment469 \\ --import-table (WebAssembly) import function table from the host environment
...@@ -969,6 +970,8 @@ fn buildOutputType(...@@ -969,6 +970,8 @@ fn buildOutputType(
969 };970 };
970 } else if (mem.eql(u8, arg, "-headerpad_max_install_names")) {971 } else if (mem.eql(u8, arg, "-headerpad_max_install_names")) {
971 headerpad_max_install_names = true;972 headerpad_max_install_names = true;
973 } else if (mem.eql(u8, arg, "-dead_strip")) {
974 linker_gc_sections = true;
972 } else if (mem.eql(u8, arg, "-dead_strip_dylibs")) {975 } else if (mem.eql(u8, arg, "-dead_strip_dylibs")) {
973 dead_strip_dylibs = true;976 dead_strip_dylibs = true;
974 } else if (mem.eql(u8, arg, "-T") or mem.eql(u8, arg, "--script")) {977 } else if (mem.eql(u8, arg, "-T") or mem.eql(u8, arg, "--script")) {
...@@ -1764,6 +1767,8 @@ fn buildOutputType(...@@ -1764,6 +1767,8 @@ fn buildOutputType(
1764 };1767 };
1765 } else if (mem.eql(u8, arg, "-headerpad_max_install_names")) {1768 } else if (mem.eql(u8, arg, "-headerpad_max_install_names")) {
1766 headerpad_max_install_names = true;1769 headerpad_max_install_names = true;
1770 } else if (mem.eql(u8, arg, "-dead_strip")) {
1771 linker_gc_sections = true;
1767 } else if (mem.eql(u8, arg, "-dead_strip_dylibs")) {1772 } else if (mem.eql(u8, arg, "-dead_strip_dylibs")) {
1768 dead_strip_dylibs = true;1773 dead_strip_dylibs = true;
1769 } else if (mem.eql(u8, arg, "--gc-sections")) {1774 } else if (mem.eql(u8, arg, "--gc-sections")) {