mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
Merge pull request #23501 from imreallybadatnames/master
Step.Compile: use LtoMode enum for lto option
This commit is contained in:
parent
227788e6d5
commit
7733b5dbe6
7 changed files with 24 additions and 12 deletions
|
|
@ -167,6 +167,9 @@ discard_local_symbols: bool = false,
|
|||
/// Position Independent Executable
|
||||
pie: ?bool = null,
|
||||
|
||||
/// Link Time Optimization mode
|
||||
lto: ?std.zig.LtoMode = null,
|
||||
|
||||
dll_export_fns: ?bool = null,
|
||||
|
||||
subsystem: ?std.Target.SubSystem = null,
|
||||
|
|
@ -185,7 +188,9 @@ force_undefined_symbols: std.StringHashMap(void),
|
|||
/// Overrides the default stack size
|
||||
stack_size: ?u64 = null,
|
||||
|
||||
/// Deprecated; prefer using `lto`.
|
||||
want_lto: ?bool = null,
|
||||
|
||||
use_llvm: ?bool,
|
||||
use_lld: ?bool,
|
||||
|
||||
|
|
@ -1711,7 +1716,15 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 {
|
|||
}
|
||||
|
||||
try addFlag(&zig_args, "PIE", compile.pie);
|
||||
try addFlag(&zig_args, "lto", compile.want_lto);
|
||||
|
||||
if (compile.lto) |lto| {
|
||||
try zig_args.append(switch (lto) {
|
||||
.full => "-flto=full",
|
||||
.thin => "-flto=thin",
|
||||
.none => "-fno-lto",
|
||||
});
|
||||
} else try addFlag(&zig_args, "lto", compile.want_lto);
|
||||
|
||||
try addFlag(&zig_args, "sanitize-coverage-trace-pc-guard", compile.sanitize_coverage_trace_pc_guard);
|
||||
|
||||
if (compile.subsystem) |subsystem| {
|
||||
|
|
|
|||
|
|
@ -313,6 +313,8 @@ pub const BuildId = union(enum) {
|
|||
}
|
||||
};
|
||||
|
||||
pub const LtoMode = enum { none, full, thin };
|
||||
|
||||
/// Renders a `std.Target.Cpu` value into a textual representation that can be parsed
|
||||
/// via the `-mcpu` flag passed to the Zig compiler.
|
||||
/// Appends the result to `buffer`.
|
||||
|
|
|
|||
|
|
@ -1074,7 +1074,6 @@ pub const CreateOptions = struct {
|
|||
/// executable this field is ignored.
|
||||
want_compiler_rt: ?bool = null,
|
||||
want_ubsan_rt: ?bool = null,
|
||||
want_lto: ?bool = null,
|
||||
function_sections: bool = false,
|
||||
data_sections: bool = false,
|
||||
time_report: bool = false,
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ use_lib_llvm: bool,
|
|||
/// and updates the final binary.
|
||||
use_lld: bool,
|
||||
c_frontend: CFrontend,
|
||||
lto: LtoMode,
|
||||
lto: std.zig.LtoMode,
|
||||
/// WASI-only. Type of WASI execution model ("command" or "reactor").
|
||||
/// Always set to `command` for non-WASI targets.
|
||||
wasi_exec_model: std.builtin.WasiExecModel,
|
||||
|
|
@ -66,8 +66,6 @@ san_cov_trace_pc_guard: bool,
|
|||
|
||||
pub const CFrontend = enum { clang, aro };
|
||||
|
||||
pub const LtoMode = enum { none, full, thin };
|
||||
|
||||
pub const DebugFormat = union(enum) {
|
||||
strip,
|
||||
dwarf: std.dwarf.Format,
|
||||
|
|
@ -105,7 +103,7 @@ pub const Options = struct {
|
|||
use_lib_llvm: ?bool = null,
|
||||
use_lld: ?bool = null,
|
||||
use_clang: ?bool = null,
|
||||
lto: ?LtoMode = null,
|
||||
lto: ?std.zig.LtoMode = null,
|
||||
/// WASI-only. Type of WASI execution model ("command" or "reactor").
|
||||
wasi_exec_model: ?std.builtin.WasiExecModel = null,
|
||||
import_memory: ?bool = null,
|
||||
|
|
@ -288,7 +286,7 @@ pub fn resolve(options: Options) ResolveError!Config {
|
|||
break :b .clang;
|
||||
};
|
||||
|
||||
const lto: LtoMode = b: {
|
||||
const lto: std.zig.LtoMode = b: {
|
||||
if (!use_lld) {
|
||||
// zig ld LTO support is tracked by
|
||||
// https://github.com/ziglang/zig/issues/8680
|
||||
|
|
|
|||
|
|
@ -771,7 +771,7 @@ pub const Object = struct {
|
|||
time_report: bool,
|
||||
sanitize_thread: bool,
|
||||
fuzz: bool,
|
||||
lto: Compilation.Config.LtoMode,
|
||||
lto: std.zig.LtoMode,
|
||||
};
|
||||
|
||||
pub fn emit(o: *Object, options: EmitOptions) error{ LinkFailure, OutOfMemory }!void {
|
||||
|
|
|
|||
|
|
@ -43,12 +43,12 @@ fn add(
|
|||
switch (target.result.os.tag) {
|
||||
.windows => {
|
||||
// https://github.com/ziglang/zig/issues/8531
|
||||
exe_cpp.want_lto = false;
|
||||
exe_cpp.lto = .none;
|
||||
},
|
||||
.macos => {
|
||||
// https://github.com/ziglang/zig/issues/8680
|
||||
exe_cpp.want_lto = false;
|
||||
exe_c.want_lto = false;
|
||||
exe_cpp.lto = .none;
|
||||
exe_c.lto = .none;
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1681,7 +1681,7 @@ pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step {
|
|||
|
||||
// This test is intentionally trying to check if the external ABI is
|
||||
// done properly. LTO would be a hindrance to this.
|
||||
test_step.want_lto = false;
|
||||
test_step.lto = .none;
|
||||
|
||||
const run = b.addRunArtifact(test_step);
|
||||
run.skip_foreign_checks = true;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue