mirror of
https://github.com/apple/swift.git
synced 2026-02-27 18:26:24 +01:00
Evolution: Replace unused --no-backward-deployment flag with --backward-deployment flag
This adds a new mode where we always build the app with the new library, and run it with the old and new library. This is used to test backward deployment of code that uses weak-linked symbols. To ensure that we properly crash if we reference an undefined symbol that is not weak linked, also pass a linker flag to bind symbols eagerly.
This commit is contained in:
24
utils/rth
24
utils/rth
@@ -34,7 +34,7 @@ class ResilienceTest(object):
|
||||
def __init__(self, target_build_swift, target_run, target_codesign,
|
||||
target_nm, tmp_dir, test_dir, test_src, lib_prefix,
|
||||
lib_suffix, additional_compile_flags,
|
||||
no_backward_deployment, no_symbol_diff):
|
||||
backward_deployment, no_symbol_diff):
|
||||
self.target_build_swift = shlex.split(target_build_swift)
|
||||
self.target_run = shlex.split(target_run)
|
||||
self.target_codesign = shlex.split(target_codesign)
|
||||
@@ -55,7 +55,7 @@ class ResilienceTest(object):
|
||||
self.lib_name = self.lib_src_name[:-6]
|
||||
self.lib_src = os.path.join(self.test_dir, 'Inputs', self.lib_src_name)
|
||||
|
||||
self.no_backward_deployment = no_backward_deployment
|
||||
self.backward_deployment = backward_deployment
|
||||
self.no_symbol_diff = no_symbol_diff
|
||||
|
||||
def run(self):
|
||||
@@ -138,6 +138,12 @@ class ResilienceTest(object):
|
||||
|
||||
def compile_main(self):
|
||||
for config in self.config_dir_map:
|
||||
# If we're testing backward deployment, we only want to build
|
||||
# the app against the new version of the library.
|
||||
if self.backward_deployment and \
|
||||
config == "BEFORE":
|
||||
continue
|
||||
|
||||
output_obj = os.path.join(self.config_dir_map[config], 'main.o')
|
||||
compiler_flags = ['-D', config, '-c', self.test_src,
|
||||
'-Xfrontend', '-enable-class-resilience',
|
||||
@@ -153,11 +159,8 @@ class ResilienceTest(object):
|
||||
def configs(self):
|
||||
for config1 in self.config_dir_map:
|
||||
for config2 in self.config_dir_map:
|
||||
# --no-backward-deployment skips testing a new application
|
||||
# linked against an old library.
|
||||
if config1 == "BEFORE" and \
|
||||
config2 == "AFTER" and \
|
||||
self.no_backward_deployment:
|
||||
if self.backward_deployment and \
|
||||
config2 == "BEFORE":
|
||||
continue
|
||||
|
||||
yield (config1, config2)
|
||||
@@ -185,6 +188,9 @@ class ResilienceTest(object):
|
||||
'-o', output_obj
|
||||
]
|
||||
|
||||
if self.is_apple_platform():
|
||||
compiler_flags += ['-Xlinker', '-bind_at_load']
|
||||
|
||||
command = self.target_build_swift + compiler_flags
|
||||
verbose_print_command(command)
|
||||
returncode = subprocess.call(command)
|
||||
@@ -221,7 +227,7 @@ def main():
|
||||
parser.add_argument('--lib-prefix', required=True)
|
||||
parser.add_argument('--lib-suffix', required=True)
|
||||
parser.add_argument('--additional-compile-flags', default='')
|
||||
parser.add_argument('--no-backward-deployment', default=False,
|
||||
parser.add_argument('--backward-deployment', default=False,
|
||||
action='store_true')
|
||||
parser.add_argument('--no-symbol-diff', default=False,
|
||||
action='store_true')
|
||||
@@ -233,7 +239,7 @@ def main():
|
||||
args.t, args.S, args.s, args.lib_prefix,
|
||||
args.lib_suffix,
|
||||
args.additional_compile_flags,
|
||||
args.no_backward_deployment,
|
||||
args.backward_deployment,
|
||||
args.no_symbol_diff)
|
||||
|
||||
return resilience_test.run()
|
||||
|
||||
Reference in New Issue
Block a user