[NFC] Generalize flags for linking in shared objects in compiler-rt tests to support using multiple shared objects at once

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

llvm-svn: 334765
This commit is contained in:
George Karpenkov 2018-06-14 20:29:47 +00:00
parent 1b465767d6
commit 320c690df3
1 changed files with 21 additions and 17 deletions

View File

@ -308,19 +308,28 @@ if config.host_os == 'Darwin' and config.ios and not config.iossim:
lit_config.warning("iOS device test cases being run sequentially")
lit_config.parallelism_groups["darwin-ios-device-sanitizer"] = 1
# Multiple substitutions are necessary to support multiple shared objects used
# at once.
# Note that substitutions with numbers have to be defined first to avoid
# being subsumed by substitutions with smaller postfix.
for postfix in ["2", "1", ""]:
if config.host_os == 'Darwin':
config.substitutions.append( ("%ld_flags_rpath_exe" + postfix, '-Wl,-rpath,@executable_path/ %dynamiclib' + postfix) )
config.substitutions.append( ("%ld_flags_rpath_so" + postfix, '-install_name @rpath/`basename %dynamiclib{}`'.format(postfix)) )
elif config.host_os == 'FreeBSD' or config.host_os == 'NetBSD':
config.substitutions.append( ("%ld_flags_rpath_exe" + postfix, "-Wl,-z,origin -Wl,-rpath,\$ORIGIN -L%T -l%xdynamiclib_namespec" + postfix) )
config.substitutions.append( ("%ld_flags_rpath_so" + postfix, '') )
elif config.host_os == 'Linux':
config.substitutions.append( ("%ld_flags_rpath_exe" + postfix, "-Wl,-rpath,\$ORIGIN -L%T -l%xdynamiclib_namespec" + postfix) )
config.substitutions.append( ("%ld_flags_rpath_so" + postfix, '') )
elif config.host_os == 'SunOS':
config.substitutions.append( ("%ld_flags_rpath_exe" + postfix, "-Wl,-R\$ORIGIN -L%T -l%xdynamiclib_namespec" + postfix) )
config.substitutions.append( ("%ld_flags_rpath_so" + postfix, '') )
if config.host_os == 'Darwin':
config.substitutions.append( ("%ld_flags_rpath_exe", '-Wl,-rpath,@executable_path/ %dynamiclib') )
config.substitutions.append( ("%ld_flags_rpath_so", '-install_name @rpath/`basename %dynamiclib`') )
elif config.host_os == 'FreeBSD' or config.host_os == 'NetBSD':
config.substitutions.append( ("%ld_flags_rpath_exe", "-Wl,-z,origin -Wl,-rpath,\$ORIGIN -L%T -l%xdynamiclib_namespec") )
config.substitutions.append( ("%ld_flags_rpath_so", '') )
elif config.host_os == 'Linux':
config.substitutions.append( ("%ld_flags_rpath_exe", "-Wl,-rpath,\$ORIGIN -L%T -l%xdynamiclib_namespec") )
config.substitutions.append( ("%ld_flags_rpath_so", '') )
elif config.host_os == 'SunOS':
config.substitutions.append( ("%ld_flags_rpath_exe", "-Wl,-R\$ORIGIN -L%T -l%xdynamiclib_namespec") )
config.substitutions.append( ("%ld_flags_rpath_so", '') )
# Must be defined after the substitutions that use %dynamiclib.
config.substitutions.append( ("%dynamiclib" + postfix, '%T/%xdynamiclib_filename' + postfix) )
config.substitutions.append( ("%xdynamiclib_filename" + postfix, 'lib%xdynamiclib_namespec{}.so'.format(postfix)) )
config.substitutions.append( ("%xdynamiclib_namespec", '%basename_t.dynamic') )
# Provide a substituion that can be used to tell Clang to use a static libstdc++.
# The substitution expands to nothing on non Linux platforms.
@ -330,11 +339,6 @@ if config.host_os == 'Linux':
else:
config.substitutions.append( ("%linux_static_libstdcplusplus", "") )
# Must be defined after the substitutions that use %dynamiclib.
config.substitutions.append( ("%dynamiclib", '%T/%xdynamiclib_filename') )
config.substitutions.append( ("%xdynamiclib_filename", 'lib%xdynamiclib_namespec.so') )
config.substitutions.append( ("%xdynamiclib_namespec", '%basename_t.dynamic') )
config.default_sanitizer_opts = []
if config.host_os == 'Darwin':
# On Darwin, we default to `abort_on_error=1`, which would make tests run