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

How to set features for different crates in a workspace? #15988

Open
junderw opened this issue Nov 29, 2023 · 2 comments
Open

How to set features for different crates in a workspace? #15988

junderw opened this issue Nov 29, 2023 · 2 comments
Labels
C-support Category: support questions

Comments

@junderw
Copy link

junderw commented Nov 29, 2023

I have a workspace with 2 crates.

  1. A library that has various features like std which I can turn off for no_std, and also by default a rand feature that includes the rand crate.
  2. A WASM binary that targets wasm32-unknown-unknown. This depends on crate 1 with default-features = false (to allow no_std)

The WASM binary replaces the #[panic_handler] and cargo check and cargo build throw no errors.

However, rust-analyzer gives me an error on the panic handler:

found duplicate lang item `panic_impl`
the lang item is first defined in crate `std` (which `test` depends on)
first definition in `std` loaded from /home/jonathan/.rustup/toolchains/1.74.0-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libstd-3354d2cb1f357486.rlib
second definition in the local crate

Here's the repo: https://github.com/bitcoinjs/tiny-secp256k1/tree/wip/modular (note: the wip/modular branch)
(I've committed the .cargo folder and .vscode folder)

@junderw junderw added the C-support Category: support questions label Nov 29, 2023
@lnicola
Copy link
Member

lnicola commented Nov 29, 2023

It might not be what you want, but you can disable the default features when working on the WASM part, which will make std go away.

The other option I can see is to use two VS Code workspaces, one with the library, and one with both, and disable the default features in the workspace settings for the latter.

@Veykril
Copy link
Member

Veykril commented Nov 29, 2023

That is currently not possible, configs are global only until #13529 is done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-support Category: support questions
Projects
None yet
Development

No branches or pull requests

3 participants