glfw: fix linking difference between sysroot and non-sysroot (#63)

This effectively gives us the dependencies we need in any case, and works around ziglang/zig#10103

Importantly, this removes a blocker for landing WebGPU support in hexops/mach#62

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2021-11-05 12:20:24 -07:00 committed by GitHub
parent 9bc9984930
commit 9f906cfd94
Failed to generate hash of commit

View file

@ -208,7 +208,6 @@ fn linkGLFWDependencies(b: *Builder, step: *std.build.LibExeObjStep, options: Op
} }
}, },
.macos => { .macos => {
step.linkFramework("Cocoa");
step.linkFramework("IOKit"); step.linkFramework("IOKit");
step.linkFramework("CoreFoundation"); step.linkFramework("CoreFoundation");
if (options.metal) { if (options.metal) {
@ -217,18 +216,18 @@ fn linkGLFWDependencies(b: *Builder, step: *std.build.LibExeObjStep, options: Op
if (options.opengl) { if (options.opengl) {
step.linkFramework("OpenGL"); step.linkFramework("OpenGL");
} }
// These are dependencies of the above frameworks, but are not properly picked by zld
// when cross-compiling Windows/Linux -> MacOS, or on MacOS (no XCode) with `zig build test -Dtarget=aarch64-macos`
// unless linked explicitly here.
//
// If b.sysroot is set, however, these must NOT be specified. This is a bug in zld.
if (b.sysroot == null) {
step.linkFramework("CoreGraphics");
step.linkFramework("CoreServices");
step.linkFramework("AppKit");
step.linkFramework("Foundation");
step.linkSystemLibrary("objc"); step.linkSystemLibrary("objc");
step.linkFramework("AppKit");
// TODO(system_sdk): update MacOS system SDK so we can remove this, see:
// https://github.com/hexops/mach/pull/63#issuecomment-962141088
switch (@import("builtin").target.os.tag) {
.macos => {},
else => {
step.linkFramework("CoreServices");
step.linkFramework("CoreGraphics");
step.linkFramework("Foundation");
},
} }
}, },
else => { else => {
@ -253,3 +252,4 @@ fn linkGLFWDependencies(b: *Builder, step: *std.build.LibExeObjStep, options: Op
}, },
} }
} }