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

Compiling with target wasm32-wasi fails #146

Closed
calebschoepp opened this issue May 27, 2024 · 3 comments
Closed

Compiling with target wasm32-wasi fails #146

calebschoepp opened this issue May 27, 2024 · 3 comments

Comments

@calebschoepp
Copy link
Contributor

Bug Report

Version

├── tracing v0.1.40
│   ├── tracing-attributes v0.1.27 (proc-macro)
│   └── tracing-core v0.1.32
├── tracing-opentelemetry v0.23.0
│   ├── tracing v0.1.40 (*)
│   ├── tracing-core v0.1.32 (*)
│   ├── tracing-log v0.2.0
│   │   └── tracing-core v0.1.32 (*)
│   └── tracing-subscriber v0.3.18
│       ├── tracing-core v0.1.32 (*)
│       └── tracing-log v0.2.0 (*)
└── tracing-subscriber v0.3.18 (*)

Platform

Darwin rocinante.local 23.5.0 Darwin Kernel Version 23.5.0: Wed May  1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000 arm64

Description

Compiling an app to a wasm32-wasi target fails e.g. cargo build --target wasm32-wasi --release. Here's an example of the error I'm seeing:

Building component tracing-spin with `cargo build --target wasm32-wasi --release`
   Compiling tracing-opentelemetry v0.23.0
error[E0432]: unresolved import `web_time`
  --> /Users/caleb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tracing-opentelemetry-0.23.0/src/layer.rs:21:5
   |
21 | use web_time::Instant;
   |     ^^^^^^^^ use of undeclared crate or module `web_time`

error[E0433]: failed to resolve: use of undeclared crate or module `js_sys`
   --> /Users/caleb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tracing-opentelemetry-0.23.0/src/lib.rs:164:67
    |
164 |         SystemTime::UNIX_EPOCH + std::time::Duration::from_millis(js_sys::Date::now() as u64)
    |                                                                   ^^^^^^ use of undeclared crate or module `js_sys`

Some errors have detailed explanations: E0432, E0433.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `tracing-opentelemetry` (lib) due to 2 previous errors
Error: Build command for component tracing-spin failed with status Exited(101)

I was able to work around this by using a fork of tracing-opentelemetry where I replaced the instances of #[cfg(target_arch = "wasm32")] with #[cfg(not(all(target_arch = "wasm32", not(target_os = "wasi"))))] in layer.rs and lib.rs. It is incorrectly trying to use js_sys and web_time when the architecture is Wasm even though they're not included as dependencies when the OS is Wasi.

@djc
Copy link
Collaborator

djc commented May 27, 2024

Thanks for the report -- are you able to submit a PR?

@calebschoepp
Copy link
Contributor Author

Thanks for the report -- are you able to submit a PR?

Happy to submit a PR 👍

@calebschoepp
Copy link
Contributor Author

#147 closes this

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

No branches or pull requests

2 participants