Fix StringRef build failure with newer libc++#8307
Open
tsukinoko-kun wants to merge 1 commit intomicrosoft:mainfrom
Open
Fix StringRef build failure with newer libc++#8307tsukinoko-kun wants to merge 1 commit intomicrosoft:mainfrom
tsukinoko-kun wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Contributor
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
format code
3da2ee1 to
51139f6
Compare
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.
Fixes #8306.
Summary
Building DXC with newer Apple toolchains fails in
include/llvm/ADT/StringRef.hbecause libc++ now rejects user specializations of certain standard library traits. DXC currently specializes:std::is_nothrow_constructible<std::string, llvm::StringRef>std::is_nothrow_constructible<std::string, llvm::StringRef &>std::is_nothrow_constructible<std::string, const llvm::StringRef &>On Xcode 26.4 / Apple clang 21 / libc++, that now produces an error like:
What this changes
This patch keeps the existing HLSL workaround for non-libc++ standard libraries, but disables those
std::is_nothrow_constructiblespecializations when building against libc++:Why this fixes the issue
The failure is caused by the specializations themselves, not by any runtime behavior in StringRef.
For libc++:
So the fix is to stop declaring the forbidden specialization on libc++, while preserving the existing behavior everywhere else.
Why I chose this approach
I looked at the HLSL-specific block in StringRef.h and tested the current Apple libc++ behavior directly. Without the manual specialization, libc++ still reports the relevant is_nothrow_constructible cases as false, which matches the intent of the original workaround.
That made this the narrowest safe fix:
Validation
I verified: