Skip to content

macOS clang base missing __GCC_DESTRUCTIVE_SIZE and __GCC_CONSTRUCTIVE_SIZE #319

Description

@mborland

Summary

Clang 19 and later predefine __GCC_DESTRUCTIVE_SIZE and
__GCC_CONSTRUCTIVE_SIZE. libc++ uses them unconditionally from C++17 on, in
<__new/interference_size.h>, to define
std::hardware_destructive_interference_size and
std::hardware_constructive_interference_size.

The native macOS bases for clang mode
(bases/cmake-native/macos-arm/clang/lib/predefined_macros.txt, the x86_64
one, and their byte-identical copies in the target-configuration directories
lib_macos_arm64/ and lib_macos_x86_64/) do not define them. The Linux docker bases do (for example
bases/docker/dev-env/clang/lib_linux_riscv64/predefined_macros.txt).

The macOS file appears to be a snapshot of Apple clang 15: it sets
__apple_build_version__ 15000309. That stays so even when the front end
emulates a newer clang with --clang_version, as HACKING.md says to do
with the scraped version. The current Command Line Tools ship Apple clang 21
and its libc++, so every C++17 or later translation unit that reaches <new>
fails.

Reproducer

#ifndef __GCC_DESTRUCTIVE_SIZE
#error "__GCC_DESTRUCTIVE_SIZE is not defined"
#endif
#ifndef __GCC_CONSTRUCTIVE_SIZE
#error "__GCC_CONSTRUCTIVE_SIZE is not defined"
#endif
int x = __GCC_DESTRUCTIVE_SIZE + __GCC_CONSTRUCTIVE_SIZE;
cpfe --clang_version=210000 --c++20 --no_wrap_diagnostics interference.cpp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions