Skip to content

tools: global-dynamic TLS for PIC sysroot builds - #125

Merged
Arshia001 merged 1 commit into
mainfrom
fix/pic-tls-global-dynamic
Jul 3, 2026
Merged

tools: global-dynamic TLS for PIC sysroot builds#125
Arshia001 merged 1 commit into
mainfrom
fix/pic-tls-global-dynamic

Conversation

@kilyanni

@kilyanni kilyanni commented Jul 1, 2026

Copy link
Copy Markdown

local-exec TLS makes PIC libc++'s errno accesses unrelocatable when errno is imported (side modules, e.g. CPython C++ extensions):

R_WASM_MEMORY_ADDR_TLS_SLEB cannot be used against an undefined symbol errno

Gate the model on CMAKE_POSITION_INDEPENDENT_CODE (PIC -> global-dynamic), matching wasixcc's PIC codegen.

local-exec TLS makes PIC libc++'s errno accesses unrelocatable when errno is
imported (side modules, e.g. CPython C++ extensions): "R_WASM_MEMORY_ADDR_TLS_SLEB
cannot be used against an undefined symbol errno". Gate the model on
CMAKE_POSITION_INDEPENDENT_CODE (PIC -> global-dynamic), matching wasixcc's PIC codegen.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the WASIX Clang CMake toolchain files to select a TLS model that is compatible with PIC builds intended for use as side modules (where errno may be imported), avoiding relocation failures caused by local-exec TLS.

Changes:

  • Gate -ftls-model= on CMAKE_POSITION_INDEPENDENT_CODE: PIC builds use global-dynamic, non-PIC builds keep local-exec.
  • Apply the same TLS-model selection logic across the standard, EH, and exnref-EH toolchain variants.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
tools/clang-wasix.cmake_toolchain Switch TLS model to global-dynamic when CMAKE_POSITION_INDEPENDENT_CODE is enabled.
tools/clang-wasix-eh.cmake_toolchain Same TLS-model gating for the EH toolchain variant.
tools/clang-wasix-exnref-eh.cmake_toolchain Same TLS-model gating for the exnref+EH toolchain variant.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@kilyanni
kilyanni requested a review from Arshia001 July 1, 2026 14:35
@Arshia001
Arshia001 merged commit c4807d2 into main Jul 3, 2026
6 checks passed
@Arshia001
Arshia001 deleted the fix/pic-tls-global-dynamic branch July 3, 2026 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants