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

wip: allow building of wasm targets #496

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

snapbug
Copy link

@snapbug snapbug commented Apr 3, 2024

WIP attempt(s) to address #494.

Create a new toolchain builder that uses the rustc-wasm32 package instead than the rustc package.

The rustc-wasm32 package doesn't provide rustdoc so I created a derivation to extract that from the regular rustc target. This shouldn't cause any issues.

Bazel selects the correct toolchain, but still errors out with the following:

❯ bazel build --config=nix //:wasm --verbose_failures
INFO: Analyzed target //:wasm (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
ERROR: /home/grawlix/repos/github.com/snapbug/rules_nixpkgs/examples/toolchains/rust/BUILD:11:12: Compiling Rust bin hello (1 files) failed: (Exit 1): process_wrapper failed: error executing command (from target //:hello)
  (cd /home/grawlix/.cache/bazel/_bazel_grawlix/e607e8e55d4b1c2cd07980276d90b4b7/sandbox/linux-sandbox/41/execroot/__main__ && \
  exec env - \
    CARGO_CFG_TARGET_ARCH=wasm32 \
    CARGO_CFG_TARGET_OS=unknown \
    CARGO_CRATE_NAME=hello \
    CARGO_MANIFEST_DIR='${pwd}' \
    CARGO_PKG_AUTHORS='' \
    CARGO_PKG_DESCRIPTION='' \
    CARGO_PKG_HOMEPAGE='' \
    CARGO_PKG_NAME=hello \
    CARGO_PKG_VERSION=0.0.0 \
    CARGO_PKG_VERSION_MAJOR=0 \
    CARGO_PKG_VERSION_MINOR=0 \
    CARGO_PKG_VERSION_PATCH=0 \
    CARGO_PKG_VERSION_PRE='' \
    SYSROOT=bazel-out/k8-fastbuild-ST-38b09129ed05/bin/external/nix_wasm_rust/rust_wasm_nix_impl \
  bazel-out/k8-opt-exec-C7777A24-ST-da94b34a892a/bin/external/rules_rust/util/process_wrapper/process_wrapper --subst 'pwd=${pwd}' -- bazel-out/k8-fastbuild-ST-38b09129ed05/bin/external/nix_wasm_rust/rust_wasm_nix_impl/bin/rustc hello.rs '--crate-name=hello' '--crate-type=bin' '--error-format=human' '--out-dir=bazel-out/k8-fastbuild-ST-38b09129ed05/bin' '--codegen=opt-level=0' '--codegen=debuginfo=0' '--remap-path-prefix=${pwd}=' '--emit=dep-info,link' '--color=always' '--target=wasm32-unknown-unknown' -L bazel-out/k8-fastbuild-ST-38b09129ed05/bin/external/nix_wasm_rust/rust_wasm_nix_impl/lib/rustlib/wasm32-unknown-unknown/lib -L bazel-out/k8-fastbuild-ST-38b09129ed05/bin/external/nix_wasm_rust/rust_wasm_nix_impl/lib/rustlib/x86_64-unknown-linux-gnu/lib '--edition=2021' '--sysroot=bazel-out/k8-fastbuild-ST-38b09129ed05/bin/external/nix_wasm_rust/rust_wasm_nix_impl')
# Configuration: 0590131d7658b76a08b19d13b2b4ddbfb70bcfab1a21c0745038366e0d666ffe
# Execution platform: @rules_nixpkgs_core//platforms:host

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
error: linker `rust-lld` not found
  |
  = note: No such file or directory (os error 2)

error: aborting due to previous error

Target //:wasm failed to build
INFO: Elapsed time: 0.168s, Critical Path: 0.08s
INFO: 5 processes: 5 internal.
FAILED: Build did NOT complete successfully

I think the way to make progress here is to do a similar thing as the rustdoc fix for rust-lld, although that might be a bit tougher as the rust-lld binary seems to be nested in the lib content. So have to investigate the full-path here, or alternatives.

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.

1 participant