[clang] [lld] [llvm] [llvm][lld][clang] Delay initializing TargetOptions in LTO builds until a Triple is available (PR #179509)

Paul Kirth via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 19 17:08:12 PST 2026


ilovepi wrote:

> ​I see that we normally are setting the triple in the combined module in LTO::add, if it isn't set yet. gold-plugin.cpp calls this too. Do you know why it isn't getting set in the case you looked at?

Oh, I guess in that test for gold had an empty triple and it doesn't look like we specify the default anywhere, like the `opt` command line. https://github.com/llvm/llvm-project/blob/450e83be59a7a32aae344fe48c403c6b3dee4951/llvm/test/tools/gold/X86/thinlto_prefix_replace.ll#L3

Maybe the new handling I added wasn't necessary in practice, since I'd guess anything coming out of a compiler that you'd be linking should have a triple... that said I suppose there probably isn't harm in the new handling, since it matches the existing override/default behavior. IIRC, that was the only test I found that failed for gold, so I guess as an alternative, we could set a triple via `opt` and drop the extra handling I added. 

Ultimately, I guess its down to whether we think its OK for a module in LTO to not have a triple, and I'd argue that its not.

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


More information about the cfe-commits mailing list