[compiler-rt] r344434 - [lit] Support the `%shared_libasan` lit substitution on Apple platforms.

Dan Liew via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 12 16:36:23 PDT 2018


Author: delcypher
Date: Fri Oct 12 16:36:23 2018
New Revision: 344434

URL: http://llvm.org/viewvc/llvm-project?rev=344434&view=rev
Log:
[lit] Support the `%shared_libasan` lit substitution on Apple platforms.

Summary:
The previous value looks Linux specific so that has been guarded with
the host OS being Linux.

On Apple platforms `%shared_libasan` expands to the absolute path of the
ASan dylib.

Previously on Linux `%shared_libasan` expanded to just the file name
of the shared library rather than the absolute path to the library.
This is likely a bug because it would rely on the OS's dynamic linker
to find the shared library which could accidentally pick up a system copy
rather than the shared library that was just built.

For other platforms we emit a warning if `config.asan_dynamic` is true.

This patch also only defines the substitution when `config.asan_dynamic`
is true because using this substitution only makes sense when the
dynamic library is available.

Reviewers: kubamracek, george.karpenkov, mgorny, phosek, etienneb, samsonov, kcc

Subscribers: #sanitizers, llvm-commits

Differential Revision: https://reviews.llvm.org/D53111

Modified:
    compiler-rt/trunk/test/asan/lit.cfg

Modified: compiler-rt/trunk/test/asan/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/lit.cfg?rev=344434&r1=344433&r2=344434&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/lit.cfg (original)
+++ compiler-rt/trunk/test/asan/lit.cfg Fri Oct 12 16:36:23 2018
@@ -101,8 +101,17 @@ config.substitutions.append( ("%clang ",
 config.substitutions.append( ("%clangxx ", build_invocation(target_cxxflags)) )
 config.substitutions.append( ("%clang_asan ", build_invocation(clang_asan_cflags)) )
 config.substitutions.append( ("%clangxx_asan ", build_invocation(clang_asan_cxxflags)) )
-config.substitutions.append( ("%shared_libasan", "libclang_rt.asan%s.so" % config.target_suffix))
 if config.asan_dynamic:
+  if config.host_os == 'Linux':
+    shared_libasan_path = os.path.join(config.compiler_rt_libdir, "libclang_rt.asan{}.so".format(config.target_suffix))
+  elif config.host_os == 'Darwin':
+    shared_libasan_path = os.path.join(config.compiler_rt_libdir, 'libclang_rt.asan_{}_dynamic.dylib'.format(config.apple_platform))
+  else:
+    lit_config.warning('%shared_libasan substitution not set but dynamic ASan is available.')
+    shared_libasan_path = None
+
+  if shared_libasan_path is not None:
+    config.substitutions.append( ("%shared_libasan", shared_libasan_path) )
   config.substitutions.append( ("%clang_asan_static ", build_invocation(clang_asan_static_cflags)) )
   config.substitutions.append( ("%clangxx_asan_static ", build_invocation(clang_asan_static_cxxflags)) )
 




More information about the llvm-commits mailing list