Repository navigation
Fix compiler-specific coroutine flags in exported CMake targets - #720
Closed
tinadu1018 wants to merge 1 commit into
Closed
tinadu1018 wants to merge 1 commit into
tinadu1018 wants to merge 1 commit into
Conversation
## Summary Use COMPILE_LANG_AND_ID:CXX,GNU in thrift_configure_target instead of checking the producer compiler at configure time. Exported usage requirements now select -fcoroutines for the consuming GNU compiler, without passing the GCC-only option to Clang. ## Prompting Intent The engineer requested a focused upstream FBThrift pull request for the compiler-flag failure exposed by Velox's Linux sanitizer build, and an explanation of why same-compiler FBThrift builds can pass while an installed package fails in a downstream Clang build. Keep the unrelated cuDF/xxhash discovery issue and the Velox pull request unchanged. ## Linked Sources - Downstream failure: https://github.com/facebookincubator/velox/actions/runs/41762595093/job/126353579801 - Upstream-fix review question: facebookincubator/velox#19909 (comment) - Producer configuration: https://github.com/meta/fbthrift/blob/63d52a48493e29f4247fddad9e16c1c3a23bac0c/CMakeLists.txt - Export helpers: https://github.com/meta/fbthrift/blob/63d52a48493e29f4247fddad9e16c1c3a23bac0c/thrift/CMakeLists.txt - Real regression component: https://github.com/meta/fbthrift/blob/63d52a48493e29f4247fddad9e16c1c3a23bac0c/thrift/common/CMakeLists.txt - Public Linux CI: https://github.com/meta/fbthrift/blob/63d52a48493e29f4247fddad9e16c1c3a23bac0c/.github/workflows/linux.yml - Contribution guidance: https://github.com/meta/fbthrift/blob/63d52a48493e29f4247fddad9e16c1c3a23bac0c/CONTRIBUTING.md ## Rationale The configure-time GNU condition describes the compiler that builds FBThrift, not the compiler that later consumes its installed targets. The language-only generator expression consequently leaks -fcoroutines from a GCC-built package into Clang consumers, which fail under -Werror. Evaluate both language and compiler in the exported generator expression. This keeps the GNU requirement for GNU consumers, including consumers of a Clang-built package, rather than suppressing warnings or deleting the GCC requirement. The CMake minimum already supports this expression. A focused Ubuntu Linux regression built and installed real thrift_common with the production configure/export functions, then compiled and ran C++20 coroutine consumers under ASAN, UBSAN, and -Werror. GCC 13.3 and Clang 18.1.3 passed all four producer/consumer combinations after the fix; the original GCC-to-Clang combination reproduced the downstream error. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: fdd7945e-1c8f-4e79-ac56-0fbeeedaffbd
Contributor
|
@vitaut has imported this pull request. If you are a Meta employee, you can view this in D129638627. |
Contributor
Contributor
|
Thank you! |
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.
Summary
Make the
-fcoroutinesusage requirement depend on the consuming C++ compiler, rather than the compiler that configured FBThrift.thrift_configure_targetcurrently checksCMAKE_CXX_COMPILER_IDat configure time, then exports a language-only expression:When FBThrift is built with GCC and its installed targets are consumed by Clang, this passes the GCC-specific flag to Clang. A downstream
-Werrorbuild then fails:Observed in Velox's Linux ASAN/UBSAN CI.
Regression history
The flag itself is not new; exporting it to downstream consumers is what changed.
v2026.09.07.00already used-fcoroutines, but through directory-leveladd_compile_options(). It affected FBThrift's own compilation and was not exported as a requirement for consumers of the installed targets.734f1641, "Express the C++ standard as a target usage requirement," moved these settings intothrift_configure_target. ItsPUBLICcall sites also exported the language-only-fcoroutinesoption.v2026.10.26.00picked up that change. A GCC-built FBThrift package now passes the flag to Velox's Clang sanitizer build, where-Werrormakes it fatal. The configure-time GNU check describes the producer, while the exported expression checks only whether the consumer is compiling C++.This is a change in the exported build requirements, not a new Velox requirement. The public C++20 requirement is intentional; this PR preserves it while selecting
-fcoroutinesaccording to the consuming compiler.Fix
Replace the configure-time condition with:
This evaluates the compiler for each consuming target. GNU C++ compilation retains the option, including when consuming a Clang-built package; Clang and other compilers do not receive it. No compiler warnings are suppressed, and no dependency versions, workflows, runtime code, or xxhash discovery are changed.
A same-compiler build does not expose this boundary: GCC accepts the original flag, while a Clang-configured FBThrift omits it entirely. The existing public Linux workflow configures, builds, and tests one tree rather than installing with GCC and compiling a downstream consumer with Clang.
Validation
Focused Ubuntu Linux (WSL) regression using GCC 13.3 and Clang 18.1.3. Built and installed real
thrift_commonusing the production configuration/export functions, then compiled and ran a C++20 coroutine consumer that calls the installed library, with-Wall -Wextra -Werrorand ASAN/UBSAN enabled.Also checked the generated compile commands: after the fix, only GNU consumers receive
-fcoroutines. This was a focused export regression, not a local run of the full FBThrift test suite.