When using llvm-libtool-darwin with LTO building llvm itself, it crashed
on a file with an asm module in the bitcode. This fixes that by
correctly registering the targets for this.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Event Timeline
Curious to hear if this is the right approach. Registering all of these targets seems like a big hammer but I think it's required unless we want to single out the targets darwin uses?
Maybe we should actually be doing what llvm-ar is? https://github.com/llvm/llvm-project/blob/a6298fb160633578f5c4c1e739044274ba8fe520/llvm/tools/llvm-ar/llvm-ar.cpp#L1271-L1273
I'm afraid I don't have any particular insight into this area, so this needs someone else to review.
I don't have direct experience with this either, but this seems sensible (I assume InitializeAllTargets is a pre-req for InitializeAllAsmParsers, although llvm-ar is just using InitializeAllTargetInfos). I'll let it sit for a few days to give others the chance to chime in though.
CC @int3, who set up LTO for LLD for Mach-O.
llvm/test/tools/llvm-libtool-darwin/asm.test | ||
---|---|---|
1 | I think you'll want REQUIRES lines for the targets you're using here (x86 and aarch64), to make the test not fail when LLVM is built without those targets. (I think just testing one architecture would be fine as well, to not require multiple targets to be enabled for running the test). |
I've updated to just use the llvm-ar logic since I assume that's the most correct option.
llvm/test/tools/llvm-libtool-darwin/asm.test | ||
---|---|---|
1 | Ah yes thanks, I added both here. The reason I want both is because theoretically depending on how you register the targets, it may only work for your native target, and not any other targets for cross compilation, so having both here verifies that. If you think having both requires is too strict, I can split these into 2 test files? Also note apparently in llvm/test the lit config is slightly different so the requires definitions are different here. |
LGTM since we're just matching llvm-ar's logic.
llvm/test/tools/llvm-libtool-darwin/asm.test | ||
---|---|---|
1 | Yeah, that logic for testing both makes sense. I do think it'd be nice to split out into two files though (just to maximize testing coverage). |
I think you'll want REQUIRES lines for the targets you're using here (x86 and aarch64), to make the test not fail when LLVM is built without those targets. (I think just testing one architecture would be fine as well, to not require multiple targets to be enabled for running the test).