Skip to content

Reduce library search path length in new build dir layout#17191

Merged
weihanglo merged 4 commits into
rust-lang:masterfrom
ranger-ross:reduce-ld-lib-path
Jul 12, 2026
Merged

Reduce library search path length in new build dir layout#17191
weihanglo merged 4 commits into
rust-lang:masterfrom
ranger-ross:reduce-ld-lib-path

Conversation

@ranger-ross

@ranger-ross ranger-ross commented Jul 9, 2026

Copy link
Copy Markdown
Member

View all comments

What does this PR try to resolve?

This PR addresses #17183 by only adding dylib crates to the library search path (LD_LIBRARY_PATH on linux, PATH on windows)

Previously, deps would be added to the search path. With the new build dir layout, I naively added all out dirs which blew up the search path hitting OS limits.

See #17183 (comment) for more details.

How to test and review this PR?

See the included test. I also verified that Zed now properly compiles with the new build-dir layout (on Linux)

@rustbot rustbot added A-build-execution Area: anything dealing with executing the compiler S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 9, 2026
@rustbot

rustbot commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

r? @epage

rustbot has assigned @epage.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ehuss, @epage, @weihanglo
  • @ehuss, @epage, @weihanglo expanded to ehuss, epage, weihanglo
  • Random selection from ehuss, epage, weihanglo

Comment thread tests/testsuite/build.rs
@ranger-ross
ranger-ross marked this pull request as draft July 11, 2026 01:03
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 11, 2026
@ranger-ross ranger-ross changed the title Reduce library search path length in build dir layout Reduce library search path length in new build dir layout Jul 11, 2026
@ranger-ross

ranger-ross commented Jul 11, 2026

Copy link
Copy Markdown
Member Author

I noticed the test was failing on stable, due to the behavior depending on rust-lang/rust@61f3e08 which still has not landed on stable.
I made the test nightly only until that commit lands on stable rust, in which case we can remove nightly only status

@ranger-ross
ranger-ross marked this pull request as ready for review July 11, 2026 14:00
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 11, 2026
@ranger-ross

Copy link
Copy Markdown
Member Author

Marking this as ready for review, the tests passed in CI and the CI failure appears to just be a spurious 503 from crates.io

Comment thread src/cargo/core/compiler/build_runner/mod.rs
Comment thread tests/testsuite/build.rs Outdated
Comment thread src/cargo/core/compiler/build_runner/mod.rs
Comment thread src/cargo/core/compiler/build_runner/mod.rs
@ranger-ross
ranger-ross force-pushed the reduce-ld-lib-path branch 2 times, most recently from 22939b2 to 50d9cbf Compare July 12, 2026 05:00

@weihanglo weihanglo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know when it is ready (pretty close I believe). Also, if we want to unblock rust-lang/rust#159076 we should do beta backport, right?

View changes since this review

Comment thread tests/testsuite/build.rs

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, I just got another idea: the current deps_output map collects every dylib output dir from every unit in the compilation session, which is not ideal. Some of the unit only need a subtree of it, and would be basically zero dylib path.

Anyway, I believe we don't need to put that much effort on this becuase dylibs are not that common as dependencies.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm yeah, good point. I probably added unit_graph.iter() to cast a wide net as possible.
I think we could construct lists per Unit instead of CompileKind.

Though, like you mentioned, dylibs usually don't make up a large percent of the crate graph so not sure if the effort for that optimization would be worth it

@ranger-ross

Copy link
Copy Markdown
Member Author

Let me know when it is ready (pretty close I believe). Also, if we want to unblock rust-lang/rust#159076 we should do beta backport, right?

I think its ready if it looks good to you.
Yeah, I think this will need to be backported.

I can raise a PR for that was well

@weihanglo weihanglo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Yeah would be nice to have a beta backport.

View changes since this review

@weihanglo
weihanglo added this pull request to the merge queue Jul 12, 2026
Merged via the queue into rust-lang:master with commit 6ff645c Jul 12, 2026
29 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 12, 2026
@weihanglo weihanglo added the beta-nominated Nominated to backport to the beta branch. label Jul 12, 2026
weihanglo added a commit that referenced this pull request Jul 12, 2026
Backports:

* #17191
* #17168
* #17179

Was only planning to backport #17191 but it builds on tests added in
#17168 so was getting merge conflicts. Given they are both bug fixes and
the new build-dir layout is still unstable, I figured it would be
simpler to backport both fixes.

r? @weihanglo
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Jul 18, 2026
Update cargo submodule

29 commits in 59800466c5c41c444d264b1010b4d57e85a7117f..3efb1f477e99b42974b982d939fd100303cdf7db
2026-07-07 15:52:22 +0000 to 2026-07-17 23:53:19 +0000
- refactor(context): normalize in `homedir` instead (rust-lang/cargo#17222)
- chore(ci): reflect doc folder move in book deployment (rust-lang/cargo#17235)
- refactor(ops): Have cargo-metadata's ops match the command name (rust-lang/cargo#17233)
- chore: Flatten src (rust-lang/cargo#17231)
- chore: Flatten `src` (rust-lang/cargo#17230)
- chore(ci): remove stale libsecret packages (rust-lang/cargo#17229)
- perf: Lazily initialize git2 fetch transports  (rust-lang/cargo#17226)
- test(trim-paths): re-enable lldb debugger tests  (rust-lang/cargo#17223)
- Include SBOM outputs in fingerprints (rust-lang/cargo#17216)
- Update cfg_aliases to 0.2.2 (rust-lang/cargo#17225)
- test(trim-paths): exercise GDB on windows-gnu (rust-lang/cargo#17221)
- feat(profile): Disable incremental compilation under CI by default (rust-lang/cargo#17220)
- Remove myself from review rotation (rust-lang/cargo#17219)
- Fix typo in comment in sync (rust-lang/cargo#17217)
- docs(ref): Improve handing of built-in profiles (rust-lang/cargo#17213)
- fix: dont apply host-config gating to stable behavior (rust-lang/cargo#17198)
- chore(deps): update msrv (rust-lang/cargo#17192)
- test: fix race in cargo_compile_with_invalid_code_in_deps (rust-lang/cargo#17203)
- Rename `-Zno-embed-metadata` to `-Zembed-metadata=no` (rust-lang/cargo#17149)
- fix(source): incorrect duplicate package warning (rust-lang/cargo#17204)
- Fix manifest schema generation: `TomlDebugInfo` enum-variants doesn't renamed (rust-lang/cargo#17202)
- Reduce library search path length in new build dir layout (rust-lang/cargo#17191)
- fix(install): Move --debug to Compilation options (rust-lang/cargo#17199)
- chore(ci): dogfood `build.warnings` (rust-lang/cargo#17195)
- docs(lints): Better match clippy in lint section titles (rust-lang/cargo#17190)
- chore: bump to 0.100.0; update changelog (rust-lang/cargo#17189)
- docs(ref): Clarify MSRV for lints (rust-lang/cargo#17184)
- docs(report): add missing entry for `cargo report future-incompatibilities` (rust-lang/cargo#17188)
- Reduce rustc `-L` args used in the new `build-dir` layout (rust-lang/cargo#17168)
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Jul 18, 2026
Update cargo submodule

29 commits in 59800466c5c41c444d264b1010b4d57e85a7117f..3efb1f477e99b42974b982d939fd100303cdf7db
2026-07-07 15:52:22 +0000 to 2026-07-17 23:53:19 +0000
- refactor(context): normalize in `homedir` instead (rust-lang/cargo#17222)
- chore(ci): reflect doc folder move in book deployment (rust-lang/cargo#17235)
- refactor(ops): Have cargo-metadata's ops match the command name (rust-lang/cargo#17233)
- chore: Flatten src (rust-lang/cargo#17231)
- chore: Flatten `src` (rust-lang/cargo#17230)
- chore(ci): remove stale libsecret packages (rust-lang/cargo#17229)
- perf: Lazily initialize git2 fetch transports  (rust-lang/cargo#17226)
- test(trim-paths): re-enable lldb debugger tests  (rust-lang/cargo#17223)
- Include SBOM outputs in fingerprints (rust-lang/cargo#17216)
- Update cfg_aliases to 0.2.2 (rust-lang/cargo#17225)
- test(trim-paths): exercise GDB on windows-gnu (rust-lang/cargo#17221)
- feat(profile): Disable incremental compilation under CI by default (rust-lang/cargo#17220)
- Remove myself from review rotation (rust-lang/cargo#17219)
- Fix typo in comment in sync (rust-lang/cargo#17217)
- docs(ref): Improve handing of built-in profiles (rust-lang/cargo#17213)
- fix: dont apply host-config gating to stable behavior (rust-lang/cargo#17198)
- chore(deps): update msrv (rust-lang/cargo#17192)
- test: fix race in cargo_compile_with_invalid_code_in_deps (rust-lang/cargo#17203)
- Rename `-Zno-embed-metadata` to `-Zembed-metadata=no` (rust-lang/cargo#17149)
- fix(source): incorrect duplicate package warning (rust-lang/cargo#17204)
- Fix manifest schema generation: `TomlDebugInfo` enum-variants doesn't renamed (rust-lang/cargo#17202)
- Reduce library search path length in new build dir layout (rust-lang/cargo#17191)
- fix(install): Move --debug to Compilation options (rust-lang/cargo#17199)
- chore(ci): dogfood `build.warnings` (rust-lang/cargo#17195)
- docs(lints): Better match clippy in lint section titles (rust-lang/cargo#17190)
- chore: bump to 0.100.0; update changelog (rust-lang/cargo#17189)
- docs(ref): Clarify MSRV for lints (rust-lang/cargo#17184)
- docs(report): add missing entry for `cargo report future-incompatibilities` (rust-lang/cargo#17188)
- Reduce rustc `-L` args used in the new `build-dir` layout (rust-lang/cargo#17168)
@rustbot rustbot added this to the 1.99.0 milestone Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-build-execution Area: anything dealing with executing the compiler beta-nominated Nominated to backport to the beta branch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants