Fix bootstrap build failure on macOS due to DYLD_LIBRARY_PATH #140055
+3
−1
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.
Fix bootstrap build failures on macOS due to DYLD_LIBRARY_PATH conflicts
Previously, the Rust bootstrap process set the
DYLD_LIBRARY_PATH
environment variable on macOS, sometimes including system paths like/usr/local/lib
. BecauseDYLD_LIBRARY_PATH
is searched before the default system library locations and uses stem matching, this could cause the dynamic linker to load incorrect library versions.A specific example is when a system framework (like ImageIO) depends on a library (like libjpeg) that also exists in
/usr/local/lib
. The presence of/usr/local/lib
inDYLD_LIBRARY_PATH
would cause/usr/local/lib/libjpeg.dylib
to be loaded instead of the version required by ImageIO, leading to runtime errors (as reported in #139400).This PR fixes the issue by modifying the
dylib_path_var
helper function (src/bootstrap/src/utils/shared_helpers.rs
) to return"DYLD_FALLBACK_LIBRARY_PATH"
instead of"DYLD_LIBRARY_PATH"
on Apple platforms.DYLD_FALLBACK_LIBRARY_PATH
is searched after the standard system paths, resolving the loading conflict while still allowing the build process to find necessary libraries in bootstrap-specific directories.Fixes #139400