AllocateTarget for ELF objects on Darwin

Hello everyone

I am linking the Clang libs into my executable for JIT compilation. In
order to enable debugging the jited code on OSX via the GDB JIT
Interface, I switched the format of the in-memory object files to ELF. I
thought this target triple should do:

Triple TT;

But Clang exits with an error:

backend data layout 'e-m:e-i64:64-f80:128-n8:16:32:64-S128'
does not match expectedtarget description
1 error generated.

The target selection is a little tricky here and I wonder if it's on
purpose or not. One solution is to add another line:


This line removes the OS info from my triple, so that the
AllocateTarget() function no longer returns a DarwinX86_64TargetInfo
from here:

The problem with DarwinX86_64TargetInfo is, that it's hard-coded for
Mach-O. It always sets the same data-layout string in the target

*** This causes the above error. Can anyone explain this behavior? Is
there anyone possibly relying on it? ***

My impression is that one of these points should be changed. Either the
branch to DarwinX86_64TargetInfo

Or DarwinX86_64TargetInfo itself should respect the object format:

if (T.isOSBinFormatMachO())

My workaround to set OS to Unknown will cause the AllocateTarget()
function to fall back to the generic X86_64TargetInfo, which also sets
the correct data-layout and avoids the above error.