Skip to content

Commit b89158d

Browse files
Aransentinandrewrk
authored andcommitted
Don't initialize the static TLS area in single-threaded builds
1 parent ed23615 commit b89158d

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

lib/std/start.zig

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -437,20 +437,22 @@ fn posixCallMainAndExit() callconv(.C) noreturn {
437437
std.os.linux.pie.relocate(phdrs);
438438
}
439439

440-
// ARMv6 targets (and earlier) have no support for TLS in hardware.
441-
// FIXME: Elide the check for targets >= ARMv7 when the target feature API
442-
// becomes less verbose (and more usable).
443-
if (comptime native_arch.isARM()) {
444-
if (at_hwcap & std.os.linux.HWCAP.TLS == 0) {
445-
// FIXME: Make __aeabi_read_tp call the kernel helper kuser_get_tls
446-
// For the time being use a simple abort instead of a @panic call to
447-
// keep the binary bloat under control.
448-
std.os.abort();
440+
if (!builtin.single_threaded) {
441+
// ARMv6 targets (and earlier) have no support for TLS in hardware.
442+
// FIXME: Elide the check for targets >= ARMv7 when the target feature API
443+
// becomes less verbose (and more usable).
444+
if (comptime native_arch.isARM()) {
445+
if (at_hwcap & std.os.linux.HWCAP.TLS == 0) {
446+
// FIXME: Make __aeabi_read_tp call the kernel helper kuser_get_tls
447+
// For the time being use a simple abort instead of a @panic call to
448+
// keep the binary bloat under control.
449+
std.os.abort();
450+
}
449451
}
450-
}
451452

452-
// Initialize the TLS area.
453-
std.os.linux.tls.initStaticTLS(phdrs);
453+
// Initialize the TLS area.
454+
std.os.linux.tls.initStaticTLS(phdrs);
455+
}
454456

455457
// The way Linux executables represent stack size is via the PT_GNU_STACK
456458
// program header. However the kernel does not recognize it; it always gives 8 MiB.

0 commit comments

Comments
 (0)