Skip to content

[utils] Replace gold with lld as the default linker on Linux #80104

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
18 changes: 9 additions & 9 deletions utils/build-presets.ini
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ reconfigure
# Use the clang that we install in the path for macros
llvm-cmake-options=
-DCROSS_TOOLCHAIN_FLAGS_LLVM_NATIVE='-DCMAKE_C_COMPILER=clang;-DCMAKE_CXX_COMPILER=clang++'
-DCLANG_DEFAULT_LINKER=gold
-DCLANG_DEFAULT_LINKER=ld.lld
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one note, as Evan says, the default is lld, so the better way to make this switch is to delete these 9 lines.

Copy link
Contributor

@etcwilde etcwilde Mar 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know we install it lld by default, but the clang-linker itself will still use BFD, which I believe will fail PR testing due to the relocation bug.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sigh, setting this linker is a maze of config options and overrides. 😿

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, I now see that @gottesmm just added a --use-linker flag last month in #79329. Whatever we decide to do here, we should switch these presets over to that new flag instead of these raw cmake overrides.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah. I can go ahead and update my lld PR to use that flag and incorporate that change there.


[preset: buildbot_linux]
mixin-preset=
Expand Down Expand Up @@ -1099,7 +1099,7 @@ skip-test-swiftdocc
# Use the clang that we install in the path for macros
llvm-cmake-options=
-DCROSS_TOOLCHAIN_FLAGS_LLVM_NATIVE='-DCMAKE_C_COMPILER=clang;-DCMAKE_CXX_COMPILER=clang++'
-DCLANG_DEFAULT_LINKER=gold
-DCLANG_DEFAULT_LINKER=ld.lld

[preset: buildbot_linux_1404_no_lldb]
mixin-preset=buildbot_incremental_linux
Expand Down Expand Up @@ -1180,7 +1180,7 @@ reconfigure
relocate-xdg-cache-home-under-build-subdir

llvm-cmake-options=
-DCLANG_DEFAULT_LINKER=gold
-DCLANG_DEFAULT_LINKER=ld.lld

build-embedded-stdlib-cross-compiling

Expand Down Expand Up @@ -1809,7 +1809,7 @@ skip-test-osx

[preset: pr_apple_llvm_project_linux]

llvm-cmake-options=-DCLANG_DEFAULT_LINKER=gold
llvm-cmake-options=-DCLANG_DEFAULT_LINKER=ld.lld

foundation
libdispatch
Expand Down Expand Up @@ -1875,7 +1875,7 @@ skip-test-libdispatch
skip-test-xctest

llvm-cmake-options=
-DCLANG_DEFAULT_LINKER=gold
-DCLANG_DEFAULT_LINKER=ld.lld

# SwiftPM package base
[preset: mixin_swiftpm_package_macos_platform]
Expand Down Expand Up @@ -1912,7 +1912,7 @@ skip-test-llbuild
skip-test-swiftpm

llvm-cmake-options=
-DCLANG_DEFAULT_LINKER=gold
-DCLANG_DEFAULT_LINKER=ld.lld

#===------------------------------------------------------------------------===#
# Test swiftPM on macOS builder
Expand Down Expand Up @@ -2184,7 +2184,7 @@ skip-test-libdispatch
skip-test-foundation

llvm-cmake-options=
-DCLANG_DEFAULT_LINKER=gold
-DCLANG_DEFAULT_LINKER=ld.lld

#===------------------------------------------------------------------------===#
# Remote Mirror Library
Expand Down Expand Up @@ -3020,7 +3020,7 @@ install-xctest
swift-install-components=autolink-driver;compiler;clang-builtin-headers;stdlib;libexec;swift-remote-mirror;sdk-overlay;license

llvm-cmake-options=
-DCLANG_DEFAULT_LINKER=gold
-DCLANG_DEFAULT_LINKER=ld.lld

[preset: source_compat_suite_macos_DA]
mixin-preset=source_compat_suite_macos_base
Expand Down Expand Up @@ -3108,7 +3108,7 @@ skip-build-benchmarks
skip-test-foundation

llvm-cmake-options=
-DCLANG_DEFAULT_LINKER=gold
-DCLANG_DEFAULT_LINKER=ld.lld

#===------------------------------------------------------------------------===#
# Toolchain Bootstrapping Stages
Expand Down