Announcement

Collapse
No announcement yet.

The Mold Linker Is Great & Set To Become Even Better

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • bug77
    replied
    Originally posted by ssokolow View Post

    There are plans to extend the commercial version of mold (sold) from only supporting macOS/iOS to also supporting Windows, if you're OK with paying for a linker. I'm not sure if their "We are considering relicensing the sold linker as free software rather than as a commercial product, given the recent developments with the official Apple linker. Since Apple's linker has gained speed, it's difficult to obtain a sufficient number of users to sustain this project." applies to that too.

    (mold currently operates under a "make people using paid operating systems pay for their linker to subsidize development of the version for free platforms" model. Note that the sold README is currently a bit stale in that it still says mold is AGPLed rather than MITed.)
    Crap. When I read this article, I immediately thought "oh good, that guy found himself a revenue stream so he can keep soldiering on". I guess not, that's a shame

    Leave a comment:


  • Azpegath
    replied
    Originally posted by NobodyXu View Post
    When performing LTO, mold fallback to using llvm/gcc to do the LTO, because LTO means the object files contains intermediate compiler-internal IR instead of binary code, and you have to pass them into a compiler to optimize and generate machine code, so using mold with LTO makes no sense.
    I found this old Phoronix article from 2022

    Mold 1.1 most notably now offers native Link-Time Optimization (LTO) support. Mold previously diverted to ld.bdf/ld.lld when encountering IR intended for LTO-capable linkers while now it can handle the intermediate representation itself. The LTO support is implemented with a linker plug-in interface similar to that of GNU ld and GNU gold. Mold's initial LTO support is focused on completeness and rather than performance, which for now at least means it's only "marginally faster" than the other linkers.​
    and the Release Note linked in the article states

    Native LTO (link-time optimization) support has been added. mold used to invoke ld.bfd or ld.lld if it encountered a GCC IR (intermediate representation) file or an LLVM IR file to delegate the task to the LTO-capable linkers, respectively. Now, mold handles IR files directly. This feature is implemented using the linker plugin API which is also used by GNU ld and GNU gold. Note that the LTO support has been added for completeness and not for speed. mold is only marginally faster than the other linkers for LTO builds because not linking but code optimization dominates.​
    And this article from June 2022

    Mold 1.3 continues improving its link-time optimization (LTO) support with now working more reliably under heavy load rather than aborting occasionally under high load on Linux. Mold 1.3 also can now be built with GCC 12 with LTO enabled, fixes an LTO issue with 32-bit hosts, and other changes.
    So I'm getting the impression that it does its own LTO, based on the IR output from the compiler that uses it?
    Last edited by Azpegath; 07 February 2024, 09:41 AM.

    Leave a comment:


  • Mustafif Khan
    replied
    I've been using mold for speeding up linking for my Rust projects and it's been great! I also want to use it as a linker for Zig but there seems to be an issue with it at the current moment.

    Leave a comment:


  • NobodyXu
    replied
    Originally posted by Azpegath View Post

    I don't understand the premise of the question.
    When performing LTO, mold fallback to using llvm/gcc to do the LTO, because LTO means the object files contains intermediate compiler-internal IR instead of binary code, and you have to pass them into a compiler to optimize and generate machine code, so using mold with LTO makes no sense.

    Leave a comment:


  • ssokolow
    replied
    Originally posted by Ironmask View Post
    I've recently seen Mold suggested as a way to speed up the rapid development cycle of Rust programs, considering it can take a while to compile larger projects (for me, just relying on SurrealDB alone is adding a good minute on to my builds). It's a shame I'm developing on Windows and can't take advantage of it, feels like even more of an example of Microsoft's total disregard of their desktop market these days.
    There are plans to extend the commercial version of mold (sold) from only supporting macOS/iOS to also supporting Windows, if you're OK with paying for a linker. I'm not sure if their "We are considering relicensing the sold linker as free software rather than as a commercial product, given the recent developments with the official Apple linker. Since Apple's linker has gained speed, it's difficult to obtain a sufficient number of users to sustain this project." applies to that too.

    (mold currently operates under a "make people using paid operating systems pay for their linker to subsidize development of the version for free platforms" model. Note that the sold README is currently a bit stale in that it still says mold is AGPLed rather than MITed.)

    Leave a comment:


  • LtdJorge
    replied
    Originally posted by Azpegath View Post
    I've been using mold as my main linker on my Gentoo system for a couple of years. I've only had problems with 3-4 packages, and it's simple to force them to use ld instead. It's been working great.
    Same but a couple months, the only problems I had is for packages that don’t correctly pass linker-plugin flags (at least with LTO), so Mold errors out saying that as it was not specified for the compiled objects, it doesn’t know what to do with the LTO object.

    Leave a comment:


  • Azpegath
    replied
    Originally posted by rene View Post
    Soooo. Given that production code is LTO'ed, mold has no benefits, right?
    I don't understand the premise of the question.

    Leave a comment:


  • rene
    replied
    Soooo. Given that production code is LTO'ed, mold has no benefits, right?

    Leave a comment:


  • Azpegath
    replied
    Originally posted by dumb ways to code View Post
    I wonder if mold can be used for the final builds or is it only for quick debug builds? Does it produce binaries that are running as fast as if when built using legacy linkers? Can LTO be performed when using mold? I couldn't find this information on the internet.
    See my previous post. As far as I know, it does all of that. There are some packages where LTO causes linker errors, but they have been very few, one or two.
    You can follow the mold tracker bug-report on Gentoo if you want, to see the state of it: https://bugs.gentoo.org/830404
    There you also have a link to an excel sheet from the mold maintainer listing the packages that cause issues.

    Gentoo wiki on mold:
    https://wiki.gentoo.org/wiki/Mold - "LTO (Link-time optimization) support has been added since mold-1.1.1"

    Leave a comment:


  • Azpegath
    replied
    I've been using mold as my main linker on my Gentoo system for a couple of years. I've only had problems with 3-4 packages, and it's simple to force them to use ld instead. It's been working great.

    Leave a comment:

Working...
X