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

stub wasm32-u-u target ? #9

Closed
pinkforest opened this issue Nov 26, 2022 · 6 comments
Closed

stub wasm32-u-u target ? #9

pinkforest opened this issue Nov 26, 2022 · 6 comments

Comments

@pinkforest
Copy link

pinkforest commented Nov 26, 2022

Re: clap-rs/clap#4510

Considering is_terminal is seen as direct migration from atty -

When people are migrating off atty they will get this error under wasm32-u-u if there is callpath to is_terminal:

  --> .cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/errno-0.2.8/src/lib.rs:33:1
   |
33 | mod sys;
   | ^^^^^^^^
   |
   = help: to create the module `sys`, create file ".cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/errno-0.2.8/src/sys.rs" or ".cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/errno-0.2.8/src/sys/mod.rs"

error[E0425]: cannot find function `errno` in module `sys`
   --> .cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/errno-0.2.8/src/lib.rs:101:10
    |
101 |     sys::errno()
    |          ^^^^^ not found in `sys`

error[E0425]: cannot find function `set_errno` in module `sys`
   --> .cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/errno-0.2.8/src/lib.rs:106:10
    |
106 |     sys::set_errno(err)
    |          ^^^^^^^^^ not found in `sys`

Would it be feasible to stub out wasm32-u-u that it still builds and provides false to is_terminal ?

Or at least if the dependency is there it does not try to build stuff in wasm32-u-u that will fail to compile ?

Considering the below -

Even if one stamps out the calls to is_terminal then io-lifetimes doesn't build at all if it's present in the dependencies

Sometimes the dependencies come via default features as in case of clap which made it pretty complicated to remove -

Yeah I know wasm32-u-u doesn't have terminal but would it be feasible to provide stubs for it to ease migration ?

Or at least cfg gate some of it out @ target_family = "wasm", target_os = "unknown" ?

Cheers

@pinkforest pinkforest changed the title wasm32-u-u target under stable-x86_64-unknown-linux-gnu stub wasm32-u-u target ? Nov 26, 2022
@sunfishcode
Copy link
Owner

Yes, I think a stub that returns false makes sense. I'll add that.

@epage
Copy link

epage commented Nov 28, 2022

Also for wasm32-unknown-unknown

error[E0432]: unresolved imports `portability::AsFilelike`, `portability::AsSocketlike`, `portability::BorrowedFilelike`, `portability::BorrowedSocketlike`, `portability::FromFilelike`, `portability::FromSocketlike`, `portability::IntoFilelike`, `portability::IntoSocketlike`, `portability::OwnedFilelike`, `portability::OwnedSocketlike`
   --> /home/runner/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/io-lifetimes-1.0.1/src/lib.rs:157:5
    |
157 |     AsFilelike, AsSocketlike, BorrowedFilelike, BorrowedSocketlike, FromFilelike, FromSocketlike,
    |     ^^^^^^^^^^  ^^^^^^^^^^^^  ^^^^^^^^^^^^^^^^  ^^^^^^^^^^^^^^^^^^  ^^^^^^^^^^^^  ^^^^^^^^^^^^^^ no `FromSocketlike` in `portability`
    |     |           |             |                 |                   |
    |     |           |             |                 |                   no `FromFilelike` in `portability`
    |     |           |             |                 no `BorrowedSocketlike` in `portability`
    |     |           |             no `BorrowedFilelike` in `portability`
    |     |           no `AsSocketlike` in `portability`
    |     no `AsFilelike` in `portability`
158 |     IntoFilelike, IntoSocketlike, OwnedFilelike, OwnedSocketlike,
    |     ^^^^^^^^^^^^  ^^^^^^^^^^^^^^  ^^^^^^^^^^^^^  ^^^^^^^^^^^^^^^ no `OwnedSocketlike` in `portability`
    |     |             |               |
    |     |             |               no `OwnedFilelike` in `portability`
    |     |             no `IntoSocketlike` in `portability`
    |     no `IntoFilelike` in `portability`

@epage
Copy link

epage commented Nov 28, 2022

Also, some calls are already stubbed. The issue will be making the dependencies platform specific.

@sunfishcode would you like me to take a stab at this?

@sunfishcode
Copy link
Owner

I've just release io-lifetimes 1.0.3 which avoids defining things that don't work on wasm32-unknown-unknown, which fixes the immediate compilation errors.

Looking at this more closely though, this makes it impossible to support is-terminal's current API on wasm32-unknoown-unknown because is-terminal expects a handle argument, and there are no handle types defined on wasm32-unknown-unknown.

I'm considering adding additional functions to is-terminal, such as fn stdout_is_terminal() -> bool, and similar for stdin/stderr, which avoid taking a handle. They'd work on all platforms, and on platforms that have no handle types, they'd be the only thing that works.

@sunfishcode
Copy link
Owner

Ah, I was mistaken above. We can implement is-terminal for Stdout and similar types; I've now submitted #10 to implement this.

@pinkforest
Copy link
Author

Cool. It all builds now 👍 thanks!

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

3 participants