Skip to content

Commit e2012dd

Browse files
authored
Merge pull request #41314 from ahoppen/pr/build-lld
[build-script] Add option to build lld as part of LLVM
2 parents 8cc2a55 + e313df8 commit e2012dd

File tree

5 files changed

+30
-10
lines changed

5 files changed

+30
-10
lines changed

utils/build-script-impl

+2-10
Original file line numberDiff line numberDiff line change
@@ -1839,16 +1839,8 @@ for host in "${ALL_HOSTS[@]}"; do
18391839
llvm_enable_projects+=("clang-tools-extra")
18401840
fi
18411841

1842-
# On non-Darwin platforms, build lld so we can always have a
1843-
# linker that is compatible with the swift we are using to
1844-
# compile the stdlib.
1845-
#
1846-
# This makes it easier to build target stdlibs on systems that
1847-
# have old toolchains without more modern linker features.
1848-
if [[ "$(uname -s)" != "Darwin" ]] ; then
1849-
if [[ ! "${SKIP_BUILD_LLD}" ]]; then
1850-
llvm_enable_projects+=("lld")
1851-
fi
1842+
if [[ ! "${SKIP_BUILD_LLD}" ]]; then
1843+
llvm_enable_projects+=("lld")
18521844
fi
18531845

18541846
cmake_options+=(

utils/build_swift/build_swift/driver_arguments.py

+3
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,9 @@ def create_argument_parser():
736736
option(['--build-libparser-only'], toggle_true('build_libparser_only'),
737737
help='build only libParser for SwiftSyntax')
738738

739+
option(['--build-lld'], toggle_true('build_lld'),
740+
help='build lld as part of llvm')
741+
739742
option('--skip-build-clang-tools-extra',
740743
toggle_false('build_clang_tools_extra'),
741744
default=True,

utils/build_swift/tests/expected_options.py

+2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
'build_lldb': False,
7373
'build_libcxx': False,
7474
'build_ninja': False,
75+
'build_lld': False,
7576
'build_osx': True,
7677
'build_playgroundsupport': False,
7778
'build_runtime_with_host_compiler': False,
@@ -538,6 +539,7 @@ class BuildScriptImplOption(_BaseOption):
538539
EnableOption('--android'),
539540
EnableOption('--build-external-benchmarks'),
540541
EnableOption('--build-ninja'),
542+
EnableOption('--build-lld'),
541543
EnableOption('--build-runtime-with-host-compiler'),
542544
EnableOption('--build-swift-dynamic-sdk-overlay'),
543545
EnableOption('--build-swift-dynamic-stdlib'),

utils/swift_build_support/swift_build_support/build_script_invocation.py

+14
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,20 @@ def convert_to_impl_arguments(self):
430430
"--llvm-install-components=%s" % args.llvm_install_components
431431
]
432432

433+
# On non-Darwin platforms, build lld so we can always have a
434+
# linker that is compatible with the swift we are using to
435+
# compile the stdlib.
436+
#
437+
# This makes it easier to build target stdlibs on systems that
438+
# have old toolchains without more modern linker features.
439+
#
440+
# On Darwin, only build lld if explicitly requested using --build-lld.
441+
should_build_lld = (platform.system() != 'Darwin' or args.build_lld)
442+
if not should_build_lld:
443+
impl_args += [
444+
"--skip-build-lld"
445+
]
446+
433447
if not args.clean_libdispatch:
434448
impl_args += [
435449
"--skip-clean-libdispatch"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# RUN: %empty-directory(%t)
2+
# RUN: mkdir -p %t
3+
# RUN: SKIP_XCODE_VERSION_CHECK=1 SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script --dry-run --build-lld 2>&1 | %FileCheck %s
4+
5+
# REQUIRES: standalone_build
6+
7+
# Check that lld is in LLVM_ENABLE_PROJECTS of the llvm-project/llvm build
8+
9+
# CHECK: '-DLLVM_ENABLE_PROJECTS={{[^']*}}lld{{[^']*}}'{{.*}}llvm-project/llvm{{$}}

0 commit comments

Comments
 (0)