Skip to content
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

Support WebAssembly target platforms wasm{32,64}-unknown-unknown #405

Merged
merged 10 commits into from
Oct 18, 2024

Conversation

jmillikin
Copy link
Collaborator

No description provided.

Copy link
Member

@fmeum fmeum left a comment

Choose a reason for hiding this comment

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

This generally looks good to me.

Could you add a test that builds a simple binary for wasm using a transition? Ideally that would also include adding a usage of libclang_rt.

@jmillikin
Copy link
Collaborator Author

Tests added:

  • wasm32_strlen_libc which builds a 32-bit .wasm binaries with a libc.a dependency, and transitively requires wasm32-unknown-unknown/libclang_rt.builtins.a.
  • wasm64_strlen_nolibc which builds a 64-bit .wasm binary with no libc dependency (since 64-bit WebAssembly is still experimental, and therefore WASI SDK doesn't exist currently).
  • wasm32_strlen_nolibc which is the same code as ^^ but 32-bit, so wasm-dis can be used to manually verify the expected difference in ABI.

@jmillikin jmillikin force-pushed the target-wasm branch 2 times, most recently from 1e13068 to c287c5e Compare October 17, 2024 10:27
@fmeum
Copy link
Member

fmeum commented Oct 17, 2024

Thanks for adding tests! CI is failing now though.

@jmillikin
Copy link
Collaborator Author

CI appears to be failing for infrastructure reasons. I'll try poking at it a bit, but it might require a bit of refactoring to the test scripts.


container_test (debian, true):

/root/.cache/[...]: write (No space left on device)

container_test (linux_sysroot, true)

bin/wasm-ld: error while loading shared libraries: libxml2.so.2: cannot open shared object file: No such file or directory

test (macos-latest, latest, false)

ERROR: /Users/runner/work/toolchains_llvm/toolchains_llvm/tests/BUILD.bazel:209:10: Compiling wasm_strlen.c failed: (Exit 1): DUMMY_GCC_TOOL failed: error executing CppCompile command (from target //:wasm_strlen) external/rules_rust/rust/private/dummy_cc_toolchain/DUMMY_GCC_TOOL -MD -MF bazel-out/darwin_arm64-fastbuild-ST-ee9519131230/bin/_objs/wasm_strlen/wasm_strlen.d ... (remaining 18 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
src/main/tools/process-wrapper-legacy.cc:80: "execvp(external/rules_rust/rust/private/dummy_cc_toolchain/DUMMY_GCC_TOOL, ...)": No such file or directory

@jmillikin
Copy link
Collaborator Author

Updated tests so that WebAssembly targets get their own directory, and the test script runs bazel clean --expunge before trying to build them -- this is intended as a mitigation to avoid running out of disk space.

Also updated tests/WORKSPACE to match tests/MODULE.bazel, and verified non-bzlmod via the following commands on my local workstation (Linux, Ubuntu 20.04)

bazel-7.0.0 test --enable_bzlmod=false //wasm:all
bazel-7.0.0 test --enable_bzlmod=true //wasm:all
bazel-7.3.2 test --enable_bzlmod=false //wasm:all
bazel-7.3.2 test --enable_bzlmod=true //wasm:all

@jmillikin
Copy link
Collaborator Author

jmillikin commented Oct 18, 2024

More test updates:

@jmillikin jmillikin force-pushed the target-wasm branch 2 times, most recently from 401c187 to ba7e71b Compare October 18, 2024 08:00
Copy link
Member

@fmeum fmeum left a comment

Choose a reason for hiding this comment

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

Thanks, this is a great addition!

@fmeum fmeum merged commit bda1c9f into bazel-contrib:master Oct 18, 2024
35 checks passed
@jmillikin jmillikin deleted the target-wasm branch October 18, 2024 09:11
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.

2 participants