diff --git a/lib/std/os/linux/tls.zig b/lib/std/os/linux/tls.zig index 0330a4e410..69e7816f13 100644 --- a/lib/std/os/linux/tls.zig +++ b/lib/std/os/linux/tls.zig @@ -211,12 +211,16 @@ fn initTLS() void { } } - // If the cpu is ARM-based, check if it supports the TLS register - if (comptime builtin.arch.isARM() and at_hwcap & std.os.linux.HWCAP_TLS == 0) { - // If the CPU does not support TLS via a coprocessor register, - // a kernel helper function can be used instead on certain linux kernels. - // See linux/arch/arm/include/asm/tls.h and musl/src/thread/arm/__set_thread_area.c. - @panic("TODO: Implement ARM fallback TLS functionality"); + // ARMv6 targets (and earlier) have no support for TLS in hardware + // FIXME: Elide the check for targets >= ARMv7 when the target feature API + // becomes less verbose (and more usable). + if (comptime builtin.arch.isARM()) { + if (at_hwcap & std.os.linux.HWCAP_TLS == 0) { + // FIXME: Make __aeabi_read_tp call the kernel helper kuser_get_tls + // For the time being use a simple abort instead of a @panic call to + // keep the binary bloat under control. + std.os.abort(); + } } var tls_align_factor: usize = undefined;