[modules] `import std;` fails with libc++ when disabling language extensions
Tested with a self-built CMake 0bb28c52 and a recent build of Clang + libc++ 19.0.
Testing with the following CMakeLists.txt
cmake_minimum_required(VERSION 3.29.0)
project("module" CXX)
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "0e5b6991-d74f-4b3d-a41c-cf096e0b2508")
set(CMAKE_CXX_MODULE_STD ON)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
#set(CMAKE_CXX_EXTENSIONS OFF)
add_executable(main main.cpp)
and the following main.cpp
import std;
int main() { std::cout << "Hello modular world\n"; }
Works as expected. After disabling the CMAKE_CXX_EXTENSIONS
it fails with the following error
error: GNU extensions was enabled in PCH file but is currently disabled
Looking in build.ninja for the module part I see
build CMakeFiles/__cmake_cxx23.dir/usr/lib/llvm-19/share/libc++/v1/std.cppm.o.ddi: CXX_SCAN____cmake_cxx23_ /usr/lib/llvm-19/share/libc++/v1/std.cppm || cmake_object_order_depends_target___cmake_cxx23
DEP_FILE = CMakeFiles/__cmake_cxx23.dir/usr/lib/llvm-19/share/libc++/v1/std.cppm.o.ddi.d
DYNDEP_INTERMEDIATE_FILE = CMakeFiles/__cmake_cxx23.dir/usr/lib/llvm-19/share/libc++/v1/std.cppm.o.ddi
FLAGS = -stdlib=libc++ -std=gnu++23 -Wno-reserved-module-identifier
INCLUDES = -I/usr/lib/llvm-19/bin/../lib/../share/libc++/v1
OBJ_FILE = CMakeFiles/__cmake_cxx23.dir/usr/lib/llvm-19/share/libc++/v1/std.cppm.o
PREPROCESSED_OUTPUT_FILE = CMakeFiles/__cmake_cxx23.dir/usr/lib/llvm-19/share/libc++/v1/std.cppm.o.ddi.i
I believe -std=gnu++23
should be -std=c++23
so the std
module and the main.cpp
use the same language mode.