japaric / steed

[INACTIVE] Rust's standard library, free of C dependencies, for Linux systems
519 stars 22 forks source link

error: failed to load source for a dependency on `collections` #159

Open anxiousmodernman opened 6 years ago

anxiousmodernman commented 6 years ago

I just ran into this issue trying to build in Arch using the lld strategy (e.g. not Docker/cross). I'm trying to compile steed itself, not a dependent crate.

Note: The redox issue linked to seems to be closed. So I'm assuming we still need to use naive_ralloc.

I edited Xargo.toml per #153 discussion, but it didn't quite work.

[dependencies]
collections = {}
rand = {}

[dependencies.std]
default-features = false
features = ["naive_ralloc"]

[dependencies.compiler_builtins]
features = ["mem"]
stage = 1

That config still yielded a similar error

error: Package `ralloc v1.0.0 (https://github.com/redox-os/ralloc#
b521bac2)` does not have these features: `allocator`

Instead I fiddled with Cargo.toml, to try building with naive_alloc.

[package]
# This is NOT an official Rust project but since most code will come from
# the rust-lang/rust repo it makes sense to use this author.
authors = ["The Rust Project Developers"]
name = "std"
version = "0.1.0"

[dependencies]
sc = "0.2.1"

[dependencies.ralloc]
default-features = false
features = ["allocator"]
optional = true
git = "https://github.com/redox-os/ralloc"

[dependencies.naive_ralloc]
optional = true
path = "naive_ralloc"

[features]
default = ["naive_ralloc"]

[profile.release]
lto = true

Then I tried building with

xargo build 

The output

error: failed to load source for a dependency on `collections`

Caused by:
  Unable to update file:///home/coleman/.rustup/toolchains/nightly
-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcollections

Caused by:
  failed to read `/home/coleman/.rustup/toolchains/nightly-x86_64-
unknown-linux-gnu/lib/rustlib/src/rust/src/libcollections/Cargo.to
ml`

Caused by:
  No such file or directory (os error 2)
error: `"cargo" "build" "--release" "--manifest-path" "/tmp/xargo.
KcG2oOf3bp5o/Cargo.toml" "--target" "x86_64-unknown-linux-gnu" "-p
" "collections"` failed with exit code: Some(101)
note: run with `RUST_BACKTRACE=1` for a backtrace

I'd like to set up a development environment for steed, but I'm not quite sure how to get past this compiler error. Any pointers?

FenrirWolf commented 6 years ago

The collections crate no longer exists and its contents were subsumed by the alloc crate. So the first place to start would probably be to change collections = {} to alloc = {} in your Xargo.toml

anxiousmodernman commented 6 years ago

I did that and it felt like progress. Still hitting a roadblock, though. My current state:

  1. did git checkout Cargo.toml to throw away my changes there
  2. Xargo.toml now looks like
[dependencies]
alloc = {}
#rand = {}   # got rid of this, too

[dependencies.std]
default-features = false
#features = ["naive_ralloc"]
features = ["alloc"]

[dependencies.compiler_builtins]
features = ["mem"]
stage = 1

This, combined with master's Cargo.toml yields:

coleman:steed/ (master✗) $ xargo build                                    [15:50:31]
    Updating registry `https://github.com/rust-lang/crates.io-index`
warning: Package `std v0.0.0 (file:///home/coleman/.rustup/toolchains/nightly-x86_64-un
known-linux-gnu/lib/rustlib/src/rust/src/libstd)` does not have feature `alloc`. It has
 a required dependency with that name, but only optional dependencies can be used as fe
atures. This is currently a warning to ease the transition, but it will become an error
 in the future.
   Compiling core v0.0.0 (file:///home/coleman/.rustup/toolchains/nightly-x86_64-unknow
n-linux-gnu/lib/rustlib/src/rust/src/libcore)
   Compiling std_unicode v0.0.0 (file:///home/coleman/.rustup/toolchains/nightly-x86_64
-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd_unicode)
   Compiling alloc v0.0.0 (file:///home/coleman/.rustup/toolchains/nightly-x86_64-unkno
wn-linux-gnu/lib/rustlib/src/rust/src/liballoc)
    Finished release [optimized] target(s) in 26.23 secs
warning: Package `std v0.0.0 (file:///home/coleman/.rustup/toolchains/nightly-x86_64-un
known-linux-gnu/lib/rustlib/src/rust/src/libstd)` does not have feature `alloc`. It has
 a required dependency with that name, but only optional dependencies can be used as fe
atures. This is currently a warning to ease the transition, but it will become an error
 in the future.
   Compiling cfg-if v0.1.2
   Compiling unwind v0.0.0 (file:///home/coleman/.rustup/toolchains/nightly-x86_64-unkn
own-linux-gnu/lib/rustlib/src/rust/src/libunwind)
   Compiling cc v1.0.4
   Compiling libc v0.2.36
   Compiling libc v0.0.0 (file:///home/coleman/.rustup/toolchains/nightly-x86_64-unknow
n-linux-gnu/lib/rustlib/src/rust/src/rustc/libc_shim)
   Compiling filetime v0.1.14
   Compiling panic_abort v0.0.0 (file:///home/coleman/.rustup/toolchains/nightly-x86_64
-unknown-linux-gnu/lib/rustlib/src/rust/src/libpanic_abort)
   Compiling alloc_system v0.0.0 (file:///home/coleman/.rustup/toolchains/nightly-x86_6
4-unknown-linux-gnu/lib/rustlib/src/rust/src/liballoc_system)
   Compiling build_helper v0.1.0 (file:///home/coleman/.rustup/toolchains/nightly-x86_6
4-unknown-linux-gnu/lib/rustlib/src/rust/src/build_helper)
   Compiling std v0.0.0 (file:///home/coleman/.rustup/toolchains/nightly-x86_64-unknown
-linux-gnu/lib/rustlib/src/rust/src/libstd)
   Compiling compiler_builtins v0.0.0 (file:///home/coleman/.rustup/toolchains/nightly-
x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/rustc/compiler_builtins_shim)
   Compiling cmake v0.1.29
   Compiling rustc_lsan v0.0.0 (file:///home/coleman/.rustup/toolchains/nightly-x86_64-
unknown-linux-gnu/lib/rustlib/src/rust/src/librustc_lsan)
   Compiling rustc_asan v0.0.0 (file:///home/coleman/.rustup/toolchains/nightly-x86_64-
unknown-linux-gnu/lib/rustlib/src/rust/src/librustc_asan)
   Compiling rustc_tsan v0.0.0 (file:///home/coleman/.rustup/toolchains/nightly-x86_64-
unknown-linux-gnu/lib/rustlib/src/rust/src/librustc_tsan)
   Compiling rustc_msan v0.0.0 (file:///home/coleman/.rustup/toolchains/nightly-x86_64-
unknown-linux-gnu/lib/rustlib/src/rust/src/librustc_msan)
error[E0463]: can't find crate for `alloc_jemalloc`

error: aborting due to previous error

error: Could not compile `std`.

To learn more, run the command again with --verbose.
error: `"cargo" "build" "--release" "--manifest-path" "/tmp/xargo.nakpYG2KW4mP/Cargo.to
ml" "--target" "x86_64-unknown-linux-gnu" "-p" "std"` failed with exit code: Some(101)
note: run with `RUST_BACKTRACE=1` for a backtrace

I'm compiling with xargo build. I have the x86_64-unknown-linux-steed.json saved to the root of the steed repo. Do I need to take additional steps to compile with this target?

anxiousmodernman commented 6 years ago

Okay I'm trying a different angle: compiling a separate binary crate against steed

Here is my build script https://github.com/anxiousmodernman/steedtest/blob/master/build.sh

The error: missing_core

It just feels like our custom target is not being picked up. In my build I ask Rust to look for our target .json in the current directory, but to no avail.

FenrirWolf commented 6 years ago

Yeah, something changed recently in Cargo or rustc that necessitates manually setting RUST_TARGET_PATH to the directory containing the target spec (typically the pwd)

edit: just noticed you're already setting that in your test script, so I'm not sure why you're still getting that error.

anxiousmodernman commented 6 years ago

We'll get there :)

FWIW, I tried cross and it didn't quite work either. However, I'd like to pursue the non-docker strategy to better grok the configuration.

kinggoesgaming commented 6 years ago

FYI: the switch from pwd to the env var was done in the latest xargo release due to changes in the rust's own build mechanism changes..