Skip to content

Commit 74c6aaf

Browse files
committed
[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 llvm-svn: 344434
1 parent bc50455 commit 74c6aaf

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

compiler-rt/test/asan/lit.cfg

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,17 @@ config.substitutions.append( ("%clang ", build_invocation(target_cflags)) )
101101
config.substitutions.append( ("%clangxx ", build_invocation(target_cxxflags)) )
102102
config.substitutions.append( ("%clang_asan ", build_invocation(clang_asan_cflags)) )
103103
config.substitutions.append( ("%clangxx_asan ", build_invocation(clang_asan_cxxflags)) )
104-
config.substitutions.append( ("%shared_libasan", "libclang_rt.asan%s.so" % config.target_suffix))
105104
if config.asan_dynamic:
105+
if config.host_os == 'Linux':
106+
shared_libasan_path = os.path.join(config.compiler_rt_libdir, "libclang_rt.asan{}.so".format(config.target_suffix))
107+
elif config.host_os == 'Darwin':
108+
shared_libasan_path = os.path.join(config.compiler_rt_libdir, 'libclang_rt.asan_{}_dynamic.dylib'.format(config.apple_platform))
109+
else:
110+
lit_config.warning('%shared_libasan substitution not set but dynamic ASan is available.')
111+
shared_libasan_path = None
112+
113+
if shared_libasan_path is not None:
114+
config.substitutions.append( ("%shared_libasan", shared_libasan_path) )
106115
config.substitutions.append( ("%clang_asan_static ", build_invocation(clang_asan_static_cflags)) )
107116
config.substitutions.append( ("%clangxx_asan_static ", build_invocation(clang_asan_static_cxxflags)) )
108117

0 commit comments

Comments
 (0)