Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(build): avoid lto use without lld #2

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ pub fn build(b: *Build) void {
const lto = b.option(bool, "lto", "Enable link time optimization") orelse false;

// writing WritingLibFiles isn't implemented on windows
// and zld the only linker suppored on macos
// and zld the only linker supported on macos
const is_macos = builtin.os.tag == .macos;
const is_windows = builtin.os.tag == .windows;
const use_lld = if (is_macos) false else if (is_windows) true else switch (optimize) {
.Debug => false,
else => true,
};
const use_lto = if (is_macos) false else if (use_lld) lto else false;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went back and forth on whether to keep is_macos here. Ended up keeping it so a reader does not need to keep the additional context in mind. But can nix it if wanted.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought I was thorough but didn't catch this, Thanks.


const liblmdb = b.addStaticLibrary(.{
.name = "lmdb",
.target = target,
Expand All @@ -40,7 +42,7 @@ pub fn build(b: *Build) void {
},
.use_lld = use_lld,
});
liblmdb.want_lto = if (is_macos) false else lto;
liblmdb.want_lto = use_lto;
liblmdb.root_module.sanitize_c = false;

const liblmdb_src = .{
Expand Down