std: Slim down the error code path in initStaticTLS

Calling @panic made the executable ~30x times bigger, use a simple
`abort()` and let the user figure out what went wrong.

Supporting ARMv6 (and earlier?) platforms is not a priority.

Closes #6676
master
LemonBoy 2020-10-18 21:54:24 +02:00 committed by Andrew Kelley
parent 1e07487904
commit 0c355bef9e
1 changed files with 10 additions and 6 deletions

View File

@ -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;