Skip to content

Impossible to build the toml crate for the riscv32imc-unknown-none-elf target in no_std #1054

@Luni-4

Description

@Luni-4

It is not possible to build the toml crate for the riscv32imc-unknown-none-elf target in a no_std environment. The following error occurs when running the cargo build --release command:

error[E0433]: failed to resolve: could not find `sync` in `alloc`
   --> /home/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/toml-0.9.8/src/de/error.rs:7:26
    |
  7 |     input: Option<alloc::sync::Arc<str>>,
    |                          ^^^^ could not find `sync` in `alloc`
    |
note: found an item that was configured out
   --> /home/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/lib.rs:233:9
    |
232 | #[cfg(all(not(no_rc), not(no_sync), target_has_atomic = "ptr"))]
    |                                     ------------------------- the item is gated behind the `ptr` feature
233 | pub mod sync;
    |         ^^^^

error[E0433]: failed to resolve: could not find `sync` in `alloc`
   --> /home/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/toml-0.9.8/src/de/error.rs:14:37
    |
 14 |     pub(crate) fn new(input: alloc::sync::Arc<str>, error: toml_parser::ParseError) -> Self {
    |                                     ^^^^ could not find `sync` in `alloc`
    |
note: found an item that was configured out
   --> /home/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/lib.rs:233:9
    |
232 | #[cfg(all(not(no_rc), not(no_sync), target_has_atomic = "ptr"))]
    |                                     ------------------------- the item is gated behind the `ptr` feature
233 | pub mod sync;
    |         ^^^^

error[E0433]: failed to resolve: could not find `sync` in `alloc`
   --> /home/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/toml-0.9.8/src/de/error.rs:205:26
    |
205 |     input: Option<alloc::sync::Arc<str>>,
    |                          ^^^^ could not find `sync` in `alloc`
    |
note: found an item that was configured out
   --> /home/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/lib.rs:233:9
    |
232 | #[cfg(all(not(no_rc), not(no_sync), target_has_atomic = "ptr"))]
    |                                     ------------------------- the item is gated behind the `ptr` feature
233 | pub mod sync;
    |         ^^^^

error[E0433]: failed to resolve: could not find `sync` in `alloc`
   --> /home/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/toml-0.9.8/src/de/error.rs:230:47
    |
230 |                 .get_or_insert_with(|| alloc::sync::Arc::from(self.source.input()));
    |                                               ^^^^ could not find `sync` in `alloc`
    |
note: found an item that was configured out
   --> /home/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/lib.rs:233:9
    |
232 | #[cfg(all(not(no_rc), not(no_sync), target_has_atomic = "ptr"))]
    |                                     ------------------------- the item is gated behind the `ptr` feature
233 | pub mod sync;
    |         ^^^^

error[E0433]: failed to resolve: could not find `sync` in `alloc`
   --> /home/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/toml-0.9.8/src/de/error.rs:242:43
    |
242 |             .get_or_insert_with(|| alloc::sync::Arc::from(self.source.input()));
    |                                           ^^^^ could not find `sync` in `alloc`
    |
note: found an item that was configured out
   --> /home/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/lib.rs:233:9
    |
232 | #[cfg(all(not(no_rc), not(no_sync), target_has_atomic = "ptr"))]
    |                                     ------------------------- the item is gated behind the `ptr` feature
233 | pub mod sync;

Is there any possible workaround? Thanks in advance!

The Cargo.toml with the salient parts:

[package]
edition = "2024"

[dependencies]
toml.version = "0.9.8"
toml.default-features = false
toml.features = ["display", "parse", "serde"]

The .cargo/config.toml

[env]
ESP_LOG="info"

[build]
rustflags = [
  # Required to obtain backtraces (e.g. when using the "esp-backtrace" crate.)
  # NOTE: May negatively impact performance of produced code
  "-C", "force-frame-pointers",
]

target = "riscv32imc-unknown-none-elf"

[unstable]
build-std = ["alloc", "core"]

The rust-toolchain.toml file

[toolchain]
channel = "nightly"
components = ["rust-src"]
targets = ["riscv32imc-unknown-none-elf"]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions