Skip to content

Commit 3b88cf7

Browse files
committed
zig api: LLD as default linker choice on Windows
Now simply typing 'zig build' works on both windows AND linux!
1 parent d35cf15 commit 3b88cf7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

build.zig

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,19 @@ pub fn build(b: *std.Build) !void {
4747
const use_llvm = if (b.option(bool, "no_llvm", "Use Zig self-hosted compiler codegen backend & linker")) |val|
4848
!val else null;
4949

50+
const use_lld = b.option(bool, "use_lld", "(default: true on Windows, false elsewhere) Force use of LLD or Zig's self-hosted linker. Throws warnings due to a zig compiler bug.")
51+
orelse switch(target.result.os.tag) {
52+
.windows => true,
53+
else => false,
54+
};
55+
5056
const config = .{
5157
.target = target,
5258
.optimize = optimize,
5359

5460
.linkage = b.option(LinkMode, "linkage", "(default: static) Build libremidi as a static or dynamic/shared library") orelse .static,
5561
.use_llvm = use_llvm,
56-
.use_lld = b.option(bool, "use_lld", "(default: false) Forces LLD for linking instead of Zig's linker. Throws warnings due to a zig compiler bug.") orelse false,
62+
.use_lld = use_lld,
5763

5864
.no_coremidi = b.option(bool, "no_coremidi", "Disable CoreMidi back-end") orelse false,
5965
.no_winmm = b.option(bool, "no_winmm", "Disable WinMM back-end") orelse false,

0 commit comments

Comments
 (0)