Skip to content

Commit d350a05

Browse files
authored
[build] Clean llbuild before building by default (#36686)
Introduce a new parameter `--skip-llbuild-clean` to prevent this from happening. This mimicks similar logic in place for `swiftpm`, `swift-driver` (#33563) and `xctest` (#19512) Addresses rdar://75057069
1 parent a5a79f2 commit d350a05

File tree

5 files changed

+34
-0
lines changed

5 files changed

+34
-0
lines changed

utils/build-script

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,11 @@ class BuildScriptInvocation(object):
796796
"--llvm-install-components=%s" % args.llvm_install_components
797797
]
798798

799+
if not args.clean_llbuild:
800+
impl_args += [
801+
"--skip-clean-llbuild"
802+
]
803+
799804
# Compute the set of host-specific variables, which we pass through to
800805
# the build script via environment variables.
801806
host_specific_variables = self.compute_host_specific_variables()

utils/build-script-impl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ KNOWN_SETTINGS=(
162162

163163
## llbuild Options
164164
llbuild-enable-assertions "1" "enable assertions in llbuild"
165+
skip-clean-llbuild "0" "skip cleaning up llbuild"
165166

166167
## LLDB Options
167168
lldb-assertions "1" "build lldb with assertions enabled"
@@ -2189,6 +2190,15 @@ for host in "${ALL_HOSTS[@]}"; do
21892190
-DSQLite3_INCLUDE_DIR:PATH="$(xcrun -sdk macosx -show-sdk-path)/usr/include"
21902191
)
21912192
fi
2193+
2194+
if [[ "${SKIP_CLEAN_LLBUILD}" == "0" ]]
2195+
then
2196+
# Ensure llbuild will rebuild from scratch, since
2197+
# arbitrary changes to the compiler can prevent
2198+
# a successful incremental build
2199+
echo "Cleaning the llbuild build directory"
2200+
call rm -rf "$(build_directory ${host} llbuild)"
2201+
fi
21922202
;;
21932203
xctest)
21942204
XCTEST_BUILD_DIR=$(build_directory ${host} xctest)

utils/build_swift/build_swift/driver_arguments.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,8 @@ def create_argument_parser():
10371037
help='skip testing Android device targets on the host machine (the '
10381038
'phone itself)')
10391039

1040+
option('--skip-clean-llbuild', toggle_false('clean_llbuild'),
1041+
help='skip cleaning up llbuild')
10401042
option('--skip-clean-swiftpm', toggle_false('clean_swiftpm'),
10411043
help='skip cleaning up swiftpm')
10421044
option('--skip-clean-swift-driver', toggle_false('clean_swift_driver'),

utils/build_swift/tests/expected_options.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@
212212
defaults.SWIFT_MAX_PARALLEL_LTO_LINK_JOBS,
213213
'swift_user_visible_version': defaults.SWIFT_USER_VISIBLE_VERSION,
214214
'symbols_package': None,
215+
'clean_llbuild': True,
215216
'clean_swiftpm': True,
216217
'clean_swift_driver': True,
217218
'test': None,
@@ -578,6 +579,7 @@ class BuildScriptImplOption(_BaseOption):
578579
dest='build_watchos_device'),
579580
DisableOption('--skip-build-watchos-simulator',
580581
dest='build_watchos_simulator'),
582+
DisableOption('--skip-clean-llbuild', dest='clean_llbuild'),
581583
DisableOption('--skip-clean-swiftpm', dest='clean_swiftpm'),
582584
DisableOption('--skip-clean-swift-driver', dest='clean_swift_driver'),
583585
DisableOption('--skip-test-android', dest='test_android'),
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# REQUIRES: standalone_build
2+
3+
# RUN: %empty-directory(%t)
4+
# RUN: mkdir -p %t
5+
# RUN: SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script --dry-run --llbuild --cmake %cmake 2>&1 | %FileCheck --check-prefix=CLEAN-LLBUILD-CHECK %s
6+
7+
# RUN: %empty-directory(%t)
8+
# RUN: mkdir -p %t
9+
# RUN: SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script --dry-run --llbuild --skip-clean-llbuild --cmake %cmake 2>&1 | %FileCheck --check-prefix=SKIP-CLEAN-LLBUILD-CHECK %s
10+
11+
# CLEAN-LLBUILD-CHECK: Cleaning the llbuild build directory
12+
# CLEAN-LLBUILD-CHECK-NEXT: rm -rf
13+
14+
# SKIP-CLEAN-LLBUILD-CHECK-NOT: Cleaning the llbuild build directory
15+
# SKIP-CLEAN-LLBUILD-CHECK-NOT: rm -rf {{.*/llbuild-[^/]*}}

0 commit comments

Comments
 (0)