[compiler-rt] r301617 - [asan] Add a compilation wrapper that codesigns shared libraries to support iOS simulator testing
Kuba Mracek via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 27 21:55:35 PDT 2017
Author: kuba.brecka
Date: Thu Apr 27 23:55:35 2017
New Revision: 301617
URL: http://llvm.org/viewvc/llvm-project?rev=301617&view=rev
Log:
[asan] Add a compilation wrapper that codesigns shared libraries to support iOS simulator testing
Tests that run on the iOS simulator require the dlopen'd dylibs are codesigned. This patch adds the "iossim_compile.py" wrapper that codesigns any produces dylib.
Differential Revision: https://reviews.llvm.org/D32561
Added:
compiler-rt/trunk/test/sanitizer_common/ios_commands/iossim_compile.py (with props)
Modified:
compiler-rt/trunk/test/asan/lit.cfg
compiler-rt/trunk/test/lit.common.cfg
Modified: compiler-rt/trunk/test/asan/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/lit.cfg?rev=301617&r1=301616&r2=301617&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/lit.cfg (original)
+++ compiler-rt/trunk/test/asan/lit.cfg Thu Apr 27 23:55:35 2017
@@ -108,14 +108,12 @@ if platform.system() == 'Windows':
asan_lit_source_dir = get_required_attr(config, "asan_lit_source_dir")
if config.android == "1":
config.available_features.add('android')
- clang_wrapper = os.path.join(asan_lit_source_dir,
- "android_commands", "android_compile.py") + " "
+ compile_wrapper = os.path.join(asan_lit_source_dir, "android_commands", "android_compile.py") + " "
else:
config.available_features.add('not-android')
- clang_wrapper = ""
def build_invocation(compile_flags):
- return " " + " ".join([clang_wrapper, config.clang] + compile_flags) + " "
+ return " " + " ".join([config.compile_wrapper, config.clang] + compile_flags) + " "
# Clang driver link 'x86' (i686) architecture to 'i386'.
target_arch = config.target_arch
Modified: compiler-rt/trunk/test/lit.common.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lit.common.cfg?rev=301617&r1=301616&r2=301617&view=diff
==============================================================================
--- compiler-rt/trunk/test/lit.common.cfg (original)
+++ compiler-rt/trunk/test/lit.common.cfg Thu Apr 27 23:55:35 2017
@@ -97,7 +97,10 @@ config.substitutions.append(
if config.emulator:
config.substitutions.append( ('%run', config.emulator) )
config.substitutions.append( ('%env ', "env ") )
+ config.compile_wrapper = ""
elif config.ios:
+ config.available_features.add('ios')
+
device_id_env = "SANITIZER_IOSSIM_TEST_DEVICE_IDENTIFIER" if config.iossim else "SANITIZER_IOS_TEST_DEVICE_IDENTIFIER"
if device_id_env in os.environ: config.environment[device_id_env] = os.environ[device_id_env]
ios_commands_dir = os.path.join(config.compiler_rt_src_root, "test", "sanitizer_common", "ios_commands")
@@ -105,9 +108,12 @@ elif config.ios:
config.substitutions.append(('%run', run_wrapper))
env_wrapper = os.path.join(ios_commands_dir, "iossim_env.py" if config.iossim else "ios_env.py")
config.substitutions.append(('%env ', env_wrapper + " "))
+ compile_wrapper = os.path.join(ios_commands_dir, "iossim_compile.py" if config.iossim else "ios_compile.py")
+ config.compile_wrapper = compile_wrapper
else:
config.substitutions.append( ('%run', "") )
config.substitutions.append( ('%env ', "env ") )
+ config.compile_wrapper = ""
# Define CHECK-%os to check for OS-dependent output.
config.substitutions.append( ('CHECK-%os', ("CHECK-" + config.host_os)))
Added: compiler-rt/trunk/test/sanitizer_common/ios_commands/iossim_compile.py
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/ios_commands/iossim_compile.py?rev=301617&view=auto
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/ios_commands/iossim_compile.py (added)
+++ compiler-rt/trunk/test/sanitizer_common/ios_commands/iossim_compile.py Thu Apr 27 23:55:35 2017
@@ -0,0 +1,32 @@
+#!/usr/bin/python
+
+import os, sys, subprocess
+
+output = None
+output_type = 'executable'
+
+args = sys.argv[1:]
+while args:
+ arg = args.pop(0)
+ if arg == '-shared':
+ output_type = 'shared'
+ elif arg == '-dynamiclib':
+ output_type = 'dylib'
+ elif arg == '-c':
+ output_type = 'object'
+ elif arg == '-S':
+ output_type = 'assembly'
+ elif arg == '-o':
+ output = args.pop(0)
+
+if output == None:
+ print "No output file name!"
+ sys.exit(1)
+
+ret = subprocess.call(sys.argv[1:])
+if ret != 0:
+ sys.exit(ret)
+
+# If we produce a dylib, ad-hoc sign it.
+if output_type in ['shared', 'dylib']:
+ ret = subprocess.call(["codesign", "-s", "-", output])
Propchange: compiler-rt/trunk/test/sanitizer_common/ios_commands/iossim_compile.py
------------------------------------------------------------------------------
svn:executable = *
More information about the llvm-commits
mailing list