This is an archive of the discontinued LLVM Phabricator instance.

[gold-plugin] Add "obj-files" option
AbandonedPublic

Authored by void on Aug 15 2018, 1:23 PM.

Details

Reviewers
pcc
Summary

Add the option "obj-files" that will print out the intermediate object files during ThinLTO. This is similar to "save-temps", but doesn't output intermediate bitcode files.

Diff Detail

Repository
rL LLVM

Event Timeline

void created this revision.Aug 15 2018, 1:23 PM
pcc added a comment.Aug 15 2018, 1:31 PM

Doesn't the obj-path option already do what you want here?

void added a comment.Aug 15 2018, 2:08 PM
In D50803#1201353, @pcc wrote:

Doesn't the obj-path option already do what you want here?

I don't believe so, or at least it's not exactly the behavior I would like. The behavior I see with save-temps that I wanted to replicate with this option is that save-temps outputs the object code in this way:

$ ld.gold -plugin LLVMgold.so -plugin-opt=save-temps -r -o x.o a.o b.o
$ ls
x.o x.o1 x.o2 a.o b.o

Where x.o1 is the object code for a.o and x.o2 is the object code for b.o. Retaining this ordering is important to my use case---i.e., live patching the Linux kernel. From what I can tell, obj-path outputs .o files to temporary files with no special ordering to the filenames.

pcc added a comment.Aug 15 2018, 2:55 PM

obj-path should produce the same order as save-temps because they use the same code path -- they both work by setting Filename to a non-empty string, which causes us to follow the code path that appends task identifiers and use non-temporary files. If you're seeing something different, maybe that should be fixed instead?

void added a comment.Aug 16 2018, 11:15 AM

Okay. That seems to work. Thanks!

void abandoned this revision.Aug 16 2018, 11:16 AM
void reclaimed this revision.Aug 16 2018, 11:25 AM

I may have spoken too soon. obj_path requires a path to the filename you want to use. This is okay, but when used in a Makefile it becomes difficult:

LDFLAGS_GOLD := -plugin $(CLANG_LIBS)/LLVMgold.so               \
        -plugin-opt=-code-model=kernel                          \
        -plugin-opt=obj_path=

What should be the value for obj_path here? I can't specify a single filename as the output files from one run of ld.gold will overwrite previous ones.

pcc added a comment.Aug 16 2018, 12:38 PM

I'm not sure, I'm not an expert on the Linux build system. There's probably some link rule somewhere that contains something like -o $@, maybe you can change it to say -o $@ -plugin-opt=obj-path=$@.o?

void abandoned this revision.Aug 16 2018, 3:20 PM

Okay. I was able to hack something together. Thanks!