This is a follow up to D102732 which also expands the logic to Darwin.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Hmm, LLD for Mach-O already has some support for LTO. @int3, do we expect --lto-O0 to work for it?
Nope, we didn't add support for --lto-O0. I *think* the ld64 equivalent is -flto-codegen-only, but we don't support that yet either (and it's undocumented). However, we do support -mllvm, so -mllvm,-O0 should work.
Should this apply to Darwin even when not using LLD?
I'm seeing an error which tracks down to this change. It works fine without the -mllvm,-O0 link flags.
FAILED: bin/llvm-tblgen [...snip...] Remaining virtual register operands UNREACHABLE executed at .../llvm-project/llvm/lib/CodeGen/MachineRegisterInfo.cpp:209! clang-13: error: unable to execute command: Abort trap: 6 clang-13: error: linker command failed due to signal (use -v to see invocation)
https://green.lab.llvm.org/green/job/clang-stage2-Rthinlto/4221/consoleFull
It should, ld64 supports passing flags to libLTO via the -mllvm flag. We have been using this on our macOS bots for a few weeks and haven't run into any issues (they are using using ld64, not lld).
@phosek, the config where I'm seeing this is a two stage bootstrap build. Could you try building again with the just built clang and see if it still works for you? I seem to be able to reliably reproduce the error locally.
Yes, that's what we use on our bots as well. However, I just noticed that your bots are using ThinLTO, is that correct? We always use full LTO and it's possible that this issue only manifests in ThinLTO.
Yes, correct, this is with ThinLTO. I tried full LTO and I don't see the error, so, yes this appears to be an issue only with ThinLTO.
For now, let me guard this behavior to if its not ThinLTO, until we get the root cause fixed.