Skip to content

wasm-pack support #21

@glauserr

Description

@glauserr

The crate does not support to be compiled with wasm32-unknown-unknown. It there any will to add support for it in the close future?

$ wasm-pack build 

error[E0433]: failed to resolve: use of undeclared type or module `sys`
    --> /home/regl/.cargo/registry/src/github.com-1ecc6299db9ec823/errno-0.2.4/src/lib.rs:35:9
     |
  35 |         sys::with_description(*self, |desc| {
     |         ^^^ use of undeclared type or module `sys`
  
  error[E0433]: failed to resolve: use of undeclared type or module `sys`
    --> /home/regl/.cargo/registry/src/github.com-1ecc6299db9ec823/errno-0.2.4/src/lib.rs:46:9
     |
  46 |         sys::with_description(*self, |desc| match desc {
     |         ^^^ use of undeclared type or module `sys`
  
  error[E0433]: failed to resolve: use of undeclared type or module `sys`
    --> /home/regl/.cargo/registry/src/github.com-1ecc6299db9ec823/errno-0.2.4/src/lib.rs:50:25
     |
  50 |                 self.0, sys::STRERROR_NAME, fm_err.0),
     |                         ^^^ use of undeclared type or module `sys`
  
  error[E0433]: failed to resolve: use of undeclared type or module `sys`
    --> /home/regl/.cargo/registry/src/github.com-1ecc6299db9ec823/errno-0.2.4/src/lib.rs:69:5
     |
  69 |     sys::errno()
     |     ^^^ use of undeclared type or module `sys`
  
  error[E0433]: failed to resolve: use of undeclared type or module `sys`
    --> /home/regl/.cargo/registry/src/github.com-1ecc6299db9ec823/errno-0.2.4/src/lib.rs:74:5
     |
  74 |     sys::set_errno(err)
     |     ^^^ use of undeclared type or module `sys`
  

Activity

lambda-fairy

lambda-fairy commented on Mar 1, 2019

@lambda-fairy
Owner

What would you like the library to do in this case?

If you want to match what std does -- have a placeholder that returns 0 -- then that's okay with me. My only concern is that it might be confusing, especially if std adds a real errno implementation in the future.

lambda-fairy

lambda-fairy commented on Mar 1, 2019

@lambda-fairy
Owner

Also, what's your use case for this? Most of the packages that depend on errno don't make sense on the web anyway.

Zaechus

Zaechus commented on Oct 25, 2019

@Zaechus

I'm having the same issue when compiling to wasm32-wasi. The build fails with the same error message for both stable and nightly channels.

lambda-fairy

lambda-fairy commented on Oct 31, 2019

@lambda-fairy
Owner

WASI support sounds reasonable to me. I'll be happy to review a PR that adds it.

lambda-fairy

lambda-fairy commented on Mar 27, 2020

@lambda-fairy
Owner

We support WASI now, so I believe this can be closed.

Itanq

Itanq commented on Apr 2, 2020

@Itanq

We support WASI now, so I believe this can be closed.

Hi @lambda-fairy , Could you please tell me in which version the support for wasm was added?
I use the latest version(v0.2.5), the problem still here. as following:

cargo build --target=wasm32-unknown-unknown
---------------
error[E0433]: failed to resolve: use of undeclared type or module `sys`
  --> D:\Environments\.cargo\registry\src\mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd\errno-0.2.5\src\lib.rs:40:9
   |
40 |         sys::with_description(*self, |desc| {
   |         ^^^ use of undeclared type or module `sys`

error[E0433]: failed to resolve: use of undeclared type or module `sys`
  --> D:\Environments\.cargo\registry\src\mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd\errno-0.2.5\src\lib.rs:51:9
   |
51 |         sys::with_description(*self, |desc| match desc {
   |         ^^^ use of undeclared type or module `sys`

error[E0433]: failed to resolve: use of undeclared type or module `sys`
  --> D:\Environments\.cargo\registry\src\mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd\errno-0.2.5\src\lib.rs:55:25
   |
55 |                 self.0, sys::STRERROR_NAME, fm_err.0),
   |                         ^^^ use of undeclared type or module `sys`

error[E0433]: failed to resolve: use of undeclared type or module `sys`
  --> D:\Environments\.cargo\registry\src\mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd\errno-0.2.5\src\lib.rs:74:5
   |
74 |     sys::errno()
   |     ^^^ use of undeclared type or module `sys`

error[E0433]: failed to resolve: use of undeclared type or module `sys`
  --> D:\Environments\.cargo\registry\src\mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd\errno-0.2.5\src\lib.rs:79:5
   |
79 |     sys::set_errno(err)
   |     ^^^ use of undeclared type or module `sys`

error[E0277]: the size for values of type `str` cannot be known at compilation time
  --> D:\Environments\.cargo\registry\src\mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd\errno-0.2.5\src\lib.rs:52:16
   |
52 |             Ok(desc) => fmt.write_str(&desc),
   |                ^^^^ doesn't have a size known at compile-time
   |
   = help: the trait `std::marker::Sized` is not implemented for `str`
   = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
   = note: all local variables must have a statically known size
   = help: unsized locals are gated as an unstable feature

error[E0277]: the size for values of type `str` cannot be known at compilation time
  --> D:\Environments\.cargo\registry\src\mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd\errno-0.2.5\src\lib.rs:52:13
   |
52 |             Ok(desc) => fmt.write_str(&desc),
   |             ^^^^^^^^ doesn't have a size known at compile-time
   |
   = help: the trait `std::marker::Sized` is not implemented for `str`
   = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
   = note: required by `std::prelude::v1::Ok`

error[E0277]: the size for values of type `str` cannot be known at compilation time
  --> D:\Environments\.cargo\registry\src\mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd\errno-0.2.5\src\lib.rs:53:13
   |
53 |             Err(fm_err) => write!(
   |             ^^^^^^^^^^^ doesn't have a size known at compile-time
   |
   = help: the trait `std::marker::Sized` is not implemented for `str`
   = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
   = note: required by `std::prelude::v1::Err`

error: aborting due to 8 previous errors

Some errors have detailed explanations: E0277, E0433.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `errno`.

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed
lambda-fairy

lambda-fairy commented on Apr 2, 2020

@lambda-fairy
Owner

@Itanq try rust nightly with the wasm32-wasi target, as mentioned in CI:

https://github.com/lambda-fairy/rust-errno/blob/master/.travis.yml

wasm32-unknown-unknown is bare WASM with no WASI, so I don't think it should work there.

Itanq

Itanq commented on Apr 4, 2020

@Itanq

@Itanq try rust nightly with the wasm32-wasi target, as mentioned in CI:

https://github.com/lambda-fairy/rust-errno/blob/master/.travis.yml

wasm32-unknown-unknown is bare WASM with no WASI, so I don't think it should work there.

got it, it work, thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @lambda-fairy@Itanq@glauserr@Zaechus

        Issue actions

          wasm-pack support · Issue #21 · lambda-fairy/rust-errno