Open
Description
To reproduce, set CLANG_BIN
to your clang binary and run this script:
#!/bin/bash
set -e
# ==== 🔧 Configuration ====
CLANG_BIN="/usr/local/bin/clang-21" # Set this to your clang binary
OUT_DIR="./build"
PCM_DIR="$OUT_DIR/pcm"
mkdir -p "$PCM_DIR"
# main.cppm
cat <<EOF >main.cppm
export module a;
EOF
# ==== 📦 Precompile modules ====
echo "🔨 Precompiling main.cppm"
"$CLANG_BIN" -std=c++20 \
-Xclang -emit-module-interface \
main.cppm -o "$PCM_DIR/main.pcm"
echo "✅ Done"
It will now crash:
🔨 Precompiling main.cppm
clang-21: /home/paul/Documents/llvm-project/clang/lib/Frontend/FrontendAction.cpp:687: bool clang::FrontendAction::BeginSourceFile(CompilerInstance &, const FrontendInputFile &): Assertion `hasASTFileSupport() && "This action does not have AST file support!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /usr/local/bin/clang-21 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir ./build/pcm/main.pcm- -disable-free -clear-ast-before-backend -main-file-name main.cppm -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/home/paul/delete-me -fcoverage-compilation-dir=/home/paul/delete-me -resource-dir /usr/local/lib/clang/21 -std=c++20 -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fno-implicit-modules -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -emit-module-interface -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/main-7a4a7d.o -x pcm /tmp/main-dc5e6d.pcm
#0 0x000055704d652b89 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/paul/Documents/llvm-project/llvm/lib/Support/Unix/Signals.inc:804:11
#1 0x000055704d65312b PrintStackTraceSignalHandler(void*) /home/paul/Documents/llvm-project/llvm/lib/Support/Unix/Signals.inc:880:1
#2 0x000055704d650ebc llvm::sys::RunSignalHandlers() /home/paul/Documents/llvm-project/llvm/lib/Support/Signals.cpp:105:5
#3 0x000055704d6538eb SignalHandler(int, siginfo_t*, void*) /home/paul/Documents/llvm-project/llvm/lib/Support/Unix/Signals.inc:418:7
#4 0x00007f54f464bcd0 (/usr/lib/libc.so.6+0x3dcd0)
#5 0x00007f54f46a5624 (/usr/lib/libc.so.6+0x97624)
#6 0x00007f54f464bba0 raise (/usr/lib/libc.so.6+0x3dba0)
#7 0x00007f54f4633582 abort (/usr/lib/libc.so.6+0x25582)
#8 0x00007f54f46334eb __assert_perror_fail (/usr/lib/libc.so.6+0x254eb)
#9 0x000055704e9fcedd clang::FrontendAction::BeginSourceFile(clang::CompilerInstance&, clang::FrontendInputFile const&) /home/paul/Documents/llvm-project/clang/lib/Frontend/FrontendAction.cpp:689:50
#10 0x000055704e90b8d3 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /home/paul/Documents/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1054:9
#11 0x000055704ebe341d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /home/paul/Documents/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:300:8
#12 0x0000557048fdd198 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /home/paul/Documents/llvm-project/clang/tools/driver/cc1_main.cpp:294:13
#13 0x0000557048fced73 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) /home/paul/Documents/llvm-project/clang/tools/driver/driver.cpp:218:5
#14 0x0000557048fcdaa9 clang_main(int, char**, llvm::ToolContext const&) /home/paul/Documents/llvm-project/clang/tools/driver/driver.cpp:259:5
#15 0x0000557049004bfa main /home/paul/Documents/llvm-project/build_debug/tools/clang/tools/driver/clang-driver.cpp:17:10
#16 0x00007f54f4635488 (/usr/lib/libc.so.6+0x27488)
#17 0x00007f54f463554c __libc_start_main (/usr/lib/libc.so.6+0x2754c)
#18 0x0000557048fcd4f5 _start (/usr/local/bin/clang-21+0x1e004f5)
clang-21: error: unable to execute command: Aborted (core dumped)
clang-21: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 21.0.0git (https://github.com/llvm/llvm-project.git 64555e3d48223c4c5a851f0cbe0278ec6f2241ba)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
Build config: +unoptimized, +assertions
clang-21: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-21: note: diagnostic msg: /tmp/main-fbfd35.cppm
clang-21: note: diagnostic msg: /tmp/main-fbfd35.sh
clang-21: note: diagnostic msg:
********************
I found this issue while investigating #58540.