Skip to content

std.system.NativePaths does not properly add macOS include directory #7559

Description

@andrewrk

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavioros-macosmacOS

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions