[clang][Darwin] Prefer the toolchain-provided libc++.dylib if there is one #170930
+158
−8
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.
When libc++ is bootstrapped with clang, the resulting clang uses the just-built libc++ headers from /bin/../include/c++/v1. However, before this patch, clang would still use the system-provided libc++.dylib (usually in the Apple SDK) because it would fail to add the corresponding linker flag to find the just-built libc++. After this patch, Clang will instead link against the toolchain provided
libc++.dylibin<install>/libif it exists, which results in programs being compiled and linked against corresponding libc++ headers and dylib.This is a re-application of #170303 which was temporarily reverted due to build breakages. This also contains minor fixes to the tests to make the more portable across platforms.
Fixes #77653
rdar://107060541