[clang] [llvm] [mlir] [support] Use VFS in `SourceMgr` for loading includes (PR #162903)
Nathan Chancellor via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 16 12:48:56 PDT 2025
nathanchance wrote:
This change breaks using `.incbin` with `-flto=thin`, which is used by the Linux kernel in a couple of places.
```
$ cat test.c
asm(" .incbin \"foo.i\" \n");
$ touch foo.i
$ clang --target=aarch64-linux-gnu -c -o /dev/null test.c
$ clang --target=aarch64-linux-gnu -flto=thin -c -o /dev/null test.c
fatal error: error in backend: Opening include file from SourceMgr without VFS
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: clang --target=aarch64-linux-gnu -flto=thin -c -o /dev/null test.c
1. <eof> parser at end of file
2. Optimizer
3. Running pass "ThinLTOBitcodeWriterPass" on module "test.c"
#0 0x000055d8362f5728 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (clang-22+0x5d86728)
#1 0x000055d8362f2ea5 llvm::sys::RunSignalHandlers() (clang-22+0x5d83ea5)
#2 0x000055d836274b47 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) CrashRecoveryContext.cpp:0:0
#3 0x000055d836274adf llvm::CrashRecoveryContext::HandleExit(int) (clang-22+0x5d05adf)
#4 0x000055d8362ef967 llvm::sys::Process::Exit(int, bool) (clang-22+0x5d80967)
#5 0x000055d8341b6956 (clang-22+0x3c47956)
#6 0x000055d83627afb6 llvm::report_fatal_error(llvm::Twine const&, bool) (clang-22+0x5d0bfb6)
#7 0x000055d83627aea6 (clang-22+0x5d0bea6)
#8 0x000055d83627b14b (clang-22+0x5d0c14b)
#9 0x000055d83629b193 llvm::SourceMgr::OpenIncludeFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&) (clang-22+0x5d2c193)
#10 0x000055d83629acbd llvm::SourceMgr::AddIncludeFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, llvm::SMLoc, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&) (clang-22+0x5d2bcbd)
#11 0x000055d8360c0642 (anonymous namespace)::AsmParser::parseDirectiveIncbin() AsmParser.cpp:0:0
#12 0x000055d8360bd1cc (anonymous namespace)::AsmParser::parseStatement((anonymous namespace)::ParseStatementInfo&, llvm::MCAsmParserSemaCallback*) AsmParser.cpp:0:0
#13 0x000055d8360b5af1 (anonymous namespace)::AsmParser::Run(bool, bool) AsmParser.cpp:0:0
#14 0x000055d83946bdcc initializeRecordStreamer(llvm::Module const&, llvm::function_ref<void (llvm::RecordStreamer&)>) ModuleSymbolTable.cpp:0:0
#15 0x000055d83946b935 llvm::ModuleSymbolTable::CollectAsmSymbols(llvm::Module const&, llvm::function_ref<void (llvm::StringRef, llvm::object::BasicSymbolRef::Flags)>) (clang-22+0x8efc935)
#16 0x000055d83560340c llvm::buildModuleSummaryIndex(llvm::Module const&, std::function<llvm::BlockFrequencyInfo* (llvm::Function const&)>, llvm::ProfileSummaryInfo*, std::function<llvm::StackSafetyInfo const* (llvm::Function const&)>) (clang-22+0x509440c)
#17 0x000055d83560b3a4 llvm::ModuleSummaryIndexAnalysis::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (clang-22+0x509c3a4)
#18 0x000055d83734c032 llvm::detail::AnalysisPassModel<llvm::Module, llvm::ModuleSummaryIndexAnalysis, llvm::AnalysisManager<llvm::Module>::Invalidator>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) PassBuilder.cpp:0:0
#19 0x000055d835e23f8f llvm::AnalysisManager<llvm::Module>::getResultImpl(llvm::AnalysisKey*, llvm::Module&) (clang-22+0x58b4f8f)
#20 0x000055d836b64eee llvm::ThinLTOBitcodeWriterPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (clang-22+0x65f5eee)
#21 0x000055d835e224e7 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (clang-22+0x58b34e7)
#22 0x000055d836a62129 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0
#23 0x000055d836a57f4c clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (clang-22+0x64e8f4c)
#24 0x000055d836a6d8e8 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (clang-22+0x64fe8e8)
#25 0x000055d83808ea59 clang::ParseAST(clang::Sema&, bool, bool) (clang-22+0x7b1fa59)
#26 0x000055d836f66006 clang::FrontendAction::Execute() (clang-22+0x69f7006)
#27 0x000055d836ececdd clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (clang-22+0x695fcdd)
#28 0x000055d83703db65 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (clang-22+0x6aceb65)
#29 0x000055d8341b6297 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (clang-22+0x3c47297)
#30 0x000055d8341b2015 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#31 0x000055d8341b45ed int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::$_0>(long, llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#32 0x000055d836d34009 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::$_0>(long) Job.cpp:0:0
#33 0x000055d836274a7e llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (clang-22+0x5d05a7e)
#34 0x000055d836d33843 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (clang-22+0x67c4843)
#35 0x000055d836cf537c clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (clang-22+0x678637c)
#36 0x000055d836cf5597 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (clang-22+0x6786597)
#37 0x000055d836d0eda8 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (clang-22+0x679fda8)
#38 0x000055d8341b1860 clang_main(int, char**, llvm::ToolContext const&) (clang-22+0x3c42860)
#39 0x000055d8341c1b67 main (clang-22+0x3c52b67)
#40 0x00007fa50f227635 (/usr/lib/libc.so.6+0x27635)
#41 0x00007fa50f2276e9 __libc_start_main (/usr/lib/libc.so.6+0x276e9)
#42 0x000055d8341afa25 _start (clang-22+0x3c40a25)
clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
ClangBuiltLinux clang version 22.0.0git (https://github.com/llvm/llvm-project.git 9deba01c1d5db607da5b943bd5a6185384608605)
...
```
```
# bad: [7fe069121b57a187e2072f01ecc84523948d9f04] [Headers][X86] Allow AVX512 masked shuffles to be used in constexpr (#162301)
# good: [9a46060aedc6bde26e939999de36442a23c07783] [mlir][linalg] Fix crash caused by nullptr dereference (#163132)
git bisect start '7fe069121b57a187e2072f01ecc84523948d9f04' '9a46060aedc6bde26e939999de36442a23c07783'
# bad: [3e251e727f6a214d11272c58db50b56544ee023d] [lldb] Correct bridgeOS -> BridgeOS spelling (#163479)
git bisect bad 3e251e727f6a214d11272c58db50b56544ee023d
# good: [b54709e9f68a6687eece0585e46f12e5fa218520] [NFC][MLIR][TableGen] Adopt NamespaceEmitter more widely (#163289)
git bisect good b54709e9f68a6687eece0585e46f12e5fa218520
# bad: [d60d0381b41ee814c270ccee0e764b84096f8171] [MLIR][Conversion] XeGPU to XeVM: Remove unused type converter source materializations. (#162947)
git bisect bad d60d0381b41ee814c270ccee0e764b84096f8171
# good: [cf1cdde24e76a4ff5bbda2128800ba3ca4132b6d] [llvm][DebugInfo] Add 'sourceLanguageVersion' field support to DICompileUnit (#162632)
git bisect good cf1cdde24e76a4ff5bbda2128800ba3ca4132b6d
# good: [c89d721165da0c50a810c3f72bf000925e756e4b] [lldb-dap] Remove timings from TestDAP_attach (#163452)
git bisect good c89d721165da0c50a810c3f72bf000925e756e4b
# bad: [f49e3d178b8b8ab3ad6a87f999b42a5a76353c2e] Repair test for WG14 N3364 (#163551)
git bisect bad f49e3d178b8b8ab3ad6a87f999b42a5a76353c2e
# bad: [9deba01c1d5db607da5b943bd5a6185384608605] [support] Use VFS in `SourceMgr` for loading includes (#162903)
git bisect bad 9deba01c1d5db607da5b943bd5a6185384608605
# good: [097f1e7625966673b881df63a241f755317b0bb9] [lldb] Do not stop the process on SIGWINCH by default. (#163182)
git bisect good 097f1e7625966673b881df63a241f755317b0bb9
# first bad commit: [9deba01c1d5db607da5b943bd5a6185384608605] [support] Use VFS in `SourceMgr` for loading includes (#162903)
```
https://github.com/llvm/llvm-project/pull/162903
More information about the cfe-commits
mailing list