[SOLVED] When building rust-1.17.0, after building libstd: error[E0463]: can't find crate for `std`

When I try to build rust-1.17.0 using the system installation of rust-1.16.0, I run into an error where rustc cannot find the newly built libstd when building stage0-test:

Building stage0 test artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
Dirty - /var/tmp/portage/dev-lang/rust-1.17.0/work/rustc-1.17.0-src/build/x86_64-unknown-linux-gnu/stage0-test/x86_64-unknown-linux-gnu/release
running: "/var/tmp/portage/dev-lang/rust-1.17.0/work/cargo-nightly-x86_64-unknown-linux-gnu/cargo/bin/cargo" "build" "-j" "4" "--target" "x86_64-unknown-linux-gnu" "-v" "--release" "--manifest-path" "/var/tmp/portage/dev-lang/rust-1.17.0/work/rustc-1.17.0-src/src/libtest/Cargo.toml"
   Compiling term v0.0.0 (file:///var/tmp/portage/dev-lang/rust-1.17.0/work/rustc-1.17.0-src/src/libterm)
   Compiling getopts v0.0.0 (file:///var/tmp/portage/dev-lang/rust-1.17.0/work/rustc-1.17.0-src/src/libgetopts)
     Running `/var/tmp/portage/dev-lang/rust-1.17.0/work/rustc-1.17.0-src/build/bootstrap/debug/rustc --crate-name term src/libterm/lib.rs --crate-type dylib --crate-type rlib --emit=dep-info,link -C prefer-dynamic -C opt-level=2 -C metadata=3a0fef509712fa1f -C extra-filename=-3a0fef509712fa1f --out-dir /var/tmp/portage/dev-lang/rust-1.17.0/work/rustc-1.17.0-src/build/x86_64-unknown-linux-gnu/stage0-test/x86_64-unknown-linux-gnu/release/deps --target x86_64-unknown-linux-gnu -L dependency=/var/tmp/portage/dev-lang/rust-1.17.0/work/rustc-1.17.0-src/build/x86_64-unknown-linux-gnu/stage0-test/x86_64-unknown-linux-gnu/release/deps -L dependency=/var/tmp/portage/dev-lang/rust-1.17.0/work/rustc-1.17.0-src/build/x86_64-unknown-linux-gnu/stage0-test/release/deps`
     Running `/var/tmp/portage/dev-lang/rust-1.17.0/work/rustc-1.17.0-src/build/bootstrap/debug/rustc --crate-name getopts src/libgetopts/lib.rs --crate-type dylib --crate-type rlib --emit=dep-info,link -C prefer-dynamic -C opt-level=2 -C metadata=b6a379af3b1f8c20 -C extra-filename=-b6a379af3b1f8c20 --out-dir /var/tmp/portage/dev-lang/rust-1.17.0/work/rustc-1.17.0-src/build/x86_64-unknown-linux-gnu/stage0-test/x86_64-unknown-linux-gnu/release/deps --target x86_64-unknown-linux-gnu -L dependency=/var/tmp/portage/dev-lang/rust-1.17.0/work/rustc-1.17.0-src/build/x86_64-unknown-linux-gnu/stage0-test/x86_64-unknown-linux-gnu/release/deps -L dependency=/var/tmp/portage/dev-lang/rust-1.17.0/work/rustc-1.17.0-src/build/x86_64-unknown-linux-gnu/stage0-test/release/deps`
error[E0463]: can't find crate for `std`

error: aborting due to previous error

error: Could not compile `term`.

Caused by:
  process didn't exit successfully: `/var/tmp/portage/dev-lang/rust-1.17.0/work/rustc-1.17.0-src/build/bootstrap/debug/rustc --crate-name term src/libterm/lib.rs --crate-type dylib --crate-type rlib --emit=dep-info,link -C prefer-dynamic -C opt-level=2 -C metadata=3a0fef509712fa1f -C extra-filename=-3a0fef509712fa1f --out-dir /var/tmp/portage/dev-lang/rust-1.17.0/work/rustc-1.17.0-src/build/x86_64-unknown-linux-gnu/stage0-test/x86_64-unknown-linux-gnu/release/deps --target x86_64-unknown-linux-gnu -L dependency=/var/tmp/portage/dev-lang/rust-1.17.0/work/rustc-1.17.0-src/build/x86_64-unknown-linux-gnu/stage0-test/x86_64-unknown-linux-gnu/release/deps -L dependency=/var/tmp/portage/dev-lang/rust-1.17.0/work/rustc-1.17.0-src/build/x86_64-unknown-linux-gnu/stage0-test/release/deps` (exit code: 101)
Build failed, waiting for other jobs to finish...
error[E0463]: can't find crate for `std`

error: aborting due to previous error

error: build failed


command did not execute successfully: "/var/tmp/portage/dev-lang/rust-1.17.0/work/cargo-nightly-x86_64-unknown-linux-gnu/cargo/bin/cargo" "build" "-j" "4" "--target" "x86_64-unknown-linux-gnu" "-v" "--release" "--manifest-path" "/var/tmp/portage/dev-lang/rust-1.17.0/work/rustc-1.17.0-src/src/libtest/Cargo.toml"
expected success, got: exit code: 101

Before I ran into this error, I tried to build rust using the official rustc-1.16.0 tarball, which failed for more obvious reasons with the same error in stage0 when building the first rustc -- that rustc tarball does include libstd, but is missing libcore on which it depends.

I am mostly following the official building-from-source documentation (README.md in the rust GitHub repo), with the notable exception that I am not making use of cargo's online registry, in order to have a network-less build.

The full build log and build script (Gentoo ebuild) is available.

I would be very glad if someone could hint me at what I am doing wrong.

How are you building it?

The way to build from master is:

$ ./configure
$ ./x.py build -j 8

Haven't had to build from source tarballs, so I'm not sure if ./x.py is included, but that script deals with bootstrapping.

The README suggests that configuration is done through config.toml, which shall be followed by ./x.py build. ./configure is only mentioned way down in the document as a legacy method of building, and instead of ./x.py build, the README suggests that ./configure should be followed by make.

Should the README be fixed to explain what you mentioned in your post here?

FWIW, even Rust's own CI script still uses configure and make, so that shouldn't be the problem. Both the Makefile and x.py are just a wrappers calling bootstrap.py anyway.

1 Like

I use ./configure --enable-debug, had missed that ./configure was no longer needed on a clean clone. Indeed all you need to do to build from master is ./x.py build.

I found the cause by reading librustc_metadata/locator.rs, section "Where to look?": The rustc tarball only contains the compiler. Included libstd-*.so and other libraries are those necessary to run the compiler, but they are not sufficient to build anything with it. For that the rust-std tarball is needed in addition, which contains all libraries and metadata to build for a specific target. A rust tarball exists, which bundles the contents of the rustc tarball and rust-std and also contains rust-docs and cargo in addition.

1 Like