-
Notifications
You must be signed in to change notification settings - Fork 10.5k
build: Add support for WASI in CMake files #31672
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
cmake/modules/AddSwift.cmake
Outdated
elseif(SWIFT_HOST_VARIANT_SDK STREQUAL WASI) | ||
# WASI lacks a true mmap; enabling minimal mmap emulation | ||
# see https://github.com/WebAssembly/wasi-libc/blob/86550c37ab14962233f73413ea0e0c0e57d056d7/libc-top-half/musl/include/sys/mman.h#L3 | ||
list(APPEND result "-Wl,wasi-emulated-mman") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it makes sense to build the toolchain for WASI. Why does the toolchain need to be built for WASI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes a huge amount of sense to build the toolchain for WASI (not that anyone has done so today, AFAIK).
For one thing, it would allow you to run the compiler in your browser. Very cool, and a great learning tool. Another use-case would be to bootstrap building the compiler as projects like Swift-driver make progress and more Swift is used in the compiler itself.
cmake/modules/AddSwift.cmake
Outdated
endif() | ||
|
||
# Double-check that we're not trying to build a dynamic library for WASM. | ||
if(SWIFTLIB_SINGLE_SDK MATCHES WASM) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't happen right? Because this is for the toolchain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It shouldn't, and didn't happen in my practice building it, was written more like an assertion here. I can remove it if you'd like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do, I think that minimizing the CMake logic is preferable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's cleaned up now.
Hmm, how are there no changes to the |
Changes to |
1d8e51f
to
7620796
Compare
@swift-ci please test |
Add basic support for WebAssembly/WASI builds in CMake files. Important to note that WebAssembly/WASI doesn't fully support dynamic linking yet, so it is disabled for now.
Related to SR-9307.
This is a part of #29465, but includes only the CMake bits that are self-contained.
(cc @compnerd @kateinoigakukun)