Skip to content

Fix remaining linking failures on native AOT/WASI - #135766

Merged
MichalStrehovsky merged 3 commits into
dotnet:mainfrom
MichalStrehovsky:nativeaot-wasi-link-support
Oct 15, 2026
Merged

MichalStrehovsky merged 3 commits into
dotnet:mainfrom
MichalStrehovsky:nativeaot-wasi-link-support

Conversation

@MichalStrehovsky

Copy link
Copy Markdown
Member

Part of a series of pull requests that enable compiling, linking, and running a Console.WriteLine hello world on WASI/native AOT.

Summary

Supply the remaining native compatibility definitions needed by the WASI portable runtime:

  • Provide __cxa_thread_atexit in stdcppshim.cpp without requiring libc++abi. A private WASI_SINGLE_THREADED definition enables it only for WASI without pthreads. Cleanup callbacks run in reverse registration order at process exit, including callbacks registered during destruction.
  • Move unix/cgroupcpu.cpp from the full-runtime list to the common Unix source list alongside PalUnix.cpp. Wasm gets its existing non-Linux fallbacks, not Linux cgroup support.

The WASI SDK does define __cxa_thread_atexit in libc++abi; the compatibility implementation supports NativeAOT links that intentionally omit that library. It is not a no-op replacement for TLS cleanup.

Validation

  • .\build.cmd clr.nativeaotruntime -rc Checked -os wasi -arch wasm - passed with zero warnings/errors.
  • Focused ABI/TLS probe, linked using the C driver and libstdc++compat.a without implicit libc++abi - linked, passed Wasm validation, and executed all four expected destructor callbacks.
  • Isolated CMake target/guard checks - the TLS symbol was present for single-threaded WASI and absent for pthread-enabled and non-WASI configurations. These are shim guard checks, not full threaded/non-WASI runtime builds.
  • Generated compile commands contained exactly one cgroupcpu.cpp compilation.
  • Both real-CoreLib Hello objects were relinked with fatal linker warnings enabled. The Preview 1 CoreLib module and Preview 2 Console component printed the expected text and exited 0; the CoreLib module also passed WABT validation.

These results are from the combined local bringup tree, including prerequisite NativeAOT/Wasm enablement, not a fresh build of this isolated main-based branch. The focused probes are local fixtures, not tests added by this PR.

Note

This PR description was generated by GitHub Copilot.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: c78266f3-08e3-4918-b2e5-9fe0ddf2ca17
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 4 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

MichalStrehovsky and others added 2 commits October 15, 2026 07:28
Co-authored-by: Copilot <[email protected]>
Copilot-Session: c78266f3-08e3-4918-b2e5-9fe0ddf2ca17
Co-authored-by: Copilot <[email protected]>
Copilot-Session: c78266f3-08e3-4918-b2e5-9fe0ddf2ca17
@MichalStrehovsky

Copy link
Copy Markdown
Member Author

/ba-g the OSX machine is "This job was abandoned." and everything is hung on that. This is a build only change and builds passed.

@MichalStrehovsky
MichalStrehovsky merged commit ce202f8 into dotnet:main Oct 15, 2026
100 of 103 checks passed
@MichalStrehovsky
MichalStrehovsky deleted the nativeaot-wasi-link-support branch October 15, 2026 07:26
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Oct 19, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasm WebAssembly architecture area-NativeAOT-coreclr

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants