<div class="gmail_quote">On Tue, May 29, 2012 at 10:28 AM, Dmitry Vyukov <span dir="ltr"><<a href="mailto:dvyukov@google.com" target="_blank">dvyukov@google.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="im"><div class="gmail_quote">On Tue, May 29, 2012 at 9:16 PM, Chandler Carruth <span dir="ltr"><<a href="mailto:chandlerc@google.com" target="_blank">chandlerc@google.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="gmail_quote"><div><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>> How do I disable that feature? I've tried -fno-builtin and/or -ffreestanding<br>
> with no success.<br>
</div>clang (as well as gcc) requires that freestanding environment provides<br>
memcpy, memmove, memset and memcmp.<br>
<br>
PS: Consider emailing cfedev, not llvmdev.<br></blockquote><div><br></div></div><div>Hi,</div><div><br></div><div>Thanks. I've emailed cfe-dev.</div><div>We absolutely need clang/llvm to not insert the calls into our code.</div>
</div></blockquote><div><br></div></div></div><div>This really isn't possible.</div><div><br></div><div>The C++ standard essentially requires the compiler to insert calls to memcpy for certain code patterns.</div><div>
<br></div><div>
What do you really need here? Clearly you have some way of handling when the user writes memcpy; what is different about Clang or LLVM inserting memcpy? </div></div>
</blockquote></div><br></div><div>I need it for ThreadSanitizer runtime. In particular</div><div><a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc?view=annotate" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc?view=annotate</a></div>
line 1238. But I had similar problems in other places.<div><div>Both memory access processing and signal handling are quite tricky, we can't allow recursion.</div></div></blockquote><div><br></div><div>The first thing to think about is that you *do* need to use -fno-builtin / -ffreestanding when compiling the runtime because it provides its own implementations of memcpy.</div>
<div><br></div><div>The second is that there is no way to write fully generic C++ code w/o inserting calls to memcpy. =/ If you are writing your memcpy implementation, you'll have to go to great lengths to use C constructs that are guaranteed to not cause this behavior, or to manually call an un-instrumented memcpy implementation. I don't know of any easy ways around this. </div>
</div>