Now that Zig ships macOS libc headers, Zig no longer needs to add the system include directory for linking libc. However, when the programmer tries to link other system libraries, for example -lcurl, Zig still needs to add the include directory into the include path.
Otherwise this results in a compile error due to missing header files.
As a workaround, one can use zig libc to show the include paths and manually pass -I (or addIncludeDir in build.zig) for the system include dirs.
We have this nice logic to decide to detect native paths:
if (cross_target.isNativeOs() and (system_libs.items.len!=0orwant_native_include_dirs)) {
constpaths=std.zig.system.NativePaths.detect(arena) catch|err| {But the implementation of system.NativePaths.detect is simply incorrect for macOS. It should include at least the same include path as zig libc but instead it includes a bunch of Linux directories that are non-existent on macOS, leading to linker warnings.
Now that Zig ships macOS libc headers, Zig no longer needs to add the system include directory for linking libc. However, when the programmer tries to link other system libraries, for example
-lcurl, Zig still needs to add the include directory into the include path.Otherwise this results in a compile error due to missing header files.
As a workaround, one can use
zig libcto show the include paths and manually pass-I(oraddIncludeDirin build.zig) for the system include dirs.We have this nice logic to decide to detect native paths:
But the implementation of
system.NativePaths.detectis simply incorrect for macOS. It should include at least the same include path aszig libcbut instead it includes a bunch of Linux directories that are non-existent on macOS, leading to linker warnings.