Skip to content

Always depends on std when built with cargo #14

Closed
@jdub

Description

@jdub

The following lines mean that libc always depends on std when built with cargo...

#![cfg_attr(not(feature = "cargo-build"), no_std)]

...

#[cfg(feature = "cargo-build")] extern crate std as core;
#[cfg(not(feature = "cargo-build"))] extern crate core;

... which doesn't work when using cargo with a no_std crate and an alternative target (without a cross-compiled std crate, but that's ultimately not what I want anyway).

In an attempt to hack around this, I added the following to my Cargo.toml:

[dependencies.libc]
version = "0.1"
features = []
default-features = false

But this is the build command line:

rustc /home/jdub/.cargo/registry/src/github.colasdn.workers.dev-0a35038f75765ae4/libc-0.1.8/rust/src/liblibc/lib.rs --crate-name libc --crate-type lib -g --cfg feature="default" --cfg feature="cargo-build" -C metadata=ef5cbad4ef5c7a1e -C extra-filename=-ef5cbad4ef5c7a1e --out-dir /home/jdub/src/derp/acpica/target/i686-unknown-linux-gnu/debug/deps --emit=dep-info,link --target ../derp/i686-unknown-linux-gnu.json -L dependency=/home/jdub/src/derp/acpica/target/i686-unknown-linux-gnu/debug/deps -L dependency=/home/jdub/src/derp/acpica/target/i686-unknown-linux-gnu/debug/deps -Awarnings

Part of the challenge here is that the libc crate is just a slim wrapper around the Rust's liblibc, so changing things is probably difficult.

Thoughts or suggestions, though? Should I not use the libc crate at all?

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