<div dir="ltr"><div>I'm just testing with a local copy. You can build an i386 LLVM on an x86-64 MacOSX box with:</div><div><br></div><font face="courier new, monospace">cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CROSSCOMPILING=True -DLLVM_TARGET_ARCH=i386-apple-macosx10.9 -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_ENABLE_LIBCXX=True -DCMAKE_C_FLAGS="-m32 -target i386-apple-macosx10.8" -DCMAKE_CXX_FLAGS="-m32 -target i386-apple-macosx10.9"</font><br>
<div><br></div><div>I would guess the Linux equivalent would be:</div><div><br></div><font face="courier new, monospace">cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CROSSCOMPILING=True -DLLVM_TARGET_ARCH=i386-pc-linux-gnu -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_ENABLE_LIBCXX -DCMAKE_C_FLAGS="-m32 -target i386-pc-linux-gnu" -DCMAKE_CXX_FLAGS="-m32 -target i386-pc-linux-gnu"</font><div>
<br></div><div>I'm still a bit fuzzy on how to XFAIL things for specific Arch/OS combinations, which we need for the JIT (e.g. Some test works on i386-apple-macosx, but not on i386-pc-linux-gnu, because the object format support differs). Pointers and/or patches welcome.</div>
<div><br></div><div>- Lang.</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, May 22, 2014 at 4:07 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On Thu, May 22, 2014 at 4:03 PM, Lang Hames <<a href="mailto:lhames@gmail.com">lhames@gmail.com</a>> wrote:<br>

> We don't have an i386 bot, I suspect nobody does (or they've been ignoring<br>
> the fact that these have been red).<br>
><br>
> Something like that sounds very useful. :)<br>
<br>
</div>I'm assuming you've got some kind of i386 machine to test this on - is<br>
it worth baselining (marking as XFAIL) that so at least /someone/<br>
(presumably at least you, maybe other people at some point) can run<br>
make check, get a green result, get an XPASS failure when you fix<br>
things, etc?<br>
<div class="HOEnZb"><div class="h5"><br>
><br>
> - Lang.<br>
><br>
><br>
> On Thu, May 22, 2014 at 3:48 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br>
>><br>
>> On Thu, May 22, 2014 at 3:30 PM, Lang Hames <<a href="mailto:lhames@gmail.com">lhames@gmail.com</a>> wrote:<br>
>> > Author: lhames<br>
>> > Date: Thu May 22 17:30:13 2014<br>
>> > New Revision: 209478<br>
>> ><br>
>> > URL: <a href="http://llvm.org/viewvc/llvm-project?rev=209478&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=209478&view=rev</a><br>
>> > Log:<br>
>> > [RuntimeDyld] Teach RuntimeDyldMachO how to handle scattered VANILLA<br>
>> > relocs on<br>
>> > i386.<br>
>> ><br>
>> > This fixes two more MCJIT regression tests on i386:<br>
>><br>
>> Do we have a public bot running these tests? (why weren't they XFAIL'd<br>
>> until now?) Do you have one internally at least that's green (how is<br>
>> it green if these tests aren't XFAIL'd on i386?) so you'll know (&<br>
>> presumably tell the community) if these regress?<br>
>><br>
>> ><br>
>> >   ExecutionEngine/MCJIT/2003-05-06-LivenessClobber.ll<br>
>> >   ExecutionEngine/MCJIT/2013-04-04-RelocAddend.ll<br>
>> ><br>
>> > The implementation of processScatteredVANILLA is tasteless<br>
>> > (*ba-dum-ching*),<br>
>> > but I'm working on a substantial tidy-up of RuntimeDyldMachO that should<br>
>> > improve things.<br>
>> ><br>
>> > This patch also fixes a type-o in<br>
>> > RuntimeDyldMachO::processSECTDIFFRelocation,<br>
>> > and teaches that method to skip over the PAIR reloc following the<br>
>> > SECTDIFF.<br>
>> ><br>
>> > <rdar://problem/16961886><br>
>> ><br>
>> ><br>
>> > Modified:<br>
>> >     llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp<br>
>> >     llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h<br>
>> ><br>
>> > Modified:<br>
>> > llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp<br>
>> > URL:<br>
>> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp?rev=209478&r1=209477&r2=209478&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp?rev=209478&r1=209477&r2=209478&view=diff</a><br>

>> ><br>
>> > ==============================================================================<br>
>> > --- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp<br>
>> > (original)<br>
>> > +++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp Thu<br>
>> > May 22 17:30:13 2014<br>
>> > @@ -460,7 +460,7 @@ relocation_iterator RuntimeDyldMachO::pr<br>
>> ><br>
>> >    uint32_t AddrB = MachO->getScatteredRelocationValue(RE2);<br>
>> >    section_iterator SBI = getSectionByAddress(*MachO, AddrB);<br>
>> > -  assert(SBI != MachO->section_end() && "Can't find seciton for address<br>
>> > B");<br>
>> > +  assert(SBI != MachO->section_end() && "Can't find section for address<br>
>> > B");<br>
>> >    uint64_t SectionBBase;<br>
>> >    SBI->getAddress(SectionBBase);<br>
>> >    uint64_t SectionBOffset = AddrB - SectionBBase;<br>
>> > @@ -483,7 +483,48 @@ relocation_iterator RuntimeDyldMachO::pr<br>
>> >    addRelocationForSection(R, SectionAID);<br>
>> >    addRelocationForSection(R, SectionBID);<br>
>> ><br>
>> > -  return RelI;<br>
>> > +  return ++RelI;<br>
>> > +}<br>
>> > +<br>
>> > +relocation_iterator RuntimeDyldMachO::processI386ScatteredVANILLA(<br>
>> > +                                            unsigned SectionID,<br>
>> > +                                            relocation_iterator RelI,<br>
>> > +                                            ObjectImage &Obj,<br>
>> > +                                            ObjSectionToIDMap<br>
>> > &ObjSectionToID) {<br>
>> > +  const MachOObjectFile *MachO =<br>
>> > +    static_cast<const MachOObjectFile*>(Obj.getObjectFile());<br>
>> > +  MachO::any_relocation_info RE =<br>
>> > +    MachO->getRelocation(RelI->getRawDataRefImpl());<br>
>> > +<br>
>> > +  SectionEntry &Section = Sections[SectionID];<br>
>> > +  uint32_t RelocType = MachO->getAnyRelocationType(RE);<br>
>> > +  bool IsPCRel = MachO->getAnyRelocationPCRel(RE);<br>
>> > +  unsigned Size = MachO->getAnyRelocationLength(RE);<br>
>> > +  uint64_t Offset;<br>
>> > +  RelI->getOffset(Offset);<br>
>> > +  uint8_t *LocalAddress = Section.Address + Offset;<br>
>> > +  unsigned NumBytes = 1 << Size;<br>
>> > +  int64_t Addend = 0;<br>
>> > +  memcpy(&Addend, LocalAddress, NumBytes);<br>
>> > +<br>
>> > +  unsigned SymbolBaseAddr = MachO->getScatteredRelocationValue(RE);<br>
>> > +  section_iterator TargetSI = getSectionByAddress(*MachO,<br>
>> > SymbolBaseAddr);<br>
>> > +  assert(TargetSI != MachO->section_end() && "Can't find section for<br>
>> > symbol");<br>
>> > +  uint64_t SectionBaseAddr;<br>
>> > +  TargetSI->getAddress(SectionBaseAddr);<br>
>> > +  SectionRef TargetSection = *TargetSI;<br>
>> > +  bool IsCode;<br>
>> > +  TargetSection.isText(IsCode);<br>
>> > +  uint32_t TargetSectionID = findOrEmitSection(Obj, TargetSection,<br>
>> > IsCode,<br>
>> > +                                               ObjSectionToID);<br>
>> > +<br>
>> > +  Addend -= SectionBaseAddr;<br>
>> > +  RelocationEntry R(SectionID, Offset, RelocType, Addend,<br>
>> > +                    IsPCRel, Size);<br>
>> > +<br>
>> > +  addRelocationForSection(R, TargetSectionID);<br>
>> > +<br>
>> > +  return ++RelI;<br>
>> >  }<br>
>> ><br>
>> >  relocation_iterator RuntimeDyldMachO::processRelocationRef(<br>
>> > @@ -498,17 +539,22 @@ relocation_iterator RuntimeDyldMachO::pr<br>
>> >    uint32_t RelType = MachO->getAnyRelocationType(RE);<br>
>> ><br>
>> >    // FIXME: Properly handle scattered relocations.<br>
>> > -  //        For now, optimistically skip these: they can often be<br>
>> > ignored, as<br>
>> > -  //        the static linker will already have applied the relocation,<br>
>> > and it<br>
>> > -  //        only needs to be reapplied if symbols move relative to one<br>
>> > another.<br>
>> > -  //        Note: This will fail horribly where the relocations *do*<br>
>> > need to be<br>
>> > -  //        applied, but that was already the case.<br>
>> > +  //        Special case the couple of scattered relocations that we<br>
>> > know how<br>
>> > +  //        to handle: SECTDIFF relocations, and scattered VANILLA<br>
>> > relocations<br>
>> > +  //        on I386.<br>
>> > +  //        For all other scattered relocations, just bail out and hope<br>
>> > for the<br>
>> > +  //        best, since the offsets computed by scattered relocations<br>
>> > have often<br>
>> > +  //        been optimisticaly filled in by the compiler. This will<br>
>> > fail<br>
>> > +  //        horribly where the relocations *do* need to be applied, but<br>
>> > that was<br>
>> > +  //        already the case.<br>
>> >    if (MachO->isRelocationScattered(RE)) {<br>
>> >      if (RelType == MachO::GENERIC_RELOC_SECTDIFF ||<br>
>> >          RelType == MachO::GENERIC_RELOC_LOCAL_SECTDIFF)<br>
>> >        return processSECTDIFFRelocation(SectionID, RelI, Obj,<br>
>> > ObjSectionToID);<br>
>> > -<br>
>> > -    return ++RelI;<br>
>> > +    else if (Arch == Triple::x86 && RelType ==<br>
>> > MachO::GENERIC_RELOC_VANILLA)<br>
>> > +      return processI386ScatteredVANILLA(SectionID, RelI, Obj,<br>
>> > ObjSectionToID);<br>
>> > +    else<br>
>> > +      return ++RelI;<br>
>> >    }<br>
>> ><br>
>> >    RelocationValueRef Value;<br>
>> ><br>
>> > Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h<br>
>> > URL:<br>
>> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h?rev=209478&r1=209477&r2=209478&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h?rev=209478&r1=209477&r2=209478&view=diff</a><br>

>> ><br>
>> > ==============================================================================<br>
>> > --- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h<br>
>> > (original)<br>
>> > +++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h Thu<br>
>> > May 22 17:30:13 2014<br>
>> > @@ -71,6 +71,12 @@ private:<br>
>> >                                               ObjectImage &ObjImg,<br>
>> >                                               ObjSectionToIDMap<br>
>> > &ObjSectionToID);<br>
>> ><br>
>> > +  relocation_iterator processI386ScatteredVANILLA(<br>
>> > +                                            unsigned SectionID,<br>
>> > +                                            relocation_iterator RelI,<br>
>> > +                                            ObjectImage &ObjImg,<br>
>> > +                                            ObjSectionToIDMap<br>
>> > &ObjSectionToID);<br>
>> > +<br>
>> >    struct EHFrameRelatedSections {<br>
>> >      EHFrameRelatedSections()<br>
>> >          : EHFrameSID(RTDYLD_INVALID_SECTION_ID),<br>
>> ><br>
>> ><br>
>> > _______________________________________________<br>
>> > llvm-commits mailing list<br>
>> > <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
>> > <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
><br>
><br>
</div></div></blockquote></div><br></div>