authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-10-18 21:54:24+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-10-21 23:35:06-04:00
log0c355bef9e424fbf06085f12fc28979d73b3d6af
treeb7ccd34b0ce21c303ed3fb69fa2f17e10efc9a0e
parent1e074879046354db1b556fc9eda51bc8dac5c6b7

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

1 files changed, 10 insertions(+), 6 deletions(-)

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