-
Notifications
You must be signed in to change notification settings - Fork 27
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
feature std
leaking when using macro in no_std env
#47
Comments
std
leaking when using macrostd
leaking when using macro in no_std env
Hi @koushiro Thanks for the report! As I see it, there are 2 problems:
Does this clarify the situation? |
@ia0 Thanks for your reply. Is there a solution for earlier rust versions? |
Yes, it's in the README too. I don't know the earliest version where it would work, but it's at least a year (tracking issue). |
But it's doesn't work for earlier stable rust version, target you could try to run the below command under
the target |
I'll look into this this week-end because it'll take some time. I want to do some experiments to see if there is a regression or if this is more of a feature request. |
Fix #47. The problem is that for stable compilers older than 1.51, we used to support no-std alloc environments, but not no-alloc environments. For compilers 1.51 and later, we additionally support no-alloc environments using resolver = "2" in Cargo.toml of the end binary.
I could take a deeper look. I finally agree with your original post. Let me restate it with my own words:
However, note that it's still not clear to me how a project may use the alloc feature with a stable compiler. I have problems with |
Fix #47. The problem is that for stable compilers older than 1.51, we used to support no-std alloc environments, but not no-alloc environments. For compilers 1.51 and later, we additionally support no-alloc environments using resolver = "2" in Cargo.toml of the end binary.
I've published |
This commit changes the Cargo workspace setup to put all crates in One Big Workspace, rather than having separate workspaces for some targets. We now use the `per-package-target` unstable cargo feature to build different crates for different targets. This means that `cargo` commands in the root workspace now work without requiring the user to `cd` into a particular directory to build a platform target --- for example, I can now run: ```console # in the repo root directory $ cargo build -p mnemos-d1 --bin mq-pro ``` and build a MnemOS binary for the MQ Pro, without having to `cd` into the MQ Pro directory. One issue is that `cargo build --workspace` (and `check --workspace`, etc) still does not work correctly, due to some [weird][1] [issues][2] with feature unification which I don't entirely understand. However, as a workaround, I've changed the workspace Cargo.toml to add a [`default-members` field][3], so that running `cargo build` or `cargo check` _without_ `--workspace` will build the subset of crates in the `default-members` key. This way, `cargo {build, check, etc}` in the repo root will do something reasonable by default, and the actual platform targets can be built/checked with `cargo $WHATEVER --package $CRATE`. IMO, this is still substantially nicer than having a bunch of separate workspaces. [1]: ia0/data-encoding#47 [2]: bincode-org/bincode#556 [3]: https://doc.rust-lang.org/cargo/reference/workspaces.html#the-default-members-field
This commit changes the Cargo workspace setup to put all crates in One Big Workspace, rather than having separate workspaces for some targets. We now use the `per-package-target` unstable cargo feature to build different crates for different targets. This means that `cargo` commands in the root workspace now work without requiring the user to `cd` into a particular directory to build a platform target --- for example, I can now run: ```shell # in the repo root directory $ cargo build -p mnemos-d1 --bin mq-pro ``` and build a MnemOS binary for the MQ Pro, without having to `cd` into the MQ Pro directory. This is also necessary in order to make the `x86_64` build process added in PR #216 work, since it relies on cargo artifact dependencies, which appear not to work across workspaces. One issue is that `cargo build --workspace` (and `check --workspace`, etc) still does not work correctly, due to some [weird][1] [issues][2] with feature unification which I don't entirely understand. However, as a workaround, I've changed the workspace Cargo.toml to add a [`default-members` field][3], so that running `cargo build` or `cargo check` _without_ `--workspace` will build the subset of crates in the `default-members` key. This way, `cargo {build, check, etc}` in the repo root will do something reasonable by default, and the actual platform targets can be built/checked with `cargo $WHATEVER --package $CRATE`. IMO, this is still substantially nicer than having a bunch of separate workspaces. [1]: ia0/data-encoding#47 [2]: bincode-org/bincode#556 [3]: https://doc.rust-lang.org/cargo/reference/workspaces.html#the-default-members-field
In PR #35,
data-encoding = { version = "2.3", default-features = false, features = ["alloc"] }
was added intolib/macro/Cargo.toml
andlib/macro/internal/Cargo.toml
. It's ok for me.But in the later commit 76e21dd,
default-features = false, features = ["alloc"]
was removed fromlib/macro/internal/Cargo.toml
, which cause the featurestd
ofdata-encoding
leaking, I think.Solution:
lib/macro/internal/Cargo.toml
BTW, we could add
resolver = "2"
to theCargo.toml
of downstream crate (only useful for rust 1.51+) to fix the issue (Cargo's New Feature Resolver), but we need to compiledata-encoding
twice.The text was updated successfully, but these errors were encountered: