Skip to content

Fix no-std support#7

Merged
EricLBuehler merged 2 commits into
EricLBuehler:masterfrom
dtolnay-contrib:nostd
Aug 11, 2025
Merged

Fix no-std support#7
EricLBuehler merged 2 commits into
EricLBuehler:masterfrom
dtolnay-contrib:nostd

Conversation

@dtolnay

@dtolnay dtolnay commented Aug 11, 2025

Copy link
Copy Markdown
Contributor

Despite having a "std" feature that can be disabled:

float8/Cargo.toml

Lines 30 to 32 in 273b1f9

[features]
default = ["std"]
std = []

the float8 crate did not work with a no-std target platform because it unconditionally enabled the half crate's default "std" feature:

float8/Cargo.toml

Lines 13 to 14 in 273b1f9

[dependencies]
half = "2.4.1"

and also unconditionally used a bunch of APIs from std, which no-std platforms do not have.

float8/src/lib.rs

Lines 83 to 87 in 273b1f9

use std::{
cmp::Ordering,
num::FpCategory,
ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, RemAssign, Sub, SubAssign},
};

error[E0463]: can't find crate for `std`
  |
  = note: the `riscv64gc-unknown-none-elf` target may not support the standard library
  = note: `std` is required by `half` because it does not declare `#![no_std]`
  = help: consider building the standard library from source with `cargo build -Zbuild-std`

@EricLBuehler EricLBuehler left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@EricLBuehler EricLBuehler merged commit ecc73a9 into EricLBuehler:master Aug 11, 2025
14 checks passed
@dtolnay dtolnay deleted the nostd branch August 11, 2025 21:55
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

Successfully merging this pull request may close these issues.

2 participants