Skip to content

[build] Clean llbuild before building by default #36686

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions utils/build-script
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,11 @@ class BuildScriptInvocation(object):
"--llvm-install-components=%s" % args.llvm_install_components
]

if not args.clean_llbuild:
impl_args += [
"--skip-clean-llbuild"
]

# Compute the set of host-specific variables, which we pass through to
# the build script via environment variables.
host_specific_variables = self.compute_host_specific_variables()
Expand Down
10 changes: 10 additions & 0 deletions utils/build-script-impl
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ KNOWN_SETTINGS=(

## llbuild Options
llbuild-enable-assertions "1" "enable assertions in llbuild"
skip-clean-llbuild "0" "skip cleaning up llbuild"

## LLDB Options
lldb-assertions "1" "build lldb with assertions enabled"
Expand Down Expand Up @@ -2189,6 +2190,15 @@ for host in "${ALL_HOSTS[@]}"; do
-DSQLite3_INCLUDE_DIR:PATH="$(xcrun -sdk macosx -show-sdk-path)/usr/include"
)
fi

if [[ "${SKIP_CLEAN_LLBUILD}" == "0" ]]
then
# Ensure llbuild will rebuild from scratch, since
# arbitrary changes to the compiler can prevent
# a successful incremental build
echo "Cleaning the llbuild build directory"
call rm -rf "$(build_directory ${host} llbuild)"
fi
;;
xctest)
XCTEST_BUILD_DIR=$(build_directory ${host} xctest)
Expand Down
2 changes: 2 additions & 0 deletions utils/build_swift/build_swift/driver_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,8 @@ def create_argument_parser():
help='skip testing Android device targets on the host machine (the '
'phone itself)')

option('--skip-clean-llbuild', toggle_false('clean_llbuild'),
help='skip cleaning up llbuild')
option('--skip-clean-swiftpm', toggle_false('clean_swiftpm'),
help='skip cleaning up swiftpm')
option('--skip-clean-swift-driver', toggle_false('clean_swift_driver'),
Expand Down
2 changes: 2 additions & 0 deletions utils/build_swift/tests/expected_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@
defaults.SWIFT_MAX_PARALLEL_LTO_LINK_JOBS,
'swift_user_visible_version': defaults.SWIFT_USER_VISIBLE_VERSION,
'symbols_package': None,
'clean_llbuild': True,
'clean_swiftpm': True,
'clean_swift_driver': True,
'test': None,
Expand Down Expand Up @@ -578,6 +579,7 @@ class BuildScriptImplOption(_BaseOption):
dest='build_watchos_device'),
DisableOption('--skip-build-watchos-simulator',
dest='build_watchos_simulator'),
DisableOption('--skip-clean-llbuild', dest='clean_llbuild'),
DisableOption('--skip-clean-swiftpm', dest='clean_swiftpm'),
DisableOption('--skip-clean-swift-driver', dest='clean_swift_driver'),
DisableOption('--skip-test-android', dest='test_android'),
Expand Down
15 changes: 15 additions & 0 deletions validation-test/BuildSystem/skip_clean_llbuild.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# REQUIRES: standalone_build

# RUN: %empty-directory(%t)
# RUN: mkdir -p %t
# 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

# RUN: %empty-directory(%t)
# RUN: mkdir -p %t
# 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

# CLEAN-LLBUILD-CHECK: Cleaning the llbuild build directory
# CLEAN-LLBUILD-CHECK-NEXT: rm -rf

# SKIP-CLEAN-LLBUILD-CHECK-NOT: Cleaning the llbuild build directory
# SKIP-CLEAN-LLBUILD-CHECK-NOT: rm -rf {{.*/llbuild-[^/]*}}