Skip to content

Commit e76b97e

Browse files
authored
[build-script] Add an option to build the Foundation tests in another mode (#78390)
Use it in the linux CI presets to set them to Debug mode and speed up the linux CI, plus add a new preset which keeps building them in Release mode. I was looking at a passing linux CI run and saw the log timings at the end: it takes [longer to build and test the swift-foundation repos than to compile all 7k+ mostly C++ files in LLVM](https://ci.swift.org/job/swift-PR-Linux/18996/console)! ``` --- Build Script Analyzer --- Build Script Log: /home/build-user/build/.build_script_log Build Percentage Build Duration (sec) Build Phase ================ ==================== =========== 9.2% 1132.94 Running tests for foundationtests 9.1% 1120.57 linux-x86_64-swift-build 9.0% 1104.2 Building llvm 7.2% 878.84 Running tests for swiftfoundationtests 6.5% 796.81 Running tests for swiftpm 5.6% 684.7 Building swiftpm 5.5% 667.92 linux-x86_64-swift-test 4.9% 597.64 ``` Looking at the log, building swift-foundation in release mode takes a long time, so let's see if changing it to debug mode helps. Some background - the Foundation repos are built twice on the linux CI: once by CMake, which is the version installed in the toolchain, then a second time by SwiftPM purely for testing. This pull only affects that second SwiftPM build for testing, which is not shipped in the final toolchain but thrown away.
1 parent cf48deb commit e76b97e

File tree

6 files changed

+29
-2
lines changed

6 files changed

+29
-2
lines changed

utils/build-presets.ini

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,7 @@ indexstore-db
913913
sourcekit-lsp
914914
swiftdocc
915915
lit-args=-v --time-tests
916+
foundation-tests-build-type=Debug
916917

917918
# rdar://problem/31454823
918919
lldb-test-swift-only
@@ -938,6 +939,11 @@ skip-test-swiftdocc
938939
# to allow to build under aarch64
939940
llvm-build-compiler-rt-with-use-runtime=0
940941

942+
[preset: buildbot_linux,release_foundation_tests]
943+
mixin-preset=buildbot_linux
944+
945+
foundation-tests-build-type=Release
946+
941947
[preset: buildbot_linux_crosscompile_wasm]
942948
mixin-preset=buildbot_linux
943949

@@ -1098,6 +1104,7 @@ reconfigure
10981104
test-optimized
10991105
skip-test-swiftdocc
11001106
lldb-test-swift-only
1107+
foundation-tests-build-type=Debug
11011108

11021109
# gcc version on amazon linux 2 is too old to configure and build tablegen.
11031110
# Use the clang that we install in the path for macros
@@ -1206,6 +1213,7 @@ swiftsyntax
12061213
swiftformat
12071214
indexstore-db
12081215
sourcekit-lsp
1216+
foundation-tests-build-type=Debug
12091217

12101218
install-llvm
12111219
install-static-linux-config

utils/build_swift/build_swift/driver_arguments.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ def _apply_default_arguments(args):
9494
if args.foundation_build_variant is None:
9595
args.foundation_build_variant = args.build_variant
9696

97+
if args.foundation_tests_build_variant is None:
98+
args.foundation_tests_build_variant = args.build_variant
99+
97100
if args.libdispatch_build_variant is None:
98101
args.libdispatch_build_variant = args.build_variant
99102

@@ -955,6 +958,12 @@ def create_argument_parser():
955958
const='Debug',
956959
help='build the Debug variant of Foundation')
957960

961+
option('--foundation-tests-build-type', store('foundation_tests_build_variant'),
962+
choices=['Debug', 'Release'],
963+
default=None,
964+
help='build the Foundation tests in a certain variant '
965+
'(Debug builds much faster)')
966+
958967
option('--debug-libdispatch', store('libdispatch_build_variant'),
959968
const='Debug',
960969
help='build the Debug variant of libdispatch')

utils/build_swift/tests/build_swift/test_driver_arguments.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,7 @@ def test_implied_defaults_build_variant(self):
542542

543543
self.assertEqual(namespace.cmark_build_variant, 'Debug')
544544
self.assertEqual(namespace.foundation_build_variant, 'Debug')
545+
self.assertEqual(namespace.foundation_tests_build_variant, 'Debug')
545546
self.assertEqual(namespace.libdispatch_build_variant, 'Debug')
546547
self.assertEqual(namespace.lldb_build_variant, 'Debug')
547548
self.assertEqual(namespace.llvm_build_variant, 'Debug')

utils/build_swift/tests/expected_options.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@
201201
'swift_debuginfo_non_lto_args': None,
202202
'force_optimized_typechecker': False,
203203
'foundation_build_variant': 'Debug',
204+
'foundation_tests_build_variant': 'Debug',
204205
'host_cc': None,
205206
'host_cxx': None,
206207
'host_libtool': None,
@@ -783,6 +784,8 @@ class BuildScriptImplOption(_BaseOption):
783784
choices=['false', 'not-merged', 'merged']),
784785
ChoicesOption('--android-arch',
785786
choices=['armv7', 'aarch64', 'x86_64']),
787+
ChoicesOption('--foundation-tests-build-type',
788+
dest='foundation_tests_build_variant', choices=['Debug', 'Release']),
786789

787790
StrOption('--android-api-level'),
788791
StrOption('--build-args'),

utils/swift_build_support/swift_build_support/products/foundationtests.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ def should_test(self, host_target):
5353
return self.args.test_foundation
5454

5555
def configuration(self):
56-
return 'release' if self.is_release() else 'debug'
56+
if self.args.foundation_tests_build_variant in ['Release', 'RelWithDebInfo']:
57+
return 'release'
58+
else:
59+
return 'debug'
5760

5861
def test(self, host_target):
5962
swift_exec = os.path.join(

utils/swift_build_support/swift_build_support/products/swiftfoundationtests.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ def should_test(self, host_target):
5353
return self.args.test_foundation
5454

5555
def configuration(self):
56-
return 'release' if self.is_release() else 'debug'
56+
if self.args.foundation_tests_build_variant in ['Release', 'RelWithDebInfo']:
57+
return 'release'
58+
else:
59+
return 'debug'
5760

5861
def test(self, host_target):
5962
swift_exec = os.path.join(

0 commit comments

Comments
 (0)