Skip to content

Commit ce4c85a

Browse files
committed
[build-script] Turn on --no-legacy-impl by default
Turns on the `--no-legacy-impl` option to build-script by default; the old behaviour is temporarily still available as `--legacy-impl`. This causes build-script to invoke build-script-impl for every individual build/test/install/etc. action rather than a single global invocation. For example, a single invocation might be for `macosx-swift-install`. This will enable the python code in build-script to drive the overall process and add additional steps in between actions without the involvement of build-script-impl. It also provides a path to refactoring the existing actions out of build-script-impl individually. Discussed as part of https://forums.swift.org/t/rfc-building-swift-packages-in-build-script/18920 The --no-legacy-impl flag was originally disabled by default because of concerns about the performance of null builds due to the increased number of script invocations. There is a small optimization in this commit to use `tr` when processing command-line options instead of bash's builtin substitution, which eliminates most of the overhead. After this change, a null build of llvm+swift changes from 1.6 s to 2.1 s on Linux, and from 5 s to 6 s on macOS. Non-null builds and builds that involve more build products than just llvm+swift (e.g. corelibs) are basically unaffected since they are not correctly incremental to begin with. The changes to build-script-impl in this commit are to fix the behaviour of --no-legacy-impl, which had bitrotted since it was introduced. These changes are to make various parts of the script not rely on variables defined in "earlier" parts of the script, which is good hygiene in general.
1 parent 66189dc commit ce4c85a

File tree

7 files changed

+151
-47
lines changed

7 files changed

+151
-47
lines changed

utils/build-script

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -527,9 +527,11 @@ class BuildScriptInvocation(object):
527527
# just invoke cmake from build-script directly rather than futzing
528528
# with build-script-impl. This makes even more sense since there
529529
# really isn't a security issue here.
530-
impl_args += [
531-
"--%s-cmake-options=%s" % (product_name, ' '.join(cmake_opts))
532-
]
530+
if len(cmake_opts) > 0:
531+
impl_args += [
532+
"--%s-cmake-options=%s" %
533+
(product_name, ' '.join(cmake_opts))
534+
]
533535

534536
if args.build_stdlib_deployment_targets:
535537
impl_args += [
@@ -839,16 +841,20 @@ class BuildScriptInvocation(object):
839841
product_classes.append(products.Swift)
840842
if self.args.build_lldb:
841843
product_classes.append(products.LLDB)
842-
if self.args.build_llbuild:
843-
product_classes.append(products.LLBuild)
844844
if self.args.build_libdispatch:
845845
product_classes.append(products.LibDispatch)
846846
if self.args.build_foundation:
847847
product_classes.append(products.Foundation)
848848
if self.args.build_xctest:
849849
product_classes.append(products.XCTest)
850+
if self.args.build_llbuild:
851+
product_classes.append(products.LLBuild)
850852
if self.args.build_swiftpm:
851853
product_classes.append(products.SwiftPM)
854+
if self.args.build_swiftsyntax:
855+
product_classes.append(products.SwiftSyntax)
856+
if self.args.build_skstresstester:
857+
product_classes.append(products.SKStressTester)
852858
return product_classes
853859

854860
def execute(self):
@@ -873,7 +879,7 @@ class BuildScriptInvocation(object):
873879
name == "merged-hosts-lipo"), "invalid action"
874880
action_name = name
875881
elif product_class is None:
876-
assert name == "package", "invalid action"
882+
assert name in ("package", "extractsymbols"), "invalid action"
877883
action_name = "{}-{}".format(host.name, name)
878884
else:
879885
assert name is not None, "invalid action"
@@ -925,6 +931,10 @@ class BuildScriptInvocation(object):
925931
for product_class in product_classes:
926932
execute_one_impl_action(host_target, product_class, "install")
927933

934+
# Extract symbols...
935+
for host_target in all_hosts:
936+
execute_one_impl_action(host_target, name="extractsymbols")
937+
928938
# Package...
929939
for host_target in all_hosts:
930940
execute_one_impl_action(host_target, name="package")

utils/build-script-impl

Lines changed: 81 additions & 37 deletions
Large diffs are not rendered by default.

utils/build_swift/driver_arguments.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ def create_argument_parser():
275275
option(['-n', '--dry-run'], store_true,
276276
help='print the commands that would be executed, but do not '
277277
'execute them')
278-
option('--no-legacy-impl', store_false('legacy_impl'),
279-
help='avoid legacy implementation')
278+
option('--legacy-impl', store_true('legacy_impl'),
279+
help='use legacy implementation')
280280

281281
option('--build-runtime-with-host-compiler', toggle_true,
282282
help='Use the host compiler, not the self-built one to compile the '

utils/build_swift/tests/expected_options.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
'install_symroot': None,
139139
'ios': False,
140140
'ios_all': False,
141-
'legacy_impl': True,
141+
'legacy_impl': False,
142142
'libdispatch_build_variant': 'Debug',
143143
'libicu_build_variant': 'Debug',
144144
'lit_args': '-sv',
@@ -411,7 +411,7 @@ class IgnoreOption(_BaseOption):
411411
SetTrueOption('-n', dest='dry_run'),
412412
SetTrueOption('-p', dest='build_swiftpm'),
413413

414-
SetFalseOption('--no-legacy-impl', dest='legacy_impl'),
414+
SetTrueOption('--legacy-impl', dest='legacy_impl'),
415415

416416
EnableOption('--android'),
417417
EnableOption('--build-external-benchmarks'),

utils/swift_build_support/swift_build_support/products/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
from .lldb import LLDB
1919
from .llvm import LLVM
2020
from .ninja import Ninja
21+
from .skstresstester import SKStressTester
2122
from .swift import Swift
2223
from .swiftpm import SwiftPM
24+
from .swiftsyntax import SwiftSyntax
2325
from .xctest import XCTest
2426

2527
__all__ = [
@@ -35,4 +37,6 @@
3537
'Swift',
3638
'SwiftPM',
3739
'XCTest',
40+
'SwiftSyntax',
41+
'SKStressTester',
3842
]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# swift_build_support/products/skstresstester.py -----------------*- python -*-
2+
#
3+
# This source file is part of the Swift.org open source project
4+
#
5+
# Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
6+
# Licensed under Apache License v2.0 with Runtime Library Exception
7+
#
8+
# See https://swift.org/LICENSE.txt for license information
9+
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
#
11+
# ----------------------------------------------------------------------------
12+
13+
from . import product
14+
15+
16+
class SKStressTester(product.Product):
17+
@classmethod
18+
def product_source_name(cls):
19+
"""product_source_name() -> str
20+
21+
The name of the source code directory of this product.
22+
"""
23+
return "swift-stress-tester"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# swift_build_support/products/swiftsyntax.py --------------------*- python -*-
2+
#
3+
# This source file is part of the Swift.org open source project
4+
#
5+
# Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
6+
# Licensed under Apache License v2.0 with Runtime Library Exception
7+
#
8+
# See https://swift.org/LICENSE.txt for license information
9+
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
#
11+
# ----------------------------------------------------------------------------
12+
13+
from . import product
14+
15+
16+
class SwiftSyntax(product.Product):
17+
@classmethod
18+
def product_source_name(cls):
19+
"""product_source_name() -> str
20+
21+
The name of the source code directory of this product.
22+
"""
23+
return "swift-syntax"

0 commit comments

Comments
 (0)