Skip to content

Fix macOS build failure with GCC 15#2095

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

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

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