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

build and target aren't distinguished during llvm building #132926

Closed
ziyao233 opened this issue Nov 12, 2024 · 0 comments · Fixed by #136681
Closed

build and target aren't distinguished during llvm building #132926

ziyao233 opened this issue Nov 12, 2024 · 0 comments · Fixed by #136681
Labels
A-cross Area: Cross compilation C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@ziyao233
Copy link

Cross-compiling rust 1.82.0 itself fails with custom LLVM used on the build and vendored llvm on the host.

$ ./x.py build -j30 -v
...
-- Installing: /root/la64_rust/rustc-1.82.0-src/build/loongarch64-unknown-linux-musl/llvm/lib/cmake/llvm/LLVMConfigExtensions.cmake
cargo:root=/root/la64_rust/rustc-1.82.0-src/build/loongarch64-unknown-linux-musl/llvm
running: "/root/la64_rust/rustc-1.82.0-src/build/x86_64-unknown-linux-musl/llvm/bin/llvm-config" "--version" (failure_mode=Exit) (created at src/core/build_steps/llvm.rs:508:17, executed at src/core/build_steps/llvm.rs:508:60)


Command "/root/la64_rust/rustc-1.82.0-src/build/x86_64-unknown-linux-musl/llvm/bin/llvm-config" "--version" (failure_mode=Exit) did not execute successfully.
It was not possible to execute the command: Os { code: 2, kind: NotFound, message: "No such file or directory" }

Traceback (most recent call last):
  File "/root/la64_rust/rustc-1.82.0-src/./x.py", line 50, in <module>
    bootstrap.main()
  File "/root/la64_rust/rustc-1.82.0-src/src/bootstrap/bootstrap.py", line 1208, in main
    bootstrap(args)
  File "/root/la64_rust/rustc-1.82.0-src/src/bootstrap/bootstrap.py", line 1184, in bootstrap
    run(args, env=env, verbose=build.verbose, is_bootstrap=True)
  File "/root/la64_rust/rustc-1.82.0-src/src/bootstrap/bootstrap.py", line 195, in run
    raise RuntimeError(err)
RuntimeError: failed to run: /root/la64_rust/rustc-1.82.0-src/build/bootstrap/debug/bootstrap build -j30 -v

config.toml is configured as

change-id = 129295
profile = "user"

[llvm]
link-shared = true
static-libstdcpp = false
use-libcxx = true
targets = "X86;LoongArch;WebAssembly"

[build]
build = "x86_64-unknown-linux-musl"
host = ["loongarch64-unknown-linux-musl"]
target = ["loongarch64-unknown-linux-musl"]
cargo = "/usr/bin/cargo"
rustc = "/usr/bin/rustc"
rustfmt = "/usr/bin/rustfmt"
locked-deps = true
vendor = true
tools = ["cargo"]
sanitizers = false
profiler = true
# Generating docs fails with the wasm32-* targets
docs = false

[install]
prefix = "/usr"

[rust]
debuginfo-level-std = 2
channel = "stable"
description = "eweOS rust %RUSTVER%"
rpath = false
backtrace-on-ice = true
remap-debuginfo = true
jemalloc = false
llvm-libunwind = "system"
codegen-units-std = 1
deny-warnings = false
lld = false
musl-root = "/usr"

[target.x86_64-unknown-linux-musl]
crt-static = false
llvm-config = "/usr/bin/llvm-config"

[target.loongarch64-unknown-linux-musl]
crt-static = false
cc="clang"
cxx="clang++"
linker="/usr/bin/loongarch64-unknown-linux-musl-clang"
musl-root="/opt/sysroot-loongarch64"
musl-libdir="/opt/sysroot-loongarch64/usr/lib"

The error occurs in src/bootstrap/src/core/build_steps/llvm.rs: find_llvm_lib_name()1,

        let find_llvm_lib_name = |extension| {
            let version =
                command(&res.llvm_config).arg("--version").run_capture_stdout(builder).stdout();
            let major = version.split('.').next().unwrap();


            match &llvm_version_suffix {
                Some(version_suffix) => format!("libLLVM-{major}{version_suffix}.{extension}"),
                None => format!("libLLVM-{major}.{extension}"),
            }
        };

which tries to exec llvm-config of LLVM built for the build, but we don't acutally build it according to the configuration.

This problematic path is generated in prebuilt_llvm_config()2

    let mut llvm_config_ret_dir = builder.llvm_out(builder.config.build);
    llvm_config_ret_dir.push("bin");
    let build_llvm_config = llvm_config_ret_dir.join(exe("llvm-config", builder.config.build));
@ziyao233 ziyao233 added the C-bug Category: This is a bug. label Nov 12, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 12, 2024
@fmease fmease added A-cross Area: Cross compilation T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Nov 12, 2024
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Feb 8, 2025
resolve `llvm-config` path properly on cross builds

Fixes rust-lang#132926
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Feb 9, 2025
resolve `llvm-config` path properly on cross builds

Fixes rust-lang#132926
bors added a commit to rust-lang-ci/rust that referenced this issue Feb 9, 2025
resolve `llvm-config` path properly on cross builds

Fixes rust-lang#132926

try-job: x86_64-mingw-2
bors added a commit to rust-lang-ci/rust that referenced this issue Feb 10, 2025
resolve `llvm-config` path properly on cross builds

Fixes rust-lang#132926

try-job: x86_64-mingw-2
bors added a commit to rust-lang-ci/rust that referenced this issue Feb 10, 2025
resolve `llvm-config` path properly on cross builds

Fixes rust-lang#132926

try-job: x86_64-mingw-2
@bors bors closed this as completed in 2becd0b Feb 10, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Feb 10, 2025
Rollup merge of rust-lang#136681 - onur-ozkan:132926, r=jieyouxu

resolve `llvm-config` path properly on cross builds

Fixes rust-lang#132926

try-job: x86_64-mingw-2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cross Area: Cross compilation C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants