diff options
| author | Jens Goldberg <jens.goldberg@gmail.com> | 2023-01-04 20:37:59 +0100 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-01-05 02:20:23 -0700 |
| commit | b89158d6fd7ce0960b3f8085368ae102b48747d0 (patch) | |
| tree | 88b939677203a55f9daea2c0a62bf81152176234 /lib/std/start.zig | |
| parent | ed2361563860031559addbe276eb64114b93cec5 (diff) | |
| download | zig-b89158d6fd7ce0960b3f8085368ae102b48747d0.tar.gz zig-b89158d6fd7ce0960b3f8085368ae102b48747d0.zip | |
Don't initialize the static TLS area in single-threaded builds
Diffstat (limited to 'lib/std/start.zig')
| -rw-r--r-- | lib/std/start.zig | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/lib/std/start.zig b/lib/std/start.zig index dcc0b7427a..1a223b9a21 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -437,20 +437,22 @@ fn posixCallMainAndExit() callconv(.C) noreturn { std.os.linux.pie.relocate(phdrs); } - // 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 native_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(); + if (!builtin.single_threaded) { + // 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 native_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(); + } } - } - // Initialize the TLS area. - std.os.linux.tls.initStaticTLS(phdrs); + // Initialize the TLS area. + std.os.linux.tls.initStaticTLS(phdrs); + } // The way Linux executables represent stack size is via the PT_GNU_STACK // program header. However the kernel does not recognize it; it always gives 8 MiB. |
