This is an archive of the discontinued LLVM Phabricator instance.

[LLVMgold.so] -plugin-opt=save-temps: save combined module to .lto.o instead of .o
ClosedPublic

Authored by MaskRay on Jul 19 2020, 7:07 PM.

Details

Summary

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

Diff Detail

Event Timeline

MaskRay created this revision.Jul 19 2020, 7:07 PM
tejohnson accepted this revision.Jul 20 2020, 9:42 AM

LGTM with minor test fix needed.

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

Filename in rm needs update too.

This revision is now accepted and ready to land.Jul 20 2020, 9:42 AM
MaskRay updated this revision to Diff 279287.Jul 20 2020, 9:56 AM
MaskRay marked an inline comment as done.
MaskRay edited the summary of this revision. (Show Details)

Fix rm filenames

MaskRay edited the summary of this revision. (Show Details)Jul 20 2020, 9:57 AM
This revision was automatically updated to reflect the committed changes.
MaskRay added a subscriber: hans.Jul 20 2020, 10:04 AM

@hans Is this ok for release/11.x ? 😳

hans added a comment.Jul 21 2020, 5:08 AM

@hans Is this ok for release/11.x ? 😳

Sounds good to me, go ahead :)

bjope added a subscriber: bjope.Jul 21 2020, 10:01 AM

Having some problems with failing stage 2 tests, that I suspect is related to this change (since the missing files do exist but with ".lto" being part of the name when looking in my test directory after a failed test run). I guess on need to add ".lto" at some more places?

These are the tests that failed:

Failed Tests (3):
  LLVM :: tools/gold/X86/cache.ll
  LLVM :: tools/gold/X86/emit-llvm.ll
  LLVM :: tools/gold/X86/relax-relocs.ll

Here are some logs:

: 'RUN: at line 70';   ls /build/stage2/test/tools/gold/X86/Output/cache.ll.tmp4.o.o1
: 'RUN: at line 71';   ls /build/stage2/test/tools/gold/X86/Output/cache.ll.tmp4.o.o2
--
Exit Code: 2

Command Output (stderr):
--
ls: cannot access /build/stage2/test/tools/gold/X86/Output/cache.ll.tmp4.o.o1: No such file or directory
Exit Code: 2

Command Output (stderr):
--
/build/stage2/bin/llvm-nm: error: /build/stage2/test/tools/gold/X86/Output/emit-llvm.ll.tmp3.o.o: No such file or directory.
FileCheck error: '<stdin>' is empty.
FileCheck command line:  /build/stage2/bin/FileCheck --check-prefix=NM /llvm-project/llvm/test/tools/gold/X86/emit-llvm.ll
Exit Code: 2

Command Output (stderr):
--
/build/stage2/bin/llvm-readobj: error: '/build/stage2/test/tools/gold/X86/Output/relax-relocs.ll.tmp.so.o': No such file or directory
FileCheck error: '<stdin>' is empty.
FileCheck command line:  /build/stage2/bin/FileCheck /llvm-project/llvm/test/tools/gold/X86/relax-relocs.ll

Having some problems with failing stage 2 tests, that I suspect is related to this change (since the missing files do exist but with ".lto" being part of the name when looking in my test directory after a failed test run). I guess on need to add ".lto" at some more places?

These are the tests that failed:

Failed Tests (3):
  LLVM :: tools/gold/X86/cache.ll
  LLVM :: tools/gold/X86/emit-llvm.ll
  LLVM :: tools/gold/X86/relax-relocs.ll

Here are some logs:

: 'RUN: at line 70';   ls /build/stage2/test/tools/gold/X86/Output/cache.ll.tmp4.o.o1
: 'RUN: at line 71';   ls /build/stage2/test/tools/gold/X86/Output/cache.ll.tmp4.o.o2
--
Exit Code: 2

Command Output (stderr):
--
ls: cannot access /build/stage2/test/tools/gold/X86/Output/cache.ll.tmp4.o.o1: No such file or directory
Exit Code: 2

Command Output (stderr):
--
/build/stage2/bin/llvm-nm: error: /build/stage2/test/tools/gold/X86/Output/emit-llvm.ll.tmp3.o.o: No such file or directory.
FileCheck error: '<stdin>' is empty.
FileCheck command line:  /build/stage2/bin/FileCheck --check-prefix=NM /llvm-project/llvm/test/tools/gold/X86/emit-llvm.ll
Exit Code: 2

Command Output (stderr):
--
/build/stage2/bin/llvm-readobj: error: '/build/stage2/test/tools/gold/X86/Output/relax-relocs.ll.tmp.so.o': No such file or directory
FileCheck error: '<stdin>' is empty.
FileCheck command line:  /build/stage2/bin/FileCheck /llvm-project/llvm/test/tools/gold/X86/relax-relocs.ll

Thanks for reporting the problem. Fixed by aa830e9768303ff8d27c015759294c4ce704d50c (I should have been more careful. Not many build bots build binutils-gdb headers and test LLVMgold.so)

Having some problems with failing stage 2 tests, that I suspect is related to this change (since the missing files do exist but with ".lto" being part of the name when looking in my test directory after a failed test run). I guess on need to add ".lto" at some more places?

These are the tests that failed:

Failed Tests (3):
  LLVM :: tools/gold/X86/cache.ll
  LLVM :: tools/gold/X86/emit-llvm.ll
  LLVM :: tools/gold/X86/relax-relocs.ll

Here are some logs:

: 'RUN: at line 70';   ls /build/stage2/test/tools/gold/X86/Output/cache.ll.tmp4.o.o1
: 'RUN: at line 71';   ls /build/stage2/test/tools/gold/X86/Output/cache.ll.tmp4.o.o2
--
Exit Code: 2

Command Output (stderr):
--
ls: cannot access /build/stage2/test/tools/gold/X86/Output/cache.ll.tmp4.o.o1: No such file or directory
Exit Code: 2

Command Output (stderr):
--
/build/stage2/bin/llvm-nm: error: /build/stage2/test/tools/gold/X86/Output/emit-llvm.ll.tmp3.o.o: No such file or directory.
FileCheck error: '<stdin>' is empty.
FileCheck command line:  /build/stage2/bin/FileCheck --check-prefix=NM /llvm-project/llvm/test/tools/gold/X86/emit-llvm.ll
Exit Code: 2

Command Output (stderr):
--
/build/stage2/bin/llvm-readobj: error: '/build/stage2/test/tools/gold/X86/Output/relax-relocs.ll.tmp.so.o': No such file or directory
FileCheck error: '<stdin>' is empty.
FileCheck command line:  /build/stage2/bin/FileCheck /llvm-project/llvm/test/tools/gold/X86/relax-relocs.ll

Thanks for reporting the problem. Fixed by aa830e9768303ff8d27c015759294c4ce704d50c (I should have been more careful. Not many build bots build binutils-gdb headers and test LLVMgold.so)

Ok, thanks! It did not cause a big problem for me though. I was just checking our downstream bots and happened to notice some failures (and maybe those bots are a bit "pedantic" because I don't think we currently use that setup in production).