authorgravatar for jens.goldberg@gmail.comJens Goldberg <jens.goldberg@gmail.com> 2023-01-04 20:37:59+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-01-05 02:20:23-07:00
logb89158d6fd7ce0960b3f8085368ae102b48747d0
tree88b939677203a55f9daea2c0a62bf81152176234
parented2361563860031559addbe276eb64114b93cec5

Don't initialize the static TLS area in single-threaded builds


1 files changed, 14 insertions(+), 12 deletions(-)

lib/std/start.zig+14-12
...@@ -437,20 +437,22 @@ fn posixCallMainAndExit() callconv(.C) noreturn {...@@ -437,20 +437,22 @@ fn posixCallMainAndExit() callconv(.C) noreturn {
437 std.os.linux.pie.relocate(phdrs);437 std.os.linux.pie.relocate(phdrs);
438 }438 }
439439
440 // ARMv6 targets (and earlier) have no support for TLS in hardware.440 if (!builtin.single_threaded) {
441 // FIXME: Elide the check for targets >= ARMv7 when the target feature API441 // ARMv6 targets (and earlier) have no support for TLS in hardware.
442 // becomes less verbose (and more usable).442 // FIXME: Elide the check for targets >= ARMv7 when the target feature API
443 if (comptime native_arch.isARM()) {443 // becomes less verbose (and more usable).
444 if (at_hwcap & std.os.linux.HWCAP.TLS == 0) {444 if (comptime native_arch.isARM()) {
445 // FIXME: Make __aeabi_read_tp call the kernel helper kuser_get_tls445 if (at_hwcap & std.os.linux.HWCAP.TLS == 0) {
446 // For the time being use a simple abort instead of a @panic call to446 // FIXME: Make __aeabi_read_tp call the kernel helper kuser_get_tls
447 // keep the binary bloat under control.447 // For the time being use a simple abort instead of a @panic call to
448 std.os.abort();448 // keep the binary bloat under control.
449 std.os.abort();
450 }
449 }451 }
450 }
451452
452 // Initialize the TLS area.453 // Initialize the TLS area.
453 std.os.linux.tls.initStaticTLS(phdrs);454 std.os.linux.tls.initStaticTLS(phdrs);
455 }
454456
455 // The way Linux executables represent stack size is via the PT_GNU_STACK457 // The way Linux executables represent stack size is via the PT_GNU_STACK
456 // program header. However the kernel does not recognize it; it always gives 8 MiB.458 // program header. However the kernel does not recognize it; it always gives 8 MiB.