aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2022-07-02 08:45:33 +0200
committerJakub Konka <kubkon@jakubkonka.com>2022-07-22 16:58:20 +0200
commit44ee42c6bc46b20b1dac1f0b3a44512a8ada9c93 (patch)
tree699e713d9a9e0e5b7c97656d8baee9ed1a4cf88a /src
parent8e75ba653b03477229cf72211e8a8bfe7b071254 (diff)
downloadzig-44ee42c6bc46b20b1dac1f0b3a44512a8ada9c93.tar.gz
zig-44ee42c6bc46b20b1dac1f0b3a44512a8ada9c93.zip
cli: parse -dead_strip MachO linker flag
Diffstat (limited to 'src')
-rw-r--r--src/link/MachO.zig7
-rw-r--r--src/main.zig5
2 files changed, 12 insertions, 0 deletions
diff --git a/src/link/MachO.zig b/src/link/MachO.zig
index d659d994eb..ad0aac94ca 100644
--- a/src/link/MachO.zig
+++ b/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");
}
diff --git a/src/main.zig b/src/main.zig
index 823cbf8757..3af8d48d99 100644
--- a/src/main.zig
+++ b/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")) {