<div dir="ltr">Does LSan have an LD_PRELOAD mode that works without ASan? Should this detect that? If so, this should be a runtime thing, something like a weak declaration that we use to detect whether LSan is present, and act accordingly.</div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Dec 26, 2013 at 2:39 AM, Kostya Serebryany <span dir="ltr"><<a href="mailto:kcc@google.com" target="_blank">kcc@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi chandlerc, dblaikie,<br>
<br>
Disobey --disable-free flag if LEAK_SANITIZER macro is defined, for PR18320.<br>
This way the build for LeakSanitizer will need to use -DCMAKE_CXX_FLAGS=-DLEAK_SANITIZER<br>
<br>
Alternatives:<br>
1. use #if __has_feature(address_sanitizer). This will solve our immediate need<br>
to make asan+lsan bootstrap clean, but will not allow to run lsan-only (w/o asan).<br>
<br>
2. Check if we have lsan at run-time instead of build time.<br>
This may actually be nicer, but the only good way to do that that I know of<br>
is to use weak functions, which will require more ifdefs.<br>
<br>
3. use getenv("CLANG_IS_RUNNING_UNDER_LEAK_DETECTOR").<br>
<br>
4. probably various others, suggestions are welcome.<br>
<br>
<a href="http://llvm-reviews.chandlerc.com/D2475" target="_blank">http://llvm-reviews.chandlerc.com/D2475</a><br>
<br>
Files:<br>
lib/Frontend/CompilerInvocation.cpp<br>
<br>
Index: lib/Frontend/CompilerInvocation.cpp<br>
===================================================================<br>
--- lib/Frontend/CompilerInvocation.cpp<br>
+++ lib/Frontend/CompilerInvocation.cpp<br>
@@ -283,6 +283,16 @@<br>
return Success;<br>
}<br>
<br>
+static bool LeakDetectionIsOn() {<br>
+#ifdef LEAK_SANITIZER<br>
+ // If we want to detect leaks with LeakSanitizer,<br>
+ // -DLEAK_SANITIZER should be passed at compile time.<br>
+ return 1;<br>
+#else<br>
+ return 0;<br>
+#endif<br>
+}<br>
+<br>
static bool ParseMigratorArgs(MigratorOptions &Opts, ArgList &Args) {<br>
Opts.NoNSAllocReallocError = Args.hasArg(OPT_migrator_no_nsalloc_error);<br>
Opts.NoFinalizeRemoval = Args.hasArg(OPT_migrator_no_finalize_removal);<br>
@@ -368,7 +378,8 @@<br>
Opts.CodeModel = Args.getLastArgValue(OPT_mcode_model);<br>
Opts.DebugPass = Args.getLastArgValue(OPT_mdebug_pass);<br>
Opts.DisableFPElim = Args.hasArg(OPT_mdisable_fp_elim);<br>
- Opts.DisableFree = Args.hasArg(OPT_disable_free);<br>
+ Opts.DisableFree =<br>
+ LeakDetectionIsOn() ? false : Args.hasArg(OPT_disable_free);<br>
Opts.DisableTailCalls = Args.hasArg(OPT_mdisable_tail_calls);<br>
Opts.FloatABI = Args.getLastArgValue(OPT_mfloat_abi);<br>
Opts.HiddenWeakVTables = Args.hasArg(OPT_fhidden_weak_vtables);<br>
@@ -742,7 +753,8 @@<br>
Diags.Report(diag::err_drv_invalid_value)<br>
<< A->getAsString(Args) << A->getValue();<br>
}<br>
- Opts.DisableFree = Args.hasArg(OPT_disable_free);<br>
+ Opts.DisableFree =<br>
+ LeakDetectionIsOn() ? false : Args.hasArg(OPT_disable_free);<br>
<br>
Opts.OutputFile = Args.getLastArgValue(OPT_o);<br>
Opts.Plugins = Args.getAllArgValues(OPT_load);<br>
<br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br></div>