Index: test/tools/gold/X86/cache.ll =================================================================== --- test/tools/gold/X86/cache.ll +++ test/tools/gold/X86/cache.ll @@ -56,10 +56,16 @@ ; This should remove it. ; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold%shlibext \ ; RUN: --plugin-opt=thinlto \ +; RUN: --plugin-opt=save-temps \ ; RUN: --plugin-opt=cache-dir=%t.cache \ ; RUN: --plugin-opt=cache-policy=cache_size_bytes=32k:prune_interval=0s \ -; RUN: -o %t3.o %t2.o %t.o +; RUN: -o %t4.o %t2.o %t.o ; RUN: ls %t.cache | count 4 +; With save-temps we can confirm that the cached files were copied into temp +; files to avoid a race condition with the cached files being pruned, since the +; gold plugin-api only accepts native objects passed back as files. +; RUN: ls %t4.o.o1 +; RUN: ls %t4.o.o2 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" Index: tools/gold/gold-plugin.cpp =================================================================== --- tools/gold/gold-plugin.cpp +++ tools/gold/gold-plugin.cpp @@ -903,9 +903,7 @@ auto AddBuffer = [&](size_t Task, std::unique_ptr MB, StringRef Path) { - // Note that this requires that the memory buffers provided to AddBuffer are - // backed by a file. - Filenames[Task] = Path; + *AddStream(Task)->OS << MB->getBuffer(); }; NativeObjectCache Cache;