Skip to content

Commit ac32948

Browse files
committed
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.
1 parent 738af9f commit ac32948

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

utils/rth

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class ResilienceTest(object):
3434
def __init__(self, target_build_swift, target_run, target_codesign,
3535
target_nm, tmp_dir, test_dir, test_src, lib_prefix,
3636
lib_suffix, additional_compile_flags,
37-
no_backward_deployment, no_symbol_diff):
37+
backward_deployment, no_symbol_diff):
3838
self.target_build_swift = shlex.split(target_build_swift)
3939
self.target_run = shlex.split(target_run)
4040
self.target_codesign = shlex.split(target_codesign)
@@ -55,7 +55,7 @@ class ResilienceTest(object):
5555
self.lib_name = self.lib_src_name[:-6]
5656
self.lib_src = os.path.join(self.test_dir, 'Inputs', self.lib_src_name)
5757

58-
self.no_backward_deployment = no_backward_deployment
58+
self.backward_deployment = backward_deployment
5959
self.no_symbol_diff = no_symbol_diff
6060

6161
def run(self):
@@ -138,6 +138,12 @@ class ResilienceTest(object):
138138

139139
def compile_main(self):
140140
for config in self.config_dir_map:
141+
# If we're testing backward deployment, we only want to build
142+
# the app against the new version of the library.
143+
if self.backward_deployment and \
144+
config == "BEFORE":
145+
continue
146+
141147
output_obj = os.path.join(self.config_dir_map[config], 'main.o')
142148
compiler_flags = ['-D', config, '-c', self.test_src,
143149
'-Xfrontend', '-enable-class-resilience',
@@ -153,11 +159,8 @@ class ResilienceTest(object):
153159
def configs(self):
154160
for config1 in self.config_dir_map:
155161
for config2 in self.config_dir_map:
156-
# --no-backward-deployment skips testing a new application
157-
# linked against an old library.
158-
if config1 == "BEFORE" and \
159-
config2 == "AFTER" and \
160-
self.no_backward_deployment:
162+
if self.backward_deployment and \
163+
config2 == "BEFORE":
161164
continue
162165

163166
yield (config1, config2)
@@ -185,6 +188,9 @@ class ResilienceTest(object):
185188
'-o', output_obj
186189
]
187190

191+
if self.is_apple_platform():
192+
compiler_flags += ['-Xlinker', '-bind_at_load']
193+
188194
command = self.target_build_swift + compiler_flags
189195
verbose_print_command(command)
190196
returncode = subprocess.call(command)
@@ -221,7 +227,7 @@ def main():
221227
parser.add_argument('--lib-prefix', required=True)
222228
parser.add_argument('--lib-suffix', required=True)
223229
parser.add_argument('--additional-compile-flags', default='')
224-
parser.add_argument('--no-backward-deployment', default=False,
230+
parser.add_argument('--backward-deployment', default=False,
225231
action='store_true')
226232
parser.add_argument('--no-symbol-diff', default=False,
227233
action='store_true')
@@ -233,7 +239,7 @@ def main():
233239
args.t, args.S, args.s, args.lib_prefix,
234240
args.lib_suffix,
235241
args.additional_compile_flags,
236-
args.no_backward_deployment,
242+
args.backward_deployment,
237243
args.no_symbol_diff)
238244

239245
return resilience_test.run()

0 commit comments

Comments
 (0)