Skip to content

Commit a7f0661

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 a829fa2 commit a7f0661

File tree

5 files changed

+28
-45
lines changed

5 files changed

+28
-45
lines changed

utils/build-presets.ini

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -697,12 +697,6 @@ reconfigure
697697
verbose-build
698698
build-ninja
699699

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

utils/build-script-impl

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

805805

806-
# We don't currently support building compiler-rt for cross-compile targets.
807-
# It's not clear that's useful anyway.
808-
if [[ $(is_cross_tools_host "${host}") ]] ; then
809-
llvm_cmake_options+=(
810-
-DLLVM_TOOL_COMPILER_RT_BUILD:BOOL=FALSE
811-
-DLLVM_BUILD_EXTERNAL_COMPILER_RT:BOOL=FALSE
812-
)
813-
else
814-
llvm_cmake_options+=(
815-
-DLLVM_TOOL_COMPILER_RT_BUILD:BOOL="$(false_true ${SKIP_BUILD_COMPILER_RT})"
816-
-DLLVM_BUILD_EXTERNAL_COMPILER_RT:BOOL="$(false_true ${SKIP_BUILD_COMPILER_RT})"
817-
)
818-
fi
819-
820806
# If we are asked to not generate test targets for LLVM and or Swift,
821807
# disable as many LLVM tools as we can. This improves compile time when
822808
# compiling with LTO.

utils/build_swift/build_swift/defaults.py

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

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
@@ -381,19 +381,6 @@ def host_cmake_options(self, host_target):
381381
# in the compiler checks CMake performs
382382
swift_cmake_options.define('CMAKE_OSX_ARCHITECTURES', arch)
383383

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

utils/swift_build_support/swift_build_support/products/llvm.py

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,14 @@ def build(self, host_target):
299299
'armv6 armv6m armv7 armv7m armv7em')
300300

301301
llvm_enable_projects = ['clang']
302+
llvm_enable_runtimes = []
302303

303304
if self.args.build_compiler_rt and \
304305
not self.is_cross_compile_target(host_target):
305-
llvm_enable_projects.append('compiler-rt')
306+
llvm_enable_runtimes.append('compiler-rt')
307+
build_targets.append("runtimes")
308+
# This is needed to build correctly TSan under Linux
309+
llvm_cmake_options.define('COMPILER_RT_USE_BUILTINS_LIBRARY', 'ON')
306310

307311
if self.args.build_clang_tools_extra:
308312
llvm_enable_projects.append('clang-tools-extra')
@@ -316,18 +320,20 @@ def build(self, host_target):
316320
if self.args.build_lld:
317321
llvm_enable_projects.append('lld')
318322

323+
if self.args.test:
324+
# LLVMTestingSupport is not built at part of `all`
325+
# and is required by some Swift tests
326+
build_targets.append('LLVMTestingSupport')
327+
319328
llvm_cmake_options.define('LLVM_ENABLE_PROJECTS',
320329
';'.join(llvm_enable_projects))
330+
llvm_cmake_options.define('LLVM_ENABLE_RUNTIMES',
331+
';'.join(llvm_enable_runtimes))
321332

322-
# In the near future we are aiming to build compiler-rt with
323-
# LLVM_ENABLE_RUNTIMES
324-
# Until that happens, we need to unset this variable from
325-
# LLVM CMakeCache.txt for two reasons
326-
# * prevent PRs testing this variable to affect other runs landing
327-
# unrelated features
328-
# * avoid fallouts should we land such change and then have to revert
329-
# it to account for unforeseen regressions
330-
llvm_cmake_options.undefine('LLVM_ENABLE_RUNTIMES')
333+
# This accounts for previous incremental runs that may have set
334+
# those in the LLVM CMakeCache.txt
335+
llvm_cmake_options.undefine('LLVM_TOOL_COMPILER_RT_BUILD')
336+
llvm_cmake_options.undefine('LLVM_BUILD_EXTERNAL_COMPILER_RT')
331337

332338
# NOTE: This is not a dead option! It is relied upon for certain
333339
# bots/build-configs!
@@ -491,9 +497,19 @@ def install(self, host_target):
491497
self.args.llvm_install_components != 'all':
492498
install_targets = []
493499
components = self.args.llvm_install_components.split(';')
500+
if 'compiler-rt' in components:
501+
# This is a courtesy fallback to avoid breaking downstream presets
502+
# we are not aware of
503+
components.remove('compiler-rt')
504+
components.append('builtins')
505+
components.append('runtimes')
506+
print('warning: replaced legacy LLVM component compiler-rt '
507+
'with builtins;runtimes -- consider updating your preset',
508+
flush=True)
509+
494510
for component in components:
495511
if self.is_cross_compile_target(host_target):
496-
if component == 'compiler-rt':
512+
if component in ['builtins', 'runtimes']:
497513
continue
498514
install_targets.append('install-{}'.format(component))
499515

0 commit comments

Comments
 (0)