glfw: do not set sysroot (prevents linking libs not in our system SDKs) (#47)

* glfw: do not set sysroot (prevents linking libs not in our system SDKs)

Fixes hexops/mach#40

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2021-10-24 21:14:13 -07:00 committed by GitHub
parent 8466a5ff08
commit 3d38f56af6
Failed to generate hash of commit

View file

@ -215,6 +215,14 @@ 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 unless linked explicitly here.
step.linkFramework("CoreGraphics");
step.linkFramework("CoreServices");
step.linkFramework("AppKit");
step.linkFramework("Foundation");
step.linkSystemLibrary("objc");
}, },
else => { else => {
// Assume Linux-like // Assume Linux-like
@ -241,17 +249,16 @@ fn linkGLFWDependencies(b: *Builder, step: *std.build.LibExeObjStep, options: Op
} }
fn includeSdkMacOS(b: *Builder, step: *std.build.LibExeObjStep) void { fn includeSdkMacOS(b: *Builder, step: *std.build.LibExeObjStep) void {
step.addFrameworkDir("/System/Library/Frameworks");
step.addSystemIncludeDir("/usr/include");
step.addLibPath("/usr/lib");
// Add the SDK as a sysroot. Using this instead of, say, absolute framework/include/lib paths
// to the SDK without a sysroot ensures that we use the same libraries/frameworks/headers on
// Mac hosts and non-Mac hosts.
const sdk_root_dir = getSdkRoot(b.allocator, "sdk-macos-11.3") catch unreachable; const sdk_root_dir = getSdkRoot(b.allocator, "sdk-macos-11.3") catch unreachable;
defer b.allocator.free(sdk_root_dir);
var sdk_sysroot = std.fs.path.join(b.allocator, &.{ sdk_root_dir, "root/" }) catch unreachable; var sdk_framework_dir = std.fs.path.join(b.allocator, &.{ sdk_root_dir, "root/System/Library/Frameworks" }) catch unreachable;
b.sysroot = sdk_sysroot; step.addFrameworkDir(sdk_framework_dir);
var sdk_include_dir = std.fs.path.join(b.allocator, &.{ sdk_root_dir, "root/usr/include" }) catch unreachable;
step.addSystemIncludeDir(sdk_include_dir);
var sdk_lib_dir = std.fs.path.join(b.allocator, &.{ sdk_root_dir, "root/usr/lib" }) catch unreachable;
step.addLibPath(sdk_lib_dir);
} }
fn includeSdkLinuxX8664(b: *Builder, step: *std.build.LibExeObjStep) void { fn includeSdkLinuxX8664(b: *Builder, step: *std.build.LibExeObjStep) void {