Skip to content

Commit 7e2c23e

Browse files
committed
[5.5 build] ensure benchmark toolchain tests use the just built dylibs
The binaries would prefer the libraries shipped in the OS to the ones just built -- employ `DYLD_LIBRARY_PATH` to pick up the latter instead. The main purpose of this change is to unblock the generation of nightly toolchains. Addresses rdar://79788142 Cherry picked from commit 3504310, #38158
1 parent 27657df commit 7e2c23e

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

utils/build-presets.ini

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,9 +1297,6 @@ mixin-preset=
12971297
# SKIP LLDB TESTS (67923799)
12981298
skip-test-lldb
12991299

1300-
# SKIP testing benchmarks (79788142)
1301-
skip-test-toolchain-benchmarks
1302-
13031300
[preset: buildbot_osx_package,use_os_runtime]
13041301
mixin-preset=
13051302
buildbot_osx_package

utils/swift_build_support/swift_build_support/products/benchmarks.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,31 @@ def build(self, host_target):
4747
def should_test(self, host_target):
4848
return self.args.test_toolchainbenchmarks
4949

50+
def _get_test_environment(self, host_target):
51+
if platform.system() == 'Darwin':
52+
# the resulting binaries would search first in /usr/lib/swift,
53+
# we need to prefer the libraries we just built
54+
return {'DYLD_LIBRARY_PATH': os.path.join(
55+
_get_toolchain_path(host_target, self, self.args),
56+
'usr', 'lib', 'swift', 'macosx')}
57+
58+
return None
59+
5060
def test(self, host_target):
5161
"""Just run a single instance of the command for both .debug and
5262
.release.
5363
"""
5464
cmdline = ['--num-iters=1', 'XorLoop']
65+
test_environment = self._get_test_environment(host_target)
66+
5567
bench_Onone = os.path.join(self.build_dir, 'bin', 'Benchmark_Onone')
56-
shell.call([bench_Onone] + cmdline)
68+
shell.call([bench_Onone] + cmdline, env=test_environment)
5769

5870
bench_O = os.path.join(self.build_dir, 'bin', 'Benchmark_O')
59-
shell.call([bench_O] + cmdline)
71+
shell.call([bench_O] + cmdline, env=test_environment)
6072

6173
bench_Osize = os.path.join(self.build_dir, 'bin', 'Benchmark_Osize')
62-
shell.call([bench_Osize] + cmdline)
74+
shell.call([bench_Osize] + cmdline, env=test_environment)
6375

6476
def should_install(self, host_target):
6577
return False
@@ -81,7 +93,11 @@ def get_dependencies(cls):
8193
swiftpm.SwiftPM]
8294

8395

84-
def run_build_script_helper(host_target, product, args):
96+
def _get_toolchain_path(host_target, product, args):
97+
# TODO check if we should prefer using product.install_toolchain_path
98+
# this logic initially was inside run_build_script_helper
99+
# and was factored out so it can be used in testing as well
100+
85101
toolchain_path = swiftpm.SwiftPM.get_install_destdir(args,
86102
host_target,
87103
product.build_dir)
@@ -90,6 +106,12 @@ def run_build_script_helper(host_target, product, args):
90106
toolchain_path += \
91107
targets.darwin_toolchain_prefix(args.install_prefix)
92108

109+
return toolchain_path
110+
111+
112+
def run_build_script_helper(host_target, product, args):
113+
toolchain_path = _get_toolchain_path(host_target, product, args)
114+
93115
# Our source_dir is expected to be './$SOURCE_ROOT/benchmarks'. That is due
94116
# the assumption that each product is in its own build directory. This
95117
# product is not like that and has its package/tools instead in

0 commit comments

Comments
 (0)