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

wasm-pack support #21

Closed
glauserr opened this issue Feb 28, 2019 · 8 comments
Closed

wasm-pack support #21

glauserr opened this issue Feb 28, 2019 · 8 comments

Comments

@glauserr
Copy link

glauserr commented Feb 28, 2019

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`
  
@lambda-fairy
Copy link
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
Copy link
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
Copy link

Zaechus commented Oct 25, 2019

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
Copy link
Owner

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

@lambda-fairy
Copy link
Owner

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

@Itanq
Copy link

Itanq commented Apr 2, 2020

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
Copy link
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
Copy link

Itanq commented Apr 4, 2020

@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
Projects
None yet
Development

No branches or pull requests

4 participants