[lld] [ELF] Fix --lto-obj-path with the ThinLTO cache (PR #211062)

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 1 06:53:10 PDT 2026


smithp35 wrote:

Apologies for the delay, I have just come back from holiday.

I think the fix and test look good to me.

I'm not too familiar with this area of the code so it took a while to work out from the description what the high-level problem was. I'll make a suggestion on rewording the description.

>From looking at the comments in the code, it also looks like DTLTO could be affected too. I think the fix will work for DTLTO too but would be good to include this in the description. With the code structure as it is today I don't think we need a separate test for DTLTO. I've added some reviewers that have worked on DTLTO for any additional comments from that side.

Suggested commit message:
```
The --lto-obj-path option no longer writes empty files if the ThinLTO cache is enabled or DTLTO is used.

The implementation of --lto-obj-path derives the native ELF file contents from the buf[] array. When the ThinLTO cache or DTLTO is used the native ELF file contents may be in the file[] array instead. Delay the writing of the native ELF file till after the existing code that extract the native ELF file contents from either file[] or buf[].
```

https://github.com/llvm/llvm-project/pull/211062


More information about the llvm-commits mailing list