Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

identifier z crashes LLVM #23383

Open
bottle2 opened this issue Jan 13, 2025 · 6 comments
Open

identifier z crashes LLVM #23383

bottle2 opened this issue Jan 13, 2025 · 6 comments

Comments

@bottle2
Copy link

bottle2 commented Jan 13, 2025

Version of emscripten/emsdk:

$ uname -a
MINGW64_NT-10.0-19045 DESKTOP-QIBT7ND 3.5.4-0bc1222b.x86_64 2024-12-05 09:27 UTC x86_64 Msys
$ emcc -v
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.74-git (1092ec30a3fb1d46b1782ff1b4db5094d3d06ae5)
clang version 20.0.0git
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: C:/msys64/clang64/opt/emscripten-llvm/bin

Failing command line in full and output with -v appended:

$ cat test1.c
int z;
$ emcc -c test1.c -v
 "C:/msys64/clang64/opt/emscripten-llvm/bin/clang.exe" -target wasm32-unknown-emscripten -fignore-exceptions -mno-bulk-memory -mno-bulk-memory-opt -mno-nontrapping-fptoint -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --sysroot=C:/msys64/clang64/lib/emscripten/cache/sysroot -DEMSCRIPTEN -Werror=implicit-function-declaration -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -c -v test1.c
clang version 20.0.0git
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: C:/msys64/clang64/opt/emscripten-llvm/bin
 (in-process)
 "C:/msys64/clang64/opt/emscripten-llvm/bin/clang.exe" -cc1 -triple wasm32-unknown-emscripten -emit-obj -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name test1.c -mrelocation-model static -mframe-pointer=none -ffp-contract=on -fno-rounding-math -mconstructor-aliases -target-cpu generic -target-feature -bulk-memory -target-feature -bulk-memory-opt -target-feature -nontrapping-fptoint -fvisibility=hidden -debugger-tuning=gdb -fdebug-compilation-dir=D:/Projetos/raytracing -v -fcoverage-compilation-dir=D:/Projetos/raytracing -resource-dir C:/msys64/clang64/opt/emscripten-llvm/lib/clang/20 -D EMSCRIPTEN -isysroot C:/msys64/clang64/lib/emscripten/cache/sysroot -internal-isystem C:/msys64/clang64/opt/emscripten-llvm/lib/clang/20/include -internal-isystem C:/msys64/clang64/lib/emscripten/cache/sysroot/include/wasm32-emscripten -internal-isystem C:/msys64/clang64/lib/emscripten/cache/sysroot/include -Werror=implicit-function-declaration -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fignore-exceptions -iwithsysroot/include/fakesdl -iwithsysroot/include/compat -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -o test1.o -x c test1.c
clang -cc1 version 20.0.0git based upon LLVM 20.0.0git default target x86_64-w64-windows-gnu
ignoring nonexistent directory "C:/msys64/clang64/lib/emscripten/cache/sysroot/include/wasm32-emscripten"
#include "..." search starts here:
#include <...> search starts here:
 C:/msys64/clang64/lib/emscripten/cache/sysroot/include/fakesdl
 C:/msys64/clang64/lib/emscripten/cache/sysroot/include/compat
 C:/msys64/clang64/opt/emscripten-llvm/lib/clang/20/include
 C:/msys64/clang64/lib/emscripten/cache/sysroot/include
End of search list.
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: C:/msys64/clang64/opt/emscripten-llvm/bin/clang.exe -target wasm32-unknown-emscripten -fignore-exceptions -mno-bulk-memory -mno-bulk-memory-opt -mno-nontrapping-fptoint -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --sysroot=C:/msys64/clang64/lib/emscripten/cache/sysroot -DEMSCRIPTEN -Werror=implicit-function-declaration -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -c -v test1.c
1.	test1.c:1:6: current parser token ';'
Exception Code: 0x80000003
 #0 0x00007ff693fc0a18 clang::ASTContext::DecodeTypeStr(char const*&, clang::ASTContext const&, clang::ASTContext::GetBuiltinTypeError&, bool&, bool) const (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0xec0a18)
 #1 0x00007ff693fc0abd clang::ASTContext::GetBuiltinType(unsigned int, clang::ASTContext::GetBuiltinTypeError&, unsigned int*) const (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0xec0abd)
 #2 0x00007ff695300bff clang::Sema::LazilyCreateBuiltin(clang::IdentifierInfo*, unsigned int, clang::Scope*, bool, clang::SourceLocation) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x2200bff)
 #3 0x00007ff69562e9cb clang::Sema::LookupBuiltin(clang::LookupResult&) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x252e9cb)
 #4 0x00007ff69563bdfb clang::Sema::LookupName(clang::LookupResult&, clang::Scope*, bool, bool) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x253bdfb)
 #5 0x00007ff695314a14 clang::Sema::HandleDeclarator(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x2214a14)
 #6 0x00007ff69531415f clang::Sema::ActOnDeclarator(clang::Scope*, clang::Declarator&) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x221415f)
 #7 0x00007ff6973ad852 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x42ad852)
 #8 0x00007ff6973aba76 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x42aba76)
 #9 0x00007ff696d3a301 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x3c3a301)
#10 0x00007ff696d39c30 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x3c39c30)
#11 0x00007ff696d38d3e clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x3c38d3e)
#12 0x00007ff696d36e7a clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x3c36e7a)
#13 0x00007ff696d36881 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x3c36881)
#14 0x00007ff695a0c39c clang::ParseAST(clang::Sema&, bool, bool) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x290c39c)
#15 0x00007ff6942d5418 clang::FrontendAction::Execute() (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x11d5418)
#16 0x00007ff693595ad4 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x495ad4)
#17 0x00007ff693621876 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x521876)
#18 0x00007ff69310676a cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x676a)
#19 0x00007ff693103a47 clang_main(int, char**, llvm::ToolContext const&) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x3a47)
#20 0x00007ff69404a30d void std::__1::vector<std::__1::optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, std::__1::allocator<std::__1::optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>>::__assign_with_size[abi:nn190106]<std::__1::optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>*, std::__1::optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>*>(std::__1::optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>*, std::__1::optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>*, long long) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0xf4a30d)
#21 0x00007ff69346f918 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x36f918)
#22 0x00007ff694049b42 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__1::optional<llvm::StringRef>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, bool*) const (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0xf49b42)
#23 0x00007ff693547690 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x447690)
#24 0x00007ff6935478ac clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*>>&, bool) const (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x4478ac)
#25 0x00007ff6935627c9 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*>>&) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x4627c9)
#26 0x00007ff693102f91 clang_main(int, char**, llvm::ToolContext const&) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x2f91)
#27 0x00007ff693110d3f main (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x10d3f)
#28 0x00007ff69310133c WinMainCRTStartup (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x133c)
#29 0x00007ff693101396 mainCRTStartup (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x1396)
#30 0x00007ffcb3497374 (C:\Windows\System32\KERNEL32.DLL+0x17374)
#31 0x00007ffcb3d9cc91 (C:\Windows\SYSTEM32\ntdll.dll+0x4cc91)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 20.0.0git
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: C:/msys64/clang64/opt/emscripten-llvm/bin
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: C:/msys64/tmp/test1-2650d9.c
clang: note: diagnostic msg: C:/msys64/tmp/test1-2650d9.sh
clang: note: diagnostic msg: 

********************
$ cat test2.c
int z = 2;
$ emcc -c test2.c -v
 "C:/msys64/clang64/opt/emscripten-llvm/bin/clang.exe" -target wasm32-unknown-emscripten -fignore-exceptions -mno-bulk-memory -mno-bulk-memory-opt -mno-nontrapping-fptoint -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --sysroot=C:/msys64/clang64/lib/emscripten/cache/sysroot -DEMSCRIPTEN -Werror=implicit-function-declaration -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -c -v test2.c
clang version 20.0.0git
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: C:/msys64/clang64/opt/emscripten-llvm/bin
 (in-process)
 "C:/msys64/clang64/opt/emscripten-llvm/bin/clang.exe" -cc1 -triple wasm32-unknown-emscripten -emit-obj -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name test2.c -mrelocation-model static -mframe-pointer=none -ffp-contract=on -fno-rounding-math -mconstructor-aliases -target-cpu generic -target-feature -bulk-memory -target-feature -bulk-memory-opt -target-feature -nontrapping-fptoint -fvisibility=hidden -debugger-tuning=gdb -fdebug-compilation-dir=D:/Projetos/raytracing -v -fcoverage-compilation-dir=D:/Projetos/raytracing -resource-dir C:/msys64/clang64/opt/emscripten-llvm/lib/clang/20 -D EMSCRIPTEN -isysroot C:/msys64/clang64/lib/emscripten/cache/sysroot -internal-isystem C:/msys64/clang64/opt/emscripten-llvm/lib/clang/20/include -internal-isystem C:/msys64/clang64/lib/emscripten/cache/sysroot/include/wasm32-emscripten -internal-isystem C:/msys64/clang64/lib/emscripten/cache/sysroot/include -Werror=implicit-function-declaration -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fignore-exceptions -iwithsysroot/include/fakesdl -iwithsysroot/include/compat -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -o test2.o -x c test2.c
clang -cc1 version 20.0.0git based upon LLVM 20.0.0git default target x86_64-w64-windows-gnu
ignoring nonexistent directory "C:/msys64/clang64/lib/emscripten/cache/sysroot/include/wasm32-emscripten"
#include "..." search starts here:
#include <...> search starts here:
 C:/msys64/clang64/lib/emscripten/cache/sysroot/include/fakesdl
 C:/msys64/clang64/lib/emscripten/cache/sysroot/include/compat
 C:/msys64/clang64/opt/emscripten-llvm/lib/clang/20/include
 C:/msys64/clang64/lib/emscripten/cache/sysroot/include
End of search list.
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: C:/msys64/clang64/opt/emscripten-llvm/bin/clang.exe -target wasm32-unknown-emscripten -fignore-exceptions -mno-bulk-memory -mno-bulk-memory-opt -mno-nontrapping-fptoint -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --sysroot=C:/msys64/clang64/lib/emscripten/cache/sysroot -DEMSCRIPTEN -Werror=implicit-function-declaration -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -c -v test2.c
1.	test2.c:1:7: current parser token '='
Exception Code: 0x80000003
 #0 0x00007ff693fc0a18 clang::ASTContext::DecodeTypeStr(char const*&, clang::ASTContext const&, clang::ASTContext::GetBuiltinTypeError&, bool&, bool) const (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0xec0a18)
 #1 0x00007ff693fc0abd clang::ASTContext::GetBuiltinType(unsigned int, clang::ASTContext::GetBuiltinTypeError&, unsigned int*) const (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0xec0abd)
 #2 0x00007ff695300bff clang::Sema::LazilyCreateBuiltin(clang::IdentifierInfo*, unsigned int, clang::Scope*, bool, clang::SourceLocation) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x2200bff)
 #3 0x00007ff69562e9cb clang::Sema::LookupBuiltin(clang::LookupResult&) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x252e9cb)
 #4 0x00007ff69563bdfb clang::Sema::LookupName(clang::LookupResult&, clang::Scope*, bool, bool) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x253bdfb)
 #5 0x00007ff695314a14 clang::Sema::HandleDeclarator(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x2214a14)
 #6 0x00007ff69531415f clang::Sema::ActOnDeclarator(clang::Scope*, clang::Declarator&) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x221415f)
 #7 0x00007ff6973ad852 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x42ad852)
 #8 0x00007ff6973aba76 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x42aba76)
 #9 0x00007ff696d3a301 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x3c3a301)
#10 0x00007ff696d39c30 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x3c39c30)
#11 0x00007ff696d38d3e clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x3c38d3e)
#12 0x00007ff696d36e7a clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x3c36e7a)
#13 0x00007ff696d36881 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x3c36881)
#14 0x00007ff695a0c39c clang::ParseAST(clang::Sema&, bool, bool) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x290c39c)
#15 0x00007ff6942d5418 clang::FrontendAction::Execute() (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x11d5418)
#16 0x00007ff693595ad4 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x495ad4)
#17 0x00007ff693621876 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x521876)
#18 0x00007ff69310676a cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x676a)
#19 0x00007ff693103a47 clang_main(int, char**, llvm::ToolContext const&) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x3a47)
#20 0x00007ff69404a30d void std::__1::vector<std::__1::optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, std::__1::allocator<std::__1::optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>>::__assign_with_size[abi:nn190106]<std::__1::optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>*, std::__1::optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>*>(std::__1::optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>*, std::__1::optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>*, long long) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0xf4a30d)
#21 0x00007ff69346f918 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x36f918)
#22 0x00007ff694049b42 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__1::optional<llvm::StringRef>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, bool*) const (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0xf49b42)
#23 0x00007ff693547690 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x447690)
#24 0x00007ff6935478ac clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*>>&, bool) const (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x4478ac)
#25 0x00007ff6935627c9 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*>>&) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x4627c9)
#26 0x00007ff693102f91 clang_main(int, char**, llvm::ToolContext const&) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x2f91)
#27 0x00007ff693110d3f main (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x10d3f)
#28 0x00007ff69310133c WinMainCRTStartup (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x133c)
#29 0x00007ff693101396 mainCRTStartup (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x1396)
#30 0x00007ffcb3497374 (C:\Windows\System32\KERNEL32.DLL+0x17374)
#31 0x00007ffcb3d9cc91 (C:\Windows\SYSTEM32\ntdll.dll+0x4cc91)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 20.0.0git
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: C:/msys64/clang64/opt/emscripten-llvm/bin
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: C:/msys64/tmp/test2-4a3495.c
clang: note: diagnostic msg: C:/msys64/tmp/test2-4a3495.sh
clang: note: diagnostic msg: 

********************
$ cat test3.c
int z(int);
$ emcc -c test3.c -v
 "C:/msys64/clang64/opt/emscripten-llvm/bin/clang.exe" -target wasm32-unknown-emscripten -fignore-exceptions -mno-bulk-memory -mno-bulk-memory-opt -mno-nontrapping-fptoint -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --sysroot=C:/msys64/clang64/lib/emscripten/cache/sysroot -DEMSCRIPTEN -Werror=implicit-function-declaration -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -c -v test3.c
clang version 20.0.0git
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: C:/msys64/clang64/opt/emscripten-llvm/bin
 (in-process)
 "C:/msys64/clang64/opt/emscripten-llvm/bin/clang.exe" -cc1 -triple wasm32-unknown-emscripten -emit-obj -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name test3.c -mrelocation-model static -mframe-pointer=none -ffp-contract=on -fno-rounding-math -mconstructor-aliases -target-cpu generic -target-feature -bulk-memory -target-feature -bulk-memory-opt -target-feature -nontrapping-fptoint -fvisibility=hidden -debugger-tuning=gdb -fdebug-compilation-dir=D:/Projetos/raytracing -v -fcoverage-compilation-dir=D:/Projetos/raytracing -resource-dir C:/msys64/clang64/opt/emscripten-llvm/lib/clang/20 -D EMSCRIPTEN -isysroot C:/msys64/clang64/lib/emscripten/cache/sysroot -internal-isystem C:/msys64/clang64/opt/emscripten-llvm/lib/clang/20/include -internal-isystem C:/msys64/clang64/lib/emscripten/cache/sysroot/include/wasm32-emscripten -internal-isystem C:/msys64/clang64/lib/emscripten/cache/sysroot/include -Werror=implicit-function-declaration -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fignore-exceptions -iwithsysroot/include/fakesdl -iwithsysroot/include/compat -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -o test3.o -x c test3.c
clang -cc1 version 20.0.0git based upon LLVM 20.0.0git default target x86_64-w64-windows-gnu
ignoring nonexistent directory "C:/msys64/clang64/lib/emscripten/cache/sysroot/include/wasm32-emscripten"
#include "..." search starts here:
#include <...> search starts here:
 C:/msys64/clang64/lib/emscripten/cache/sysroot/include/fakesdl
 C:/msys64/clang64/lib/emscripten/cache/sysroot/include/compat
 C:/msys64/clang64/opt/emscripten-llvm/lib/clang/20/include
 C:/msys64/clang64/lib/emscripten/cache/sysroot/include
End of search list.
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: C:/msys64/clang64/opt/emscripten-llvm/bin/clang.exe -target wasm32-unknown-emscripten -fignore-exceptions -mno-bulk-memory -mno-bulk-memory-opt -mno-nontrapping-fptoint -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --sysroot=C:/msys64/clang64/lib/emscripten/cache/sysroot -DEMSCRIPTEN -Werror=implicit-function-declaration -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -c -v test3.c
1.	test3.c:1:11: current parser token ';'
Exception Code: 0x80000003
 #0 0x00007ff693fc0a18 clang::ASTContext::DecodeTypeStr(char const*&, clang::ASTContext const&, clang::ASTContext::GetBuiltinTypeError&, bool&, bool) const (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0xec0a18)
 #1 0x00007ff693fc0abd clang::ASTContext::GetBuiltinType(unsigned int, clang::ASTContext::GetBuiltinTypeError&, unsigned int*) const (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0xec0abd)
 #2 0x00007ff695300bff clang::Sema::LazilyCreateBuiltin(clang::IdentifierInfo*, unsigned int, clang::Scope*, bool, clang::SourceLocation) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x2200bff)
 #3 0x00007ff69562e9cb clang::Sema::LookupBuiltin(clang::LookupResult&) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x252e9cb)
 #4 0x00007ff69563bdfb clang::Sema::LookupName(clang::LookupResult&, clang::Scope*, bool, bool) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x253bdfb)
 #5 0x00007ff695314a14 clang::Sema::HandleDeclarator(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x2214a14)
 #6 0x00007ff69531415f clang::Sema::ActOnDeclarator(clang::Scope*, clang::Declarator&) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x221415f)
 #7 0x00007ff6973ad852 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x42ad852)
 #8 0x00007ff6973aba76 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x42aba76)
 #9 0x00007ff696d3a301 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x3c3a301)
#10 0x00007ff696d39c30 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x3c39c30)
#11 0x00007ff696d38d3e clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x3c38d3e)
#12 0x00007ff696d36e7a clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x3c36e7a)
#13 0x00007ff696d36881 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x3c36881)
#14 0x00007ff695a0c39c clang::ParseAST(clang::Sema&, bool, bool) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x290c39c)
#15 0x00007ff6942d5418 clang::FrontendAction::Execute() (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x11d5418)
#16 0x00007ff693595ad4 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x495ad4)
#17 0x00007ff693621876 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x521876)
#18 0x00007ff69310676a cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x676a)
#19 0x00007ff693103a47 clang_main(int, char**, llvm::ToolContext const&) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x3a47)
#20 0x00007ff69404a30d void std::__1::vector<std::__1::optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, std::__1::allocator<std::__1::optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>>::__assign_with_size[abi:nn190106]<std::__1::optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>*, std::__1::optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>*>(std::__1::optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>*, std::__1::optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>*, long long) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0xf4a30d)
#21 0x00007ff69346f918 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x36f918)
#22 0x00007ff694049b42 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__1::optional<llvm::StringRef>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, bool*) const (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0xf49b42)
#23 0x00007ff693547690 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x447690)
#24 0x00007ff6935478ac clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*>>&, bool) const (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x4478ac)
#25 0x00007ff6935627c9 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*>>&) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x4627c9)
#26 0x00007ff693102f91 clang_main(int, char**, llvm::ToolContext const&) (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x2f91)
#27 0x00007ff693110d3f main (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x10d3f)
#28 0x00007ff69310133c WinMainCRTStartup (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x133c)
#29 0x00007ff693101396 mainCRTStartup (C:\msys64\clang64\opt\emscripten-llvm\bin\clang.exe+0x1396)
#30 0x00007ffcb3497374 (C:\Windows\System32\KERNEL32.DLL+0x17374)
#31 0x00007ffcb3d9cc91 (C:\Windows\SYSTEM32\ntdll.dll+0x4cc91)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 20.0.0git
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: C:/msys64/clang64/opt/emscripten-llvm/bin
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: C:/msys64/tmp/test3-427fb9.c
clang: note: diagnostic msg: C:/msys64/tmp/test3-427fb9.sh
clang: note: diagnostic msg: 

********************
@sbc100
Copy link
Collaborator

sbc100 commented Jan 13, 2025

Something strange must be going on with your test program.

$ cat test.c 
int z = 2;
$ ./emcc -c test.c 

What happens if you try to compile that same file with gcc or clang on your host system?

Perhaps it has some kind of unicode or hidden characters in there? Can you attach the source file to this bug?

@bottle2
Copy link
Author

bottle2 commented Jan 13, 2025

it is just the ASCII lowercase letter z, typed using my keyboard. no tricks whatsoever. both gcc and clang work fine.

further evidence:

$ file test{1,2,3}.c
test1.c: ASCII text
test2.c: ASCII text
test3.c: ASCII text

I'm using Emscripten packaged for MSYS2:

$ pacman -Qi mingw-w64-clang-x86_64-emscripten
Name            : mingw-w64-clang-x86_64-emscripten
Version         : 3.1.74-1
Description     : Compile C and C++ into highly-optimizable JavaScript for the web (mingw-w64)
Architecture    : any
URL             : https://emscripten.org
Licenses        : custom
Groups          : None
Provides        : mingw-w64-clang-x86_64-binaryen
Depends On      : mingw-w64-clang-x86_64-gcc-libs  mingw-w64-clang-x86_64-nodejs  mingw-w64-clang-x86_64-python  mingw-w64-clang-x86_64-zlib  mingw-w64-clang-x86_64-zstd
Optional Deps   : mingw-w64-clang-x86_64-ruby: for using websockify addon
                  mingw-w64-clang-x86_64-cmake: for emcc --show-ports
Required By     : None
Optional For    : None
Conflicts With  : mingw-w64-clang-x86_64-binaryen
Replaces        : None
Installed Size  : 1133.40 MiB
Packager        : CI (msys2/msys2-autobuild/35ff0b71/12477838395)
Build Date      : Tue Dec 24 03:57:31 2024
Install Date    : Wed Dec 25 17:41:02 2024
Install Reason  : Explicitly installed
Install Script  : Yes
Validated By    : SHA-256 Sum  Signature

@sbc100
Copy link
Collaborator

sbc100 commented Jan 13, 2025

Sounds like maybe come issue with the llvm build that MSYS2 is shipping.

What happens if you do C:/msys64/clang64/opt/emscripten-llvm/bin/clang.exe -c test.c on its own? Presumably that same failure? If that crashes then its likely an issue with that package and we should file a bug with mingw-w64-clang-x86_64-emscripten I guess?

@bottle2
Copy link
Author

bottle2 commented Jan 13, 2025

error is still reproduced using this clang. I will shortly try different _llvm_project_revision used here to try to reproduce the error in other versions: https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-emscripten/PKGBUILD
then report to MSYS2 if so.

@zygoloid
Copy link

I wonder if this is related to llvm/llvm-project#118734 -- a bug in MS' compiler and/or linker resulted in the builtins table getting miscompiled. I think we had thought this only affected MSVC, not MinGW, but it might fit the symptoms.

@bottle2
Copy link
Author

bottle2 commented Jan 14, 2025

I downgraded my MSYS2 package from version 3.1.74 to version 3.1.72 and the problem no longer occurs.

version 3.1.72 fetches commit 1c4caece05f1885ba6ed80755d6b5de1b9f99579 from llvm-project
version 3.1.74 fetches commit 322eb1a92e6d4266184060346616fa0dbe39e731 from llvm-project

I'm in the mood to do some git bisecting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants