[PATCH] Optional support for dynamic Asan runtime

Yury Gribov tetra2005 at gmail.com
Wed Mar 26 09:28:49 PDT 2014



================
Comment at: lib/asan/asan_linux.cc:100
@@ +99,3 @@
+#if ASAN_DYNAMIC
+    badsym = "__asan_static";
+#else
----------------
Alexey Samsonov wrote:
> Weird indentation.
Yeah, moved from other place.

================
Comment at: lib/asan/asan_linux.cc:105
@@ +104,3 @@
+  if (dlsym(RTLD_DEFAULT, badsym)) {
+    Report("Your application is linked against "
+      "incompatible ASan runtimes.\n");
----------------
Alexey Samsonov wrote:
> Consider running tools/clang/tools/clang-format/clang-format-diff.py on your patch.
Ok, good to know.

================
Comment at: lib/asan/asan_malloc_linux.cc:115
@@ +114,3 @@
+  if (!asan_inited)
+    return AsanPreinitAlloc(size);
+  if (AsanIsPreinitAllocated(ptr))
----------------
Alexey Samsonov wrote:
> This is just wrong. Is realloc() called before asan_inited or on PreinitAllocated pointers?
AFAIR realloc() is called before asan_inited on PreinitAlloc-ated pointers (dlerror calls it to allocate string). So what's wrong exactly?

================
Comment at: test/asan/lit.cfg:43
@@ +42,3 @@
+if config.asan_dynamic:
+  clang_asan_static_cflags = list(clang_asan_cflags)
+  clang_asan_cflags.append('-shared-libasan')
----------------
Alexey Samsonov wrote:
> Why do you need this?
To make a copy of clang_asan_cflags (they are changed below).

================
Comment at: test/asan/lit.cfg:45
@@ +44,3 @@
+  clang_asan_cflags.append('-shared-libasan')
+  clang_asan_static_cxxflags = list(clang_asan_cxxflags)
+  clang_asan_cxxflags.append('-shared-libasan')
----------------
Alexey Samsonov wrote:
> and this?
Likewise.

================
Comment at: cmake/Modules/AddCompilerRT.cmake:75
@@ +74,3 @@
+  # Add installation command.
+  install(TARGETS ${name}
+    ARCHIVE DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
----------------
Alexey Samsonov wrote:
> Is it possible to use
>   install(TARGETS ${name}
>     ARCHIVE DESTINATION ...
>     LIBRARY DESTINATION ...)
> in the add_compiler_rt_runtime above and get rid of add_compiler_rt_{static,shared}_runtime rules?
Yeah, this failed with separate installs but cumulative one seems to work. Renaming add_compiler_rt_static_runtime is going to cause some churn though...

================
Comment at: lib/asan/CMakeLists.txt:57
@@ +56,3 @@
+
+set(ASAN_DYNAMIC_LIBS stdc++)
+append_if(COMPILER_RT_HAS_LIBPTHREAD pthread ASAN_DYNAMIC_LIBS)
----------------
Alexey Samsonov wrote:
>   set(ASAN_DYNAMIC_LIBS stdc++ c m)
I wonder whether I need 'c' at all.


http://llvm-reviews.chandlerc.com/D3042



More information about the llvm-commits mailing list