From 9f906cfd944a2dc9c5385a9e08231aa5c6f46521 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Fri, 5 Nov 2021 12:20:24 -0700 Subject: [PATCH] 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 --- glfw/build.zig | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/glfw/build.zig b/glfw/build.zig index 18a9ac10..b86f8dc3 100644 --- a/glfw/build.zig +++ b/glfw/build.zig @@ -208,7 +208,6 @@ fn linkGLFWDependencies(b: *Builder, step: *std.build.LibExeObjStep, options: Op } }, .macos => { - step.linkFramework("Cocoa"); step.linkFramework("IOKit"); step.linkFramework("CoreFoundation"); if (options.metal) { @@ -217,18 +216,18 @@ fn linkGLFWDependencies(b: *Builder, step: *std.build.LibExeObjStep, options: Op if (options.opengl) { step.linkFramework("OpenGL"); } + step.linkSystemLibrary("objc"); + step.linkFramework("AppKit"); - // 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"); + // 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 => { @@ -253,3 +252,4 @@ fn linkGLFWDependencies(b: *Builder, step: *std.build.LibExeObjStep, options: Op }, } } +