Skip to content

[lld] Allow opt-out from building lld via --skip-build-lld #73539

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 3 commits into from
May 10, 2024
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
4 changes: 3 additions & 1 deletion utils/build_swift/build_swift/driver_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -830,8 +830,10 @@ def create_argument_parser():
option('--build-ninja', toggle_true,
help='build the Ninja tool')

option(['--build-lld'], toggle_true('build_lld'),
option(['--build-lld'], toggle_true('build_lld'), default=True,
help='build lld as part of llvm')
option(['--skip-build-lld'], toggle_false('build_lld'),
help='skip building lld as part of llvm')

option('--skip-build-clang-tools-extra',
toggle_false('build_clang_tools_extra'),
Expand Down
3 changes: 2 additions & 1 deletion utils/build_swift/tests/expected_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
'build_libcxx': False,
'build_linux_static': False,
'build_ninja': False,
'build_lld': False,
'build_lld': True,
'build_osx': True,
'build_playgroundsupport': False,
'build_runtime_with_host_compiler': False,
Expand Down Expand Up @@ -753,6 +753,7 @@ class BuildScriptImplOption(_BaseOption):
DisableOption('--skip-build-zlib', dest='build_zlib'),
DisableOption('--skip-build-curl', dest='build_curl'),
DisableOption('--skip-build-compiler-rt', dest='build_compiler_rt'),
DisableOption('--skip-build-lld', dest='build_lld'),

ChoicesOption('--compiler-vendor',
choices=['none', 'apple']),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,16 +463,7 @@ def convert_to_impl_arguments(self):
"--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:
if not args.build_lld:
impl_args += [
"--skip-build-lld"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,13 +324,14 @@ def build(self, host_target):
if self.args.build_clang_tools_extra:
llvm_enable_projects.append('clang-tools-extra')

# Always build lld -- on non-Darwin so we can always have a
# Building lld is on by default -- on non-Darwin so we can always have a
# linker that is compatible with the swift we are using to
# compile the stdlib, but on Darwin too for Embedded Swift use cases.
#
# This makes it easier to build target stdlibs on systems that
# have old toolchains without more modern linker features.
llvm_enable_projects.append('lld')
if self.args.build_lld:
llvm_enable_projects.append('lld')

llvm_cmake_options.define('LLVM_ENABLE_PROJECTS',
';'.join(llvm_enable_projects))
Expand Down