| author | |
| committer | |
| log | 7733b5dbe603033a1ed9e8d0146ef7432d5ffd5b |
| tree | c8f2ff9bdd944039b012e05ec30ffd7126e75c88 |
| parent | 227788e6d5025933d6d70086fb939dcf487fee0a |
| signature |
Step.Compile: use LtoMode enum for lto option7 files changed, 24 insertions(+), 12 deletions(-)
lib/std/Build/Step/Compile.zig+14-1| ... | @@ -167,6 +167,9 @@ discard_local_symbols: bool = false, | ... | @@ -167,6 +167,9 @@ discard_local_symbols: bool = false, |
| 167 | /// Position Independent Executable | 167 | /// Position Independent Executable |
| 168 | pie: ?bool = null, | 168 | pie: ?bool = null, |
| 169 | 169 | ||
| 170 | /// Link Time Optimization mode | ||
| 171 | lto: ?std.zig.LtoMode = null, | ||
| 172 | |||
| 170 | dll_export_fns: ?bool = null, | 173 | dll_export_fns: ?bool = null, |
| 171 | 174 | ||
| 172 | subsystem: ?std.Target.SubSystem = null, | 175 | subsystem: ?std.Target.SubSystem = null, |
| ... | @@ -185,7 +188,9 @@ force_undefined_symbols: std.StringHashMap(void), | ... | @@ -185,7 +188,9 @@ force_undefined_symbols: std.StringHashMap(void), |
| 185 | /// Overrides the default stack size | 188 | /// Overrides the default stack size |
| 186 | stack_size: ?u64 = null, | 189 | stack_size: ?u64 = null, |
| 187 | 190 | ||
| 191 | /// Deprecated; prefer using `lto`. | ||
| 188 | want_lto: ?bool = null, | 192 | want_lto: ?bool = null, |
| 193 | |||
| 189 | use_llvm: ?bool, | 194 | use_llvm: ?bool, |
| 190 | use_lld: ?bool, | 195 | use_lld: ?bool, |
| 191 | 196 | ||
| ... | @@ -1711,7 +1716,15 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 { | ... | @@ -1711,7 +1716,15 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 { |
| 1711 | } | 1716 | } |
| 1712 | 1717 | ||
| 1713 | try addFlag(&zig_args, "PIE", compile.pie); | 1718 | try addFlag(&zig_args, "PIE", compile.pie); |
| 1714 | try addFlag(&zig_args, "lto", compile.want_lto); | 1719 | |
| 1720 | if (compile.lto) |lto| { | ||
| 1721 | try zig_args.append(switch (lto) { | ||
| 1722 | .full => "-flto=full", | ||
| 1723 | .thin => "-flto=thin", | ||
| 1724 | .none => "-fno-lto", | ||
| 1725 | }); | ||
| 1726 | } else try addFlag(&zig_args, "lto", compile.want_lto); | ||
| 1727 | |||
| 1715 | try addFlag(&zig_args, "sanitize-coverage-trace-pc-guard", compile.sanitize_coverage_trace_pc_guard); | 1728 | try addFlag(&zig_args, "sanitize-coverage-trace-pc-guard", compile.sanitize_coverage_trace_pc_guard); |
| 1716 | 1729 | ||
| 1717 | if (compile.subsystem) |subsystem| { | 1730 | if (compile.subsystem) |subsystem| { |
lib/std/zig.zig+2| ... | @@ -313,6 +313,8 @@ pub const BuildId = union(enum) { | ... | @@ -313,6 +313,8 @@ pub const BuildId = union(enum) { |
| 313 | } | 313 | } |
| 314 | }; | 314 | }; |
| 315 | 315 | ||
| 316 | pub const LtoMode = enum { none, full, thin }; | ||
| 317 | |||
| 316 | /// Renders a `std.Target.Cpu` value into a textual representation that can be parsed | 318 | /// Renders a `std.Target.Cpu` value into a textual representation that can be parsed |
| 317 | /// via the `-mcpu` flag passed to the Zig compiler. | 319 | /// via the `-mcpu` flag passed to the Zig compiler. |
| 318 | /// Appends the result to `buffer`. | 320 | /// Appends the result to `buffer`. |
src/Compilation.zig-1| ... | @@ -1074,7 +1074,6 @@ pub const CreateOptions = struct { | ... | @@ -1074,7 +1074,6 @@ pub const CreateOptions = struct { |
| 1074 | /// executable this field is ignored. | 1074 | /// executable this field is ignored. |
| 1075 | want_compiler_rt: ?bool = null, | 1075 | want_compiler_rt: ?bool = null, |
| 1076 | want_ubsan_rt: ?bool = null, | 1076 | want_ubsan_rt: ?bool = null, |
| 1077 | want_lto: ?bool = null, | ||
| 1078 | function_sections: bool = false, | 1077 | function_sections: bool = false, |
| 1079 | data_sections: bool = false, | 1078 | data_sections: bool = false, |
| 1080 | time_report: bool = false, | 1079 | time_report: bool = false, |
src/Compilation/Config.zig+3-5| ... | @@ -48,7 +48,7 @@ use_lib_llvm: bool, | ... | @@ -48,7 +48,7 @@ use_lib_llvm: bool, |
| 48 | /// and updates the final binary. | 48 | /// and updates the final binary. |
| 49 | use_lld: bool, | 49 | use_lld: bool, |
| 50 | c_frontend: CFrontend, | 50 | c_frontend: CFrontend, |
| 51 | lto: LtoMode, | 51 | lto: std.zig.LtoMode, |
| 52 | /// WASI-only. Type of WASI execution model ("command" or "reactor"). | 52 | /// WASI-only. Type of WASI execution model ("command" or "reactor"). |
| 53 | /// Always set to `command` for non-WASI targets. | 53 | /// Always set to `command` for non-WASI targets. |
| 54 | wasi_exec_model: std.builtin.WasiExecModel, | 54 | wasi_exec_model: std.builtin.WasiExecModel, |
| ... | @@ -66,8 +66,6 @@ san_cov_trace_pc_guard: bool, | ... | @@ -66,8 +66,6 @@ san_cov_trace_pc_guard: bool, |
| 66 | 66 | ||
| 67 | pub const CFrontend = enum { clang, aro }; | 67 | pub const CFrontend = enum { clang, aro }; |
| 68 | 68 | ||
| 69 | pub const LtoMode = enum { none, full, thin }; | ||
| 70 | |||
| 71 | pub const DebugFormat = union(enum) { | 69 | pub const DebugFormat = union(enum) { |
| 72 | strip, | 70 | strip, |
| 73 | dwarf: std.dwarf.Format, | 71 | dwarf: std.dwarf.Format, |
| ... | @@ -105,7 +103,7 @@ pub const Options = struct { | ... | @@ -105,7 +103,7 @@ pub const Options = struct { |
| 105 | use_lib_llvm: ?bool = null, | 103 | use_lib_llvm: ?bool = null, |
| 106 | use_lld: ?bool = null, | 104 | use_lld: ?bool = null, |
| 107 | use_clang: ?bool = null, | 105 | use_clang: ?bool = null, |
| 108 | lto: ?LtoMode = null, | 106 | lto: ?std.zig.LtoMode = null, |
| 109 | /// WASI-only. Type of WASI execution model ("command" or "reactor"). | 107 | /// WASI-only. Type of WASI execution model ("command" or "reactor"). |
| 110 | wasi_exec_model: ?std.builtin.WasiExecModel = null, | 108 | wasi_exec_model: ?std.builtin.WasiExecModel = null, |
| 111 | import_memory: ?bool = null, | 109 | import_memory: ?bool = null, |
| ... | @@ -288,7 +286,7 @@ pub fn resolve(options: Options) ResolveError!Config { | ... | @@ -288,7 +286,7 @@ pub fn resolve(options: Options) ResolveError!Config { |
| 288 | break :b .clang; | 286 | break :b .clang; |
| 289 | }; | 287 | }; |
| 290 | 288 | ||
| 291 | const lto: LtoMode = b: { | 289 | const lto: std.zig.LtoMode = b: { |
| 292 | if (!use_lld) { | 290 | if (!use_lld) { |
| 293 | // zig ld LTO support is tracked by | 291 | // zig ld LTO support is tracked by |
| 294 | // https://github.com/ziglang/zig/issues/8680 | 292 | // https://github.com/ziglang/zig/issues/8680 |
src/codegen/llvm.zig+1-1| ... | @@ -771,7 +771,7 @@ pub const Object = struct { | ... | @@ -771,7 +771,7 @@ pub const Object = struct { |
| 771 | time_report: bool, | 771 | time_report: bool, |
| 772 | sanitize_thread: bool, | 772 | sanitize_thread: bool, |
| 773 | fuzz: bool, | 773 | fuzz: bool, |
| 774 | lto: Compilation.Config.LtoMode, | 774 | lto: std.zig.LtoMode, |
| 775 | }; | 775 | }; |
| 776 | 776 | ||
| 777 | pub fn emit(o: *Object, options: EmitOptions) error{ LinkFailure, OutOfMemory }!void { | 777 | pub fn emit(o: *Object, options: EmitOptions) error{ LinkFailure, OutOfMemory }!void { |
test/standalone/c_compiler/build.zig+3-3| ... | @@ -43,12 +43,12 @@ fn add( | ... | @@ -43,12 +43,12 @@ fn add( |
| 43 | switch (target.result.os.tag) { | 43 | switch (target.result.os.tag) { |
| 44 | .windows => { | 44 | .windows => { |
| 45 | // https://github.com/ziglang/zig/issues/8531 | 45 | // https://github.com/ziglang/zig/issues/8531 |
| 46 | exe_cpp.want_lto = false; | 46 | exe_cpp.lto = .none; |
| 47 | }, | 47 | }, |
| 48 | .macos => { | 48 | .macos => { |
| 49 | // https://github.com/ziglang/zig/issues/8680 | 49 | // https://github.com/ziglang/zig/issues/8680 |
| 50 | exe_cpp.want_lto = false; | 50 | exe_cpp.lto = .none; |
| 51 | exe_c.want_lto = false; | 51 | exe_c.lto = .none; |
| 52 | }, | 52 | }, |
| 53 | else => {}, | 53 | else => {}, |
| 54 | } | 54 | } |
test/tests.zig+1-1| ... | @@ -1681,7 +1681,7 @@ pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step { | ... | @@ -1681,7 +1681,7 @@ pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step { |
| 1681 | 1681 | ||
| 1682 | // This test is intentionally trying to check if the external ABI is | 1682 | // This test is intentionally trying to check if the external ABI is |
| 1683 | // done properly. LTO would be a hindrance to this. | 1683 | // done properly. LTO would be a hindrance to this. |
| 1684 | test_step.want_lto = false; | 1684 | test_step.lto = .none; |
| 1685 | 1685 | ||
| 1686 | const run = b.addRunArtifact(test_step); | 1686 | const run = b.addRunArtifact(test_step); |
| 1687 | run.skip_foreign_checks = true; | 1687 | run.skip_foreign_checks = true; |