Skip to content

Immediately Terminates with "'rustc --print target-list' failed" #526

Closed

Description

@pr0me

Hey,

after installing cross, any attempt on using it for building terminates with

$ cross build --target armv7-unknown-linux-gnueabihf --verbose
error: `"rustc" "--print" "target-list"` failed with exit code: Some(1)
   0: error_chain::backtrace::imp::InternalBacktrace::new
   1: <std::process::Command as cross::extensions::CommandExt>::status_result
   2: <std::process::Command as cross::extensions::CommandExt>::run_and_get_stdout
   3: cross::main
   4: std::sys_common::backtrace::__rust_begin_short_backtrace
   5: main
   6: __libc_start_main
   7: _start

I tested this for different programs and different targets.

My environment:

cross 0.2.1
cargo 1.51.0-nightly (ab64d1393 2021-02-10)

# my local rustc
rustc 1.52.0-nightly (5fa22fe6f 2021-02-14)
rustup 1.23.1 (3df2264a9 2020-11-30)

docker 20.10.1
runc 1.0.0-rc92

Any idea on how to fix this is appreciated, thanks.

Activity

  1. changed the title [-]Immediately Terminates with '"rustc --print target-list" failed'[/-] [+]Immediately Terminates with "'rustc --print target-list' failed"[/+] on Mar 5, 2021
  2. clarfonthey commented on May 6, 2021

    @clarfonthey

    Also getting this error. Not really sure where to go from here.

  3. uber-alles-code commented on Jun 6, 2021

    @uber-alles-code

    Having the same issue...

  4. ondrowan commented on Aug 5, 2021

    @ondrowan

    The same thing started to happen with Rust 1.54.0 and target armv7-unknown-linux-gnueabihf. It works with 1.52.1 and 1.53.0.

  5. dbischof90 commented on Mar 24, 2022

    @dbischof90

    Has this been resolved? I'm getting this error as well:

    $ sudo cross build --target armv7-unknown-linux-gnueabihf
    error: `"rustc" "--print" "target-list"` failed with exit code: Some(1)
    note: run with `RUST_BACKTRACE=1` for a backtrace
    
  6. Emilgardis commented on Mar 24, 2022

    @Emilgardis
    Member

    @dbischof90 can you please add -vv to the arguments for debug output? Also what version of cross are tou using?

  7. dbischof90 commented on Mar 24, 2022

    @dbischof90

    Rowing back - I think I solved at least my case.

    I had to add my user to the docker usergroup and run it without sudo, that seemed to make the difference!

    EDIT: my cross setup is

    $ cross -V
    cross 0.2.1
    cargo 1.59.0 (49d8809dc 2022-02-10)
    

    and I run on Arch. But that seems to be unrelated here. With -vv I see that

    [...]
    + "/usr/bin/docker" "run" "--userns" "host" "-e" "PKG_CONFIG_ALLOW_CROSS=1" "--rm" "--user" "1000:1000" "-e" "XARGO_HOME=/xargo" "-e" "CARGO_HOME=/cargo" "-e" "CARGO_TARGET_DIR=/target" "-e" "USER=daniel" "-e" "CROSS_RUNNER=" "-v" "/home/daniel/.xargo:/xargo:Z" "-v" "/home/daniel/.cargo:/cargo:Z" "-v" "/cargo/bin" "-v" "/home/daniel/Programming/Rust/helloworld:/project:Z" "-v" "/home/daniel/.rustup/toolchains/stable-x86_64-unknown-linux-gnu:/rust:Z,ro" "-v" "/home/daniel/Programming/Rust/helloworld/target:/target:Z" "-w" "/project" "-i" "-t" "rustembedded/cross:armv7-unknown-linux-gnueabihf-0.2.1" "sh" "-c" "PATH=$PATH:/rust/bin cargo build --target armv7-unknown-linux-gnueabihf -vv"
    [...]
    

    so it needs my username as input which might not be accessible if called through sudo. Is that possible?

  8. Alexhuszagh commented on Jun 15, 2022

    @Alexhuszagh
    Contributor

    This command should be running on the host, and therefore shouldn't be affected by whether or not Docker is invoked or not.

    let target_list = rustc::target_list(false)?;

    This failing suggests something odd is happening with your system. Can you report the output of:

    # we don't care about stdout, just the error output and exit code
    $ rustc --print target-list >/dev/null
    $ echo $?

    This should give 0, indicating success, but something tells me on your systems it's not.

    I've tried this on x86_64-unknown-linux-gnu and with the following toolchain versions:

    • rustc 1.52.0-nightly (8e54a2113 2021-02-13)
    • rustc 1.59.0 (9d1b2106e 2022-02-23)
    • rustc 1.61.0 (fe5b13d68 2022-05-18)
    • rustc 1.63.0-nightly (5435ed691 2022-06-07)

    I've tried both the 0.2.1 release and cross built from main. This suggests to me it's probably not an issue in cross or the rust version but an issue in the installed rust toolchain.

    tl;dr rustc --print target-list is returning a non-zero exit code, suggesting it's failed, which is causing cross to fail.

  9. Alexhuszagh commented on Jul 2, 2022

    @Alexhuszagh
    Contributor

    This no longer reproduces it seems. I've got verbose output information from cross v0.2.2 running with those specific toolchains, on an x86_64-unknown-linux-gnu host. This might an issue if you haven't installed some dependencies to run cargo or other Rust binaries, such as libgcc.

    $ cross +1.54 --version
    cross 0.2.2
    Warning: using older rustc `1.54.0 (a178d0322 2021-07-26)` for the target. Current active rustc on the host is `rustc 1.61.0 (fe5b13d68 2022-05-18)`.
     > Update with `rustup update --force-non-host 1.54-x86_64-unknown-linux-gnu`
    Warning: Falling back to `cargo` on the host.
    cargo 1.54.0 (5ae8d74b3 2021-06-22)
    + cargo metadata --format-version 1 --filter-platform armv7-unknown-linux-gnueabihf
    + rustc --print sysroot
    + rustup toolchain list
    Warning: using older rustc `1.54.0 (a178d0322 2021-07-26)` for the target. Current active rustc on the host is `rustc 1.61.0 (fe5b13d68 2022-05-18)`.
     > Update with `rustup update --force-non-host 1.54.0-x86_64-unknown-linux-gnu`
    + rustup target list --toolchain 1.54.0-x86_64-unknown-linux-gnu
    + rustup component list --toolchain 1.54.0-x86_64-unknown-linux-gnu
    + rustup component add rust-src --toolchain 1.54.0-x86_64-unknown-linux-gnu
    info: downloading component 'rust-src'
    info: installing component 'rust-src'
    + /usr/bin/docker
    + /usr/bin/docker run --userns host -e 'PKG_CONFIG_ALLOW_CROSS=1' -e 'XARGO_HOME=/xargo' -e 'CARGO_HOME=/cargo' -e 'CARGO_TARGET_DIR=/target' -e 'CROSS_RUNNER=' -e 'USER=ahuszagh' --rm --user 1000:1000 -v /home/ahuszagh/.xargo:/xargo:Z -v /home/ahuszagh/.cargo:/cargo:Z -v /cargo/bin -v /home/ahuszagh/Desktop/cross/rust-c-hello-world:/project:Z -v /home/ahuszagh/.rustup/toolchains/1.54.0-x86_64-unknown-linux-gnu:/rust:Z,ro -v /home/ahuszagh/Desktop/cross/rust-c-hello-world/target:/target:Z -w /project -i ghcr.io/cross-rs/armv7-unknown-linux-gnueabihf:main sh -c 'PATH=$PATH:/rust/bin cargo run --target armv7-unknown-linux-gnueabihf -vv'
           Fresh cc v1.0.73
           Fresh hellopp v0.1.0 (/project)
        Finished dev [unoptimized + debuginfo] target(s) in 0.14s
         Running `/linux-runner armv7 /target/armv7-unknown-linux-gnueabihf/debug/hellopp`
    Hello, world!

    Nor does it fail on the nightly compiler:

    $ cross +nightly-2021-02-14 --version
    cross 0.2.2
    Warning: using older rustc `1.52.0-nightly (8e54a2113 2021-02-13)` for the target. Current active rustc on the host is `rustc 1.61.0 (fe5b13d68 2022-05-18)`.
     > Update with `rustup update --force-non-host nightly-2021-02-14-x86_64-unknown-linux-gnu`
    Warning: Falling back to `cargo` on the host.
    cargo 1.51.0-nightly (ab64d1393 2021-02-10)
    $ cross +nightly-2021-02-14 run --target armv7-unknown-linux-gnueabihf -vv
    + cargo metadata --format-version 1 --filter-platform armv7-unknown-linux-gnueabihf
    + rustc --print sysroot
    + rustup toolchain list
    Warning: using older rustc `1.52.0-nightly (8e54a2113 2021-02-13)` for the target. Current active rustc on the host is `rustc 1.61.0 (fe5b13d68 2022-05-18)`.
     > Update with `rustup update --force-non-host nightly-2021-02-14-x86_64-unknown-linux-gnu`
    + rustup target list --toolchain nightly-2021-02-14-x86_64-unknown-linux-gnu
    + rustup component list --toolchain nightly-2021-02-14-x86_64-unknown-linux-gnu
    + /usr/bin/docker
    + /usr/bin/docker run --userns host -e 'PKG_CONFIG_ALLOW_CROSS=1' -e 'XARGO_HOME=/xargo' -e 'CARGO_HOME=/cargo' -e 'CARGO_TARGET_DIR=/target' -e 'CROSS_RUNNER=' -e 'USER=ahuszagh' --rm --user 1000:1000 -v /home/ahuszagh/.xargo:/xargo:Z -v /home/ahuszagh/.cargo:/cargo:Z -v /cargo/bin -v /home/ahuszagh/Desktop/cross/rust-c-hello-world:/project:Z -v /home/ahuszagh/.rustup/toolchains/nightly-2021-02-14-x86_64-unknown-linux-gnu:/rust:Z,ro -v /home/ahuszagh/Desktop/cross/rust-c-hello-world/target:/target:Z -w /project -i ghcr.io/cross-rs/armv7-unknown-linux-gnueabihf:main sh -c 'PATH=$PATH:/rust/bin cargo run --target armv7-unknown-linux-gnueabihf -vv'
       Compiling cc v1.0.73
         Running `CARGO=/rust/bin/cargo CARGO_CRATE_NAME=cc CARGO_MANIFEST_DIR=/cargo/registry/src/github.1485827954.workers.dev-1ecc6299db9ec823/cc-1.0.73 CARGO_PKG_AUTHORS='Alex Crichton <alex@alexcrichton.com>' CARGO_PKG_DESCRIPTION='A build-time dependency for Cargo build scripts to assist in invoking the native
    C compiler to compile native C code into a static archive to be linked into Rust
    code.
    ' CARGO_PKG_HOMEPAGE='https://github.com/alexcrichton/cc-rs' CARGO_PKG_LICENSE=MIT/Apache-2.0 CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=cc CARGO_PKG_REPOSITORY='https://github.com/alexcrichton/cc-rs' CARGO_PKG_VERSION=1.0.73 CARGO_PKG_VERSION_MAJOR=1 CARGO_PKG_VERSION_MINOR=0 CARGO_PKG_VERSION_PATCH=73 CARGO_PKG_VERSION_PRE='' LD_LIBRARY_PATH='/target/debug/deps:/rust/lib' rustc --crate-name cc --edition=2018 /cargo/registry/src/github.1485827954.workers.dev-1ecc6299db9ec823/cc-1.0.73/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C metadata=83d179b7eb1eef0a -C extra-filename=-83d179b7eb1eef0a --out-dir /target/debug/deps -L dependency=/target/debug/deps --cap-lints warn`
       Compiling hellopp v0.1.0 (/project)
         Running `CARGO=/rust/bin/cargo CARGO_CRATE_NAME=build_script_build CARGO_MANIFEST_DIR=/project CARGO_PKG_AUTHORS='Jorge Aparicio <japaricious@gmail.com>' CARGO_PKG_DESCRIPTION='' CARGO_PKG_HOMEPAGE='' CARGO_PKG_LICENSE='' CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=hellopp CARGO_PKG_REPOSITORY='' CARGO_PKG_VERSION=0.1.0 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=1 CARGO_PKG_VERSION_PATCH=0 CARGO_PKG_VERSION_PRE='' CARGO_PRIMARY_PACKAGE=1 LD_LIBRARY_PATH='/target/debug/deps:/rust/lib' rustc --crate-name build_script_build build.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=5f47bddf08f026e8 -C extra-filename=-5f47bddf08f026e8 --out-dir /target/debug/build/hellopp-5f47bddf08f026e8 -C incremental=/target/debug/incremental -L dependency=/target/debug/deps --extern cc=/target/debug/deps/libcc-83d179b7eb1eef0a.rlib`
         Running `/target/debug/build/hellopp-5f47bddf08f026e8/build-script-build`
    [hellopp 0.1.0] TARGET = Some("armv7-unknown-linux-gnueabihf")
    [hellopp 0.1.0] OPT_LEVEL = Some("0")
    [hellopp 0.1.0] HOST = Some("x86_64-unknown-linux-gnu")
    [hellopp 0.1.0] CC_armv7-unknown-linux-gnueabihf = None
    [hellopp 0.1.0] CC_armv7_unknown_linux_gnueabihf = Some("arm-linux-gnueabihf-gcc")
    [hellopp 0.1.0] CFLAGS_armv7-unknown-linux-gnueabihf = None
    [hellopp 0.1.0] CFLAGS_armv7_unknown_linux_gnueabihf = None
    [hellopp 0.1.0] TARGET_CFLAGS = None
    [hellopp 0.1.0] CFLAGS = None
    [hellopp 0.1.0] CRATE_CC_NO_DEFAULTS = None
    [hellopp 0.1.0] DEBUG = Some("true")
    [hellopp 0.1.0] CARGO_CFG_TARGET_FEATURE = Some("aclass,dsp,v5te,v6,v6k,v6t2,v7,vfp2")
    [hellopp 0.1.0] running: "arm-linux-gnueabihf-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-march=armv7-a" "-mfpu=vfpv3-d16" "-Wall" "-Wextra" "-o" "/target/armv7-unknown-linux-gnueabihf/debug/build/hellopp-716ff43ad176b8b9/out/hello.o" "-c" "hello.c"
    [hellopp 0.1.0] exit code: 0
    [hellopp 0.1.0] AR_armv7-unknown-linux-gnueabihf = None
    [hellopp 0.1.0] AR_armv7_unknown_linux_gnueabihf = None
    [hellopp 0.1.0] TARGET_AR = None
    [hellopp 0.1.0] AR = None
    [hellopp 0.1.0] CROSS_COMPILE = None
    [hellopp 0.1.0] running: "arm-linux-gnueabihf-ar" "cq" "/target/armv7-unknown-linux-gnueabihf/debug/build/hellopp-716ff43ad176b8b9/out/libhello.a" "/target/armv7-unknown-linux-gnueabihf/debug/build/hellopp-716ff43ad176b8b9/out/hello.o"
    [hellopp 0.1.0] exit code: 0
    [hellopp 0.1.0] running: "arm-linux-gnueabihf-ar" "s" "/target/armv7-unknown-linux-gnueabihf/debug/build/hellopp-716ff43ad176b8b9/out/libhello.a"
    [hellopp 0.1.0] exit code: 0
    [hellopp 0.1.0] cargo:rustc-link-lib=static=hello
    [hellopp 0.1.0] cargo:rustc-link-search=native=/target/armv7-unknown-linux-gnueabihf/debug/build/hellopp-716ff43ad176b8b9/out
    [hellopp 0.1.0] cargo:rerun-if-changed=build.rs
    [hellopp 0.1.0] cargo:rerun-if-changed=hello.c
         Running `CARGO=/rust/bin/cargo CARGO_BIN_NAME=hellopp CARGO_CRATE_NAME=hellopp CARGO_MANIFEST_DIR=/project CARGO_PKG_AUTHORS='Jorge Aparicio <japaricious@gmail.com>' CARGO_PKG_DESCRIPTION='' CARGO_PKG_HOMEPAGE='' CARGO_PKG_LICENSE='' CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=hellopp CARGO_PKG_REPOSITORY='' CARGO_PKG_VERSION=0.1.0 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=1 CARGO_PKG_VERSION_PATCH=0 CARGO_PKG_VERSION_PRE='' CARGO_PRIMARY_PACKAGE=1 LD_LIBRARY_PATH='/target/debug/deps:/rust/lib' OUT_DIR=/target/armv7-unknown-linux-gnueabihf/debug/build/hellopp-716ff43ad176b8b9/out rustc --crate-name hellopp src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=5f1ff406c81f9e5d -C extra-filename=-5f1ff406c81f9e5d --out-dir /target/armv7-unknown-linux-gnueabihf/debug/deps --target armv7-unknown-linux-gnueabihf -C linker=arm-linux-gnueabihf-gcc -C incremental=/target/armv7-unknown-linux-gnueabihf/debug/incremental -L dependency=/target/armv7-unknown-linux-gnueabihf/debug/deps -L dependency=/target/debug/deps -L native=/target/armv7-unknown-linux-gnueabihf/debug/build/hellopp-716ff43ad176b8b9/out -l static=hello`
        Finished dev [unoptimized + debuginfo] target(s) in 2.58s
         Running `/linux-runner armv7 /target/armv7-unknown-linux-gnueabihf/debug/hellopp`
    Hello, world!

    If there are still issues, I'll re-open this.

  10. winrid commented on Mar 29, 2023

    @winrid

    So, I'm running into this.

    $ rustc --print target-list >/dev/null
    $ echo $?
    

    Would print 0.

    But the build would fail on getting the target list:

    $ sudo RUST_BACKTRACE=full cross build --release --target x86_64-unknown-linux-gnu
    Error: 
       0: could not execute `rustc --print target-list`
       1: No such file or directory (os error 2)
    
    Location:
       /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/core/src/convert/mod.rs:726
    
      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
                                    ⋮ 2 frames hidden ⋮                               
       3: cross::errors::CommandError::to_section_report::h19dfd76fc668725b
          at <unknown source file>:<unknown line>
       4: <std::process::Command as cross::extensions::CommandExt>::run_and_get_output::h5dd7c5a81ef94138
          at <unknown source file>:<unknown line>
       5: <std::process::Command as cross::extensions::CommandExt>::run_and_get_stdout::h78986cbdf3e2207d
          at <unknown source file>:<unknown line>
       6: cross::rustc::target_list::ha260fea6c471dce0
          at <unknown source file>:<unknown line>
       7: cross::main::h5d5d583c6dbd93a0
          at <unknown source file>:<unknown line>
       8: std::sys_common::backtrace::__rust_begin_short_backtrace::h1bb08b2e026b925e
          at <unknown source file>:<unknown line>
       9: main<unknown>
          at <unknown source file>:<unknown line>
      10: __libc_start_main<unknown>
          at <unknown source file>:<unknown line>
      11: _start<unknown>
          at <unknown source file>:<unknown line>
    
    Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering.
    

    My user is part of the docker group:

    $ groups winrid
    winrid : winrid sudo docker
    

    Still debugging.

  11. winrid commented on Mar 29, 2023

    @winrid

    Okay, it works fine without sudo I guess. Something with the build system is running the build as the wrong user. Weird error message in this case, but I guess that's the issue.

  12. winrid commented on Mar 29, 2023

    @winrid

    Update: The CI is indeed running as the correct user, confirmed via "echo "$USER" before cross build.

    However, now, when I run as my own user, I get:

    cross build --release --target x86_64-unknown-linux-gnu
       Compiling libc v0.2.139
       Compiling cfg-if v1.0.0
       Compiling once_cell v1.17.1
    error: failed to run custom build command for `libc v0.2.139`
    
    Caused by:
      process didn't exit successfully: `/target/release/build/libc-ba75df37419bc002/build-script-build` (exit status: 1)
      --- stderr
      /target/release/build/libc-ba75df37419bc002/build-script-build: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /target/release/build/libc-ba75df37419bc002/build-script-build)
      /target/release/build/libc-ba75df37419bc002/build-script-build: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /target/release/build/libc-ba75df37419bc002/build-script-build)
      /target/release/build/libc-ba75df37419bc002/build-script-build: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /target/release/build/libc-ba75df37419bc002/build-script-build)
    warning: build failed, waiting for other jobs to finish...
    
    

    On Debian Testing.

    If I omit --release, then it works (I get sqlx compilation errors probably due to not passing env variable into cross/docker, which I can always fix):

    $ cross build --target x86_64-unknown-linux-gnu
       Compiling... [snip]
    

    Info:

    winrid@orchestrator01:/tmp/weatherfybackend$ cargo --version
    cargo 1.68.2 (6feb7c9cf 2023-03-26)
    winrid@orchestrator01:/tmp/weatherfybackend$ rustc --version
    rustc 1.68.2 (9eb3afe9e 2023-03-27)
    winrid@orchestrator01:/tmp/weatherfybackend$ rustup --version
    rustup 1.25.2 (17db695f1 2023-02-01)
    winrid@orchestrator01:/tmp/weatherfybackend$ lsb_release -a
    No LSB modules are available.
    Distributor ID:	Debian
    Description:	Debian GNU/Linux 10 (buster)
    Release:	10
    Codename:	buster
    

    Wonder if it's due to a somewhat old version of Debian... will try upgrading I guess since 10 is EOL. Build servers tend to live too long. :)

  13. Emilgardis commented on Mar 29, 2023

    @Emilgardis
    Member

    The issue you're seeing is #724

  14. added a commit that references this issue on Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpending-closeIssue will be closed if no further comments

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions