[build-script] Add option to build lld as part of LLVM

This commit is contained in:
Alex Hoppen
2022-02-11 09:32:48 +01:00
parent 3c805eefed
commit e313df88ce
5 changed files with 30 additions and 10 deletions

View File

@@ -1833,16 +1833,8 @@ for host in "${ALL_HOSTS[@]}"; do
llvm_enable_projects+=("clang-tools-extra")
fi
# On non-Darwin platforms, build lld so we can always have a
# linker that is compatible with the swift we are using to
# compile the stdlib.
#
# This makes it easier to build target stdlibs on systems that
# have old toolchains without more modern linker features.
if [[ "$(uname -s)" != "Darwin" ]] ; then
if [[ ! "${SKIP_BUILD_LLD}" ]]; then
llvm_enable_projects+=("lld")
fi
if [[ ! "${SKIP_BUILD_LLD}" ]]; then
llvm_enable_projects+=("lld")
fi
cmake_options+=(

View File

@@ -721,6 +721,9 @@ def create_argument_parser():
option(['--build-libparser-only'], toggle_true('build_libparser_only'),
help='build only libParser for SwiftSyntax')
option(['--build-lld'], toggle_true('build_lld'),
help='build lld as part of llvm')
option('--skip-build-clang-tools-extra',
toggle_false('build_clang_tools_extra'),
default=True,

View File

@@ -71,6 +71,7 @@ EXPECTED_DEFAULTS = {
'build_lldb': False,
'build_libcxx': False,
'build_ninja': False,
'build_lld': False,
'build_osx': True,
'build_playgroundsupport': False,
'build_runtime_with_host_compiler': False,
@@ -531,6 +532,7 @@ EXPECTED_OPTIONS = [
EnableOption('--android'),
EnableOption('--build-external-benchmarks'),
EnableOption('--build-ninja'),
EnableOption('--build-lld'),
EnableOption('--build-runtime-with-host-compiler'),
EnableOption('--build-swift-dynamic-sdk-overlay'),
EnableOption('--build-swift-dynamic-stdlib'),

View File

@@ -427,6 +427,20 @@ class BuildScriptInvocation(object):
"--llvm-install-components=%s" % args.llvm_install_components
]
# On non-Darwin platforms, build lld so we can always have a
# linker that is compatible with the swift we are using to
# compile the stdlib.
#
# This makes it easier to build target stdlibs on systems that
# have old toolchains without more modern linker features.
#
# On Darwin, only build lld if explicitly requested using --build-lld.
should_build_lld = (platform.system() != 'Darwin' or args.build_lld)
if not should_build_lld:
impl_args += [
"--skip-build-lld"
]
if not args.clean_libdispatch:
impl_args += [
"--skip-clean-libdispatch"

View File

@@ -0,0 +1,9 @@
# RUN: %empty-directory(%t)
# RUN: mkdir -p %t
# RUN: SKIP_XCODE_VERSION_CHECK=1 SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script --dry-run --build-lld 2>&1 | %FileCheck %s
# REQUIRES: standalone_build
# Check that lld is in LLVM_ENABLE_PROJECTS of the llvm-project/llvm build
# CHECK: '-DLLVM_ENABLE_PROJECTS={{[^']*}}lld{{[^']*}}'{{.*}}llvm-project/llvm{{$}}