Forward framework dirs to embedded clang in addition to linker on macOS #3195
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
It seems that the default system/framework paths on macOS is a bit off currently (issue #2319 , #2208). Figuring out the best way to determine these paths is a bit over my head but while trying to work around the issue I do think I've encountered a bug in how zig passes arguments to
zig cc
:It seems like if you use
exe.addFrameworkDir(path)
, the path is only forwarded to the linker (-F path
), not the embedded clang (-iframework path
).Proposed solution
Forward the argument to embedded clang in addition to the linker.
Feel free to close this if my reasoning is wrong :)
To reproduce
Here is an example project: https://github.com/gustavolsson/zig-sokol-test
I'm trying to build the OpenGL app on macOS (old one 10.13.16) and get zig cc errors about Cocoa.h not being found. I want to work around the issue by explicitly specifying the path to Cocoa.framework on my specific machine,
/System/Library/Frameworks
, usingexe.addFrameworkDir(...)
:(Note that I also enable the system linker hack because once
zig cc
succeeds the linking crashes due to MachO problems, which is way over my head and I want to show that the proposed fix manages to build the code)I get the following error:
Note that the
zig cc
command does not include-iframework /System/Library/Frameworks
even though it exists in the zig build-exe command.After the proposed change in main.cpp I can successfully build the app.
zig build --verbose-cc
outputs the following: