Skip to content

Commit

Permalink
Fix building with no-std
Browse files Browse the repository at this point in the history
Trying to build in an no-std doesn't work.
Example with zune-jpg and x86_64-unknown-uefi:

```
> cargo build -p zune-jpeg --target x86_64-unknown-uefi --no-default-features
   Compiling zune-core v0.2.13 (/home/zoid/clone/active/zune-image/zune-core)
error[E0463]: can't find crate for `std`
  |
  = note: the `x86_64-unknown-uefi` target may not support the standard library
  = note: `std` is required by `zune_core` because it does not declare `#![no_std]`
[...]
```

This seems to be due to a bug (or expected behavior) in the cargo
worktrees: rust-lang/cargo#8366

From zune-jpeg we can't disable the default features of zune-core.
But that's no problem, since zune-jpeg already enabled the std feature
in zune-core, whenver its std feature is enabled.

With this patch, compilation succeeds:

```
> cargo build -p zune-jpeg --target x86_64-unknown-uefi --no-default-features
   Compiling zune-jpeg v0.3.16 (/home/zoid/clone/active/zune-image/zune-jpeg)
warning: dropping unsupported crate type `cdylib` for target `x86_64-unknown-uefi`

warning: `zune-jpeg` (lib) generated 1 warning
    Finished dev [unoptimized + debuginfo] target(s) in 0.15s
```

Signed-off-by: Daniel Schaefer <[email protected]>
  • Loading branch information
JohnAZoidberg authored and etemesi254 committed Jun 11, 2023
1 parent 627ece4 commit bff0c87
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions crates/zune-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ license = "MIT OR Apache-2.0 OR Zlib"
[features]
# When present, we can use std facilities to detect
# if a specific feature exists
# Not enabled by default. Other zune crates can enable dep:zune-core/std by default.
# But if we enable it here, they can't disable it anymore.
# See: https://github.com/rust-lang/cargo/issues/8366
std = []
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
default = ["std"]

[dependencies]
bitflags = "2.1.0"
serde = { version = "1.0.52", optional = true }
serde = { version = "1.0.52", optional = true }

0 comments on commit bff0c87

Please sign in to comment.