authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-10-18 00:01:33-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-10-18 17:47:57-04:00
logec21da0d51afa9b688ed99425b307e23a9c57a07
treec4550372d33a445e2da6ff9eebab0a955e56eea9
parentf9a34131128dffaeac7561afe34956ec2ee17fef

compiler: fix LTO availability logic

Before this commit, the logic would fail with a "LTO not available" error if the user set `-fno-lto` which doesn't make sense. This commit corrects the logic to understand when the user is explicitly requesting to turn LTO off.

1 files changed, 5 insertions(+), 5 deletions(-)

src/Compilation.zig+5-5
......@@ -946,13 +946,13 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
946946 };
947947
948948 const lto = blk: {
949 if (options.want_lto) |explicit| {
950 if (!use_lld and !options.target.isDarwin())
949 if (options.want_lto) |want_lto| {
950 if (want_lto and !use_lld and !options.target.isDarwin())
951951 return error.LtoUnavailableWithoutLld;
952 break :blk explicit;
952 break :blk want_lto;
953953 } else if (!use_lld) {
954 // TODO zig ld LTO support
955 // See https://github.com/ziglang/zig/issues/8680
954 // zig ld LTO support is tracked by
955 // https://github.com/ziglang/zig/issues/8680
956956 break :blk false;
957957 } else if (options.c_source_files.len == 0) {
958958 break :blk false;