<div dir="ltr">Thanks for the explanations! (it was worth asking) <div><br></div><div>I do want to build libFuzzer itself (and its tests) using the <span style="font-size:12.8px">just-built clang. So, </span><span style="font-size:12.8px">llvm/runtimes then. </span></div><div><span style="font-size:12.8px">I'd name the directory </span><span style="font-size:12.8px">llvm/runtimes/libFuzzer, if possible (the old path was lib/Fuzzer which is how the tool got it's name, actually)</span></div><div><span style="font-size:12.8px">George, would you like to send the change for review? </span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">--kcc</span></div><div><br></div><div><span style="font-size:12.8px"><br></span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 9, 2017 at 2:37 PM, Chris Bieneman <span dir="ltr"><<a href="mailto:cbieneman@apple.com" target="_blank">cbieneman@apple.com</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><span class=""><blockquote type="cite"><div>On May 9, 2017, at 2:19 PM, George Karpenkov <<a href="mailto:ekarpenkov@apple.com" target="_blank">ekarpenkov@apple.com</a>> wrote:</div><br class="m_-5671233790260223790Apple-interchange-newline"><div><div style="word-wrap:break-word"><div>+Chris.</div><div><br></div><div>My understanding was that it is technically impossible for things in “lib”, as they are built first, and there’s no way to tell them to do that before “clang”.</div><div>I’m not a CMake expert, and I might be wrong.</div></div></div></blockquote><div><br></div></span><div>It is not impossible, it would just involve excessive hacks. Since it seems like this isn't a short-term solution we're talking about I am very opposed to throwing hacks into the build system. I'd rather we actually fix the problem(s). More below.</div><span class=""><br><blockquote type="cite"><div><div style="word-wrap:break-word"><br><div><blockquote type="cite"><div>On May 9, 2017, at 2:15 PM, Kostya Serebryany <<a href="mailto:kcc@google.com" target="_blank">kcc@google.com</a>> wrote:</div><br class="m_-5671233790260223790Apple-interchange-newline"><div><br class="m_-5671233790260223790Apple-interchange-newline"><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div class="gmail_quote" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">On Tue, May 9, 2017 at 1:56 PM, George Karpenkov<span class="m_-5671233790260223790Apple-converted-space"> </span><span dir="ltr"><<a href="mailto:ekarpenkov@apple.com" target="_blank">ekarpenkov@apple.<wbr>com</a>></span><span class="m_-5671233790260223790Apple-converted-space"> </span>wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><div>Again, after offline conversation with Chris Bieneman:</div><div><br></div><div> - move to compiler-rt would be too complicated due to change in licenses</div><div> - it would make much more sense to move to “tools” folder instead, for the following reasons:</div><div>   <span class="m_-5671233790260223790Apple-converted-space"> </span>* conceptually, it’s a tool, not a library</div><div>   <span class="m_-5671233790260223790Apple-converted-space"> </span>* all other projects in “lib” depend on LLVM and can not build without LLVM, libFuzzer does not</div><div>   <span class="m_-5671233790260223790Apple-converted-space"> </span>* practically speaking, CMake has no way of knowing whether Clang is being built when</div><div>     <span class="m_-5671233790260223790Apple-converted-space"> </span>“lib” is compiled, yet it does know for projects in tools.</div><div><br></div><div>Using a freshly built clang for projects in “tools” is embarrassingly easy and only requires a couple of lines</div><div>of configuration change.</div><div><br></div><div>Kostya, what about moving to “tools” then?</div></div></blockquote><div><br></div><div>Well, ok, this sounds cool. </div><div>But can we make one more step and try to preserve the code where it is, for the sake of compatibility? </div></div></div></blockquote></div></div></div></blockquote><div><br></div></span><div>Please no. This code doesn't actually belong in lib, it has never fit the model of an LLVM library, we really need to pull it out of there. </div><span class=""><br><blockquote type="cite"><div><div style="word-wrap:break-word"><div><blockquote type="cite"><div><div class="gmail_quote" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div>E.g. can we have the CMake in tools while still keeping the code in lib? </div></div></div></blockquote></div></div></div></blockquote><div><br></div></span>Could we contrive a hack in the build system to do it? Yes, but I will fight violently against allowing that change into the build system because the right answer here is to move the code.</div><div><span class=""><br><blockquote type="cite"><div><div style="word-wrap:break-word"><div><blockquote type="cite"><div><div class="gmail_quote" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div>Or a link of some kind?</div></div></div></blockquote></div></div></div></blockquote><div><br></div></span><div>Links are incredibly fragile on Windows, and they trip up a lot of SCM tools. We have one in LLDB's repo that causes me nothing but problems, so I am also strongly opposed to that.</div><span class=""><br><blockquote type="cite"><div><div style="word-wrap:break-word"><div><blockquote type="cite"><div><div class="gmail_quote" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div><br></div><div>My worry is that there are already quite a few places that know where libFuzzer code is, </div><div>and I don't control all of them. </div></div></div></blockquote></div></div></div></blockquote><div><br></div></span><div>Downstream clients will have to update. That is kinda how these things work, I can't imagine re-pointing an SCM checkout being a huge burden.</div><span class=""><br><blockquote type="cite"><div><div style="word-wrap:break-word"><div><blockquote type="cite"><div><div class="gmail_quote" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div><br></div><div>And, finally, I really don't get why we can do something in tools and can't do the same in lib. </div><div>Or we simply don't want to do it to keep things simple? </div></div></div></blockquote></div></div></div></blockquote><div><br></div></span><div>Not all functionality in CMake is order-independent. Specifically the detection of targets is not. In order to support what you're trying to do you are going to change behavior based on the presence of the clang target. Which means the clang target must be added before your CMake is processed.</div><div><br></div><div>To support this our build system has strict ordering requirements such that things in lib cannot depend on things in tools. If you need to depend on clang, you need to not be in lib.</div><div><br></div><div>Also, generally speaking Fuzzer is a library under lib that also has nested tests, which is *not* how the lib directory is supposed to be structured. It never should have been allowed to be structured like that. If you want the tests next to the library, it is a tool or a runtime, but not a lib.</div><div><br></div><div>As I see there are two options to move forward with, and it really depends on how you intend to use the just-built clang.</div><div><br></div><div>(1) If you want to use just-built clang to build libFuzzer and its tests, it should be a runtime.</div><div>(2) If you want to use just-built clang to only build libFuzzer's tests, it should be a tool.</div><div><br></div><div>I think that since it is a runtime library, it should be a runtime, and I expect it would mostly work to just copy the Fuzzer directory into llvm/runtimes.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>-Chris</div></font></span><span class=""><br><blockquote type="cite"><div><div style="word-wrap:break-word"><div><blockquote type="cite"><div><div class="gmail_quote" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div><br></div><div>--kcc </div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><div><div class="m_-5671233790260223790h5"><br><div><blockquote type="cite"><div>On May 9, 2017, at 11:07 AM, Dan Liew <<a href="mailto:dan@su-root.co.uk" target="_blank">dan@su-root.co.uk</a>> wrote:</div><br class="m_-5671233790260223790m_877734713401612435Apple-interchange-newline"><div><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">On 9 May 2017 at 18:55, Kostya Serebryany <</span><a href="mailto:kcc@google.com" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">kcc@google.com</a><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">> wrote:</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><blockquote type="cite" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br><br>On Tue, May 9, 2017 at 10:23 AM, Dan Liew <<a href="mailto:dan@su-root.co.uk" target="_blank">dan@su-root.co.uk</a>> wrote:<br><blockquote type="cite"><br><blockquote type="cite">Does anyone see good reasons why libFuzzer should remain in llvm repo<br>(as<br>opposed to moving it to compiler-rt)?<br></blockquote><br>Does moving LibFuzzer to compiler-rt imply that it is compiled as part<br>of compiler-rt and shipped with it?<br><br>How does that fit with LibFuzzer's model of allowing the user to<br>provide their own `main()`.<br></blockquote><br><br>libFuzzer doesn't allow users to use their own main (not any more).<br>Although I am not sure how that's related to moving libFuzzer somewhere.<br></blockquote><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">Oops. That shows how long it's been since I looked at the source code.</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">It was related in that if LibFuzzer was shipped as part of compiler-rt</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">I presumed we would need to supply both libraries to end users.</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">Given that this feature was removed it is a non-issue.</span></div></blockquote></div></div></div></div></blockquote></div></div></blockquote></div><br></div></div></blockquote></span></div><br></div></blockquote></div><br></div>