llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
26.71k stars 10.94k forks source link

stdatomic.h is not working in C mode (15.0.0) #57710

Closed ngg closed 1 year ago

ngg commented 1 year ago

libc++ 15.0.0 added the new stdatomic.h file: https://github.com/llvm/llvm-project/blob/llvmorg-15.0.0/libcxx/include/stdatomic.h

This file has a before C++23 compatibility code which should include other stdatomic.h file shipped elsewhere: https://github.com/llvm/llvm-project/blob/llvmorg-15.0.0/libcxx/include/stdatomic.h#L223-L231.

Unfortunately, this is not triggered when in C mode, because the _LIBCPP_COMPILER_CLANG_BASED is only set in __config within an #ifdef __cplusplus region: https://github.com/llvm/llvm-project/blob/llvmorg-15.0.0/libcxx/include/__config#L25

Most other header files that should be working from C code as well use #include_next directives unconditionally or when __cplusplus is not defined. Here are some working examples:

smeenai commented 1 year ago

See the discussion in https://reviews.llvm.org/D131435. Unfortunately I've been on leave and haven't had time to address @ldionne's suggestions. I'd be happy for you or someone else to pick up that work if you need it.