build: support config clang stdlib and fix default#210
Merged
feihongxu0824 merged 9 commits intomainfrom Mar 11, 2026
Merged
Conversation
This reverts commit 61322e4.
Collaborator
Author
|
#214 add clang CI and will track ut problem there. |
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.
Greptile Summary
This PR introduces a user-configurable
CLANG_USE_LIBCXXCMake option to control whether Clang useslibc++orlibstdc++, replacing the previous hard-coded-stdlib=libc++flag. The default isONon Apple platforms andOFFelsewhere, which aligns with platform conventions. The change also cleans up trailing whitespace in several function bodies.Key changes:
CLANG_USE_LIBCXXoption and derivedCLANG_STDLIB_OPTIONvariable used across compile and link flags._target_link_librariesand helpers.Issues found:
CLANG_STDLIB_OPTIONis empty, the compile-flag generator expression gains a trailing semicolon (-fcolor-diagnostics;), which causes CMake to emit an empty string as a separate compiler argument — a potential build error on some Clang versions.CMAKE_CXX_COMPILER_ID MATCHES "Clang"uses regex and inadvertently matches"AppleClang". Because the downstream generator expressions use exactCXX_COMPILER_ID:Clangmatching,CLANG_STDLIB_OPTIONis set for Apple Clang users but silently never applied. UsingSTREQUAL "Clang"would make the intent explicit.-stdlibflag is forwarded to C compilations (viaC_COMPILER_ID:Clang), which is unnecessary since-stdlibis a C++ concept.Confidence Score: 3/5
CLANG_STDLIB_OPTIONtrailing-semicolon issue can cause silent or noisy build failures for Linux/LLVM Clang users with the default OFF setting, and theMATCHESvsSTREQUALinconsistency makes the logic harder to maintain. These issues reduce confidence below a clean pass.MATCHEScondition at line 375 both need attention.Important Files Changed
CLANG_USE_LIBCXXoption (default ON on Apple, OFF elsewhere) and aCLANG_STDLIB_OPTIONvariable used in compile/link flags. Key issues: emptyCLANG_STDLIB_OPTIONcreates a trailing semicolon in the generator expression that can emit a blank compiler argument;MATCHES "Clang"unintentionally catches AppleClang while downstream generator expressions do not;-stdlibflag is unnecessarily applied to C compilations.Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[CMake Configure] --> B{APPLE platform?} B -- Yes --> C[CLANG_USE_LIBCXX = ON default] B -- No --> D[CLANG_USE_LIBCXX = OFF default] C --> E{CMAKE_CXX_COMPILER_ID\nMATCHES Clang?\nnote: also matches AppleClang} D --> E E -- No --> F[CLANG_STDLIB_OPTION = empty string] E -- Yes --> G{CLANG_USE_LIBCXX?} G -- ON --> H[CLANG_STDLIB_OPTION = -stdlib=libc++] G -- OFF --> I{APPLE?} I -- Yes --> F I -- No --> J[CLANG_STDLIB_OPTION = -stdlib=libstdc++] H --> K[Applied via generator expressions\nC_COMPILER_ID:Clang compile flags\nCXX_COMPILER_ID:Clang link flags] J --> K F --> L[⚠️ Empty value → trailing semicolon\nin generator expression → blank arg] K --> M[Build targets use CLANG_STDLIB_OPTION]Last reviewed commit: a217750