Stream: t-compiler/help

Topic: failed to run stage0 rustc - why?


Joshua Nelson (May 08 2020 at 13:14, on Zulip):

I'm trying to understand an error I got on CI: https://github.com/rust-lang/rust/pull/71994#issuecomment-625539912
I can reproduce locally, but I have no idea why it fails. The only error message is

 failed to run "build/x86_64-unknown-linux-gnu/stage0/bin/rustc" "--crate-name" "cc" "--edition=2018" "/cargo/registry/src/github.com-1ecc6299db9ec823/cc-1.0.50/src/lib.rs" "--error-format=json" "--json=diagnostic-rendered-ansi" "--crate-type" "lib" "--emit=dep-info,metadata,link" "-C" "opt-level=3" "-C" "debuginfo=0" "-C" "metadata=9e7bf81b9fe8db6d" "-C" "extra-filename=-9e7bf81b9fe8db6d" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-std/release/deps" "-L" "dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-std/release/deps" "--cap-lints" "allow" "-Zbinary-dep-depinfo"', src/bootstrap/bin/rustc.rs:205:54

but when I run that command locally it works! (or at least I assume it works since there's no output and exits with 0) Does anyone have ideas?

Joshua Nelson (May 08 2020 at 13:16, on Zulip):

Or hold on it only works if I have RUSTC_BOOTSTRAP=1 in the environment - maybe that wasn't set for some reason? I don't know what that has to do with my change though.

Joshua Nelson (May 08 2020 at 13:25, on Zulip):

It looks like the issue is environment variables aren't being set ... but I'm not sure why that could happen.

$ git diff
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py
index 9e56dd3770d..5d6a877307a 100644
--- a/src/bootstrap/bootstrap.py
+++ b/src/bootstrap/bootstrap.py
@@ -677,7 +677,10 @@ class RustBuild(object):
         # See also: <https://github.com/rust-lang/rust/issues/70208>.
         if "CARGO_BUILD_TARGET" in env:
             del env["CARGO_BUILD_TARGET"]
+        print("setting RUSTC_BOOTSTRAP=1")
         env["RUSTC_BOOTSTRAP"] = '1'
+        print("setting RUST_BACKTRACE=1")
+        env["RUST_BACKTRACE"] = '1'
         env["CARGO_TARGET_DIR"] = build_dir
         env["RUSTC"] = self.rustc()
         env["LD_LIBRARY_PATH"] = os.path.join(self.bin_root(), "lib") + \
$ ./x.py check
Updating only changed submodules
Submodules updated in 0.01 seconds
setting RUSTC_BOOTSTRAP=1
setting RUST_BACKTRACE=1
    Finished dev [unoptimized] target(s) in 0.12s
Checking rustdoc artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
Checking clippy artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
Checking std artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
   Compiling cc v1.0.50
   Compiling libc v0.2.69
   Compiling autocfg v0.1.7
thread 'main' panicked at '

 failed to run "build/x86_64-unknown-linux-gnu/stage0/bin/rustc" "--crate-name" "cc" "--edition=2018" "/home/joshua/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/cc-1.0.50/src/lib.rs" "--error-format=json" "--json=diagnostic-rendered-ansi" "--crate-type" "lib" "--emit=dep-info,metadata,link" "-C" "opt-level=3" "-C" "debuginfo=0" "-C" "metadata=9e7bf81b9fe8db6d" "-C" "extra-filename=-9e7bf81b9fe8db6d" "--out-dir" "/home/joshua/src/rust/build/x86_64-unknown-linux-gnu/stage0-std/release/deps" "-L" "dependency=/home/joshua/src/rust/build/x86_64-unknown-linux-gnu/stage0-std/release/deps" "--cap-lints" "allow" "-Zbinary-dep-depinfo"', src/bootstrap/bin/rustc.rs:205:54
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: could not compile `cc`.
Joshua Nelson (May 08 2020 at 13:26, on Zulip):

I guess I can try applying my changes one at a time?

Joshua Nelson (May 08 2020 at 13:32, on Zulip):

ok this is the one that breaks things:

$ git diff
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py
index 9e56dd3770d..80ef994ce64 100644
--- a/src/bootstrap/bootstrap.py
+++ b/src/bootstrap/bootstrap.py
@@ -906,6 +906,8 @@ def bootstrap(help_triggered):

     build.check_vendored_status()

+    build.build_dir = (build.get_toml('build-dir', 'build') or 'build').replace("$ROOT", build.rust_root)
+
     data = stage0_data(build.rust_root)
     build.date = data['date']
     build.rustc_channel = data['rustc']
simulacrum (May 08 2020 at 13:33, on Zulip):

I suspect it's because your build_dir is not the same as the build/ directory bootstrap is expecting

simulacrum (May 08 2020 at 13:33, on Zulip):

we look for the bootstrap compiler in something like root.join("build")... I think

Joshua Nelson (May 08 2020 at 13:34, on Zulip):

This should default to build though: build.get_toml('build-dir', 'build') or 'build'

Joshua Nelson (May 08 2020 at 13:34, on Zulip):

maybe it needs to be relative to the current directory _at that time_ as opposed to at the time of the build?

Joshua Nelson (May 08 2020 at 13:34, on Zulip):

I can use abspath and see if that helps

Joshua Nelson (May 08 2020 at 13:35, on Zulip):

yay that did it :tada:

simulacrum (May 08 2020 at 13:37, on Zulip):

yeah I think that's right

Last update: Sep 28 2020 at 15:15UTC