Closed as not planned
Description
When using TLS from the global allocator on arm64 macos, I get the following fatal runtime error:
fatal runtime error: global allocator may not use TLS
This doesn't happen on x86 linux, and I can't find any mention of it anywhere. Grepping the rust repo returns nothing for that error either, so I'm not sure where it's coming from
I tried this code:
use std::alloc::{GlobalAlloc, System};
#[global_allocator]
static GLOBAL: Allocator = Allocator;
struct Allocator;
thread_local! {
static FOO: usize = 0;
}
unsafe impl GlobalAlloc for Allocator {
unsafe fn alloc(&self, layout: std::alloc::Layout) -> *mut u8 {
FOO.with(|foo| {
println!("{foo}");
});
System.alloc(layout)
}
unsafe fn dealloc(&self, ptr: *mut u8, layout: std::alloc::Layout) {
System.dealloc(ptr, layout)
}
}
fn main() {
let hello = String::from("hello");
println!("{hello}");
}
Meta
rustc --version --verbose
:
rustc 1.79.0 (129f3b996 2024-06-10)
binary: rustc
commit-hash: 129f3b9964af4d4a709d1383930ade12dfe7c081
commit-date: 2024-06-10
host: aarch64-apple-darwin
release: 1.79.0
LLVM version: 18.1.7
Backtrace
<backtrace>