mjansson/rpmalloc

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

Opened this issue · 0 comments

__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