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

SCons: Refactor Linux linker options with linker=<bfd|gold|lld|mold> #63278

Merged
merged 1 commit into from
Jul 22, 2022

Conversation

akien-mga
Copy link
Member

@akien-mga akien-mga commented Jul 21, 2022

The new option is linker and lets the user specify the argument to
the-fuse_ld= linker flag directly. The supported options are:

  • default: No change, typically uses GNU ld (bfd) unless the user or
    distro picked a different default /usr/bin/ld.
  • bfd: GNU ld from binutils
  • gold: GNU gold from binutils
  • lld: lld from LLVM
  • mold: mold, an extremely fast modern linker, not (yet) intended for
    use in production but great for development speed. Provided by distro
    mold package or needs to be compiled from source and installed to
    /usr otherwise.

Removes the use_lld=yes option, and make lld actually usable with GCC
too.

Not all the above are compatible or recommend for LTO, we recommend
using GNU ld with GCC LTO, or lld with LLVM ThinLTO.

@akien-mga akien-mga added this to the 4.0 milestone Jul 21, 2022
@akien-mga akien-mga requested review from Calinou and bruvzg July 21, 2022 09:53
@akien-mga akien-mga requested a review from a team as a code owner July 21, 2022 09:53
platform/linuxbsd/detect.py Outdated Show resolved Hide resolved
@akien-mga akien-mga force-pushed the scons-linux-refactor-linker branch 2 times, most recently from 1f05a82 to 70ad959 Compare July 21, 2022 10:21
@akien-mga akien-mga requested a review from a team as a code owner July 21, 2022 10:21
@akien-mga
Copy link
Member Author

As a side note, @Calinou suggested this in godotengine/godot-proposals#4531 (comment):

Replace use_lto=yes and use_thinlto=yes with lto=none|thin|full.

I think that makes sense, could be done in a follow-up PR.

@akien-mga akien-mga force-pushed the scons-linux-refactor-linker branch from 70ad959 to 534f85a Compare July 21, 2022 10:25
@akien-mga akien-mga removed the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Jul 21, 2022
@Riteo
Copy link
Contributor

Riteo commented Jul 21, 2022

Is this really needed? I always use LINKFLAGS="-fuse-ld=mold" and it works fine. I see this as a compiler dependent feature tbh

@akien-mga
Copy link
Member Author

akien-mga commented Jul 21, 2022

Is this really needed? I always use LINKFLAGS="-fuse-ld=mold" and it works fine. I see this as a compiler dependent feature tbh

Well the same can be said of most other build options. You can set CC and CXX instead of use_llvm=yes, etc., and LINKFLAGS="-fuse-ld=lld" instead of use_lld=yes which we currently have. Pass CCFLAGS="-flto" LINKFLAGS="-flto" instead of use_lto=yes, etc.

We just abstract them in a way that makes them either to use. Personally I always have to double check the exact syntax of the link flag so IMO having an option we can validate makes a lot of sense.

It's also more discoverable (we can document it, and you can see it in scons --help). I'd wager a significant proportion of people who compile Godot don't know they can use a faster linker than the default GNU ld.

platform/linuxbsd/detect.py Show resolved Hide resolved
platform/linuxbsd/detect.py Outdated Show resolved Hide resolved
@akien-mga akien-mga force-pushed the scons-linux-refactor-linker branch from 534f85a to 54472be Compare July 21, 2022 22:46
platform/linuxbsd/detect.py Outdated Show resolved Hide resolved
The new option is `linker` and lets the user specify the argument to
the`-fuse_ld=` linker flag directly. The supported options are:

- `default`: No change, typically uses GNU ld (bfd) unless the user or
  distro picked a different default `/usr/bin/ld`.
- `bfd`: GNU ld from binutils
- `gold`: GNU gold from binutils
- `lld`: lld from LLVM
- `mold`: mold, an extremely fast modern linker, not (yet) intended for
  use in production but great for development speed. Provided by distro
  `mold` package or needs to be compiled from source and installed to
  `/usr` otherwise.

Removes the `use_lld=yes` option, and make lld actually usable with GCC
too.

Not all the above are compatible or recommend for LTO, we recommend
using GNU ld with GCC LTO, or lld with LLVM ThinLTO.
@akien-mga akien-mga force-pushed the scons-linux-refactor-linker branch from 54472be to c8479c0 Compare July 21, 2022 23:00
Copy link
Contributor

@Riteo Riteo left a comment

Choose a reason for hiding this comment

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

Looks fine!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a SCons option for Mold linker
3 participants