Skip to content

Commit eb6d51a

Browse files
authored
[Cygwin] Enable TLS on Cygwin target (#138618)
Cygwin environment and toolchain supports EMUTLS. From https://cygwin.com/git/?p=newlib-cygwin.git;a=blob;f=config/tls.m4;hb=HEAD#l118, ``` $ LANG=C gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-cygwin/15/lto-wrapper.exe Target: x86_64-pc-cygwin Configured with: (snip) Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 15.0.1 20250406 (experimental) (GCC) $ echo '__thread int a; int b; int main() { return a = b; }' | gcc -S -xc -o- - | grep __emutls_get_address call __emutls_get_address .def __emutls_get_address; .scl 2; .type 32; .endef ```
1 parent f4c3254 commit eb6d51a

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

clang/lib/Basic/Targets/X86.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,6 @@ class LLVM_LIBRARY_VISIBILITY CygwinX86_64TargetInfo : public X86_64TargetInfo {
965965
CygwinX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
966966
: X86_64TargetInfo(Triple, Opts) {
967967
this->WCharType = TargetInfo::UnsignedShort;
968-
TLSSupported = false;
969968
}
970969

971970
void getTargetDefines(const LangOptions &Opts,

clang/test/Driver/emulated-tls.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// RUN: | FileCheck -check-prefix=NOEMU %s
99
// RUN: %clang -### --target=i686-pc-cygwin %s 2>&1 \
1010
// RUN: | FileCheck -check-prefix=EMU %s
11+
// RUN: %clang -### --target=x86_64-pc-cygwin %s 2>&1 \
12+
// RUN: | FileCheck -check-prefix=EMU %s
1113
// RUN: %clang -### --target=i686-pc-openbsd %s 2>&1 \
1214
// RUN: | FileCheck -check-prefix=EMU %s
1315

@@ -17,6 +19,8 @@
1719
// RUN: | FileCheck -check-prefix=EMU %s
1820
// RUN: %clang -### -target i686-pc-cygwin %s -fno-emulated-tls -femulated-tls 2>&1 \
1921
// RUN: | FileCheck -check-prefix=EMU %s
22+
// RUN: %clang -### -target x86_64-pc-cygwin %s -fno-emulated-tls -femulated-tls 2>&1 \
23+
// RUN: | FileCheck -check-prefix=EMU %s
2024
// RUN: %clang -### -target i686-pc-openbsd %s -fno-emulated-tls -femulated-tls 2>&1 \
2125
// RUN: | FileCheck -check-prefix=EMU %s
2226

@@ -26,6 +30,8 @@
2630
// RUN: | FileCheck -check-prefix=NOEMU %s
2731
// RUN: %clang -### -target i686-pc-cygwin %s -femulated-tls -fno-emulated-tls 2>&1 \
2832
// RUN: | FileCheck -check-prefix=NOEMU %s
33+
// RUN: %clang -### -target x86_64-pc-cygwin %s -femulated-tls -fno-emulated-tls 2>&1 \
34+
// RUN: | FileCheck -check-prefix=NOEMU %s
2935
// RUN: %clang -### -target i686-pc-openbsd %s -femulated-tls -fno-emulated-tls 2>&1 \
3036
// RUN: | FileCheck -check-prefix=NOEMU %s
3137

0 commit comments

Comments
 (0)