Skip to content

tools depending on rustc crates can't build with rust.download-rustc=true and llvm.download-ci-llvm=false options #123586

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

Closed
onur-ozkan opened this issue Apr 7, 2024 · 3 comments · Fixed by #123642
Labels
T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@onur-ozkan
Copy link
Member

When trying to build tools that rely on rustc crates using the rust.download-rustc=true and llvm.download-ci-llvm=false options, ld can not find the LLVM it needs.

$ x build miri
...
...
...
  = note: /usr/bin/ld: cannot find -lLLVM-18-rust-1.79.0-nightly: No such file or directory
          collect2: error: ld returned 1 exit status


error: could not compile `rustdoc-tool` (bin "rustdoc_tool_binary") due to 1 previous error
Build completed unsuccessfully in 0:01:02

I have also attempted to build rustdoc and clippy and they too failed due to the same issue. So I am quite sure this happens on any tool that uses rustc crates.

@onur-ozkan onur-ozkan added the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Apr 7, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 7, 2024
@onur-ozkan onur-ozkan removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 7, 2024
@onur-ozkan
Copy link
Member Author

I am unsure whether this is a bug in bootstrap or a limitation of using precompiled CI rustc.. 🤔

cc @nikic

@bjorn3
Copy link
Member

bjorn3 commented Apr 8, 2024

Building tools that link against rustc internals requires both the rustc-dev and llvm-tools-preview components to be installed. The former for all crate metadata and librustc_driver.so in the sysroot, while the latter is for libLLVM.so. Linking against the libLLVM.so in the rustc component that rustc itself is linked against doesn't work as it isn't in the sysroot for the target. It is in lib/ rather than lib/rustlib/some-target-triple/lib.

@onur-ozkan
Copy link
Member Author

onur-ozkan commented Apr 8, 2024

I am unsure whether this is a bug in bootstrap or a limitation of using precompiled CI rustc.. 🤔

Even if llvm.download-ci-llvm is set to true, stage > 0 rustc will always use the prebuilt LLVM library which comes with ci-rustc. So I tried to use locally-built LLVM libraries in the ci-rustc by replacing the existing LLVM libraries with the locally built ones, and it appears that this is indeed a limitation of using rust.download-rustc=true as it fails with the following error:

$ ./build/host/ci-rustc/bin/rustc --version
./build/host/ci-rustc/bin/rustc: symbol lookup error: /home/nimda/devspace/.other/rustc-builds/build/x86_64-unknown-linux-gnu/ci-rustc/bin/../lib/librustc_driver-a03ea465d8e03db1.so: undefined symbol: LLVMInitializeARMTargetInfo, version LLVM_18.1

So, if rust.download-rustc is set to true and llvm.download-ci-llvm is false, I believe bootstrap should terminate the process (as it always uses prebuilt LLVM libraries from ci-rustc, there is no point to build LLVM locally) while parsing the configuration.

@bors bors closed this as completed in 873de7e Apr 13, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Apr 13, 2024
Rollup merge of rust-lang#123642 - onur-ozkan:restrict-llvm-option, r=Mark-Simulacrum

do not allow using local llvm while using rustc from ci

From: rust-lang#123586 (comment)

> Even if `llvm.download-ci-llvm` is set to true, `stage > 0` rustc will always use the prebuilt LLVM library which comes with ci-rustc. So I tried to use locally-built LLVM libraries in the ci-rustc by replacing the existing LLVM libraries with the locally built ones, and it appears that this is indeed a limitation of using `rust.download-rustc=true` as it fails with the following error:
>
> ```
> $ ./build/host/ci-rustc/bin/rustc --version
> ./build/host/ci-rustc/bin/rustc: symbol lookup error: /home/nimda/devspace/.other/rustc-builds/build/x86_64-unknown-linux-gnu/ci-rustc/bin/../lib/librustc_driver-a03ea465d8e03db1.so: undefined symbol: LLVMInitializeARMTargetInfo, version LLVM_18.1
> ```
>
> So, if `rust.download-rustc` is set to true and `llvm.download-ci-llvm` is false, I believe bootstrap should terminate the process (as it always uses prebuilt LLVM libraries from ci-rustc, there is no point to build LLVM locally) while parsing the configuration.

Resolves rust-lang#123586

r? Mark-Simulacrum
RalfJung pushed a commit to RalfJung/miri that referenced this issue Apr 15, 2024
…ulacrum

do not allow using local llvm while using rustc from ci

From: rust-lang/rust#123586 (comment)

> Even if `llvm.download-ci-llvm` is set to true, `stage > 0` rustc will always use the prebuilt LLVM library which comes with ci-rustc. So I tried to use locally-built LLVM libraries in the ci-rustc by replacing the existing LLVM libraries with the locally built ones, and it appears that this is indeed a limitation of using `rust.download-rustc=true` as it fails with the following error:
>
> ```
> $ ./build/host/ci-rustc/bin/rustc --version
> ./build/host/ci-rustc/bin/rustc: symbol lookup error: /home/nimda/devspace/.other/rustc-builds/build/x86_64-unknown-linux-gnu/ci-rustc/bin/../lib/librustc_driver-a03ea465d8e03db1.so: undefined symbol: LLVMInitializeARMTargetInfo, version LLVM_18.1
> ```
>
> So, if `rust.download-rustc` is set to true and `llvm.download-ci-llvm` is false, I believe bootstrap should terminate the process (as it always uses prebuilt LLVM libraries from ci-rustc, there is no point to build LLVM locally) while parsing the configuration.

Resolves #123586

r? Mark-Simulacrum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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