Index: llvm/tools/gold/gold-plugin.cpp =================================================================== --- llvm/tools/gold/gold-plugin.cpp +++ llvm/tools/gold/gold-plugin.cpp @@ -556,6 +556,14 @@ return *claimed ? LDPS_ERR : LDPS_OK; } + if (!options::thinlto) { + // Close the fd now. The linker opens it specifically for this claim_file + // call and doesn't close it. + // When thinlto is enabled, we need to keep it open but we can still close + // it when thinlto is disabled. + release_input_file(file->handle); + } + std::unique_ptr Obj = std::move(*ObjOrErr); Modules.emplace_back();