Skip to content
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

Add support for LLD linker, cmake options for LLD and Gold #3263

Merged
merged 1 commit into from
May 2, 2022

Conversation

vlstill
Copy link
Contributor

@vlstill vlstill commented Apr 28, 2022

A somewhat different approach to the same problem as in #3262, where @grg wrote:

LLD is much faster than gold in testing, so prefer LLD if it is found.

Test results for a debug build with the Intel Tofino backend after
touching a single file:

gold: 313.410 s (averaged across 10 runs)
lld: 151.783 s (averaged across 10 runs)

The difference is mainly in the options to enable/disable lookup for linkers.

Tested with GCC & Clang. Since the detection fails if the -fuse-ld=??? is not supported by the given gcc/clang version there is no need for version checks.

@grg grg requested review from grg and ChrisDodd April 28, 2022 21:00
Copy link
Contributor

@grg grg left a comment

Choose a reason for hiding this comment

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

Looks good to me.

It's slightly more verbose than my proposal, but it's better for at least two reasons:

  1. It eliminates some duplication.
  2. Total lines of code should be smaller, and with fewer levels of nested ifs, if we have 3+ linker options.

@grg grg requested a review from fruffy April 28, 2022 21:05
@vlstill vlstill marked this pull request as ready for review April 29, 2022 10:46
@fruffy fruffy merged commit bab0301 into p4lang:main May 2, 2022
else ()
message(STATUS "Using the default system linker.")
if (BUILD_STATIC_RELEASE AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0)
add_cxx_compiler_option ("-flto")
Copy link
Contributor

@davidbolvansky davidbolvansky Jun 16, 2022

Choose a reason for hiding this comment

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

GCC LTO does not work with LLD.

(LLD does not support gcc lto files..)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could disable LLD if using static release & GCC. Although I would like to know why is LTO enable only with static builds, it seems like a rather ad-hoc decision to me.

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.

4 participants