https://github.com/kikairoya created https://github.com/llvm/llvm-project/pull/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 ``` >From de268f7f1d19de21ece1ab4c6b53c008beeeec33 Mon Sep 17 00:00:00 2001 From: kikairoya <kikair...@gmail.com> Date: Sat, 19 Apr 2025 07:00:39 +0900 Subject: [PATCH] [Cygwin] TLS for Cygwin target should be available 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 --- clang/lib/Basic/Targets/X86.h | 1 - clang/test/Driver/emulated-tls.cpp | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h index 194f3faef1be3..2f6fb33a7b597 100644 --- a/clang/lib/Basic/Targets/X86.h +++ b/clang/lib/Basic/Targets/X86.h @@ -965,7 +965,6 @@ class LLVM_LIBRARY_VISIBILITY CygwinX86_64TargetInfo : public X86_64TargetInfo { CygwinX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) : X86_64TargetInfo(Triple, Opts) { this->WCharType = TargetInfo::UnsignedShort; - TLSSupported = false; } void getTargetDefines(const LangOptions &Opts, diff --git a/clang/test/Driver/emulated-tls.cpp b/clang/test/Driver/emulated-tls.cpp index 3ee901a835858..431105bdfdf45 100644 --- a/clang/test/Driver/emulated-tls.cpp +++ b/clang/test/Driver/emulated-tls.cpp @@ -8,6 +8,8 @@ // RUN: | FileCheck -check-prefix=NOEMU %s // RUN: %clang -### --target=i686-pc-cygwin %s 2>&1 \ // RUN: | FileCheck -check-prefix=EMU %s +// RUN: %clang -### --target=x86_64-pc-cygwin %s 2>&1 \ +// RUN: | FileCheck -check-prefix=EMU %s // RUN: %clang -### --target=i686-pc-openbsd %s 2>&1 \ // RUN: | FileCheck -check-prefix=EMU %s @@ -17,6 +19,8 @@ // RUN: | FileCheck -check-prefix=EMU %s // RUN: %clang -### -target i686-pc-cygwin %s -fno-emulated-tls -femulated-tls 2>&1 \ // RUN: | FileCheck -check-prefix=EMU %s +// RUN: %clang -### -target x86_64-pc-cygwin %s -fno-emulated-tls -femulated-tls 2>&1 \ +// RUN: | FileCheck -check-prefix=EMU %s // RUN: %clang -### -target i686-pc-openbsd %s -fno-emulated-tls -femulated-tls 2>&1 \ // RUN: | FileCheck -check-prefix=EMU %s @@ -26,6 +30,8 @@ // RUN: | FileCheck -check-prefix=NOEMU %s // RUN: %clang -### -target i686-pc-cygwin %s -femulated-tls -fno-emulated-tls 2>&1 \ // RUN: | FileCheck -check-prefix=NOEMU %s +// RUN: %clang -### -target x86_64-pc-cygwin %s -femulated-tls -fno-emulated-tls 2>&1 \ +// RUN: | FileCheck -check-prefix=NOEMU %s // RUN: %clang -### -target i686-pc-openbsd %s -femulated-tls -fno-emulated-tls 2>&1 \ // RUN: | FileCheck -check-prefix=NOEMU %s _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits