-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorfrontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.zig ccZig as a drop-in C compiler featureZig as a drop-in C compiler feature
Milestone
Description
Zig Version
0.14.0-dev.3008+7cef585f5
Steps to Reproduce and Observed Behavior
I wrote this helper function:
pub fn linkMacOSSDK(b: *Builder, compile: *std.Build.Step.Compile) void {
if (b.sysroot == null) {
@panic(" Pass --sysroot <path/to/macOS/SDK>");
}
const path_include = b.pathJoin(&.{ b.sysroot.?, "/usr/include" });
//const path_include = "/usr/include";
//const path_lib = b.pathJoin(&.{ b.sysroot.?, "/usr/lib" });
const path_lib = "/usr/lib";
const path_framework = b.pathJoin(&.{ b.sysroot.?, "/System/Library/Frameworks" });
//const path_framework = "/System/Library/Frameworks";
std.debug.print("Exposing macOS SDK to {s}:\n", .{compile.name});
std.debug.print("\x1b[2m", .{});
std.debug.print(" + include path: {s}\n", .{path_include});
std.debug.print(" + library path: {s}\n", .{path_lib});
std.debug.print(" + framework path: {s}\n", .{path_framework});
std.debug.print("\x1b[0m", .{});
compile.addSystemIncludePath(.{ .cwd_relative = path_include });
compile.addLibraryPath(.{ .cwd_relative = path_lib });
compile.addFrameworkPath(.{ .cwd_relative = path_framework });
}And it works (yey! 🥳) But it shows that not everywhere the sysroot is handled the same way. I have to manually prepend the sysroot to the include search path and the frameworks search path, but NOT to the library search path. When I did prepend it, I got an error saying something along the lines of:
cannot open directory: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/
Notice that it basically looked in: sysroot/sysroot/usr/lib.
Expected Behavior
Specifying a sysroot should probably alter the behaviour of all search paths? If not, then they should probably at least behave uniformly across addSystemIncludePath, addLibraryPath, and addFrameworkPath.
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorfrontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.zig ccZig as a drop-in C compiler featureZig as a drop-in C compiler feature