Open marxin opened 2 years ago
Partial linking is tricky, and partial linking with LTO is trickier. Maybe we should just concatenate given LTO object files if -r is given and handle a file created such way as a bundle of object files? As long as mold creates such files and can consume them, it should work as a whole.
@janhubicka Can help us I guess.
There are three ways one can meaningfully partial link with LTO (all implemented in GCC) 1) one can just use ld -r and concatenate object files This is used for building kernel. 2) one can do partial LTO producing final binary. invoke lto plugin that will read the LTO bytecode and produce combined .o file containing final binary. This is commonly done in GCC testuite. I am not sure how much other practical uses we have 3) one can do partial LTO producing LTO data. Here you invoke lto plugin, read LTO bytecode and stream combined one. This should be useful to optimize link times when a common static library (such as libbackend.a in GCC) is linked into multiple binaries. At LTO stream-in the type mergin and declaration merging is done so produced combined object files works faster.
I do 1 by simply invoking ld and not using wrapper. LTO section has seeds added to it so just merging them work. This was implemented by Andi Kleen so I would need to look up the details
2/2 i do by invoking linker via plugin as Martin does. Partcular mode is done via -flinker-output=rel and -flinker-output=nolto-rel
So I assume that mold differs from gold/bfs that with -r it does not attempt to do the plugin path? Honza
On Thu, May 12, 2022 at 10:34 AM Martin Liška @.***> wrote:
@janhubicka https://github.com/janhubicka Can help us I guess.
— Reply to this email directly, view it on GitHub https://github.com/rui314/mold/issues/509#issuecomment-1124690392, or unsubscribe https://github.com/notifications/unsubscribe-auth/AK7OQW3D3RQNWGYLJ3JJHVLVJS67VANCNFSM5VXMHPIA . You are receiving this because you were mentioned.Message ID: @.***>
It's documented here https://github.com/rui314/mold/blob/main/docs/design.md under Incremental linking
bullet point.
I noticed that LTO is not run for partial linking:
while using mold:
I verified that
mold
does not call GCC'sWPA
.