Commit 582991a5a8

LemonBoy <thatlemon@gmail.com>
2020-03-16 09:54:11
build: Expose function-sections switch
1 parent a2432b6
Changed files (1)
lib
lib/std/build.zig
@@ -1157,8 +1157,14 @@ pub const LibExeObjStep = struct {
 
     valgrind_support: ?bool = null,
 
+    /// Create a .eh_frame_hdr section and a PT_GNU_EH_FRAME segment in the ELF
+    /// file.
     link_eh_frame_hdr: bool = false,
 
+    /// Place every function in its own section so that unused ones may be
+    /// safely garbage-collected during the linking phase.
+    link_function_sections: bool = false,
+
     /// Uses system Wine installation to run cross compiled Windows build artifacts.
     enable_wine: bool = false,
 
@@ -1884,7 +1890,9 @@ pub const LibExeObjStep = struct {
         if (self.link_eh_frame_hdr) {
             try zig_args.append("--eh-frame-hdr");
         }
-
+        if (self.link_function_sections) {
+            try zig_args.append("-ffunction-sections");
+        }
         if (self.single_threaded) {
             try zig_args.append("--single-threaded");
         }