From 55fa315b0352b63454206600d6803fafacb42d5e Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Mon, 20 Jul 2020 09:58:31 -0700 Subject: [LLVMgold.so] -plugin-opt=save-temps: save combined module to .lto.o instead of .o This matches LLD and fixes https://sourceware.org/bugzilla/show_bug.cgi?id=26262#c1 .o is a bad choice for save-temps output because it is easy to override the bitcode file (*.o) ``` # Use bfd for the example, -fuse-ld=gold is similar. clang -flto -c a.c # generate bitcode file a.o clang -fuse-ld=bfd -flto a.o -o a -Wl,-plugin-opt=save-temps # override a.o # The user repeats the command but get surprised, because a.o is now a combined module. clang -fuse-ld=bfd -flto a.o -o a -Wl,-plugin-opt=save-temps ``` Reviewed By: tejohnson Differential Revision: https://reviews.llvm.org/D84132 --- llvm/tools/gold/gold-plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'llvm/tools/gold') diff --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp index 7654d44..0124e0a 100644 --- a/llvm/tools/gold/gold-plugin.cpp +++ b/llvm/tools/gold/gold-plugin.cpp @@ -1050,7 +1050,7 @@ static std::vector, bool>> runLTO() { if (!options::obj_path.empty()) Filename = options::obj_path; else if (options::TheOutputType == options::OT_SAVE_TEMPS) - Filename = output_name + ".o"; + Filename = output_name + ".lto.o"; else if (options::TheOutputType == options::OT_ASM_ONLY) Filename = output_name; bool SaveTemps = !Filename.empty(); -- cgit v1.1