-
-
Notifications
You must be signed in to change notification settings - Fork 297
Emscripten: Add druntime & Phobos support #5259
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
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
80bccc9
Add some primitive Emscripten support, based on WASI
kinke e5da7df
CI: Add Emscripten job
kinke 1f50a08
[try building Phobos too]
kinke 9ed0812
[ignore unittest failures, and try running the Phobos debug testrunne…
kinke a4e9abd
[fix linking with emcc]
kinke f75de5e
[enable addon-package smoke test for Emscripten too]
kinke a825d0c
[add importc_compare test]
kinke 834c6d1
[druntime: Fix some issues reported by importc_compare]
kinke 918f918
[fix core.sys.posix.sys.types and core.stdc.limits]
kinke 8771d6e
[fix core.sys.posix.sys.stat]
kinke e4616bf
[fix core.sys.posix.sys.socket]
kinke f342c2c
Emscripten: Switch from predefined CRuntime_WASI to CRuntime_Musl
kinke 06c29f2
[CI: Try mounting host timezone DB into node process]
kinke 346bf95
[finish removal of wasm-ld linker special case]
kinke 2d81f40
[add -Xcc=-nostdlib to 55-target-wasm-naked.conf]
kinke 7ef92df
[avoid warning wrt. ignored -Xcc switches when using -link-internally]
kinke ca0e64f
[fix core.sync.event unittest failure]
kinke 4459e8d
[try using default Posix timezone data dir]
kinke 2830c39
[Phobos: Hack around lacking TZ env var support]
kinke 7cbdd31
[polish]
kinke 9beaff6
[changelog]
kinke 33d6afb
[polish phobos]
kinke aad1338
[fix core.stdc.limits]
kinke 1956ff6
[fix remaining mismatching constants reported by importc_compare, exc…
kinke e18b055
[oh, Phobos depends on wchar_t being a Unicode char type, not int]
kinke ad2d653
Merge remote-tracking branch 'origin/master' into emscripten
kinke d48cbac
[leave WCHAR_{MIN,MAX} as they were, fix wint_t to int, and generaliz…
kinke a753093
[default to -Xcc=-sALLOW_MEMORY_GROWTH in Emscripten runtime .conf]
kinke fe39ae6
[fix [u]int_fast16_t regression]
kinke 1d64f48
[bump Emscripten SDK to latest v6.0.8]
kinke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| name: "Emscripten: Install additional prerequisites" | ||
| inputs: | ||
| emsdk_version: | ||
| required: false | ||
| default: '6.0.8' | ||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: "Install emsdk" # into ../emsdk | ||
| shell: bash | ||
| run: | | ||
| set -eux | ||
| cd .. | ||
|
|
||
| git clone https://github.com/emscripten-core/emsdk.git | ||
| cd emsdk | ||
| ./emsdk install '${{ inputs.emsdk_version }}' | ||
| ./emsdk activate '${{ inputs.emsdk_version }}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| name: "Emscripten: Cross-compile druntime & phobos incl. test runners, install libs + .conf, run druntime & phobos unittests" | ||
| inputs: | ||
| arch: | ||
| required: true | ||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Cross-compile druntime & phobos incl. test runners & install libs + .conf | ||
| shell: bash | ||
| run: | | ||
| set -eux | ||
| cd .. | ||
|
|
||
| os='emscripten' | ||
| arch='${{ inputs.arch }}' | ||
| triple="$arch-unknown-$os" | ||
|
|
||
| bootstrap-ldc/bin/ldc-build-runtime \ | ||
| --ninja \ | ||
| --dFlags="-mtriple=$triple" \ | ||
| --linkerFlags="--preload-file;/usr/share/zoneinfo" \ | ||
| --ldcSrcDir="$PWD/ldc" \ | ||
| --installWithSuffix="-$os-$arch" \ | ||
| --testrunners \ | ||
| CMAKE_INSTALL_PREFIX="$PWD/install" \ | ||
| RT_CONF_TRIPLE_REGEX="$arch-.*-$os" \ | ||
| CMAKE_TOOLCHAIN_FILE="$PWD/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake" \ | ||
| BUILD_LTO_LIBS=ON | ||
|
|
||
| - name: Run druntime unittests | ||
| shell: bash | ||
| run: | | ||
| set -eux | ||
| cd ../ldc-build-runtime.tmp | ||
|
|
||
| ../emsdk/node/*/bin/node ./druntime-test-runner-debug.js | ||
| ../emsdk/node/*/bin/node ./druntime-test-runner.js | ||
|
|
||
| - name: Run phobos unittests | ||
| shell: bash | ||
| run: | | ||
| set -eux | ||
| cd ../ldc-build-runtime.tmp | ||
|
|
||
| ../emsdk/node/*/bin/node ./phobos2-test-runner-debug.js | ||
| ../emsdk/node/*/bin/node ./phobos2-test-runner.js | ||
|
|
||
| - name: Run `importc_compare` | ||
| shell: bash | ||
| run: | | ||
| set -eux | ||
| cd .. | ||
|
|
||
| os='emscripten' | ||
| arch='${{ inputs.arch }}' | ||
| triple="$arch-unknown-$os" | ||
|
|
||
| bootstrap-ldc/bin/ldc2 \ | ||
| -defaultlib=druntime-ldc -L-Linstall/lib-$os-$arch \ | ||
| -gcc="$PWD/emsdk/upstream/emscripten/emcc" \ | ||
| --mtriple=$triple \ | ||
| -I$PWD/ldc/runtime/druntime/test/importc_compare/src \ | ||
| $PWD/ldc/runtime/druntime/test/importc_compare/src/importc_compare.d | ||
|
|
||
| emsdk/node/*/bin/node ./importc_compare.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 is e.g. also still to polish, causing the Alpine CI job failures (no integrated LLD, but external
wasm-ld).This all dates back to the very early wasm support, like the wasm-defaults .conf file - we used to only support bare-metal wasm, so no druntime and Phobos to link, and no need for a C compiler as linker driver, since there wasn't a wasm libc support either. So we used to invoke
wasm-ld(unless we have an integrated LLD) with the ld CLI interface, for all (non-WASI) wasm targets.We can keep this behavior for backwards-compatibility, but then only when targeting an unknown/none OS. We already do that in
55-target-wasm-naked.confnowadays, via the-link-internally(=> use integrated lld withwasm-ldCLI interface) - but only if LLD integration was enabled at build-time.So the compiler special case here would only be needed without LLD integration. Not sure that's worth the trouble, incl. the
link_WebAssemblylit complication (looking for an externalwasm-ld), which I haven't gotten rid of yet.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.
In theory, using most modern system
clangas link driver for bare-metal Wasm should be fine?wasm-ldis a standard part of LLVM distributions nowadays.One notable exception is (at least) macOS 15's clang. So you'll have to have either MacPorts/Homebrew LLVM/Clang available to use as
-gcc, or usewasi-sdk's (oremsdk's).But if we use
-link-internallyby default, then you probably won't notice the difference most of the time.Uh oh!
There was an error while loading. Please reload this page.
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.
Oh right - I've just tested this with my system-default clang 18, and it works with an extra
-Xcc=-nostdlib:So yeah, that should be good enough. Noone has requested an
ldCLI interface for other targets either, so...