Skip to content

Commit 6789969

Browse files
committed
Use LLVM runtimes build
LLVM plans to remove the legacy methods for building compiler-rt. This change updates build-script to use LLVM_ENABLE_RUNTIMES to build compiler-rt with the just-built clang instead of the legacy methods. This does not update the llvm-install-components in build-presets.ini -- this is done on purpose to stress more the migration logic, some of the presets will be updated with a subsequent PRs Addresses rdar://113972453
1 parent 117a5ec commit 6789969

File tree

5 files changed

+21
-45
lines changed

5 files changed

+21
-45
lines changed

utils/build-presets.ini

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -699,12 +699,6 @@ reconfigure
699699
verbose-build
700700
build-ninja
701701

702-
# TODO: remove when we will transition from LLVM_TOOL_COMPILER_RT_BUILD
703-
# to LLVM_USE_RUNTIMES to build compiler-rt (#60993), so we can leverage
704-
# the value for SANITIZER_MIN_OSX_VERSION set in cmake_product.py
705-
extra-cmake-options=
706-
-DCLANG_COMPILER_RT_CMAKE_ARGS:STRING="-DSANITIZER_MIN_OSX_VERSION:STRING=10.13"
707-
708702
# Do not build swift or cmark
709703
skip-build-swift
710704
skip-build-cmark

utils/build-script-impl

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -770,20 +770,6 @@ function set_build_options_for_host() {
770770
esac
771771

772772

773-
# We don't currently support building compiler-rt for cross-compile targets.
774-
# It's not clear that's useful anyway.
775-
if [[ $(is_cross_tools_host "${host}") ]] ; then
776-
llvm_cmake_options+=(
777-
-DLLVM_TOOL_COMPILER_RT_BUILD:BOOL=FALSE
778-
-DLLVM_BUILD_EXTERNAL_COMPILER_RT:BOOL=FALSE
779-
)
780-
else
781-
llvm_cmake_options+=(
782-
-DLLVM_TOOL_COMPILER_RT_BUILD:BOOL="$(false_true ${SKIP_BUILD_COMPILER_RT})"
783-
-DLLVM_BUILD_EXTERNAL_COMPILER_RT:BOOL="$(false_true ${SKIP_BUILD_COMPILER_RT})"
784-
)
785-
fi
786-
787773
# If we are asked to not generate test targets for LLVM and or Swift,
788774
# disable as many LLVM tools as we can. This improves compile time when
789775
# compiling with LTO.

utils/build_swift/build_swift/defaults.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def llvm_install_components():
119119
platforms.
120120
"""
121121
components = ['llvm-ar', 'llvm-cov', 'llvm-profdata', 'IndexStore', 'clang',
122-
'clang-resource-headers', 'compiler-rt', 'clangd', 'LTO']
122+
'clang-resource-headers', 'builtins', 'runtimes', 'clangd', 'LTO']
123123
if os.sys.platform == 'darwin':
124124
components.extend(['dsymutil'])
125125
else:

utils/swift_build_support/swift_build_support/products/cmake_product.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -375,19 +375,6 @@ def host_cmake_options(self, host_target):
375375
# in the compiler checks CMake performs
376376
swift_cmake_options.define('CMAKE_OSX_ARCHITECTURES', arch)
377377

378-
# We don't currently support building compiler-rt for cross-compile targets.
379-
# It's not clear that's useful anyway.
380-
if self.is_cross_compile_target(host_target):
381-
llvm_cmake_options.define('LLVM_TOOL_COMPILER_RT_BUILD:BOOL', 'FALSE')
382-
llvm_cmake_options.define('LLVM_BUILD_EXTERNAL_COMPILER_RT:BOOL', 'FALSE')
383-
else:
384-
llvm_cmake_options.define('LLVM_TOOL_COMPILER_RT_BUILD:BOOL',
385-
cmake.CMakeOptions.true_false(
386-
self.args.build_compiler_rt))
387-
llvm_cmake_options.define('LLVM_BUILD_EXTERNAL_COMPILER_RT:BOOL',
388-
cmake.CMakeOptions.true_false(
389-
self.args.build_compiler_rt))
390-
391378
# If we are asked to not generate test targets for LLVM and or Swift,
392379
# disable as many LLVM tools as we can. This improves compile time when
393380
# compiling with LTO.

utils/swift_build_support/swift_build_support/products/llvm.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,12 @@ def build(self, host_target):
274274
llvm_cmake_options.define('COMPILER_RT_INTERCEPT_LIBDISPATCH', 'ON')
275275

276276
llvm_enable_projects = ['clang']
277+
llvm_enable_runtimes = []
277278

278279
if self.args.build_compiler_rt and \
279280
not self.is_cross_compile_target(host_target):
280-
llvm_enable_projects.append('compiler-rt')
281+
llvm_enable_runtimes.append('compiler-rt')
282+
build_targets.append("runtimes")
281283

282284
if self.args.build_clang_tools_extra:
283285
llvm_enable_projects.append('clang-tools-extra')
@@ -296,16 +298,13 @@ def build(self, host_target):
296298

297299
llvm_cmake_options.define('LLVM_ENABLE_PROJECTS',
298300
';'.join(llvm_enable_projects))
301+
llvm_cmake_options.define('LLVM_ENABLE_RUNTIMES',
302+
';'.join(llvm_enable_runtimes))
299303

300-
# In the near future we are aiming to build compiler-rt with
301-
# LLVM_ENABLE_RUNTIMES
302-
# Until that happens, we need to unset this variable from
303-
# LLVM CMakeCache.txt for two reasons
304-
# * prevent PRs testing this variable to affect other runs landing
305-
# unrelated features
306-
# * avoid fallouts should we land such change and then have to revert
307-
# it to account for unforeseen regressions
308-
llvm_cmake_options.undefine('LLVM_ENABLE_RUNTIMES')
304+
# This accounts for previous incremental runs that may have set
305+
# those in the LLVM CMakeCache.txt
306+
llvm_cmake_options.undefine('LLVM_TOOL_COMPILER_RT_BUILD')
307+
llvm_cmake_options.undefine('LLVM_BUILD_EXTERNAL_COMPILER_RT')
309308

310309
# NOTE: This is not a dead option! It is relied upon for certain
311310
# bots/build-configs!
@@ -464,9 +463,19 @@ def install(self, host_target):
464463
self.args.llvm_install_components != 'all':
465464
install_targets = []
466465
components = self.args.llvm_install_components.split(';')
466+
if 'compiler-rt' in components:
467+
# This is a courtesy fallback to avoid breaking downstream presets
468+
# we are not aware of
469+
components.remove('compiler-rt')
470+
components.append('builtins')
471+
components.append('runtimes')
472+
print('warning: replaced legacy LLVM component compiler-rt '
473+
'with builtins;runtimes -- consider updating your preset',
474+
flush=True)
475+
467476
for component in components:
468477
if self.is_cross_compile_target(host_target):
469-
if component == 'compiler-rt':
478+
if component in ['builtins', 'runtimes']:
470479
continue
471480
install_targets.append('install-{}'.format(component))
472481

0 commit comments

Comments
 (0)