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

rust-analyzer +nightly (and similar) should not set LD_LIBRARY_PATH #4245

Closed
jyn514 opened this issue Mar 11, 2025 · 4 comments
Closed

rust-analyzer +nightly (and similar) should not set LD_LIBRARY_PATH #4245

jyn514 opened this issue Mar 11, 2025 · 4 comments

Comments

@jyn514
Copy link
Member

jyn514 commented Mar 11, 2025

Problem you are trying to solve

I am trying to reduce the number of spurious rebuilds that occur in rust-lang/rust itself. One such spurious rebuild happens when using rustup-managed rust-analyzer, in which case rustup sets LD_LIBRARY_PATH. See rust-lang/rust#138333 for more details about why that causes issues.

Solution you'd like

Rust-analyzer does not use rustc_private libraries, and my understanding is that their architecture is very specifically designed so that they will never need to (@rust-lang/rust-analyzer, can you confirm?). That means that rustup does not need to set LD_LIBRARY_PATH for that proxy.

In particular, the following should leave LD_LIBRARY_PATH unmodified:

  • rust-analyzer (when rust-analyzer is a rustup-managed toolchain proxy)
  • rust-analyzer +toolchain

these should still add rustc --print target-libdir to LD_LIBRARY_PATH:

  • rustup run toolchain rust-analyzer
  • cargo +nightly (and all other proxies)

Notes

(-zsh@pop-os) ~/src/rust3 spurious-llvm-rebuilds
; git log --oneline -n1 HEAD~
385970f0c1f (upstream/master, upstream/HEAD) Auto merge of #137655 - nnethercote:split-edges-iterator, r=nnethercote
; rustup --version
rustup 1.27.1 (54dd3d00f 2024-04-24)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.87.0-nightly (00f245915 2025-02-26)`
@ChrisDenton
Copy link
Member

Could you expand on the difference between rust-analyzer +toolchain and rustup run toolchain rust-analyzer? Why does one need LD_LIBRARY_PATH and the other one doesn't?

@jyn514
Copy link
Member Author

jyn514 commented Mar 11, 2025

rustup run toolchain is the general form, which can run any program, including non-proxied commands. for instance, rustup run nightly whoami just works: #3387 (and sometimes that's useful for "i have a cargo-foo extension in path that's not managed by rustup, but does depend on rustc_private": https://jyn.dev/rustc-driver/#a-digression-more-about-rustup-proxies). in every case where rustup run runs a command, it sets LD_LIBRARY_PATH, even for non-proxied commands. so i don't think rust-analyzer should be special there, especially since bootstrap doesn't ever use rustup run.

@Veykril
Copy link
Member

Veykril commented Mar 11, 2025

We do depend on rustc crates when built in tree, and we also link against the rustc driver dylib iirc

@jyn514
Copy link
Member Author

jyn514 commented Mar 11, 2025

oh. well, never mind, then.

@jyn514 jyn514 closed this as completed Mar 11, 2025
@rami3l rami3l closed this as not planned Won't fix, can't repro, duplicate, stale Mar 11, 2025
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

4 participants