Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

./x.py test src/test/ui fails to build compiletest #100062

Closed
RalfJung opened this issue Aug 2, 2022 · 10 comments · Fixed by #100088
Closed

./x.py test src/test/ui fails to build compiletest #100062

RalfJung opened this issue Aug 2, 2022 · 10 comments · Fixed by #100088

Comments

@RalfJung
Copy link
Member

RalfJung commented Aug 2, 2022

$ ./x.py test src/test/ui --test-args align --bless
Building rustbuild
    Finished dev [unoptimized] target(s) in 0.05s
Building stage0 std artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
    Finished release [optimized + debuginfo] target(s) in 0.20s
Copying stage0 std from stage0 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
Building stage0 compiler artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
    Finished release [optimized + debuginfo] target(s) in 0.34s
Copying stage0 rustc from stage0 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
Assembling stage1 compiler (x86_64-unknown-linux-gnu)
Building stage1 std artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
    Finished release [optimized + debuginfo] target(s) in 0.17s
Copying stage1 std from stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
Building stage0 tool compiletest (x86_64-unknown-linux-gnu)
   Compiling proc-macro2 v1.0.37
   Compiling unicode-xid v0.2.2
   Compiling syn v1.0.91
   Compiling cfg-if v1.0.0
   Compiling libc v0.2.126
   Compiling serde_derive v1.0.140
   Compiling memchr v2.5.0
   Compiling lazy_static v1.4.0
   Compiling autocfg v1.1.0
   Compiling regex-syntax v0.6.26
   Compiling parking_lot_core v0.8.5
   Compiling ryu v1.0.5
   Compiling serde v1.0.140
   Compiling serde_json v1.0.82
   Compiling anyhow v1.0.51
   Compiling smallvec v1.8.1
   Compiling log v0.4.14
   Compiling scopeguard v1.1.0
   Compiling once_cell v1.12.0
   Compiling itoa v1.0.2
   Compiling pin-project-lite v0.2.8
   Compiling diff v0.1.13
   Compiling unicode-width v0.1.8
   Compiling ansi_term v0.12.1
   Compiling same-file v1.0.6
   Compiling glob v0.3.0
   Compiling instant v0.1.12
   Compiling tracing-core v0.1.21
   Compiling sharded-slab v0.1.1
   Compiling lock_api v0.4.7
   Compiling thread_local v1.1.4
   Compiling getopts v0.2.21
   Compiling walkdir v2.3.2
   Compiling unified-diff v0.2.1
   Compiling regex-automata v0.1.10
error[E0407]: method `backtrace` is not a member of trait `StdError`
   --> /home/r/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.51/src/context.rs:127:5
    |
127 | /     fn backtrace(&self) -> Option<&Backtrace> {
128 | |         self.error.backtrace()
129 | |     }
    | |_____^ not a member of trait `StdError`

error[E0407]: method `backtrace` is not a member of trait `StdError`
   --> /home/r/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.51/src/context.rs:141:5
    |
141 | /     fn backtrace(&self) -> Option<&Backtrace> {
142 | |         Some(self.error.backtrace())
143 | |     }
    | |_____^ not a member of trait `StdError`

error[E0407]: method `backtrace` is not a member of trait `StdError`
   --> /home/r/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.51/src/error.rs:904:5
    |
904 | /     fn backtrace(&self) -> Option<&Backtrace> {
905 | |         Some(unsafe { ErrorImpl::backtrace(self.erase()) })
906 | |     }
    | |_____^ not a member of trait `StdError`

error[E0407]: method `backtrace` is not a member of trait `StdError`
  --> /home/r/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.51/src/wrapper.rs:71:5
   |
71 | /     fn backtrace(&self) -> Option<&crate::backtrace::Backtrace> {
72 | |         self.0.backtrace()
73 | |     }
   | |_____^ not a member of trait `StdError`

   Compiling aho-corasick v0.7.18
error[E0599]: no method named `backtrace` found for type parameter `E` in the current scope
  --> /home/r/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.51/src/backtrace.rs:41:20
   |
39 | / macro_rules! backtrace_if_absent {
40 | |     ($err:expr) => {
41 | |         match $err.backtrace() {
   | |                    ^^^^^^^^^ method not found in `E`
42 | |             Some(_) => None,
...  |
45 | |     };
46 | | }
   | |_- in this expansion of `backtrace_if_absent!`
   |
  ::: /home/r/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.51/src/context.rs:27:29
   |
27 |               let backtrace = backtrace_if_absent!(self);
   |                               -------------------------- in this macro invocation

error[E0599]: no method named `backtrace` found for type parameter `E` in the current scope
   --> /home/r/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.51/src/context.rs:128:20
    |
128 |         self.error.backtrace()
    |                    ^^^^^^^^^ method not found in `E`

error[E0599]: no method named `backtrace` found for type parameter `E` in the current scope
  --> /home/r/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.51/src/backtrace.rs:41:20
   |
39 | / macro_rules! backtrace_if_absent {
40 | |     ($err:expr) => {
41 | |         match $err.backtrace() {
   | |                    ^^^^^^^^^ method not found in `E`
42 | |             Some(_) => None,
...  |
45 | |     };
46 | | }
   | |_- in this expansion of `backtrace_if_absent!`
   |
  ::: /home/r/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.51/src/error.rs:33:25
   |
33 |           let backtrace = backtrace_if_absent!(error);
   |                           --------------------------- in this macro invocation

error[E0599]: no method named `backtrace` found for type parameter `E` in the current scope
   --> /home/r/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.51/src/backtrace.rs:41:20
    |
39  | / macro_rules! backtrace_if_absent {
40  | |     ($err:expr) => {
41  | |         match $err.backtrace() {
    | |                    ^^^^^^^^^ method not found in `E`
42  | |             Some(_) => None,
...   |
45  | |     };
46  | | }
    | |_- in this expansion of `backtrace_if_absent!`
    |
   ::: /home/r/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.51/src/error.rs:530:25
    |
530 |           let backtrace = backtrace_if_absent!(error);
    |                           --------------------------- in this macro invocation

error[E0599]: no method named `backtrace` found for reference `&(dyn std::error::Error + Send + Sync + 'static)` in the current scope
   --> /home/r/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.51/src/error.rs:886:42
    |
886 |                 return Self::error(this).backtrace();
    |                                          ^^^^^^^^^ method not found in `&(dyn std::error::Error + Send + Sync + 'static)`

   Compiling quote v1.0.18
error[E0599]: no method named `backtrace` found for struct `Box<(dyn std::error::Error + Send + Sync + 'static)>` in the current scope
   --> /home/r/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.51/src/backtrace.rs:41:20
    |
39  | / macro_rules! backtrace_if_absent {
40  | |     ($err:expr) => {
41  | |         match $err.backtrace() {
    | |                    ^^^^^^^^^ method not found in `Box<(dyn std::error::Error + Send + Sync + 'static)>`
42  | |             Some(_) => None,
...   |
45  | |     };
46  | | }
    | |_- in this expansion of `backtrace_if_absent!`
    |
   ::: /home/r/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.51/src/kind.rs:113:25
    |
113 |           let backtrace = backtrace_if_absent!(error);
    |                           --------------------------- in this macro invocation

   Compiling atty v0.2.14
error[E0599]: no method named `backtrace` found for struct `Box<(dyn std::error::Error + Send + Sync + 'static)>` in the current scope
  --> /home/r/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.51/src/wrapper.rs:72:16
   |
72 |         self.0.backtrace()
   |                ^^^^^^^^^ method not found in `Box<(dyn std::error::Error + Send + Sync + 'static)>`

Some errors have detailed explanations: E0407, E0599.
For more information about an error, try `rustc --explain E0407`.
error: could not compile `anyhow` due to 11 previous errors
warning: build failed, waiting for other jobs to finish...
Build completed unsuccessfully in 0:00:11
@RalfJung
Copy link
Member Author

RalfJung commented Aug 2, 2022

This seems to have started recently; going back to before #99768 fixes the problem.

@RalfJung
Copy link
Member Author

RalfJung commented Aug 2, 2022

Cc @dtolnay any idea what might be happening here? Not everyone sees this behavior, strangely.

@dtolnay
Copy link
Member

dtolnay commented Aug 2, 2022

Looks like #99431 (comment), and probably needs the same fix. Something is lying about the exit status of rustc.

@RalfJung
Copy link
Member Author

RalfJung commented Aug 2, 2022

Cc @yaahc who seems to be (or has been) getting similar errors

@RalfJung
Copy link
Member Author

RalfJung commented Aug 2, 2022

@dtolnay hm, but this code seems to forward the exist status correctly

if status.success() {
std::process::exit(0);
// note: everything below here is unreachable. do not put code that
// should run on success, after this block.
}
if verbose > 0 {
println!("\nDid not run successfully: {}\n{:?}\n-------------", status, cmd);
}
if let Some(mut on_fail) = on_fail {
on_fail.status().expect("Could not run the on_fail command");
}
// Preserve the exit code. In case of signal, exit with 0xfe since it's
// awkward to preserve this status in a cross-platform way.
match status.code() {
Some(i) => std::process::exit(i),
None => {
eprintln!("rustc exited with {}", status);
std::process::exit(0xfe);
}
}

@RalfJung
Copy link
Member Author

RalfJung commented Aug 2, 2022

One possible issue is that anyhow does not seem to propagate --target (set via the TARGET env var) to rustc. (This would likely also make it fail in Miri cross-interpretation.)

The bootstrap rustc binary uses --target to determine whether to use the bootstrap sysroot or the sysroot matching the target build.

@RalfJung
Copy link
Member Author

RalfJung commented Aug 2, 2022

IOW, this logic from autocfg is missing.

@yaahc
Copy link
Member

yaahc commented Aug 2, 2022

Cc @yaahc who seems to be (or has been) getting similar errors

Not sure what's going on in this case sadly :/ I had this issue because of a bug in rustc-perf but I haven't seen it show up outside of that context.

@RalfJung
Copy link
Member Author

RalfJung commented Aug 3, 2022

I can confirm that the issue is fixed by applying dtolnay/anyhow#249.

@bors bors closed this as completed in 1b57946 Aug 3, 2022
@RalfJung
Copy link
Member Author

RalfJung commented Aug 5, 2022

I am pretty sure this was caused by #99431: after that PR, the build probe of anyhow fails to build with latest libstd. It still works with the bootstrap compiler's libstd though, which is why anyhow thinks it can use the backtrace feature, but actually can't.
(EDIT: and now I see @dtolnay has already linked to that PR. oops)

eyre has exactly the same problem: eyre-rs/eyre#84

RalfJung pushed a commit to RalfJung/rust-analyzer that referenced this issue Apr 20, 2024
RalfJung pushed a commit to RalfJung/rust-analyzer that referenced this issue Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants