Closed haze closed 1 year ago
Some more investigation:
Copying the libSystem.tbd gets us further:
Oddly enough, non debug versions of the compiler work with libSystem.14.tbd
added.
Seeing a similar issue on Zig version 0.11.0-dev.3258+7621e5693 running macOS Sonoma. @haze have you been able to find any temporary workarounds here yet that work? If so, mind sending over some instructions?
@morgangallant (and for anyone else either brave or forced to upgrade):
I forget whether or not you need to compile zig from source to pick up the new libSystem.tbd
files. I always build zig from source. I'm not going to upload the tbd
here, but you can easily grab it from your Xcode 15 installation. You can use this command to find the full path, like this:
fd libSystem -e=tbd (xcrun --show-sdk-path)
/Applications/Xcode-15.0.0-Beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreTelephony.framework/Support/libSystemDetermination.tbd
/Applications/Xcode-15.0.0-Beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libSystem_asan.tbd
/Applications/Xcode-15.0.0-Beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libSystem.B.tbd
/Applications/Xcode-15.0.0-Beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libSystem.B_asan.tbd
/Applications/Xcode-15.0.0-Beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd
Then you want to copy /Applications/Xcode-15.0.0-Beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd
to zig/lib/libc/darwin/
:
cp /Applications/Xcode-15.0.0-Beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd zig/lib/libc/darwin/libSystem.14.tbd
I'm unsure if there's an edge case that I'm missing. For the most part I've been able to use zig without hassle after copying the tbd
file.
For the most part I've been able to use zig without hassle after copying the tbd file.
Thanks, this worked for me. I'm using the nightly binary downloads from ziglang.org FWIW.
In summary:
$ curl https://ziglang.org/builds/zig-macos-aarch64-0.11.0-dev.3393+34d44e0c1.tar.xz -O
$ tar -xf ./zig-macos-aarch64-0.11.0-dev.3393+34d44e0c1.tar.xz
$ cp /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/lib/libSystem.tbd zig-macos-aarch64-0.11.0-dev.3393+34d44e0c1/lib/libc/darwin/libSystem.14.tbd
$ alias zig='./zig-macos-aarch64-0.11.0-dev.3393+34d44e0c1/zig'
Then zig build run
works. Maybe augmenting $PATH would be better.
Thank you all! Worked like a charm :)
For those who stumble onto this thread in the future, following @StanislavNikolov's solution to the tee solved the problem. Only step not mentioned was that I had to install the updated Command Line Tools for Xcode 15 Beta (from here) to get the MacOSX14.sdk
file.
I am converting this issue into a tracking issue for macOS 14 Sonoma and related problems.
has there been any progress on this?
has there been any progress on this?
The PR mentioned above should be rebased off of main. From my experience, nix doesn’t work still, but natively it should work. If you don’t want to compile zig again with the new branch, you can use the workarounds mentioned earlier in the discussion
Thank you team, it worked for me.
Just beware my distribution contains libSystem.B.tbd
instead.
@kprotty and myself just found out a couple of days ago that, even with the suggested fix involving moving the libSystem.tbd
file to the right place, it seems the Zig compiler is passing the wrong CPU flags.
We found this because I was playing around with some AES primitives from std.crypto
but couldn't figure out why it was falling back to the non-accelerated software implementation of it. Passing -Dcpu=apple_latest
seems to fix the issue.
/cc @jedisct1
@kprotty and myself just found out a couple of days ago that, even with the suggested fix involving moving the
libSystem.tbd
file to the right place, it seems the Zig compiler is passing the wrong CPU flags.We found this because I was playing around with some AES primitives from
std.crypto
but couldn't figure out why it was falling back to the non-accelerated software implementation of it. Passing-Dcpu=apple_latest
seems to fix the issue./cc @jedisct1
This should be filed as a separate issue as it has nothing to do with the OS version.
This should be filed as a separate issue as it has nothing to do with the OS version. — @kubkon
Given that this only happens in Sonoma, and that if you just zig build
without that flag in Ventura everything works like it should, I would say that this actually seems to have something to do with the OS version?
If you still think I should move this into a separate issue just let me know 👍
This should be filed as a separate issue as it has nothing to do with the OS version. — @kubkon
Given that this only happens in Sonoma, and that if you just
zig build
without that flag in Ventura everything works like it should, I would say that this actually seems to have something to do with the OS version?If you still think I should move this into a separate issue just let me know 👍
I would strongly believe that to be a coincidence.
In summary:
$ curl https://ziglang.org/builds/zig-macos-aarch64-0.11.0-dev.3393+34d44e0c1.tar.xz -O $ tar -xf ./zig-macos-aarch64-0.11.0-dev.3393+34d44e0c1.tar.xz $ cp /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/lib/libSystem.tbd zig-macos-aarch64-0.11.0-dev.3393+34d44e0c1/lib/libc/darwin/libSystem.14.tbd $ alias zig='./zig-macos-aarch64-0.11.0-dev.3393+34d44e0c1/zig'
Then
zig build run
works. Maybe augmenting $PATH would be better.
If you don't have full XCode installed and instead just have the command line tools (from xcode-select ...
) then you'll find libSystem.tbd
here instead:
ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX14.5.sdk/usr/lib/libSystem.tbd /opt/homebrew/Cellar/zig/0.13.0/lib/zig/libc/darwin/libSystem.tbd
⚠️ Note the MacOSX14.5.sdk
part of the path and the zig version/location will change over time for newer versions of MacOS and zig, e.g. MacOSX15.1.sdk
, and where you've installed zig to
Zig Version
0.11.0-dev.3380+7e0a02ee2
Steps to Reproduce and Observed Behavior
On a computer running macOS 14 Sonoma (23A5257q):
I was able to successfully link the programs by using the intermediary object files in
zig-cache
, or by usingbuild-obj
by usingzld
built from zld HEAD, or the Xcode 15 clang.When using
—-verbose-link
and copying thezig ld
command (does that even still exist?) and replacing it withzld
, it works.Expected Behavior
The compilation process should succeed.