Skip to content

Commit 6acec0f

Browse files
authored
fix(build): avoid lto use without lld (#2)
Co-authored-by: Ronald M Zielaznicki <[email protected]>
1 parent 825c6a5 commit 6acec0f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

build.zig

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ pub fn build(b: *Build) void {
2121
const lto = b.option(bool, "lto", "Enable link time optimization") orelse false;
2222

2323
// writing WritingLibFiles isn't implemented on windows
24-
// and zld the only linker suppored on macos
24+
// and zld the only linker supported on macos
2525
const is_macos = builtin.os.tag == .macos;
2626
const is_windows = builtin.os.tag == .windows;
2727
const use_lld = if (is_macos) false else if (is_windows) true else switch (optimize) {
2828
.Debug => false,
2929
else => true,
3030
};
31+
const use_lto = if (is_macos) false else if (use_lld) lto else false;
32+
3133
const liblmdb = b.addStaticLibrary(.{
3234
.name = "lmdb",
3335
.target = target,
@@ -40,7 +42,7 @@ pub fn build(b: *Build) void {
4042
},
4143
.use_lld = use_lld,
4244
});
43-
liblmdb.want_lto = if (is_macos) false else lto;
45+
liblmdb.want_lto = use_lto;
4446
liblmdb.root_module.sanitize_c = false;
4547

4648
const liblmdb_src = .{

0 commit comments

Comments
 (0)