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

George Karpenkov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 14 13:34:13 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL334765: [NFC] Generalize flags for linking in shared objects in compiler-rt tests to… (authored by george.karpenkov, committed by ).
Herald added subscribers: llvm-commits, delcypher.

Changed prior to commit:
  https://reviews.llvm.org/D48156?vs=151293&id=151416#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D48156

Files:
  compiler-rt/trunk/test/lit.common.cfg


Index: compiler-rt/trunk/test/lit.common.cfg
===================================================================
--- compiler-rt/trunk/test/lit.common.cfg
+++ compiler-rt/trunk/test/lit.common.cfg
@@ -308,19 +308,28 @@
   lit_config.warning("iOS device test cases being run sequentially")
   lit_config.parallelism_groups["darwin-ios-device-sanitizer"] = 1
 
-
-if config.host_os == 'Darwin':
-  config.substitutions.append( ("%ld_flags_rpath_exe", '-Wl,-rpath, at 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", '') )
+# 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, at 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, '') )
+
+  # 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 @@
 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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48156.151416.patch
Type: text/x-patch
Size: 3637 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180614/73defbc2/attachment.bin>


More information about the llvm-commits mailing list