<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote">On Thu, Aug 22, 2013 at 11:56 AM, Steven Newbury <span dir="ltr"><<a href="mailto:steve@snewbury.org.uk" target="_blank">steve@snewbury.org.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Thu, 2013-08-22 at 11:50 +0400, Alexey Samsonov wrote:<br>
> On Thu, Aug 22, 2013 at 11:39 AM, Steven Newbury <<a href="mailto:steve@snewbury.org.uk">steve@snewbury.org.uk</a>>wrote:<br>
><br>
> > On Thu, 2013-08-22 at 11:27 +0400, Alexey Samsonov wrote:<br>
> > > Hi Steven,<br>
> > ><br>
> > > This looks interesting and raises a number of questions :)<br>
> > ><br>
> > > 1) Does applying this patch actually bring working sanitizers to x32<br>
> > > platform?<br>
> > > That is, after you build the clang, does "clang -fsanitize=whatever<br>
> > foo.c"<br>
> > > compile/link/run with expected results?<br>
> > > I doubt that, as there is some platform-specific code in all the<br>
> > > sanitizers, and many of them heavily depend<br>
> > > on the address space layout. Porting TSan and MSan to 32-bit address<br>
> > space<br>
> > > is especially hard, and we don't plan<br>
> > > to do this anytime soon. I think it makes sense to build only the<br>
> > libraries<br>
> > > that are expected to work on a given arch.<br>
> > ><br>
> > I should have made clear this is very much a WIP. I expect to have make<br>
> > an effort to port compiler-rt, but first I need to be able to generate<br>
> > elf32_x86_64 objects with Clang. I confess, my method of porting code<br>
> > to x32 so far has consisted of trying to build existing code and<br>
> > modifying what breaks, or disabling features where inapplicable. I<br>
> > haven't studied the code well enough to understand and predict where I'm<br>
> > going to have make modification in advance. It's worked so far with<br>
> > most things I've attempted but LLVM/Clang/compiler-rt is an order of<br>
> > magnitude more complex than anything else I've poked at. The biggest<br>
> > success I've had so far with this method is porting of Mozilla<br>
> > Spidermonkey/js17.<br>
> ><br>
><br>
> So, IIUC, if you're working on making LLVM/Clang/compiler-rt source tree<br>
> build on x32 host, I suggest your first step should be: disable building<br>
> compiler-rt<br>
> on x32 host :) One of the reasons: in makefile-based build compiler-rt<br>
> sources<br>
> are compiled with just-built Clang (I honestly don't know if Clang can<br>
> target x32<br>
> at the moment). Another reason: compiler-rt code is really arch-specific,<br>
> and even<br>
> if it compiles, it wouldn't work.<br>
><br>
</div></div>See accompanied Clang patch in other email. I've attempted to get Clang<br>
to target x32, I'm also suspicious that x32 built clang isn't correctly<br>
working to produce 64-bit code, but that's a somewhat different bug that<br>
I haven't yet attempted to address. Without modifying Clang to target<br>
x32, the x32 *built* Clang fails to compile compiler-rt with -m64, I<br>
need help decoding the crash backtrace to figure out where that bug<br>
lies, but it's not related to (or helped by) my patch.<br></blockquote><div><br></div><div>So, it looks like Clang built on x32 host:</div><div>(a) doesn't work with -m64 (can't target x86_64)</div><div>(b) can target x32 with your patch.</div>
<div>If that's the case, (a) should be investigated (maybe, you can open a bug for this</div><div>as a start), while you should try to get your patch for (b) submitted. Let's move the</div><div>discussion to that thread, most likely you'll have to add tests and find a</div>
<div>reviewer for that patch.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">><br>
> ><br>
> > > 2) If we're stepping on the path of porting some sanitizers to x32, it<br>
> > > would be great to<br>
> > > setup a buildbot, make our tests pass cleanly, and make this bot public<br>
> > to<br>
> > > catch regressions.<br>
> > > Do you have plans for that? Running sanitizer test suites also leads us<br>
> > > to...<br>
> > ><br>
> > I'm new to llvm/clang, I'm going to have to take guidance from others.<br>
> ><br>
> > > 3) Do you plan to add support for building sanitizers on x32 to CMake<br>
> > build<br>
> > > system? It would<br>
> > > make sense (and, in fact, I would start from there), as our testsuite can<br>
> > > be run only in CMake builds.<br>
> > ><br>
> > I can do so, (locally switch to cmake) I have a little experience with<br>
> > cmake so I should be able to figure it out. From my distro point of<br>
> > view, the plan on Gentoo is to switch to CMake for the LLVM/Clang<br>
> > ebuild, but it hasn't happened yet. Perhaps this could be expedited, I<br>
> > can contact the package maintainer.<br>
><br>
><br>
> FTR, CMake would probably see that we our host is neither x86_64 nor i386,<br>
> and won't build anything in compiler-rt. If it wouldn't, we should go and<br>
> fix this.<br>
><br>
<br>
</div>Maybe. Although, technically it *is* x86_64, but with a different ABI.<br>
I don't know how that's handled, although it works for ARM/MIPS, right??<br></blockquote><div><br></div><div>Yes, we're able to target ARM on x86_64 host if that's what you're asking about.</div><div>
<br></div></div>-- <br><div>Alexey Samsonov, MSK</div>
</div></div>