zig
zig copied to clipboard
macOS: `--libc` flag doesn't setup framework dirs for `-framework`
Zig Version
0.14.1
Steps to Reproduce and Observed Behavior
The basic issue is that src/Compilation.zig (via LibCDirs.detect) will properly set framework paths for things like clang. But src/main.zig which does framework searches does not. We should run the same detection logic on libc text files for main.zig and add that to the framework paths.
Install the macOS SDK somewhere. Create a libc txt file like this:
# The directory that contains `stdlib.h`.
# On POSIX-like systems, include directories be found with: `cc -E -Wp,-v -xc /dev/null`
include_dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/usr/include
# The system-specific include directory. May be the same as `include_dir`.
# On Windows it's the directory that includes `vcruntime.h`.
# On POSIX it's the directory that includes `sys/errno.h`.
sys_include_dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/usr/include
# The directory that contains `crt1.o` or `crt2.o`.
# On POSIX, can be found with `cc -print-file-name=crt1.o`.
# Not needed when targeting MacOS.
crt_dir=
# The directory that contains `vcruntime.lib`.
# Only needed when targeting MSVC on Windows.
msvc_lib_dir=
# The directory that contains `kernel32.lib`.
# Only needed when targeting MSVC on Windows.
kernel32_lib_dir=
# The directory that contains `crtbeginS.o` and `crtendS.o`
# Only needed when targeting Haiku.
gcc_dir=
Build:
zig build-lib empty.c -framework CoreFoundation -lc --libc libc.txt
Get an error:
error: unable to find framework 'CoreFoundation'. searched paths: none
Expected Behavior
Builds
This should probably also set the library path, since its all consistent on macOS.