Issue 123828
Summary clang++ segfault when using import std in module
Labels clang
Assignees
Reporter 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](https://github.com/jpc0/clang20importstdsegfault) that has a basic reproduction as well as the relevant preprocessed source and associated run script. 

In the repo run:
```sh
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`
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to