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

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

Closed
syvb opened this issue Aug 4, 2021 · 3 comments · Fixed by #2741
Closed

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

syvb opened this issue Aug 4, 2021 · 3 comments · Fixed by #2741
Labels
A-cargo Area: affects the cargo wrapper (cargo miri) C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement

Comments

@syvb
Copy link
Contributor

syvb commented Aug 4, 2021

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
Copy link

ghost commented Aug 4, 2021

cargo-miri probably doesn't know about the .vxe suffix, so it doesn't create t.vxe:

miri/cargo-miri/bin.rs

Lines 703 to 710 in 3ca53e0

let filename = out_filename("", "");
if verbose {
eprintln!("[cargo-miri rustc] writing run info to `{}`", filename.display());
}
info.store(&filename);
// For Windows, do the same thing again with `.exe` appended to the filename.
// (Need to do this here as cargo moves that "binary" to a different place before running it.)
info.store(&out_filename("", ".exe"));

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:

_ => match this.tcx.sess.target.os.as_str() {
"linux" | "macos" => return shims::posix::foreign_items::EvalContextExt::emulate_foreign_item_by_name(this, link_name, abi, args, dest, ret),
"windows" => return shims::windows::foreign_items::EvalContextExt::emulate_foreign_item_by_name(this, link_name, abi, args, dest, ret),
target => throw_unsup_format!("the target `{}` is not supported", target),

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
Copy link
Member

RalfJung commented Aug 6, 2021

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

@bjorn3
Copy link
Member

bjorn3 commented Aug 6, 2021

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.

@RalfJung RalfJung added A-cargo Area: affects the cargo wrapper (cargo miri) C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement labels Dec 16, 2021
@RalfJung RalfJung changed the title cargo-miri can't find binary for x86_64-wrs-vxworks cargo-miri does not support target x86_64-wrs-vxworks Dec 16, 2021
@bors bors closed this as completed in 9f316ae Dec 27, 2022
RalfJung pushed a commit to RalfJung/rust that referenced this issue Dec 28, 2022
cargo-miri: use rustc to determine the output filename

This should fix rust-lang/miri#2740 and fix rust-lang/miri#1867: we no longer need to hard-code the file name logic in cargo-miri.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cargo Area: affects the cargo wrapper (cargo miri) C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants