japaric / xargo

The sysroot manager that lets you build and customize `std`
Apache License 2.0
1.09k stars 93 forks source link

Most basic attempt to use fails. #208

Open vi opened 6 years ago

vi commented 6 years ago
$ cargo new --bin qwer
     Created binary (application) `qwer` project
$ cd qwer
$ xargo build
   Compiling core v0.0.0 (file:///home/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore)
    Finished release [optimized] target(s) in 45.4 secs
   Compiling qwer v0.1.0 (file:///tmp/q/qwer)
error[E0463]: can't find crate for `std`

Even if Xargo not supposed to be used like this, error message should be more helpful. Or it should produce result similar to plain cargo build.

$ cat >> Xargo.toml
[dependencies]
std = {}

$ xargo build
    Updating registry `https://github.com/rust-lang/crates.io-index`
   Compiling cfg-if v0.1.2                                                      
   Compiling libc v0.2.40
   Compiling cc v1.0.9
   Compiling core v0.0.0 (file:///home/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore)
   Compiling unwind v0.0.0 (file:///home/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libunwind)
   Compiling filetime v0.1.15
   Compiling build_helper v0.1.0 (file:///home/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/build_helper)
   Compiling std v0.0.0 (file:///home/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd)
   Compiling cmake v0.1.29
   Compiling compiler_builtins v0.0.0 (file:///home/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/rustc/compiler_builtins_shim)
   Compiling rustc_asan v0.0.0 (file:///home/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/librustc_asan)
   Compiling rustc_msan v0.0.0 (file:///home/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/librustc_msan)
   Compiling rustc_lsan v0.0.0 (file:///home/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/librustc_lsan)
   Compiling rustc_tsan v0.0.0 (file:///home/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/librustc_tsan)
   Compiling std_unicode v0.0.0 (file:///home/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd_unicode)
   Compiling libc v0.0.0 (file:///home/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/rustc/libc_shim)
   Compiling panic_abort v0.0.0 (file:///home/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libpanic_abort)
   Compiling alloc v0.0.0 (file:///home/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/liballoc)
   Compiling alloc_system v0.0.0 (file:///home/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/liballoc_system)
error[E0463]: can't find crate for `alloc_jemalloc`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: Could not compile `std`.
$ cat > Xargo.toml
[dependencies]
std = {default-features=false, features=["force_alloc_system"]}
$ xargo build
...
   Compiling alloc_system v0.0.0 (file:///home/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/liballoc_system)
error[E0463]: can't find crate for `panic_unwind`
$ cat >> Cargo.toml
[profile.release]
panic = "abort"
$ xargo build --release
   Compiling qwer v0.1.0 (file:///tmp/q/qwer)
    Finished release [optimized] target(s)

Each of previous step should have either produced the executable or a meaningful error message.

japaric commented 6 years ago

Use xargo build --target $HOST (where e.g. HOST = x86_64-unknown-linux-gnu) when compiling natively. This is due to Cargo "feature" and it's documented in the README.

Feel free to send a PR improving the error message!

vi commented 6 years ago

alloc_jemalloc problem persists even with --target, with std = {}.