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

Crates calling rustc from build.rs broken (e.g. autocfg) #1527

Open
4 of 11 tasks
larsch opened this issue Jul 15, 2024 · 0 comments
Open
4 of 11 tasks

Crates calling rustc from build.rs broken (e.g. autocfg) #1527

larsch opened this issue Jul 15, 2024 · 0 comments

Comments

@larsch
Copy link

larsch commented Jul 15, 2024

Checklist

Describe your issue

Crates with a build.rs that try to execute rustc fail (libLLVM.so not in linker search path).

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

x86_64-pc-windows-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.5

Example

Run cargo init and add this build.rs:

fn main() {
    assert!(
        std::process::Command::new("rustc")
            .arg("--version")
            .status()
            .unwrap()
            .success(),
        "Failed to run rustc"
    );
}

Running cross run --target x86_64-pc-windows-gnu fails with the error Failed to run rust.

Caused by:
  process didn't exit successfully: `/target/debug/build/minimal-5e6e7e96bd90ecd5/build-script-build` (exit status: 101)
  --- stderr
  rustc: error while loading shared libraries: libLLVM.so.18.1-rust-1.81.0-nightly: cannot open shared object file: No such file or directory
  thread 'main' panicked at build.rs:2:5:
  Failed to run rustc
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Additional information / notes

Issue appears to be that the rust compiler is installed in /rust/lib which is not in the dynamic linker search path.

The autocfg crate tries to execute rustc to detect compiler version/features.

Workaround: Setting LD_LIBRARY_PATH=/rust/lib:

Cargo.toml:

[build.env]
passthrough = ["LD_LIBRARY_PATH=/rust/lib"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants