Skip to content

[LLD][COFF] Emit ARM64X relocations for TLS directory - #213529

Merged
cjacek merged 1 commit into
llvm:mainfrom
cjacek:arm64x-tls-relocs
Aug 6, 2026
Merged

cjacek merged 1 commit into
llvm:mainfrom
cjacek:arm64x-tls-relocs

Conversation

@cjacek

@cjacek cjacek commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

The current behavior of merging EC and native chunks to have a single TLS directory for both views matches the MSVC linker, but it has its shortcomings. In addition to merging, that solution requires all TLS callbacks to use -arm64xsameaddress, leaving it to the CRT to handle. If the appropriate EC object files are not pulled in by linked EC code and thus never have a chance to mark the callback with -arm64xsameaddress, this may lead to an invalid image that crashes at runtime.

This patch avoids the entire problem by using entirely separate TLS directories for EC and native views along with the standard ARM64X dynamic relocation mechanism. Since callback lists are now separate, a missing -arm64xsameaddress is no longer a problem.

Also, mingw-w64-crt currently doesn't mark its TLS callbacks with -arm64xsameaddress. That could be changed if needed, but with this change, it is no longer necessary.

The current behavior of merging EC and native chunks to have a single TLS
directory for both views matches the MSVC linker, but it has its shortcomings.
In addition to merging, that solution requires all TLS callbacks to use
-arm64xsameaddress, leaving it to the CRT to handle. If the appropriate EC
object files are not pulled in by linked EC code and thus never have a chance
to mark the callback with -arm64xsameaddress, this may lead to an invalid image
that crashes at runtime.

This patch avoids the entire problem by using entirely separate TLS directories
for EC and native views along with the standard ARM64X dynamic relocation
mechanism. Since callback lists are now separate, a missing -arm64xsameaddress
is no longer a problem.

Also, mingw-w64-crt currently doesn't mark its TLS callbacks with
-arm64xsameaddress. That could be changed if needed, but with this change, it is
no longer necessary.
@llvmorg-github-actions

llvmorg-github-actions Bot commented Aug 2, 2026 •

Copy link
Copy Markdown

@llvm/pr-subscribers-lld-coff
@llvm/pr-subscribers-platform-windows

@llvm/pr-subscribers-lld

Author: Jacek Caban (cjacek)

Changes

The current behavior of merging EC and native chunks to have a single TLS directory for both views matches the MSVC linker, but it has its shortcomings. In addition to merging, that solution requires all TLS callbacks to use -arm64xsameaddress, leaving it to the CRT to handle. If the appropriate EC object files are not pulled in by linked EC code and thus never have a chance to mark the callback with -arm64xsameaddress, this may lead to an invalid image that crashes at runtime.

This patch avoids the entire problem by using entirely separate TLS directories for EC and native views along with the standard ARM64X dynamic relocation mechanism. Since callback lists are now separate, a missing -arm64xsameaddress is no longer a problem.

Also, mingw-w64-crt currently doesn't mark its TLS callbacks with -arm64xsameaddress. That could be changed if needed, but with this change, it is no longer necessary.


Full diff: https://github.com/llvm/llvm-project/pull/213529.diff

3 Files Affected:

  • (modified) lld/COFF/Driver.cpp (+1-4)
  • (modified) lld/COFF/Writer.cpp (+22-4)
  • (modified) lld/test/COFF/arm64x-tls.s (+56-10)
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index 9d39aff73601b..6583e43271ad6 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -2841,8 +2841,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
 
   if (ctx.hybridSymtab) {
     // On ARM64X, merge tls chunks, there may be only one true _tls_start and
-    // _tls_end chunk. Additionally, both views use the same _tls_used and
-    // _tls_index.
+    // _tls_end chunk.
     auto maybeReplaceWithNative = [&](StringRef name) {
       auto nativeSym = dyn_cast_or_null<DefinedRegular>(
           ctx.hybridSymtab->findUnderscore(name));
@@ -2852,8 +2851,6 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
               dyn_cast_or_null<DefinedRegular>(ctx.symtab.findUnderscore(name)))
         nativeSym->getChunk()->replace(ecSym->getChunk());
     };
-    maybeReplaceWithNative("_tls_used");
-    maybeReplaceWithNative("_tls_index");
     maybeReplaceWithNative("_tls_start");
     maybeReplaceWithNative("_tls_end");
   }
diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp
index 33826c9146c50..3cab426df55cf 100644
--- a/lld/COFF/Writer.cpp
+++ b/lld/COFF/Writer.cpp
@@ -267,7 +267,7 @@ class Writer {
   void sortBySectionOrder(std::vector<Chunk *> &chunks);
   void fixPartialSectionChars(StringRef name, uint32_t chars);
   bool fixGnuImportChunks();
-  void fixTlsAlignment();
+  void fixTlsAlignment(SymbolTable &symtab);
   PartialSection *createPartialSection(StringRef name, uint32_t outChars);
   PartialSection *findPartialSection(StringRef name, uint32_t outChars);
 
@@ -815,7 +815,7 @@ void Writer::run() {
     // Fix up the alignment in the TLS Directory's characteristic field,
     // if a specific alignment value is needed
     if (tlsAlignment)
-      fixTlsAlignment();
+      ctx.forEachSymtab([&](SymbolTable &symtab) { fixTlsAlignment(symtab); });
   }
 
   if (!ctx.config.pdbPath.empty() && ctx.config.debug) {
@@ -2940,6 +2940,24 @@ void Writer::createDynamicRelocs() {
                              LOAD_CONFIG_TABLE * sizeof(data_directory) +
                              offsetof(data_directory, Size),
                          ctx.symtab.loadConfigSize);
+
+  auto nativeTlsUsed =
+      dyn_cast_or_null<Defined>(ctx.hybridSymtab->findUnderscore("_tls_used"));
+  auto ecTlsUsed =
+      dyn_cast_or_null<Defined>(ctx.symtab.findUnderscore("_tls_used"));
+  if (nativeTlsUsed || ecTlsUsed) {
+    ctx.dynamicRelocs->add(IMAGE_DVRT_ARM64X_FIXUP_TYPE_VALUE, sizeof(uint32_t),
+                           dataDirOffset64 +
+                               TLS_TABLE * sizeof(data_directory) +
+                               offsetof(data_directory, RelativeVirtualAddress),
+                           Arm64XRelocVal(ecTlsUsed));
+    if (!nativeTlsUsed || !ecTlsUsed)
+      ctx.dynamicRelocs->add(
+          IMAGE_DVRT_ARM64X_FIXUP_TYPE_VALUE, sizeof(uint32_t),
+          dataDirOffset64 + TLS_TABLE * sizeof(data_directory) +
+              offsetof(data_directory, Size),
+          ecTlsUsed ? sizeof(coff_tls_directory64) : 0);
+  }
 }
 
 PartialSection *Writer::createPartialSection(StringRef name,
@@ -2958,9 +2976,9 @@ PartialSection *Writer::findPartialSection(StringRef name, uint32_t outChars) {
   return nullptr;
 }
 
-void Writer::fixTlsAlignment() {
+void Writer::fixTlsAlignment(SymbolTable &symtab) {
   Defined *tlsSym =
-      dyn_cast_or_null<Defined>(ctx.symtab.findUnderscore("_tls_used"));
+      dyn_cast_or_null<Defined>(symtab.findUnderscore("_tls_used"));
   if (!tlsSym)
     return;
 
diff --git a/lld/test/COFF/arm64x-tls.s b/lld/test/COFF/arm64x-tls.s
index 608604fab2fb3..4a900edcee676 100644
--- a/lld/test/COFF/arm64x-tls.s
+++ b/lld/test/COFF/arm64x-tls.s
@@ -12,7 +12,7 @@
 // RUN: llvm-lib -machine:arm64x -out:tls.lib tls-aarch64.obj tls-arm64ec.obj loadconfig-arm64ec.obj loadconfig-arm64.obj
 // RUN: lld-link -machine:arm64x -dll -noentry aarch64.obj arm64ec.obj tls.lib -out:out.dll
 
-// Check that we're using native _tls_index and _tls_used for both views.
+// Check that we're using the right _tls_index and _tls_used for both views.
 
 // RUN: llvm-readobj --coff-tls-directory --hex-dump=.ec --hex-dump=.a64 out.dll | FileCheck %s
 // CHECK:      Format: COFF-ARM64X
@@ -20,13 +20,13 @@
 // CHECK-NEXT: AddressSize: 64bit
 // CHECK-EMPTY:
 // CHECK-NEXT: Hex dump of section '.a64':
-// CHECK-NEXT: 0x180004000 00500000 04500000 00700000 01700000
+// CHECK-NEXT: 0x180004000 00500000 04500000 00800000 01800000
 // CHECK-EMPTY:
 // CHECK-NEXT: Hex dump of section '.ec':
-// CHECK-NEXT: 0x180006000 00500000 04500000 00700000 01700000
+// CHECK-NEXT: 0x180007000 00600000 04600000 00800000 01800000
 // CHECK-NEXT: TLSDirectory {
-// CHECK-NEXT:   StartAddressOfRawData: 0x180007000
-// CHECK-NEXT:   EndAddressOfRawData: 0x180007001
+// CHECK-NEXT:   StartAddressOfRawData: 0x180008000
+// CHECK-NEXT:   EndAddressOfRawData: 0x180008001
 // CHECK-NEXT:   AddressOfIndex: 0x180005000
 // CHECK-NEXT:   AddressOfCallBacks: 0x0
 // CHECK-NEXT:   SizeOfZeroFill: 0x0
@@ -40,14 +40,14 @@
 // CHECK-NEXT:   AddressSize: 64bit
 // CHECK-EMPTY:
 // CHECK-NEXT:   Hex dump of section '.a64':
-// CHECK-NEXT:   0x180004000 00500000 04500000 00700000 01700000
+// CHECK-NEXT:   0x180004000 00500000 04500000 00800000 01800000
 // CHECK-EMPTY:
 // CHECK-NEXT:   Hex dump of section '.ec':
-// CHECK-NEXT:   0x180006000 00500000 04500000 00700000 01700000
+// CHECK-NEXT:   0x180007000 00600000 04600000 00800000 01800000
 // CHECK-NEXT:   TLSDirectory {
-// CHECK-NEXT:     StartAddressOfRawData: 0x180007000
-// CHECK-NEXT:     EndAddressOfRawData: 0x180007001
-// CHECK-NEXT:     AddressOfIndex: 0x180005000
+// CHECK-NEXT:     StartAddressOfRawData: 0x180008000
+// CHECK-NEXT:     EndAddressOfRawData: 0x180008001
+// CHECK-NEXT:     AddressOfIndex: 0x180006000
 // CHECK-NEXT:     AddressOfCallBacks: 0x0
 // CHECK-NEXT:     SizeOfZeroFill: 0x0
 // CHECK-NEXT:     Characteristics [ (0x100000)
@@ -56,6 +56,52 @@
 // CHECK-NEXT:   }
 // CHECK-NEXT: }
 
+// RUN: lld-link -machine:arm64x -dll -noentry arm64ec.obj tls.lib -out:out-ec.dll
+// RUN: llvm-readobj --coff-tls-directory out-ec.dll | FileCheck --check-prefix=EC-ONLY %s
+// EC-ONLY:      Format: COFF-ARM64X
+// EC-ONLY-NEXT: Arch: aarch64
+// EC-ONLY-NEXT: AddressSize: 64bit
+// EC-ONLY-NEXT: TLSDirectory {
+// EC-ONLY-NEXT: }
+// EC-ONLY-NEXT: HybridObject {
+// EC-ONLY-NEXT:   Format: COFF-ARM64EC
+// EC-ONLY-NEXT:   Arch: aarch64
+// EC-ONLY-NEXT:   AddressSize: 64bit
+// EC-ONLY-NEXT:   TLSDirectory {
+// EC-ONLY-NEXT:     StartAddressOfRawData: 0x180006000
+// EC-ONLY-NEXT:     EndAddressOfRawData: 0x180006001
+// EC-ONLY-NEXT:     AddressOfIndex: 0x180004000
+// EC-ONLY-NEXT:     AddressOfCallBacks: 0x0
+// EC-ONLY-NEXT:     SizeOfZeroFill: 0x0
+// EC-ONLY-NEXT:     Characteristics [ (0x100000)
+// EC-ONLY-NEXT:       IMAGE_SCN_ALIGN_1BYTES (0x100000)
+// EC-ONLY-NEXT:     ]
+// EC-ONLY-NEXT:   }
+// EC-ONLY-NEXT: }
+
+// RUN: lld-link -machine:arm64x -dll -noentry aarch64.obj tls.lib -out:out-native.dll
+// RUN: llvm-readobj --coff-tls-directory out-native.dll | FileCheck --check-prefix=NATIVE-ONLY %s
+// NATIVE-ONLY:      Format: COFF-ARM64X
+// NATIVE-ONLY-NEXT: Arch: aarch64
+// NATIVE-ONLY-NEXT: AddressSize: 64bit
+// NATIVE-ONLY-NEXT: TLSDirectory {
+// NATIVE-ONLY-NEXT:   StartAddressOfRawData: 0x180006000
+// NATIVE-ONLY-NEXT:   EndAddressOfRawData: 0x180006001
+// NATIVE-ONLY-NEXT:   AddressOfIndex: 0x180005000
+// NATIVE-ONLY-NEXT:   AddressOfCallBacks: 0x0
+// NATIVE-ONLY-NEXT:   SizeOfZeroFill: 0x0
+// NATIVE-ONLY-NEXT:   Characteristics [ (0x100000)
+// NATIVE-ONLY-NEXT:     IMAGE_SCN_ALIGN_1BYTES (0x100000)
+// NATIVE-ONLY-NEXT:   ]
+// NATIVE-ONLY-NEXT: }
+// NATIVE-ONLY-NEXT: HybridObject {
+// NATIVE-ONLY-NEXT:   Format: COFF-ARM64EC
+// NATIVE-ONLY-NEXT:   Arch: aarch64
+// NATIVE-ONLY-NEXT:   AddressSize: 64bit
+// NATIVE-ONLY-NEXT:   TLSDirectory {
+// NATIVE-ONLY-NEXT:   }
+// NATIVE-ONLY-NEXT: }
+
 #--- tls-aarch64.s
         .section .defa64,"dr",discard,_tls_index
         .globl _tls_index

@cjacek

cjacek commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

Those are additional fixes, on top of #212845. As discussed there, this avoid shortcomings of the current solution. @pmsjt

@mstorsjo mstorsjo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks nice and straightforward to me.

I wonder if we should merge this soon too (in order to get it included for a potential RC3 backport), or if we should wait a few days for @pmsjt to maybe follow up first.

@mstorsjo

mstorsjo commented Aug 6, 2026

Copy link
Copy Markdown
Member

@cjacek - What's your take on this, vs the upcoming RC3 next week, vs mingw-w64-crt, vs enabling ARM64X in mingw builds? Do you want to aim for getting this into RC3 next week if we think this patch is fine, or do we try to add -arm64xsameaddress everywhere where needed in mingw-w64-crt while waiting for input on this patch, for being able to reenable the ARM64X builds? Or do we hold off enabling ARM64X builds for llvm-mingw until even later? (The threshold for backporting patches to the releases, in particular later releases, is always higher than early in the RC process.)

@cjacek
cjacek merged commit 65e92e0 into llvm:main Aug 6, 2026
14 checks passed
@cjacek
cjacek deleted the arm64x-tls-relocs branch August 6, 2026 13:27
@cjacek

cjacek commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

I merged it, I hope we can have it in RC3 and avoid having -arm64xsameaddress in mingw-w64-crt.

@pmsjt I'd still appreciate your opinion when you have time and I'm happy to follow-up if needed.

@cjacek cjacek added this to the LLVM 23.x Release milestone Aug 6, 2026
@github-project-automation github-project-automation Bot moved this from Needs Triage to Done in LLVM Release Status Aug 6, 2026
@github-project-automation github-project-automation Bot moved this to Needs Triage in LLVM Release Status Aug 6, 2026
@cjacek

cjacek commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

/cherry-pick 65e92e0

@llvmbot

llvmbot commented Aug 6, 2026

Copy link
Copy Markdown
Member

/pull-request #214498

@llvm-ci

llvm-ci commented Aug 6, 2026

Copy link
Copy Markdown

LLVM Buildbot has detected a new failure on builder sanitizer-aarch64-linux running on sanitizer-buildbot8 while building lld at step 2 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/51/builds/41717

Here is the relevant piece of the build log for the reference
Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure) (timed out)
...
-- Install configuration: "Release"
[203/208] Generating MSAN_INST_GTEST.gtest-all.cc.aarch64-with-call.o
[204/208] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.aarch64-with-call.o
[205/208] Generating Msan-aarch64-with-call-Test
[206/208] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.aarch64.o
[207/208] Generating Msan-aarch64-Test
[207/208] Running compiler_rt regression tests
llvm-lit: /home/b/sanitizer-aarch64-linux/build/llvm-project/llvm/utils/lit/lit/discovery.py:273: warning: input '/home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/interception/Unit' contained no tests
llvm-lit: /home/b/sanitizer-aarch64-linux/build/llvm-project/llvm/utils/lit/lit/discovery.py:273: warning: input '/home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/Unit' contained no tests
-- Testing: 6502 tests, 72 workers --
command timed out: 1200 seconds without output running [b'python', b'../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'], attempting to kill
process killed by signal 9
program finished with exit code -1
elapsedTime=2262.238767
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
Step 14 (test compiler-rt default) failure: test compiler-rt default (failure)
...
[1892/1922] Building CXX object libcxx/src/CMakeFiles/cxx_static.dir/filesystem/filesystem_error.cpp.o
[1893/1922] Building CXX object libcxx/src/CMakeFiles/cxx_static.dir/barrier.cpp.o
[1894/1922] Building CXX object libcxx/src/CMakeFiles/cxx_static.dir/condition_variable.cpp.o
[1895/1922] Building CXX object libcxx/src/CMakeFiles/cxx_static.dir/charconv.cpp.o
[1896/1922] Building CXX object libcxx/src/CMakeFiles/cxx_static.dir/atomic.cpp.o
[1897/1922] Building CXX object libcxx/src/CMakeFiles/cxx_static.dir/random_shuffle.cpp.o
[1898/1922] Building CXX object libcxx/src/CMakeFiles/cxx_static.dir/regex.cpp.o
[1899/1922] Building CXX object libcxx/src/CMakeFiles/cxx_static.dir/print.cpp.o
[1900/1922] Building CXX object libcxx/src/CMakeFiles/cxx_static.dir/ios.cpp.o
[1901/1922] Building CXX object libcxx/src/CMakeFiles/cxx_static.dir/random.cpp.o
[1902/1922] Building CXX object libcxx/src/CMakeFiles/cxx_static.dir/memory.cpp.o
[1903/1922] Building CXX object libcxx/src/CMakeFiles/cxx_static.dir/thread.cpp.o
[1904/1922] Building CXX object libcxx/src/CMakeFiles/cxx_static.dir/ostream.cpp.o
[1905/1922] Building CXX object libcxx/src/CMakeFiles/cxx_static.dir/filesystem/directory_iterator.cpp.o
[1906/1922] Building CXX object libcxx/src/CMakeFiles/cxx_static.dir/strstream.cpp.o
[1907/1922] Building CXX object libcxx/src/CMakeFiles/cxx_experimental.dir/experimental/chrono_exception.cpp.o
[1908/1922] Building CXX object libcxx/src/CMakeFiles/cxx_static.dir/filesystem/filesystem_clock.cpp.o
[1909/1922] Building CXX object libcxx/src/CMakeFiles/cxx_static.dir/chrono.cpp.o
[1910/1922] Building CXX object libcxx/src/CMakeFiles/cxx_static.dir/filesystem/directory_entry.cpp.o
[1911/1922] Building CXX object libcxx/src/CMakeFiles/cxx_static.dir/string.cpp.o
[1912/1922] Building CXX object libcxx/src/CMakeFiles/cxx_experimental.dir/experimental/tzdb_list.cpp.o
[1913/1922] Building CXX object libcxx/src/CMakeFiles/cxx_static.dir/ios.instantiations.cpp.o
[1914/1922] Building CXX object libcxx/src/CMakeFiles/cxx_static.dir/algorithm.cpp.o
[1915/1922] Building CXX object libcxx/src/CMakeFiles/cxx_static.dir/filesystem/operations.cpp.o
[1916/1922] Building CXX object libcxxabi/src/CMakeFiles/cxxabi_static_objects.dir/cxa_demangle.cpp.o
[1917/1922] Linking CXX static library lib/libc++abi.a
[1918/1922] Building CXX object libcxx/src/CMakeFiles/cxx_experimental.dir/experimental/tzdb.cpp.o
[1919/1922] Building CXX object libcxx/src/CMakeFiles/cxx_static.dir/locale.cpp.o
[1920/1922] Linking CXX static library lib/libc++.a
[1921/1922] Building CXX object libcxx/src/CMakeFiles/cxx_experimental.dir/experimental/time_zone.cpp.o
[1922/1922] Linking CXX static library lib/libc++experimental.a
[200/208] Generating MSAN_INST_GTEST.gtest-all.cc.aarch64.o
[201/208] Installing libcxx_tsan_aarch64...
[0/1] Install the project...
-- Install configuration: "Release"
[203/208] Generating MSAN_INST_GTEST.gtest-all.cc.aarch64-with-call.o
[204/208] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.aarch64-with-call.o
[205/208] Generating Msan-aarch64-with-call-Test
[206/208] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.aarch64.o
[207/208] Generating Msan-aarch64-Test
[207/208] Running compiler_rt regression tests
llvm-lit: /home/b/sanitizer-aarch64-linux/build/llvm-project/llvm/utils/lit/lit/discovery.py:273: warning: input '/home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/interception/Unit' contained no tests
llvm-lit: /home/b/sanitizer-aarch64-linux/build/llvm-project/llvm/utils/lit/lit/discovery.py:273: warning: input '/home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/Unit' contained no tests
-- Testing: 6502 tests, 72 workers --

command timed out: 1200 seconds without output running [b'python', b'../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'], attempting to kill
process killed by signal 9
program finished with exit code -1
elapsedTime=2262.238767
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..

dyung pushed a commit to llvmbot/llvm-project that referenced this pull request Aug 7, 2026
The current behavior of merging EC and native chunks to have a single
TLS directory for both views matches the MSVC linker, but it has its
shortcomings. In addition to merging, that solution requires all TLS
callbacks to use -arm64xsameaddress, leaving it to the CRT to handle. If
the appropriate EC object files are not pulled in by linked EC code and
thus never have a chance to mark the callback with -arm64xsameaddress,
this may lead to an invalid image that crashes at runtime.

This patch avoids the entire problem by using entirely separate TLS
directories for EC and native views along with the standard ARM64X
dynamic relocation mechanism. Since callback lists are now separate, a
missing -arm64xsameaddress is no longer a problem.

Also, mingw-w64-crt currently doesn't mark its TLS callbacks with
-arm64xsameaddress. That could be changed if needed, but with this
change, it is no longer necessary.

(cherry picked from commit 65e92e0)
@pmsjt

pmsjt commented Aug 7, 2026

Copy link
Copy Markdown

I merged it, I hope we can have it in RC3 and avoid having -arm64xsameaddress in mingw-w64-crt.

@pmsjt I'd still appreciate your opinion when you have time and I'm happy to follow-up if needed.

We are actively working on this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

5 participants