-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
zig cc: unsupported darwin linker args #4841
Comments
Oh, one more thing I forgot to mention:
If I then use it like |
you're missing edit: oops, I see that you noticed this. can you confirm that it's a problem on zig's end though? |
The thing is: if I use a single-threaded make, it does not happen. It seems to happen only with |
You could verify this with |
Seems like it is a make issue, because make dumps a wrong command line in verbose mode. I tried to use the |
(2) is a make issue as noted above As for (1) I am repurposing this issue to address it. If you run into any more independent problems, let's handle those in new issues. |
Alright so the remaining issue has to do with the fact that Zig uses LLD as the linker, and until very recently the mach-o LLD code was unmaintained. It does not support these flags. However now I expect this new team to quickly bring LLD up to speed for mach-o, and so I expect this issue to be resolved with the release of LLVM 11 (in 6 months). |
@andrewrk BTW, I was about to download the latest builds from https://ziglang.org/download/#release-master, but it seems to be not updated since yesterday for some reason. Don't know if it is expected or not. |
I don't quite understand this comment. Couldn't Zig just pass the provided Or do you say that the error messages I see are from the LLD linker and not from Zig? |
Regarding (2) and (4), my impression it is essentially the same problem, which is a space between
I'll test and report back ASAP. |
Thanks for letting me know. Fixed in ziglang/www.ziglang.org@88683aa (had to update the update-download-page.zig script to the latest zig std lib after making breaking changes). |
Which one? |
E.g. |
sorry, I meant, which linker? |
Clang on MacOS uses |
The macOS linker |
Ah, OK. Thanks for the clarifications regarding those linker issues! I cross my fingers that LLD's macos support will be improved soon :-) |
Quick question: Have you considered adding something like |
@andrewrk I tried with the latest build, to check if I reproduced with a very simple
And I get The following command failed: If I try a slightly different command-line without |
Thanks for the report. Solved in f8cc6a1. |
This is a big topic, too big to answer as a quick question |
Great! I can confirm that |
Good to know. Let's revisit the linker issues once LLVM 11 is a bit further along in the release cycle. |
LLVM 11 seems to have be have been released in October. Is this fixed? |
I can shed some more light on (1):
All of the flags with the exception of While not a permanent fix, it is now possible to fall back to the system linker on macOS by setting |
These linker args are now supported by zld. $ sw_vers
ProductName: macOS
ProductVersion: 13.1
BuildVersion: 22C65
$ zig version
0.11.0-dev.1023+1c711b0a6
$ zig c++ -o main main.cpp -Wl,-search_paths_first -Wl,-headerpad_max_install_names -Wl,-force_load -Wl,/opt/local-2022.10/lib/libz.a -v
MachO Flush... zig ld -dynamic -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -search_paths_first -headerpad_max_install_names /opt/local-2022.10/lib/libz.a /Users/mike/project/zig/work/main/zig-cache/o/a8ee99607d7d9ab78e53561974b39bdd/main.o /Users/mike/project/zig/work/main/zig-cache/o/d56d9e695295e64a617c9618d425bcc5/libcompiler_rt.a /Users/mike/project/zig/work/main/zig-cache/o/1c116bd4f79c02580e72b1128a68a868/libc++abi.a /Users/mike/project/zig/work/main/zig-cache/o/5b02b02b8b0a4913d1f1edf075b37d0c/libc++.a -o main -lSystem -lc -L/usr/lib -F/System/Library/Frameworks -force_load /opt/local-2022.10/lib/libz.a |
Thanks a lot for adding
zig cc
andzig c++
functionality. It is really useful.I tried to use
zig c++
instead of the standard LLVM toolchain for one of my projects. I build it on MacOS. In general, it mostly works, but I've discovered the following issues:-Wl,my_linker_option
. They are important for proper linking of the project. But some of them are not supported yet.make -j 2
I start seeing some issues:It seems as if there is a race condition somewhere. As you can seen in zig's command line it misses
c++
after zig somehow.ninja
and then runninja
, I see issues with dependency tracking supported by clang. Specifically, there seems to be an issue with handling of-MF
flags (see below). Same project can be build just fine if I use the vanilla LLVM toolchain.It would be nice if these issues could be resolved.
Please let me know if I can provide any additional information that would allow to fix these issues.
The text was updated successfully, but these errors were encountered: