On Sun, May 19, 2013 at 7:53 AM, Peter Collingbourne <span dir="ltr"><<a href="mailto:peter@pcc.me.uk" target="_blank">peter@pcc.me.uk</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 class="HOEnZb"><div class="h5">On Sun, May 19, 2013 at 07:04:39AM -0700, David Blaikie wrote:<br>
> On May 19, 2013 6:31 AM, "Peter Collingbourne" <<a href="mailto:peter@pcc.me.uk">peter@pcc.me.uk</a>> wrote:<br>
> ><br>
> > On Fri, May 17, 2013 at 11:57:24PM -0000, David Blaikie wrote:<br>
> > > Author: dblaikie<br>
> > > Date: Fri May 17 18:57:24 2013<br>
> > > New Revision: 182177<br>
> > ><br>
> > > URL: <a href="http://llvm.org/viewvc/llvm-project?rev=182177&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=182177&view=rev</a><br>
> > > Log:<br>
> > > Fix the UBSan CMake build broken in r182118<br>
> > ><br>
> > > Modified:<br>
> > >     compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt<br>
> > ><br>
> > > Modified: compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt<br>
> > > URL:<br>
> <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt?rev=182177&r1=182176&r2=182177&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt?rev=182177&r1=182176&r2=182177&view=diff</a><br>

> > ><br>
> ==============================================================================<br>
> > > --- compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt (original)<br>
> > > +++ compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt Fri May 17<br>
> 18:57:24 2013<br>
> > > @@ -83,7 +83,9 @@ else()<br>
> > >      add_compiler_rt_object_library(RTSanitizerCommonLibc ${arch}<br>
> > >        SOURCES ${SANITIZER_LIBCDEP_SOURCES} CFLAGS ${SANITIZER_CFLAGS})<br>
> > >      add_compiler_rt_static_runtime(clang_rt.san-${arch} ${arch}<br>
> > > -      SOURCES ${SANITIZER_SOURCES} CFLAGS ${SANITIZER_CFLAGS})<br>
> > > +      SOURCES ${SANITIZER_SOURCES}<br>
> > > +      $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}> CFLAGS<br>
> > > +      ${SANITIZER_CFLAGS})<br>
> ><br>
> > So it looks like we're building most of sanitizer_common's<br>
> > objects twice here.  Is there any reason why we shouldn't use<br>
> > RTSanitizerCommon's objects when building clang_rt.san?<br>
><br>
> My very limited understanding is that this is using the objects<br>
> (target_objects) rather than the source, but I admit I haven't spent<br>
> much/any time understanding the cmake build system or our use of it (& had<br>
> some help from Richard smith with this change).<br>
><br>
> If you have better ideas/understanding about how to do this, I'm happy to<br>
> defer to that.<br>
<br>
</div></div>Well, we're using the target objects from RTSanitizerCommonLibc, but<br>
RTSanitizerCommon (where the majority of sanitizer_common lives)<br>
objects are rebuilt because we use ${SANITIZER_SOURCES} to refer to<br>
the source files.  I think we ought to be able to use this in place<br>
of the add_compiler_rt_static_runtime command above:<br>
<br>
add_compiler_rt_static_runtime(clang_rt.san-${arch} ${arch}<br>
  SOURCES $<TARGET_OBJECTS:RTSanitizerCommon.${arch}><br>
<div class="im">  $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}> CFLAGS<br>
</div>  ${SANITIZER_CFLAGS})<br>
<br>
But first, I'd like to ask Richard why he used ${SANITIZER_SOURCES}<br>
when he introduced clang_rt.san in r177606.<br></blockquote><div><br></div><div>Only because I wasn't aware of the alternative. Fixed in r182218, thanks.</div></div>