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

Failed to run build command for libc, failed to get rustc version #1189

Open
4 of 11 tasks
beeb opened this issue Jan 20, 2023 · 12 comments
Open
4 of 11 tasks

Failed to run build command for libc, failed to get rustc version #1189

beeb opened this issue Jan 20, 2023 · 12 comments
Labels
bug needs-information needs more information to replicate

Comments

@beeb
Copy link

beeb commented Jan 20, 2023

Checklist

Describe your issue

When trying to build my project at https://github.com/beeb/remote-wol-rs using cross, I am faced with the following error:

failed to run custom build command for libc v0.2.139

thread 'main' panicked at 'Failed to get rustc version', /home/valentin/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/libc-0.2.139/build.rs:135:9

I have to use the nightly toolchain. I performed a cargo clean before building.

What target(s) are you cross-compiling for?

aarch64-unknown-linux-gnu, x86_64-pc-windows-gnu, x86_64-unknown-linux-gnu

Which operating system is the host (e.g computer cross is on) running?

  • macOS
  • Windows
  • Linux / BSD
  • other OS (specify in description)

What architecture is the host?

  • x86_64 / AMD64
  • arm32
  • arm64 (including Mac M1)

What container engine is cross using?

  • docker
  • podman
  • other container engine (specify in description)

cross version

cross 0.2.4 (8c86a98 2023-01-06)

Example

❯ cargo build --package=remote_wol --lib --target-dir=target/front --target=wasm32-unknown-unknown --no-default-features --features=hydrate --release
// This above is required before building the main binary below, and works fine (doesn't use cross)

❯ cross build --package=remote_wol --bin=remote_wol --target-dir=target/server --no-default-features --features=ssr --release --target aarch64-unknown-linux-gnu
   Compiling libc v0.2.139
   Compiling syn v1.0.107
   Compiling futures-channel v0.3.25
   Compiling num-traits v0.2.15
   Compiling bytes v1.3.0
   Compiling futures-util v0.3.25
error: failed to run custom build command for `libc v0.2.139`

Caused by:
  process didn't exit successfully: `/target/release/build/libc-30baa802e0a1b71f/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-changed=build.rs

  --- stderr
  thread 'main' panicked at 'Failed to get rustc version', /home/valentin/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/libc-0.2.139/build.rs:135:9
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...

Additional information / notes

Another project at work (not public) cross-compiles fine on the same machine, with the same targets, even libc v0.2.139 which is the same version as above. Not sure what's different about this project.

@Emilgardis Emilgardis added the needs-information needs more information to replicate label Jan 20, 2023
@beeb
Copy link
Author

beeb commented Jan 20, 2023

Luckily this doesn't happen in CI on ubuntu-latest, seems to be related to my machine.

@Emilgardis
Copy link
Member

Emilgardis commented Jan 20, 2023

can you run with cross build -v ..., then when you see + /path/to/docker run ... abort and copy the command line,
then replace at the end -t ghcr.io/cross-rs/aarch64-unknown-linux-gnu:main sh -c ... with -it ghcr.io/cross-rs/aarch64-unknown-linux-gnu:main sh
(the -it is important), you'll now be in a shell,
from here, add to env the same thing cross does (which is setting PATH, so something like export PATH="$PATH":"/home/me/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin") and then run

rustc --version

@beeb
Copy link
Author

beeb commented Jan 20, 2023

can you run with cross build -v ...

sure! This below is ran inside the container shell.

$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/valentin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin
$ rustc --version
rustc 1.68.0-nightly (4781233a7 2023-01-16)
$ 

@Emilgardis
Copy link
Member

so why is it failing here

I'm not sure what's happening here, maybe something is setting RUSTC to be something else? but that shouldn't be possible imo as build scripts are contained when it comes to env vars

@beeb
Copy link
Author

beeb commented Jan 20, 2023

Not sure if that's what you meant, but that's what I get in the container:

$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/valentin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin
$ echo $RUSTC

So yeah something is up with the RUSTC environment variable

@Emilgardis
Copy link
Member

No, RUSTC will not be set, RUSTC is set at build time so that's not the issue, if it was it would panic on an earlier line, not 135.

@beeb
Copy link
Author

beeb commented Jan 20, 2023

Okay yep that's actually strange. It means RUSTC is correct, invoking the rustc --version command succeeds, but somehow parsing the return value fails...

@Emilgardis Emilgardis added the bug label Jan 20, 2023
@Emilgardis
Copy link
Member

can you add

[patch.crates-io.libc]
git = "https://github.com/Emilgardis/libc"
branch = "debug-output"

to your Cargo.toml, and then run with -vv, you should then see something like

Fresh bumpalo v3.12.0
       Fresh autocfg v1.1.0
       Fresh cfg-if v1.0.0
       Fresh wasm-bindgen-shared v0.2.83
       Fresh version_check v0.9.4
warning: rustc="rustc"
warning: output=Ok(Output { status: ExitStatus(unix_wait_status(0)), stdout: "rustc 1.66.1 (90743e729 2023-01-10)\n", stderr: "" })
       Fresh wasm-bindgen-backend v0.2.83
       Fresh serde_derive v1.0.152
       Fresh thiserror-impl v1.0.38
       Fresh wasm-bindgen-macro-support v0.2.83

@beeb
Copy link
Author

beeb commented Jan 21, 2023

Thanks for taking the time to solve this with me @Emilgardis here is the output with the patched libc:

The following warnings were emitted during compilation:

warning: rustc="rustc"
warning: output=Ok(Output { status: ExitStatus(unix_wait_status(32512)), stdout: "", stderr: "rustc: error while loading shared libraries: libLLVM-15-rust-1.68.0-nightly.so: cannot open shared object file: No such file or directory\n" })

error: failed to run custom build command for `libc v0.2.139 (https://github.com/Emilgardis/libc?branch=debug-output#559f49bd)`

Caused by:
  process didn't exit successfully: `/target/release/build/libc-708b5fb0a0841d73/build-script-build` (exit status: 101)
  --- stdout
  cargo:warning=rustc="rustc"
  cargo:warning=output=Ok(Output { status: ExitStatus(unix_wait_status(32512)), stdout: "", stderr: "rustc: error while loading shared libraries: libLLVM-15-rust-1.68.0-nightly.so: cannot open shared object file: No such file or directory\n" })

  --- stderr
  thread 'main' panicked at 'Failed to get rustc version', /home/valentin/.cargo/git/checkouts/libc-c7c8c88c119db40f/559f49b/build.rs:136:9
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...

@michaelherger

This comment was marked as off-topic.

@michaelherger

This comment was marked as off-topic.

@Emilgardis

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug needs-information needs more information to replicate
Projects
None yet
Development

No branches or pull requests

3 participants