rust-lang / miri

An interpreter for Rust's mid-level intermediate representation
Apache License 2.0
4.37k stars 337 forks source link

cargo-miri does not support target x86_64-wrs-vxworks #1867

Closed syvb closed 1 year ago

syvb commented 3 years ago

cargo-miri gets invoked by itself with a non-existent binary path when emulating the x86_64-wrs-vxworks target, causing an error:

$ cargo new t
     Created binary (application) `t` package
$ cd t
$ cargo miri run --target x86_64-wrs-vxworks
   Compiling t v0.1.0 (/tmp/t)
    Finished dev [unoptimized + debuginfo] target(s) in 0.21s
     Running `/home/smit/.cargo/bin/cargo-miri target/x86_64-wrs-vxworks/debug/t.vxe`
fatal error: `cargo-miri` called with unexpected first argument `target/x86_64-wrs-vxworks/debug/t.vxe`; please only invoke this binary through `cargo miri`
ghost commented 3 years ago

cargo-miri probably doesn't know about the .vxe suffix, so it doesn't create t.vxe: https://github.com/rust-lang/miri/blob/3ca53e03070d3e409d274d4f2bf56fb4377333ca/cargo-miri/bin.rs#L703-L710

I don't know if just fixing that is sufficient to support x86_64-wrs-vxworks. There are some other places that do not support x86_64-wrs-vxworks, for example: https://github.com/rust-lang/miri/blob/3ca53e03070d3e409d274d4f2bf56fb4377333ca/src/shims/foreign_items.rs#L613-L616

I tried to reproduce this, but I got some different errors. Perhaps I'm not using the correct version. ``` $ cargo miri run --target x86_64-wrs-vxworks Compiling compiler_builtins v0.1.49 Checking core v0.0.0 (/home/hyd-dev/.rustup/toolchains/miri/lib/rustlib/src/rust/library/core) Compiling libc v0.2.98 Compiling cc v1.0.69 Compiling std v0.0.0 (/home/hyd-dev/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std) Compiling unwind v0.0.0 (/home/hyd-dev/.rustup/toolchains/miri/lib/rustlib/src/rust/library/unwind) Checking rustc-std-workspace-core v1.99.0 (/home/hyd-dev/.rustup/toolchains/miri/lib/rustlib/src/rust/library/rustc-std-workspace-core) Checking alloc v0.0.0 (/home/hyd-dev/.rustup/toolchains/miri/lib/rustlib/src/rust/library/alloc) Checking cfg-if v0.1.10 Checking adler v0.2.3 Checking rustc-demangle v0.1.18 Checking rustc-std-workspace-alloc v1.99.0 (/home/hyd-dev/.rustup/toolchains/miri/lib/rustlib/src/rust/library/rustc-std-workspace-alloc) Checking panic_unwind v0.0.0 (/home/hyd-dev/.rustup/toolchains/miri/lib/rustlib/src/rust/library/panic_unwind) Checking panic_abort v0.0.0 (/home/hyd-dev/.rustup/toolchains/miri/lib/rustlib/src/rust/library/panic_abort) Checking gimli v0.23.0 Checking std_detect v0.1.5 (/home/hyd-dev/.rustup/toolchains/miri/lib/rustlib/src/rust/library/stdarch/crates/std_detect) Checking object v0.22.0 Checking hashbrown v0.11.0 Checking miniz_oxide v0.4.0 Checking addr2line v0.14.0 error[E0432]: unresolved import `libc::sigaddset` --> /home/hyd-dev/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/sys/unix/process/process_common.rs:54:37 | 54 | pub use libc::{sigemptyset, sigaddset}; | ^^^^^^^^^ no `sigaddset` in the root error[E0531]: cannot find unit struct, unit variant or constant `EHOSTUNREACH` in crate `libc` --> /home/hyd-dev/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/sys/unix/mod.rs:147:15 | 147 | libc::EHOSTUNREACH => HostUnreachable, | ^^^^^^^^^^^^ help: a constant with a similar name exists: `ENETUNREACH` | ::: /home/hyd-dev/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.98/src/vxworks/mod.rs:656:1 | 656 | pub const ENETUNREACH: ::c_int = 51; | ------------------------------------ similarly named constant `ENETUNREACH` defined here error[E0531]: cannot find unit struct, unit variant or constant `ELOOP` in crate `libc` --> /home/hyd-dev/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/sys/unix/mod.rs:151:15 | 151 | libc::ELOOP => FilesystemLoop, | ^^^^^ not found in `libc` error[E0531]: cannot find unit struct, unit variant or constant `EMLINK` in crate `libc` --> /home/hyd-dev/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/sys/unix/mod.rs:156:15 | 156 | libc::EMLINK => TooManyLinks, | ^^^^^^ not found in `libc` error[E0531]: cannot find unit struct, unit variant or constant `ENETDOWN` in crate `libc` --> /home/hyd-dev/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/sys/unix/mod.rs:158:15 | 158 | libc::ENETDOWN => NetworkDown, | ^^^^^^^^ not found in `libc` error[E0531]: cannot find unit struct, unit variant or constant `ESPIPE` in crate `libc` --> /home/hyd-dev/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/sys/unix/mod.rs:165:15 | 165 | libc::ESPIPE => NotSeekable, | ^^^^^^ help: a constant with a similar name exists: `EPIPE` | ::: /home/hyd-dev/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.98/src/vxworks/mod.rs:642:1 | 642 | pub const EPIPE: ::c_int = 32; | ------------------------------ similarly named constant `EPIPE` defined here error[E0531]: cannot find unit struct, unit variant or constant `ETXTBSY` in crate `libc` --> /home/hyd-dev/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/sys/unix/mod.rs:168:15 | 168 | libc::ETXTBSY => ExecutableFileBusy, | ^^^^^^^ not found in `libc` error[E0531]: cannot find unit struct, unit variant or constant `EXDEV` in crate `libc` --> /home/hyd-dev/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/sys/unix/mod.rs:169:15 | 169 | libc::EXDEV => CrossesDevices, | ^^^^^ not found in `libc` Some errors have detailed explanations: E0432, E0531. For more information about an error, try `rustc --explain E0432`. error: could not compile `std` due to 8 previous errors error: `"/home/hyd-dev/.rustup/toolchains/miri/bin/cargo" "check" "--release" "--manifest-path" "/tmp/xargo.Itu9HV1h4Zag/Cargo.toml" "--target" "x86_64-wrs-vxworks" "-p" "std"` failed with exit code: Some(101) note: run with `RUST_BACKTRACE=1` for a backtrace fatal error: failed to run xargo ```
RalfJung commented 3 years ago

Yeah cargo-miri needs to know about some platform-specific things around here and here. Probably vxworks needs its own special cases there.

bjorn3 commented 3 years ago

cargo-miri could use echo | rustc - --crate-name the_crate_name --print=file-names --crate-type bin to get the filename for an executable in a way that will work for every platform rustc supports. This is roughly what cargo does, except that it uses ____ as placeholder name.