8

Mold (linker) 1.0 released

 2 years ago
source link: https://lwn.net/Articles/878759/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Mold (linker) 1.0 released

[Posted December 15, 2021 by corbet]
Version 1.0 of the mold linker has been released.

mold 1.0 is the first stable and production-ready release of the high-speed linker. On Linux-based systems, it should "just work" as a faster drop-in replacement for the default GNU linker for most user-land programs. If you are building a large executable which takes a long time to link, mold is worth a try to see if it can shorten your build time.


(Log in to post comments)

Mold (linker) 1.0 released

Posted Dec 15, 2021 18:16 UTC (Wed) by donbarry (guest, #10485) [Link]

AGPL v3 license.. An .... interesting choice.

The Github LICENSE page explains why -- it's not out of a love for free software:

"I'm looking for a sponsor who wants to purchase the copyright of this work and relicense it under a more liberal license such as the MIT license. For now, mold is released under the GNU AGPL v3."

Mold (linker) 1.0 released

Posted Dec 15, 2021 18:40 UTC (Wed) by yodermk (guest, #3803) [Link]

I don't see why that would be a problem in practice. It's not like anyone is interacting with a linker over a network. So it's basically like GPL. And I don't see any problem with an executable program being GPL. Kind of restrictive for a library though.

Mold (linker) 1.0 released

Posted Dec 15, 2021 19:20 UTC (Wed) by donbarry (guest, #10485) [Link]

That's true, and in that sense it is a real contribution to the community. But what rankles is using the AGPLv3 as something of perceived poison pill, even though it really isn't in this case, with the goal being a payout -- cough -- I mean a permissive license.

Not exactly in line with the whole ethic of the license itself.

Mold (linker) 1.0 released

Posted Dec 15, 2021 19:32 UTC (Wed) by mathstuf (subscriber, #69389) [Link]

I guess I see it as analogous to freedom zero. The FSF doesn't have a say in *how* the AGPLv3 gets used just like a developer can't really say that $the_illuminati (or whatever boogeyman might be at hand) can't use $my_project for $evil. Sure, you can name and shame, but putting such terms into the license itself isn't really productive in the long run. At least here in this case, we (humanity) get a fast, FOSS linker that pushes boundaries in the meantime.

Mold (linker) 1.0 released

Posted Dec 15, 2021 20:58 UTC (Wed) by atai (subscriber, #10977) [Link]

Then FSF did say license cannot restrict use, in regard to some "hacker activism" license proposed to say doing evil not allowed

Mold (linker) 1.0 released

Posted Dec 15, 2021 19:40 UTC (Wed) by NYKevin (subscriber, #129325) [Link]

That's capitalism. If we all lived in a magical communist utopia, then these licenses would not need to exist in the first place. If the FSF did not want people to use these licenses in this fashion,* then I think they should have more carefully considered the incentives that were likely to result from their existence.

* I am rather skeptical that this is how the FSF feels, however, because RMS endorsed the practice of selling exceptions to the GPL all the way back in 2010: https://www.fsf.org/blogs/rms/selling-exceptions. So it may simply be that they do not agree with you, and would see nothing wrong with this practice anyway.

Mold (linker) 1.0 released

Posted Dec 15, 2021 20:16 UTC (Wed) by rvolgers (subscriber, #63218) [Link]

There are plenty of companies which use GPL for their open source release and sell alternative license options for money.

If anything, this is more public-spirited than that approach.

People like the GPL because it enforces giving more rights to users. But that also means people and companies may not like the GPL because it leaves fewer exclusive rights for them to sell for money.

There is nothing wrong with recognizing there are potential downsides to the GPL and that companies are willing to pay to avoid them.

Mold (linker) 1.0 released

Posted Dec 15, 2021 21:03 UTC (Wed) by atai (subscriber, #10977) [Link]

Putting a non cloud related program under AGPL may make sense, for example mupdf. Because it is not clear if someone else may use a non cloud intended program on the cloud or over the network someday

Mold (linker) 1.0 released

Posted Dec 15, 2021 20:20 UTC (Wed) by cyperpunks (subscriber, #39406) [Link]

Why not work on LLD instead? It goes in circles around gold and ld already:
https://lld.llvm.org/

Mold (linker) 1.0 released

Posted Dec 15, 2021 20:34 UTC (Wed) by jhoblitt (subscriber, #77733) [Link]

The primary author worked on lld and claims that mold is significantly faster. https://github.com/rui314/mold#mold-a-modern-linker

I have never used mold and can't attest to its performance.

Mold (linker) 1.0 released

Posted Dec 15, 2021 21:10 UTC (Wed) by syrjala (subscriber, #47399) [Link]

So after gold is left rotting for long enough we end up with mold?

Mold (linker) 1.0 released

Posted Dec 15, 2021 22:03 UTC (Wed) by atai (subscriber, #10977) [Link]

can gold be revitalized?

Mold (linker) 1.0 released

Posted Dec 15, 2021 21:11 UTC (Wed) by ballombe (subscriber, #9523) [Link]

Does it speed up LTO ?
Now that would be something!

Mold (linker) 1.0 released

Posted Dec 15, 2021 21:59 UTC (Wed) by Vipketsh (guest, #134480) [Link]

LTO is predominantly a compiler thing and is thus limited by the speed of the compiler, not the linker.

Mold (linker) 1.0 released

Posted Dec 15, 2021 21:18 UTC (Wed) by Karellen (subscriber, #67644) [Link]

From the README.md:

It is sometimes very hard to pass an appropriate command line option to cc to specify an alternative linker. [...]

For some reason, I thought that setting the "LD" environment variable would work for most GNU build tools. But checking the GNU make Implicit Variables documentation, although there exists CC & CCFLAGS, and CXX & CXXFLAGS, and similar (but not always exact) snowclones of tool & toolFLAGS variables for AR, AS, CPP, FC, CO, LEX, YACC, PC and LINT, and there is an LDFLAGS, there is no LD equivalent!

What a bizarre inconsistency.

Mold (linker) 1.0 released

Posted Dec 15, 2021 21:31 UTC (Wed) by Bigos (subscriber, #96807) [Link]

The problem is, you rarely execute the linker directly. Most often you do it using the compiler frontend, such as gcc, g++, clang, etc. Hence most often you link using CC or CXX (at least in C/C++ land).

And these frontends had to learn alternate linkers on their own using command line parameters. This is how -fuse-ld=$LINKER came to be. Unfortunately, for whatever reason (various linkers not being completely compatible?), the $LINKER parameter, at least for gcc, is restricted to a list of linkers, mold not being one of them. Also note that $LINKER is not the executable name, it is ld.$LINKER instead (like ld.gold).

https://gcc.gnu.org/onlinedocs/gcc-11.2.0/gcc/Link-Option...

Mold (linker) 1.0 released

Posted Dec 15, 2021 22:12 UTC (Wed) by madscientist (subscriber, #16861) [Link]

The contents of the manual are the MINIMUM set of variables that are assigned. The docs make this pretty clear where it says: Here is a table of some of the more common variables. If you want to know the full set of default variables you can ask make to show them to you:

$ make -pf/dev/null | grep ^LD
make: *** No targets.  Stop.
LD = ld

As already mentioned, though, it's very rare that anyone actually uses ld directly. These days, unless you're trying to create a bare executable, you pretty much have to use the compiler's front end because it will add important linker options and internal (but critically important) libraries. Indeed, most of make's built-in rules don't use $(LD) they use $(CC) (or the equivalent for other languages).

Mold (linker) 1.0 released

Posted Dec 15, 2021 21:57 UTC (Wed) by Vipketsh (guest, #134480) [Link]

I didn't get why a new linker built for speed was so important, but after looking at the README here, I sort of understand:
Program (linker output size)
Chrome 96 (1.89 GiB)
Clang 13 (3.18 GiB)
Firefox 89 libxul (1.64 GiB)

So, programs these days weigh in at multiple gigabytes. Anyone know what the breakdown of those gigabytes are ? Surely it is not all machine code...

Mold (linker) 1.0 released

Posted Dec 15, 2021 22:50 UTC (Wed) by mathstuf (subscriber, #69389) [Link]

With templates and, more generally, monomorphization that happens, libraries can be *quite* large. Without optimization, some projects I work on have multi-hundred MB *object* files, nevermind libraries. Given how much just raw code that gets dumped out these days from DOM specs and other API IDL files for modern browsers…I'm not really all that surprised here. Optimization helps *a lot* by eliding lots of symbol names and inlining only-visible-inside-the-TU instantiations, but that's not what developers are necessarily working on all the time.

Mold (linker) 1.0 released

Posted Dec 16, 2021 0:27 UTC (Thu) by rillian (subscriber, #11344) [Link]

Well, most of it is probably debug tables. You'll note the release downloads are ~10% that size.

These are also huge programs. According to tokei on today's main branches:

firefox 37M lines of code (3M C, 6M C++, 4M headers, 8M Javascript, 3M Rust)
chromium 36M lines (14M C++, 5M headers, 4M Javascript)
linux 32M lines (21M C, 7M headers)

Browsers are effectively an entire userspace unto themselves, so it's not surprising builds are the same size as a minimal desktop image.

Otherwise, what mathstuf said. Link times on large C++ applications can be a real bottleneck, especially for incremental development. Linux has the advantage of being in C, and more modular.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK