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