The object format can be set to something other than MachO, e.g.
to use ELF-on-Darwin for MCJIT. This already works on Windows, so
there's no reason it shouldn't on Darwin.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Hi,
Interesting idea. I could see that could be useful in reducing variance in a product if your expertise is in ELF. I'm sure you know, but you should be wary with this; I wouldn't bet on the backends being quite as object-format agnostic as you'd hope, quite apart from any interactions with externally defined objects.
I did spot one thing with the patch (see below). I also think Lang should have at least a brief glance at it. He's far more aware of whether this could work than me.
Cheers.
Tim.
lib/MC/MCObjectFileInfo.cpp | ||
---|---|---|
844–845 ↗ | (On Diff #15960) | The new condition is redundant: isOSBinFormatMachO is the same as your added clause, so it amounts to completely removing the isOSDarwin check. Which actually does seem like quite an improvement, even if the code you get out of x86_64-macosx-elf is clinically insane. |
It actually works quite nicely in practice, but I agree that I won't enable it in production anytime soon. In the meantime, it's quite quite useful for testing purposes. I assume it only work so nicely because a lot of the work as already been done to support ELF-on-windows.
lib/MC/MCObjectFileInfo.cpp | ||
---|---|---|
844–845 ↗ | (On Diff #15960) | Ah, interesting. Does anybody know why the TT.isOSDarwin() was there in the first place? |
lib/MC/MCObjectFileInfo.cpp | ||
---|---|---|
844–845 ↗ | (On Diff #15960) | History. Until recently, the increasingly inaccurately named Triple only had 4 components. MachO was implied by either a Darwin OS or an explicit "MachO" environment/ABI. Looks like a fairly mechanical change when the separate object format field was added, which didn't quite work in this case. This patch (well, the simplified version) is looking better and better! |
Apologies for the delay. This looks good to me, but I'll get Jim Grosbach (who owns MC) to take a peek too - since this touches non-JIT codegen too.
Glad to have a look. On holiday at the moment so if I don't get to it before then, please ping me on the 4th when I'm back at my desk where I have all the relevant bits available.
Jim
@grosbach. Sorry I forgot about this. Pinging now :). I would guess it's possible to add a testcase. What should it do? Just check that the filetype is ELF when setting the triple to say x86_64-apple-darwin14.0.0-elf?
Bump. This is a very simple thing and works well. @grosbach, were you waiting on me adding a test case, if so does the proposed one sounds ok?