[bootstrap] Don't reverse the order of dylib search path entries - #161377
Open
jnkel wants to merge 1 commit into
Open
[bootstrap] Don't reverse the order of dylib search path entries#161377jnkel wants to merge 1 commit into
jnkel wants to merge 1 commit into
Conversation
This comment has been minimized.
This comment has been minimized.
jnkel
force-pushed
the
fix-dylib-search-order
branch
from
August 19, 2026 23:44
02b6017 to
67e8a19
Compare
jieyouxu
reviewed
Aug 20, 2026
Comment on lines
-145
to
-148
| for path in path { | ||
| list.insert(0, path); | ||
| } | ||
| cmd.env(dylib_path_var(), t!(env::join_paths(list))); |
Member
There was a problem hiding this comment.
Remark: I remember this was for a specific reason (or two), need to double-check
Member
|
The code in Also, this is such a mess.. the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
add_dylib_pathhelper function prepends paths to the beginning of the dynamic linker search path, but it reverses their order while doing so. This is surprising and undocumented, and seems to be unexpected by several callers of this function.Particularly,
rustc_lib_pathsappends theci-llvmpath to the list it returns; reversing the order putsci-llvmat a higher priority than the compiler's lib directory. On my system, this currently causes./x testto fail (when building the unstable book), because the stage0 compiler is run using CI LLVM instead of stage0 LLVM (which are currently different because stage0 is on LLVM 22 while main is on LLVM 23).Might be worth a try build as this change could potentially cause issues if there is somewhere we depend on this ordering reversal. I checked all the call-sites (and ran
./x testlocally) and I don't think anyone intentionally relied on the ordering being reversed. I did find one snippet that concerned me (from #144303, cc @Kobzol):rust/src/bootstrap/src/core/build_steps/test.rs
Lines 437 to 448 in f7d782a
The comment states we're inserting
builder.rustc_libdir(tested_compiler)at the highest priority in the search path, but becauseadd_dylib_pathreversed the ordering, it's actually inserted at the lowest priority. I don't know how to reproduce the issue this was supposed to fix, so I can't be sure that this PR doesn't cause a regression.Follow-up to #161335. r? @jieyouxu