Skip to content

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

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 1 commit into from
May 25, 2022

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Feb 10, 2022

I find that lld links faster than the default linker for release builds and it’s convenient if we can just build it as part of Swift’s LLVM build.

Note that to use lld, you still need to set extra-cmake-options=-DLLVM_ENABLE_LLD:BOOL=TRUE manually. This PR does not do so because we can only start using that flag after lld has been built.

@ahoppen ahoppen requested a review from gottesmm February 10, 2022 09:49
@ahoppen
Copy link
Member Author

ahoppen commented Feb 10, 2022

@swift-ci Please smoke test

@ahoppen
Copy link
Member Author

ahoppen commented Feb 10, 2022

@swift-ci Please smoke test macOS

@gottesmm
Copy link
Contributor

@ahoppen I thought we already built LLD by default on certain platforms. Specifically Linux/windows. Or is me memory wrong. @compnerd

@compnerd
Copy link
Member

Yes, windows builds lld already.

@@ -429,6 +429,11 @@ def convert_to_impl_arguments(self):
"--llvm-install-components=%s" % args.llvm_install_components
]

if args.build_lld:
impl_args += [
"--llvm-install-components=%s" % args.llvm_install_components
Copy link
Contributor

@gottesmm gottesmm Feb 11, 2022

Choose a reason for hiding this comment

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

Does llvm install components accumulate in build-script like this? Doesn't this break the usage of llvm-install-components above.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure how I managed to commit this, but this should have been

if args.build_lld:
  impl_args += ["--build-lld"]

🤦

@@ -429,6 +429,11 @@ def convert_to_impl_arguments(self):
"--llvm-install-components=%s" % args.llvm_install_components
Copy link
Contributor

Choose a reason for hiding this comment

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

This specifically.

@@ -1832,7 +1833,7 @@ for host in "${ALL_HOSTS[@]}"; do
#
# 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 [[ "$(uname -s)" != "Darwin" || "${BUILD_LLD}" ]] ; then
if [[ ! "${SKIP_BUILD_LLD}" ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

@ahoppen I was thinking... we already have a skip-build-lld option... so we really shouldn't add another build-lld option to build-script-impl. In general we want to simplify build-script-impl by not adding new state like this.

I have a counter-proposal, why don't we remove the Darwin check here. Instead, in build-script lets just pass in skip-build-lldb to build-script-impl if we are on Darwin and build-lld isn't set. Then build-script-impl is simpler and doesn't have an additional variable. What are your thoughts?

@ahoppen
Copy link
Member Author

ahoppen commented Feb 11, 2022

Very good idea, @gottesmm. I changed the PR to remove the Darwin check in build-script-impl and instead make build-script decide whether lld should be built.

@ahoppen
Copy link
Member Author

ahoppen commented Feb 11, 2022

@swift-ci Please smoke test

llvm_enable_projects+=("lld")
fi
if [[ ! "${SKIP_BUILD_LLD}" ]]; then
llvm_enable_projects+=("lld")
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a build-script unit test that makes sure we don't break this by mistake? Then I think this LGTM. I am also fine if you want to merge this now and write the test in a subsequent PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

What do you mean by a build-script unit test? I don’t think I ever saw unit tests for build-script 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

I added a unit test. @gottesmm Could you take another look?

@ahoppen
Copy link
Member Author

ahoppen commented Apr 12, 2022

@swift-ci Please smoke test

@ahoppen
Copy link
Member Author

ahoppen commented Apr 13, 2022

@swift-ci Please smoke test Linux

@ahoppen ahoppen requested a review from gottesmm May 24, 2022 11:04
@ahoppen
Copy link
Member Author

ahoppen commented May 24, 2022

@swift-ci Please smoke test

Copy link
Contributor

@gottesmm gottesmm left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for adding the test!

@ahoppen ahoppen merged commit e2012dd into swiftlang:main May 25, 2022
@ahoppen ahoppen deleted the pr/build-lld branch May 25, 2022 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants