Commit 44ee42c6bc
src/link/MachO.zig
@@ -565,6 +565,7 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No
man.hash.addOptional(self.base.options.search_strategy);
man.hash.addOptional(self.base.options.headerpad_size);
man.hash.add(self.base.options.headerpad_max_install_names);
+ man.hash.add(self.base.options.gc_sections orelse false);
man.hash.add(self.base.options.dead_strip_dylibs);
man.hash.addListOfBytes(self.base.options.lib_dirs);
man.hash.addListOfBytes(self.base.options.framework_dirs);
@@ -1003,6 +1004,12 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No
try argv.append("-headerpad_max_install_names");
}
+ if (self.base.options.gc_sections) |is_set| {
+ if (is_set) {
+ try argv.append("-dead_strip");
+ }
+ }
+
if (self.base.options.dead_strip_dylibs) {
try argv.append("-dead_strip_dylibs");
}
src/main.zig
@@ -463,6 +463,7 @@ const usage_build_generic =
\\ -search_dylibs_first (Darwin) search `libx.dylib` in each dir in library search paths, then `libx.a`
\\ -headerpad [value] (Darwin) set minimum space for future expansion of the load commands in hexadecimal notation
\\ -headerpad_max_install_names (Darwin) set enough space as if all paths were MAXPATHLEN
+ \\ -dead_strip (Darwin) remove function and data that are unreachable by the entry point of exported symbols
\\ -dead_strip_dylibs (Darwin) remove dylibs that are unreachable by the entry point or exported symbols
\\ --import-memory (WebAssembly) import memory from the environment
\\ --import-table (WebAssembly) import function table from the host environment
@@ -969,6 +970,8 @@ fn buildOutputType(
};
} else if (mem.eql(u8, arg, "-headerpad_max_install_names")) {
headerpad_max_install_names = true;
+ } else if (mem.eql(u8, arg, "-dead_strip")) {
+ linker_gc_sections = true;
} else if (mem.eql(u8, arg, "-dead_strip_dylibs")) {
dead_strip_dylibs = true;
} else if (mem.eql(u8, arg, "-T") or mem.eql(u8, arg, "--script")) {
@@ -1764,6 +1767,8 @@ fn buildOutputType(
};
} else if (mem.eql(u8, arg, "-headerpad_max_install_names")) {
headerpad_max_install_names = true;
+ } else if (mem.eql(u8, arg, "-dead_strip")) {
+ linker_gc_sections = true;
} else if (mem.eql(u8, arg, "-dead_strip_dylibs")) {
dead_strip_dylibs = true;
} else if (mem.eql(u8, arg, "--gc-sections")) {