Skip to content

clang++ segfault when using import std in module #123828

@jpc0

Description

@jpc0

While building a module that has import std I get a segfault in clang++ 20 building with a very new cmake.

I am using the flags -stdlib=libc++ -Xclang -fno-validate-pch and the linker flags -stdlib=libc++ -lc++abi. I have also tested with onl the -stdlib=libc++ flag and -stdlib=libc++ -lc++abi linker flags and get the same error.

The CMake output before the stackdump is:

/usr/bin/clang++-20   -stdlib=libc++ -g -std=gnu++23 -MD -MT CMakeFiles/test.dir/test.cpp.o -MF CMakeFiles/test.dir/test.cpp.o.d @CMakeFiles/test.dir/test.cpp.o.modmap -o CMakeFiles/test.dir/test.cpp.o -c /home/jpc0/devel/git/debug/clang20/test.cpp
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.

I am running on Ubuntu 24.04.1 LTS under WSL if that makes any difference. I do not currenly have a different configuration of OS to test under.

I have a git repo here that has a basic reproduction as well as the relevant preprocessed source and associated run script.

In the repo run:

cmake -S . --preset debug
cmake --build build

and the crash will happen. All variables passed to cmake is in the CMakePresets debug preset.

Ubuntu clang version 20.0.0 (++20250120081916+d35d7f4b13c0-1~exp1~20250120202047.676)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-20/bin
cmake version 3.31.4-g98de8ec

I got clang from the ubuntu repo added video the llvm install script: deb http://apt.llvm.org/noble/ llvm-toolchain-noble main

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:modulesC++20 modules and Clang Header Modules

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions