Skip to content

Commit 55fa315

Browse files
committed
[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
1 parent 2875df0 commit 55fa315

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

llvm/test/tools/gold/X86/parallel.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
; RUN: llvm-as -o %t.bc %s
2-
; RUN: rm -f %t.0.5.precodegen.bc %t.1.5.precodegen.bc %t.o %t.o1
2+
; RUN: rm -f %t.0.5.precodegen.bc %t.1.5.precodegen.bc %t.lto.o %t.lto.o1
33
; RUN: env LD_PRELOAD=%llvmshlibdir/LLVMgold%shlibext %gold -plugin %llvmshlibdir/LLVMgold%shlibext -u foo -u bar -plugin-opt lto-partitions=2 -plugin-opt save-temps -m elf_x86_64 -o %t %t.bc
44
; RUN: llvm-dis %t.0.5.precodegen.bc -o - | FileCheck --check-prefix=CHECK-BC0 %s
55
; RUN: llvm-dis %t.1.5.precodegen.bc -o - | FileCheck --check-prefix=CHECK-BC1 %s
6-
; RUN: llvm-nm %t.o | FileCheck --check-prefix=CHECK0 %s
7-
; RUN: llvm-nm %t.o1 | FileCheck --check-prefix=CHECK1 %s
6+
; RUN: llvm-nm %t.lto.o | FileCheck --check-prefix=CHECK0 %s
7+
; RUN: llvm-nm %t.lto.o1 | FileCheck --check-prefix=CHECK1 %s
88

99
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
1010
target triple = "x86_64-unknown-linux-gnu"

llvm/test/tools/gold/X86/relocation-model-pic.ll

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,44 +10,44 @@
1010
; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold%shlibext \
1111
; RUN: --shared \
1212
; RUN: --plugin-opt=save-temps %t.o -o %t-out
13-
; RUN: llvm-readobj -r %t-out.o | FileCheck %s --check-prefix=PIC
13+
; RUN: llvm-readobj -r %t-out.lto.o | FileCheck %s --check-prefix=PIC
1414

1515
; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold%shlibext \
1616
; RUN: --export-dynamic --noinhibit-exec -pie \
1717
; RUN: --plugin-opt=save-temps %t.o -o %t-out
18-
; RUN: llvm-readobj -r %t-out.o | FileCheck %s --check-prefix=PIC
18+
; RUN: llvm-readobj -r %t-out.lto.o | FileCheck %s --check-prefix=PIC
1919

2020
; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold%shlibext \
2121
; RUN: --export-dynamic --noinhibit-exec \
2222
; RUN: --plugin-opt=save-temps %t.o -o %t-out
23-
; RUN: llvm-readobj -r %t-out.o | FileCheck %s --check-prefix=STATIC
23+
; RUN: llvm-readobj -r %t-out.lto.o | FileCheck %s --check-prefix=STATIC
2424

2525
; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold%shlibext \
2626
; RUN: -r \
2727
; RUN: --plugin-opt=save-temps %t.o -o %t-out
28-
; RUN: llvm-readobj -r %t-out.o | FileCheck %s --check-prefix=STATIC
28+
; RUN: llvm-readobj -r %t-out.lto.o | FileCheck %s --check-prefix=STATIC
2929

3030
;; PIC source.
3131

3232
; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold%shlibext \
3333
; RUN: --shared \
3434
; RUN: --plugin-opt=save-temps %t.pic.o -o %t-out
35-
; RUN: llvm-readobj -r %t-out.o | FileCheck %s --check-prefix=PIC
35+
; RUN: llvm-readobj -r %t-out.lto.o | FileCheck %s --check-prefix=PIC
3636

3737
; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold%shlibext \
3838
; RUN: --export-dynamic --noinhibit-exec -pie \
3939
; RUN: --plugin-opt=save-temps %t.pic.o -o %t-out
40-
; RUN: llvm-readobj -r %t-out.o | FileCheck %s --check-prefix=PIC
40+
; RUN: llvm-readobj -r %t-out.lto.o | FileCheck %s --check-prefix=PIC
4141

4242
; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold%shlibext \
4343
; RUN: --export-dynamic --noinhibit-exec \
4444
; RUN: --plugin-opt=save-temps %t.pic.o -o %t-out
45-
; RUN: llvm-readobj -r %t-out.o | FileCheck %s --check-prefix=STATIC
45+
; RUN: llvm-readobj -r %t-out.lto.o | FileCheck %s --check-prefix=STATIC
4646

4747
; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold%shlibext \
4848
; RUN: -r \
4949
; RUN: --plugin-opt=save-temps %t.pic.o -o %t-out
50-
; RUN: llvm-readobj -r %t-out.o | FileCheck %s --check-prefix=PIC
50+
; RUN: llvm-readobj -r %t-out.lto.o | FileCheck %s --check-prefix=PIC
5151

5252

5353
; PIC: R_X86_64_GOTPCREL foo

llvm/test/tools/gold/X86/thinlto.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
; RUN: llvm-bcanalyzer -dump %t4.index.bc | FileCheck %s --check-prefix=COMBINED
4343
; RUN: llvm-nm %t4 | FileCheck %s --check-prefix=NM
4444
; Ensure ld does not emit empty combined module in default.
45-
; RUN: ls %t4.o* | count 2
45+
; RUN: ls %t4.lto.o* | count 2
4646

4747
; Check with --no-map-whole-files
4848
; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \

llvm/tools/gold/gold-plugin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@ static std::vector<std::pair<SmallString<128>, bool>> runLTO() {
10501050
if (!options::obj_path.empty())
10511051
Filename = options::obj_path;
10521052
else if (options::TheOutputType == options::OT_SAVE_TEMPS)
1053-
Filename = output_name + ".o";
1053+
Filename = output_name + ".lto.o";
10541054
else if (options::TheOutputType == options::OT_ASM_ONLY)
10551055
Filename = output_name;
10561056
bool SaveTemps = !Filename.empty();

0 commit comments

Comments
 (0)