japaric / xargo

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

xargo doesn't work with cranelift #304

Open jyn514 opened 3 years ago

jyn514 commented 3 years ago
$  cat config.toml
[rust]
codegen-backends = ["cranelift"]
$ x.py test --stage 0 src/tools/miri
error: failed to run `rustc` to learn about target-specific information

Caused by:
  process didn't exit successfully: `/home/joshua/rustc/build/bootstrap/debug/rustc - --crate-name ___ --print=file-names -Cdebug-assertions=off --sysroot /home/joshua/.cache/miri/HOST -Z force-unstable-if-unmarked --target x86_64-unknown-linux-gnu --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=cfg` (exit code: 1)
  --- stderr
  error: failed to find a `codegen-backends` folder in the sysroot candidates:
  * /home/joshua/rustc/build/x86_64-unknown-linux-gnu
  * /home/joshua/rustc/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu
  * /home/joshua/rustc/build/x86_64-unknown-linux-gnu/stage0-sysroot

error: `"/home/joshua/rustc/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "check" "--release" "--manifest-path" "/tmp/xargo.z0UAkyvzwjGN/Cargo.toml" "--target" "x86_64-unknown-linux-gnu" "-p" "std"` failed with exit code: Some(101)
   0: error_chain::backtrace::imp::InternalBacktrace::new
   1: <error_chain::State as core::default::Default>::default
   2: <std::process::Command as xargo::extensions::CommandExt>::run
   3: xargo::sysroot::build
   4: xargo::sysroot::update
   5: xargo::main_inner
   6: std::sys_common::backtrace::__rust_begin_short_backtrace
   7: std::rt::lang_start::{{closure}}
   8: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
             at /rustc/4708ac76ee6ec7e278a00f49a40b5bfbcdfd6168/library/core/src/ops/function.rs:259:13
      std::panicking::try::do_call
             at /rustc/4708ac76ee6ec7e278a00f49a40b5bfbcdfd6168/library/std/src/panicking.rs:381:40
      std::panicking::try
             at /rustc/4708ac76ee6ec7e278a00f49a40b5bfbcdfd6168/library/std/src/panicking.rs:345:19
      std::panic::catch_unwind
             at /rustc/4708ac76ee6ec7e278a00f49a40b5bfbcdfd6168/library/std/src/panic.rs:382:14
      std::rt::lang_start_internal
             at /rustc/4708ac76ee6ec7e278a00f49a40b5bfbcdfd6168/library/std/src/rt.rs:51:25
   9: main
  10: __libc_start_main
  11: _start

fatal error: failed to run xargo
$ fd codegen-backends /home/joshua/rustc/build/x86_64-unknown-linux-gnu
/home/joshua/rustc/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends
$ ls /home/joshua/rustc/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends
librustc_codegen_cranelift-1.49.0-dev.so
jyn514 commented 3 years ago

Maybe this is actually an x.py bug, since the folder is in stage1 and not stage0-sysroot? Not sure where to report it.

RalfJung commented 3 years ago

Can you reproduce this with xargo directly, independent of Miri or x.py? If no, this is likely the wrong repository.

The rust repository might be a better fit also because to me this looks first like a cranelift issue.^^ xargo does not even interact much directly with rustc (just a bit via rustc_version), it mostly calls cargo in special ways.

jyn514 commented 3 years ago

I'm not sure where I would start trying to reproduce this.

cc @bjorn3 - do you know what's going wrong here?

bjorn3 commented 3 years ago

Does it work with --stage 1?

bjorn3 commented 3 years ago

I think I now what happens. Tools require Rustc instead of Assemble. This means that CodegenBackend is never built and thus rustc fails when trying to load cg_clif.

jyn514 commented 3 years ago

... is this why you can't run tools in-tree?

https://zulip-archive.rust-lang.org/257328clippy/19387Runclippyintree.html

bjorn3 commented 3 years ago

I am not quite sure that has the same reason, but it could be.