Open stevapple opened 2 years ago
can you try with -fno-split-cold-code
as mentioned in https://github.com/bazelbuild/rules_swift/pull/831/files if that fixes it? Do you have instructions to build llbuildSwift which I can try to repro this?
@hiraditya, -fno-split-cold-code
does workaround the issue. You can likely follow the build here:
https://github.com/compnerd/swift-build/blob/main/.github/workflows/swift-toolchain.yml#L1274-L1296
Disabling the bindings should allow you to build without the Swift compiler.
Is it possible to get the preprocessed(.ii) file for the file producing crash, e.g., Nina-C-API.cpp . I don't have windows machine or the toolchain but with preprocessed file the crash should be reproducible on linux machine (with right compiler flags).
Function has token parameter but isn't an intrinsic
call void @"?AddIncludeFile@SourceMgr@llvm@@QEAAIAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@VSMLoc@2@AEAV34@@Z.cold.1"(ptr %NewBufOrErr, token %51) #33, !dbg !8335
in function ?AddIncludeFile@SourceMgr@llvm@@QEAAIAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@VSMLoc@2@AEAV34@@Z
fatal error: error in backend: Broken function found, compilation aborted!
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: S:\\Library\\Developer\\Toolchains\\unknown-Asserts-development.xctoolchain\\usr\\bin\\clang.exe -target x86_64-unknown-windows-msvc -g -gcodeview -O2 -DSWIFT_PACKAGE=1 -fblocks -I S:\\SourceCache\\swift-project\\llbuild\\lib\\llvm\\Support\\include -I S:\\SourceCache\\swift-project\\llbuild\\lib\\llvm\\Demangle\\include -fmodule-map-file=S:\\SourceCache\\swift-project\\llbuild\\.build\\x86_64-unknown-windows-msvc\\release\\llvmDemangle.build\\module.modulemap -DLLVM_ON_WIN32 -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_MT -D_DLL -Xclang --dependent-lib=msvcrt -IS:\\Library\\sqlite-3.36.0\\usr\\include -MD -MT dependencies -MF S:\\SourceCache\\swift-project\\llbuild\\.build\\x86_64-unknown-windows-msvc\\release\\llvmSupport.build\\SourceMgr.cpp.d -std=c++14 -c S:\\SourceCache\\swift-project\\llbuild\\lib\\llvm\\Support\\SourceMgr.cpp -o S:\\SourceCache\\swift-project\\llbuild\\.build\\x86_64-unknown-windows-msvc\\release\\llvmSupport.build\\SourceMgr.cpp.o
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module 'S:\SourceCache\swift-project\llbuild\lib\llvm\Support\SourceMgr.cpp'.
4. Running pass 'Module Verifier' on function '@"?AddIncludeFile@SourceMgr@llvm@@QEAAIAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@VSMLoc@2@AEAV34@@Z"'
Exception Code: 0xE0000046
#0 0x00007ffcef7bfe7c (C:\Windows\System32\KERNELBASE.dll+0x8fe7c)
#1 0x00007ff6dd64c00a llvm::CrashRecoveryContext::HandleExit(int) S:\SourceCache\swift-project\llvm-project\llvm\lib\Support\CrashRecoveryContext.cpp:450:0
#2 0x00007ff6dd64fcf3 llvm::sys::Process::Exit(int, bool) S:\SourceCache\swift-project\llvm-project\llvm\lib\Support\Process.cpp:97:0
#3 0x00007ff6dbfc2d70 LLVMErrorHandler S:\SourceCache\swift-project\llvm-project\clang\tools\driver\cc1_main.cpp:96:0
#4 0x00007ff6dd620cd6 std::basic_string<char,std::char_traits<char>,std::allocator<char> >::{dtor} C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.35.32215\include\xstring:3270:0
#5 0x00007ff6dd620cd6 llvm::report_fatal_error(class llvm::Twine const &, bool) S:\SourceCache\swift-project\llvm-project\llvm\lib\Support\ErrorHandling.cpp:104:0
#6 0x00007ff6dd620e71 llvm::report_fatal_error(char const *, bool) S:\SourceCache\swift-project\llvm-project\llvm\lib\Support\ErrorHandling.cpp:83:0
#7 0x00007ff6dd0d9c60 `anonymous namespace'::VerifierLegacyPass::runOnFunction S:\SourceCache\swift-project\llvm-project\llvm\lib\IR\Verifier.cpp:6411:0
#8 0x00007ff6dcfc9319 llvm::FPPassManager::runOnFunction(class llvm::Function &) S:\SourceCache\swift-project\llvm-project\llvm\lib\IR\LegacyPassManager.cpp:1430:0
#9 0x00007ff6dcfc9570 llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Function,1,0,void>,0,0>::operator++ S:\SourceCache\swift-project\llvm-project\llvm\include\llvm\ADT\ilist_iterator.h:157:0
#10 0x00007ff6dcfc9570 llvm::FPPassManager::runOnModule(class llvm::Module &) S:\SourceCache\swift-project\llvm-project\llvm\lib\IR\LegacyPassManager.cpp:1475:0
#11 0x00007ff6dcfc9827 `anonymous namespace'::MPPassManager::runOnModule S:\SourceCache\swift-project\llvm-project\llvm\lib\IR\LegacyPassManager.cpp:1545:0
#12 0x00007ff6dcfc8fd7 llvm::legacy::PassManager::run(class llvm::Module &) S:\SourceCache\swift-project\llvm-project\llvm\lib\IR\LegacyPassManager.cpp:1672:0
#13 0x00007ff6dda37e15 `anonymous namespace'::EmitAssemblyHelper::RunCodegenPipeline S:\SourceCache\swift-project\llvm-project\clang\lib\CodeGen\BackendUtil.cpp:1071:0
#14 0x00007ff6dda36f16 std::unique_ptr<llvm::ToolOutputFile,std::default_delete<llvm::ToolOutputFile> >::operator bool C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.35.32215\include\memory:3202:0
#15 0x00007ff6dda36f16 `anonymous namespace'::EmitAssemblyHelper::EmitAssembly S:\SourceCache\swift-project\llvm-project\clang\lib\CodeGen\BackendUtil.cpp:1094:0
#16 0x00007ff6dda37821 std::unique_ptr<llvm::TargetMachine,std::default_delete<llvm::TargetMachine> >::operator bool C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.35.32215\include\memory:3202:0
#17 0x00007ff6dda37821 clang::EmitBackendOutput(class clang::DiagnosticsEngine &, class clang::HeaderSearchOptions const &, class clang::CodeGenOptions const &, class clang::TargetOptions const &, class clang::LangOptions const &, class llvm::StringRef, class llvm::Module *, enum clang::BackendAction, class llvm::IntrusiveRefCntPtr<class llvm::vfs::FileSystem>, class std::unique_ptr<class llvm::raw_pwrite_stream, struct std::default_delete<class llvm::raw_pwrite_stream>>) S:\SourceCache\swift-project\llvm-project\clang\lib\CodeGen\BackendUtil.cpp:1254:0
#18 0x00007ff6e03c4ac8 clang::BackendConsumer::HandleTranslationUnit(class clang::ASTContext &) S:\SourceCache\swift-project\llvm-project\clang\lib\CodeGen\CodeGenAction.cpp:386:0
#19 0x00007ff6def4b097 clang::finalize S:\SourceCache\swift-project\llvm-project\clang\include\clang\Sema\TemplateInstCallback.h:54:0
#20 0x00007ff6def4b097 clang::ParseAST(class clang::Sema &, bool, bool) S:\SourceCache\swift-project\llvm-project\clang\lib\Parse\ParseAST.cpp:203:0
#21 0x00007ff6de134ab0 clang::ASTFrontendAction::ExecuteAction(void) S:\SourceCache\swift-project\llvm-project\clang\lib\Frontend\FrontendAction.cpp:1218:0
#22 0x00007ff6e03c352b clang::CodeGenAction::ExecuteAction(void) S:\SourceCache\swift-project\llvm-project\clang\lib\CodeGen\CodeGenAction.cpp:1221:0
#23 0x00007ff6de13489e clang::FrontendAction::Execute(void) S:\SourceCache\swift-project\llvm-project\clang\lib\Frontend\FrontendAction.cpp:1115:0
#24 0x00007ff6de0f7553 llvm::Error::getPtr S:\SourceCache\swift-project\llvm-project\llvm\include\llvm\Support\Error.h:270:0
#25 0x00007ff6de0f7553 llvm::Error::operator bool S:\SourceCache\swift-project\llvm-project\llvm\include\llvm\Support\Error.h:234:0
#26 0x00007ff6de0f7553 clang::CompilerInstance::ExecuteAction(class clang::FrontendAction &) S:\SourceCache\swift-project\llvm-project\clang\lib\Frontend\CompilerInstance.cpp:1070:0
#27 0x00007ff6de1b0fab clang::ExecuteCompilerInvocation(class clang::CompilerInstance *) S:\SourceCache\swift-project\llvm-project\clang\lib\FrontendTool\ExecuteCompilerInvocation.cpp:273:0
#28 0x00007ff6dbfc40f2 cc1_main(class llvm::ArrayRef<char const *>, char const *, void *) S:\SourceCache\swift-project\llvm-project\clang\tools\driver\cc1_main.cpp:1248:0
#29 0x00007ff6dbfabc1a ExecuteCC1Tool S:\SourceCache\swift-project\llvm-project\clang\tools\driver\driver.cpp:370:0
#30 0x00007ff6ddffe1fa clang::driver::CC1Command::Execute::__l7::<lambda_1>::operator() S:\SourceCache\swift-project\llvm-project\clang\lib\Driver\Job.cpp:465:0
#31 0x00007ff6ddffe1fa llvm::function_ref<void __cdecl(void)>::callback_fn<`clang::driver::CC1Command::Execute'::`7'::<lambda_1> > S:\SourceCache\swift-project\llvm-project\llvm\include\llvm\ADT\STLFunctionalExtras.h:45:0
#32 0x00007ff6dd64c0df llvm::CrashRecoveryContext::RunSafely(class llvm::function_ref<(void)>) S:\SourceCache\swift-project\llvm-project\llvm\lib\Support\CrashRecoveryContext.cpp:242:0
#33 0x00007ff6ddffe818 clang::driver::CC1Command::Execute(class llvm::ArrayRef<class llvm::Optional<class llvm::StringRef>>, class std::basic_string<char, struct std::char_traits<char>, class std::allocator<char>> *, bool *) const S:\SourceCache\swift-project\llvm-project\clang\lib\Driver\Job.cpp:465:0
#34 0x00007ff6ddf769c5 std::_Func_class<void,clang::driver::Command const &,int>::_Empty C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.35.32215\include\functional:888:0
#35 0x00007ff6ddf769c5 std::function<void __cdecl(clang::driver::Command const &,int)>::operator bool C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.35.32215\include\functional:1118:0
#36 0x00007ff6ddf769c5 clang::driver::Compilation::ExecuteCommand(class clang::driver::Command const &, class clang::driver::Command const *&, bool) const S:\SourceCache\swift-project\llvm-project\clang\lib\Driver\Compilation.cpp:201:0
#37 0x00007ff6ddf76b70 clang::driver::Compilation::ExecuteJobs(class clang::driver::JobList const &, class llvm::SmallVectorImpl<struct std::pair<int, class clang::driver::Command const *>> &, bool) const S:\SourceCache\swift-project\llvm-project\clang\lib\Driver\Compilation.cpp:254:0
#38 0x00007ff6ddf5c2d0 llvm::SmallVectorBase<unsigned int>::empty S:\SourceCache\swift-project\llvm-project\llvm\include\llvm\ADT\SmallVector.h:94:0
#39 0x00007ff6ddf5c2d0 clang::driver::Driver::ExecuteCompilation(class clang::driver::Compilation &, class llvm::SmallVectorImpl<struct std::pair<int, class clang::driver::Command const *>> &) S:\SourceCache\swift-project\llvm-project\clang\lib\Driver\Driver.cpp:1825:0
#40 0x00007ff6dbfaeab9 clang_main(int, char **) S:\SourceCache\swift-project\llvm-project\clang\tools\driver\driver.cpp:550:0
#41 0x00007ff6dffe6194 invoke_main D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78:0
#42 0x00007ff6dffe6194 __scrt_common_main_seh D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288:0
#43 0x00007ffcf01a26bd (C:\Windows\System32\KERNEL32.DLL+0x126bd)
#44 0x00007ffcf234a9f8 (C:\Windows\SYSTEM32\ntdll.dll+0x5a9f8)
It is a different function and file, but the issue should be the same. Thanks for looking into this @hiraditya!
i'm unable to repro with the script and pre-processed file on Linux machine. I am using latest clang on x64 Ubuntu machine. Do we know the SHA of the compiler? or if I can download the compiler (for Windows) that's also fine, as I got hold of a Windows machine.
It will produce "Function has token parameter but isn't an intrinsic" error on nearly every file, which may be related to llvm/llvm-project#40056
Although it's most probably a
clang
bug, we can see if it's workaround-able, so it won't block us for building "release" Swift tools with SwiftPM.