On Mon, Oct 15, 2012 at 11:51 PM, Jean-Daniel Dupas <span dir="ltr"><<a href="mailto:devlists@shadowlab.org" target="_blank">devlists@shadowlab.org</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word"><br><div><div>Le 16 oct. 2012 à 08:42, Alexey Samsonov <<a href="mailto:samsonov@google.com" target="_blank">samsonov@google.com</a>> a écrit :</div><div><div class="h5"><br><blockquote type="cite">
<br><br><div class="gmail_quote">On Tue, Oct 16, 2012 at 1:46 AM, Jean-Daniel Dupas <span dir="ltr"><<a href="mailto:devlists@shadowlab.org" target="_blank">devlists@shadowlab.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div style="word-wrap:break-word"><br><div><div>Le 15 oct. 2012 à 23:32, Jean-Daniel Dupas <<a href="mailto:devlists@shadowlab.org" target="_blank">devlists@shadowlab.org</a>> a écrit :</div><div><div><br>
<blockquote type="cite"><br>Le 15 oct. 2012 à 21:31, "Sean McBride" <<a href="mailto:sean@rogue-research.com" target="_blank">sean@rogue-research.com</a>> a écrit :<br><br><blockquote type="cite">On Mon, 15 Oct 2012 12:21:17 -0700, David Blaikie said:<br>

<br><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">I see that there have been recent changes wrt -fcatch-undefined-<br></blockquote>behavior, and within the last week or so something changed such that my<br>

own build of clang (built with CMake on OS X) is unable to build simple<br>programs that use -fcatch-undefined-behavior, I get link errors like:<br><blockquote type="cite"><br>"___ubsan_handle_divrem_overflow", referenced from:<br>

    _main in test-OSZvjm.o<br>"___ubsan_handle_type_mismatch", referenced from:<br>    _main in test-OSZvjm.o<br><br>Any ideas why?<br><br></blockquote><br>This is a new feature. Instead of generating traps, -fcatch-undefined-<br>

behavior generates library calls that make it easier to find what is<br>wrong (each undefined behavior calls a different function).<br><br>This functions are provided by the ubsan library that is part of<br>compiler-rt. But I'm not sure the integration to the Makefile build<br>

system is done yet.<br></blockquote><br>You mean with the CMake build system?<br></blockquote><br>Generally "Makefile build system" describes the configure+make build<br>system (at least when it's discussed here).<br>

<br><blockquote type="cite">Perhaps if I build using autotools it will work?  Or do you mean it<br></blockquote>works nowhere yet?<br><br>I believe the implication is that it works with the CMake build<br>system. But you will need to checkout the compiler-rt LLVM project<br>

into llvm/projects to build it along with clang. (& I assume you'll<br>need to install compiler-rt alongside clang as well, but hopefully the<br>install target does that)<br></blockquote><br>As I said in my original post, I am using CMake (not autotools aka configure+make).  I do have llvm/projects.<br>

<br>My full little 'build everything' script is:<br><br>------------<br>(cd ~/llvm/llvm/; svn up)<br>(cd ~/llvm/llvm/tools/clang; svn up)<br>(cd ~/llvm/llvm/projects/compiler-rt; svn up)<br><br>mkdir -p ~/llvm/llvm-rel-bin<br>

rm -rf ~/llvm/llvm-rel-bin/*<br><br>mkdir -p ~/llvm/llvm-rel-install<br>rm -rf ~/llvm/llvm-rel-install/*<br><br>cd ~/llvm/llvm-rel-bin<br>CC="$(xcrun --find cc)" CXX="$(xcrun --find c++)" cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=OFF -DCMAKE_INSTALL_PREFIX=~/llvm/llvm-rel-install ../llvm<br>

make -j16 install<br></blockquote><br>Yep, it looks like the driver integration for the darwin toolchain is missing too.<br><br>The ubsan library should probably be append to the link flags somewhere in Toolchains.cpp:DarwinClang::AddLinkRuntimeLibArgs(), but I don't see it anywhere.<br>

<br></blockquote><br></div></div><span style="background-color:transparent">Digging a little further, I found this in ubsan_value.h.</span></div><div><br></div><div><div style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(0,132,0)">

// For now, only support linux. Other platforms should be easy to add, and</div><div style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(0,132,0)">// probably work as-is.</div><div style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(120,73,42)">

#if !defined(__linux__)</div><div style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(120,73,42)"><div style="margin:0px">#error "UBSan not supported for this platform!"</div><div style="margin:0px">#endif</div>

</div></div></div></blockquote><div><br></div><div>Yes, as I can see ubsan runtime library is currently supported only in CMake build and is built on Linux only.</div></div></blockquote><div><br></div></div></div><div>That's unfortunate that clang try to emit function calls on platforms that does not support it.</div>
</div></div></blockquote><div><br></div><div>Right now, we could just emit calls to @llvm.trap on unsupported platforms, but some of the remaining checks actually need runtime library support. I would prefer to get the runtime working on more platforms, rather than working around its absence.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div>That said, do you need patches for darwin/make integration, or are you already working on it (or planning to do it after usban is done on linux) ?</div>
</div></div></blockquote><div><br></div><div>Patches to support Darwin are very much welcome. I don't have a Darwin machine, so I've not added this support myself.</div></div>