Fix macOS build failure with GCC 15#2095
Closed
DrishtiTripathi2230 wants to merge 5 commits into
Closed
Conversation
Defining _XOPEN_SOURCE on Darwin lowers __DARWIN_C_LEVEL, hiding quick_exit/at_quick_exit. GCC 15's libstdc++ <cstdlib> unconditionally does 'using ::quick_exit;', which fails to compile when those symbols are hidden. Defining _DARWIN_C_SOURCE alongside _XOPEN_SOURCE restores full Darwin visibility while keeping the POSIX/SUSv2 definitions cctz needs elsewhere. Scoped to __APPLE__ only; no effect on other platforms. Fixes abseil#2027
…EN_SOURCE" This reverts commit c7f471f.
…PEN_SOURCE" This reverts commit 5b123e1.
Contributor
|
This code is forked from https://github.com/google/cctz, can you please open a PR there? |
Contributor
|
This also seems like maybe the fix to google/cctz#265 was just too wide? Could we just add Apple to the exclusion list? The original issue was to fix a problem in QNX |
Contributor
Author
|
Thanks for the guidance — opened google/cctz#343 with the narrower Closing this PR since the fix belongs upstream. Per devbww's note on |
Contributor
|
If everything goes smoothly it shouldn't take more than a few days :) |
mkruskal-google
pushed a commit
to google/cctz
that referenced
this pull request
Jun 29, 2026
* Exclude Apple platforms from _XOPEN_SOURCE definition _XOPEN_SOURCE 500 was added in #266 to fix a QNX-specific compile error. On Apple platforms, defining it lowers __DARWIN_C_LEVEL, hiding C11 additions like quick_exit/at_quick_exit. GCC 15's libstdc++ <cstdlib> unconditionally re-exports these symbols, which fails to compile when they're hidden by this macro. Add __APPLE__ to the existing exclusion list alongside FreeBSD and OpenBSD, consistent with how those platforms are already handled. See abseil/abseil-cpp#2095 * Add temporary CI workflow to verify macOS GCC15 build * Fix CI workflow: use mkdir -p to avoid build dir conflict * Fix CI workflow: rename build dir to avoid case-insensitive collision with Bazel BUILD file * Fix CI workflow: disable BUILD_TESTING to skip GTest/benchmark deps * Fix missing #endif causing unterminated #if compile error * Revert "Exclude Apple platforms from _XOPEN_SOURCE definition" This reverts commit 3ae438d. * Reapply "Exclude Apple platforms from _XOPEN_SOURCE definition" This reverts commit 433ab0e. * Remove temporary CI verification workflow
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 #2027
Problem
Building Abseil on macOS with Homebrew GCC 15 fails with:
error: 'quick_exit' has not been declared in '::'error: 'at_quick_exit' has not been declared in '::'Root cause
_XOPEN_SOURCE 500, defined intime_zone_format.ccto expose SUSv2/POSIXdefinitions, lowers
__DARWIN_C_LEVELon Darwin, hiding C11 additions likequick_exit/at_quick_exit. GCC 15's libstdc++<cstdlib>now unconditionallyre-exports these into the global namespace, which fails when the underlying
declarations are hidden.
Fix
Define
_DARWIN_C_SOURCEalongside_XOPEN_SOURCE, scoped to__APPLE__only,restoring both POSIX and C11 visibility on Darwin without affecting other
platforms (Linux/FreeBSD/OpenBSD behavior unchanged).
Testing
Verified with a CI workflow on a macos-latest runner + Homebrew GCC 15: