Skip to content

Commit 5619138

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 6c9a724 commit 5619138

File tree

7 files changed

+152
-51
lines changed

7 files changed

+152
-51
lines changed

utils/build-script

+16-6
Original file line numberDiff line numberDiff line change
@@ -531,9 +531,11 @@ class BuildScriptInvocation(object):
531531
# just invoke cmake from build-script directly rather than futzing
532532
# with build-script-impl. This makes even more sense since there
533533
# really isn't a security issue here.
534-
impl_args += [
535-
"--%s-cmake-options=%s" % (product_name, ' '.join(cmake_opts))
536-
]
534+
if len(cmake_opts) > 0:
535+
impl_args += [
536+
"--%s-cmake-options=%s" %
537+
(product_name, ' '.join(cmake_opts))
538+
]
537539

538540
if args.build_stdlib_deployment_targets:
539541
impl_args += [
@@ -844,16 +846,20 @@ class BuildScriptInvocation(object):
844846
product_classes.append(products.Swift)
845847
if self.args.build_lldb:
846848
product_classes.append(products.LLDB)
847-
if self.args.build_llbuild:
848-
product_classes.append(products.LLBuild)
849849
if self.args.build_libdispatch:
850850
product_classes.append(products.LibDispatch)
851851
if self.args.build_foundation:
852852
product_classes.append(products.Foundation)
853853
if self.args.build_xctest:
854854
product_classes.append(products.XCTest)
855+
if self.args.build_llbuild:
856+
product_classes.append(products.LLBuild)
855857
if self.args.build_swiftpm:
856858
product_classes.append(products.SwiftPM)
859+
if self.args.build_swiftsyntax:
860+
product_classes.append(products.SwiftSyntax)
861+
if self.args.build_skstresstester:
862+
product_classes.append(products.SKStressTester)
857863
return product_classes
858864

859865
def execute(self):
@@ -878,7 +884,7 @@ class BuildScriptInvocation(object):
878884
name == "merged-hosts-lipo"), "invalid action"
879885
action_name = name
880886
elif product_class is None:
881-
assert name == "package", "invalid action"
887+
assert name in ("package", "extractsymbols"), "invalid action"
882888
action_name = "{}-{}".format(host.name, name)
883889
else:
884890
assert name is not None, "invalid action"
@@ -930,6 +936,10 @@ class BuildScriptInvocation(object):
930936
for product_class in product_classes:
931937
execute_one_impl_action(host_target, product_class, "install")
932938

939+
# Extract symbols...
940+
for host_target in all_hosts:
941+
execute_one_impl_action(host_target, name="extractsymbols")
942+
933943
# Package...
934944
for host_target in all_hosts:
935945
execute_one_impl_action(host_target, name="package")

0 commit comments

Comments
 (0)