The gold linker allowed you to output the ELF files after LTO was run. It did
it by using the 'obj-path' option. This replicates that behavior.
Details
Diff Detail
- Repository
- rLLD LLVM Linker
- Build Status
Buildable 28564 Build 28563: arc lint + arc unit
Event Timeline
Replicating the gold behavior sounds fine, but does this patch work? This change seems to leave Buf uninitialized while Buf will be used later. Also, in gold LTO plugin, -obj-path overwrites -save-temps, but this change doesn't seem to replicate that behavior. Could you add tests?
The filenames of Task=0 and different. Is this preferable?
t.o t2.o were compiled with -module-summary
ld.lld --plugin-opt=obj-path=t3.o -shared t.o t2.o => creates t2.o0 t2.o1 t2.o2
gold --plugin=~/llvm/Release/lib/LLVMgold.so --plugin-opt=thinlto --plugin-opt=obj-path=t3.o -shared t.o t2.o => creates t2.o t2.o1 t2.o2
I'll add a test in a bit. I tested it and it did work, but I may have missed something. Let me get the test in and then you can take a look afterwards. Thanks!
I'm not sure it's important, but I modified it to retain the original behavior just in case.
test/ELF/lto/obj-path.ll | ||
---|---|---|
13 | Can you also verify %t3 to make sure that lld outputs a correct output file even if obj-path is given? |
ELF/LTO.cpp | ||
---|---|---|
226 | I don't think we need this kind of sophisticated abstraction. I believe you can just write Buf contents to files after data is written to Buf. Please take a look at https://gist.github.com/rui314/836cc9dab97922271b63dba3d1d5a3f5. All tests still pass with that patch. So, if my understanding is correct, the only difference between save-temps and obj-path is the basename of the created temporary files. Is this your expected behavior? |
ELF/LTO.cpp | ||
---|---|---|
226 | I implemented your suggestion here. The two options are similar, but have some important differences; save-temps outputs a lot of intermediate bitcode files. A new basename is good because it allows you to place the temps in a different directory. It might be possible to combine the two somehow? |
I think it is correct, but I'm not confident to press the "Accept Revision" button :) Added another expert
LGTM
test/ELF/lto/obj-path.ll | ||
---|---|---|
14 | We don't normally split check lines into multiple files like this. Can you move the check line for SYMBOLS from the other file into this one (and remove the one for ELF since it is unused)? |
I don't think we need this kind of sophisticated abstraction. I believe you can just write Buf contents to files after data is written to Buf. Please take a look at https://gist.github.com/rui314/836cc9dab97922271b63dba3d1d5a3f5. All tests still pass with that patch.
So, if my understanding is correct, the only difference between save-temps and obj-path is the basename of the created temporary files. Is this your expected behavior?