Skip to content

Fix macOS build failure with GCC 15#2095

Closed
DrishtiTripathi2230 wants to merge 5 commits into
abseil:masterfrom
DrishtiTripathi2230:fix-2027-darwin-xopen-source
Closed

Fix macOS build failure with GCC 15#2095
DrishtiTripathi2230 wants to merge 5 commits into
abseil:masterfrom
DrishtiTripathi2230:fix-2027-darwin-xopen-source

Conversation

@DrishtiTripathi2230

Copy link
Copy Markdown
Contributor

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 in time_zone_format.cc to expose SUSv2/POSIX
definitions, lowers __DARWIN_C_LEVEL on Darwin, hiding C11 additions like
quick_exit/at_quick_exit. GCC 15's libstdc++ <cstdlib> now unconditionally
re-exports these into the global namespace, which fails when the underlying
declarations are hidden.

Fix

Define _DARWIN_C_SOURCE alongside _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:

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
@mkruskal-google

Copy link
Copy Markdown
Contributor

This code is forked from https://github.com/google/cctz, can you please open a PR there?

@mkruskal-google

Copy link
Copy Markdown
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

@DrishtiTripathi2230

Copy link
Copy Markdown
Contributor Author

Thanks for the guidance — opened google/cctz#343 with the narrower
fix you suggested (adding APPLE to the exclusion list alongside
FreeBSD/OpenBSD). Verified the same way, via CI on macos-latest +
Homebrew GCC 15.

Closing this PR since the fix belongs upstream. Per devbww's note on
cctz#265, it may take a bit to propagate down to Abseil — happy to
help verify once it does.

@mkruskal-google

Copy link
Copy Markdown
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Can't build on macOS with GCC 15

3 participants