Index: lld/ELF/Driver.cpp =================================================================== --- lld/ELF/Driver.cpp +++ lld/ELF/Driver.cpp @@ -1264,10 +1264,18 @@ for (auto *Arg : Args.filtered(OPT_wrap)) Symtab->addSymbolWrap(Arg->getValue()); + // Do link-time optimization if given files are LLVM bitcode + // files. This compiles bitcode files into real object files. Symtab->addCombinedLTOObject(); if (errorCount()) return; + // If -thinlto-index-only is given, we should create only "index + // files" and not object files. Index file creation is already done + // in addCombinedLTOObject, so we are done if that's the case. + if (Config->ThinLTOIndexOnly) + return; + // Apply symbol renames for -wrap. Symtab->applySymbolWrap(); Index: lld/ELF/LTO.cpp =================================================================== --- lld/ELF/LTO.cpp +++ lld/ELF/LTO.cpp @@ -301,7 +301,7 @@ // files. After that, we exit from linker and ThinLTO backend runs in a // distributed environment. if (Config->ThinLTOIndexOnly) - exit(0); + return {}; for (std::unique_ptr &File : Files) if (File)