Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

__builtin_thread_pointer broken on aarch64 macOS (at least with apple clang 16) #346

Open
thomcc opened this issue Nov 5, 2024 · 2 comments

Comments

@thomcc
Copy link

thomcc commented Nov 5, 2024

__builtin_thread_pointer() doesn't appear to work for me, on my aarch64 darwin machine running macOS 15.0.1 with (tools from) XCode 16.0.0 (currently the latest version).

If I build using the provided build tools, it fails (with a clang crash oddly enough) while building with

fatal error: error in backend: Target OS doesn't support __builtin_thread_pointer() yet.

That's probably out of your control though, and not why I filed this issue. Oddly enough if I build by hand, the build succeeds, but then I hit this assert when running your tests, almost immediately (which is why I'm filing this issue).

(If I don't build with asserts, then I crash later on presumably for the same reason)

If I delete the use of __builtin_thread_pointer() and uncomment the commented out #if #elif ... chain in get_thread_id() (e.g. implementing get_thread_id with the inline asm instead), then everything works great.

Some more detailed platform info, should it be useful:

$ clang --version
Apple clang version 16.0.0 (clang-1600.0.26.3)
Target: arm64-apple-darwin24.0.0
Thread model: posix
InstalledDir: /Applications/Xcode-16.0.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
$ uname -a
Darwin zeta.local 24.0.0 Darwin Kernel Version 24.0.0: Tue Sep 24 23:39:07 PDT 2024; root:xnu-11215.1.12~1/RELEASE_ARM64_T6000 arm64
@thomcc
Copy link
Author

thomcc commented Dec 7, 2024

It seems that mimalloc hit this same problem, on aarch64 apple targets LLVM just reads the wrong register: microsoft/mimalloc#343 (comment).

@ronaaron
Copy link

Just to add: when compiling my '8th' compiler it succeeds compiling, but the runtime behavior is quite bad. Reverting rpmalloc to an older version (955f44b) works properly.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants