Commit 3c0238e731

Hubert Jasudowicz <hubert.jasudowicz@gmail.com>
2021-02-22 20:37:10
std/build: Add support for LTO configuration
1 parent 4f11a88
Changed files (1)
lib
lib/std/build.zig
@@ -1421,6 +1421,8 @@ pub const LibExeObjStep = struct {
     /// Overrides the default stack size
     stack_size: ?u64 = null,
 
+    want_lto: ?bool = null,
+
     const LinkObject = union(enum) {
         StaticPath: []const u8,
         OtherStep: *LibExeObjStep,
@@ -2589,6 +2591,14 @@ pub const LibExeObjStep = struct {
             }
         }
 
+        if (self.want_lto) |lto| {
+            if (lto) {
+                try zig_args.append("-flto");
+            } else {
+                try zig_args.append("-fno-lto");
+            }
+        }
+
         if (self.subsystem) |subsystem| {
             try zig_args.append("--subsystem");
             try zig_args.append(switch (subsystem) {