Mold 2.0
github.com
github.com
I've recently been trying to speed up our project builds, and found that linking is absolutely a huge bottleneck. I've got 24 cores * 2 threads to build on, and maybe 30% of that power goes unused because of the linker.
I've made a previous attempt to build with mold but it didn't quite work at the time. I'll be giving it another try.
Having a ridiculously long cycle time massacres productivity and job satisfaction.
[0] https://devblogs.microsoft.com/cppblog/improved-linker-funda...
All that said, I'm not convinced the licensing is the issue here (although I wish them the best). We are in a world that has grown accustom to free development tools and building a commercially viable business in tooling is incredibly difficult. I'm always amazed by how many developers I know who make a living by creating software yet are unwilling to pay for software themselves.
Bullshit. Most organizations are absolutely fine with different ad-hoc licenses for various closed source software. Applying different standards to copyleft licenses is just due to FUD.
> AGPL would only restrict deploying a privately modified linker via a network service which isn't a realistic scenario for a basic dev tool.
Interacting with linker over network service may sound weird, but it's not that uncommon. For example Unity offers Cloud build service for their engine which means indirectly interacting with Android and iOS toolchains. All major cloud providers are making solutions where the development tools and libraries are tightly integrated with their cloud service in attempts to make it harder migrating your project away from them. Regular CI/CD service providers are including the most popular development tools in their default environment, both to simplify the development process and also so that they can better cache them thus saving network costs and speeding up builds compared to each customer downloading the toolchain manually. There was also a period where multiple companies where pushing a remote dev environment as a solution to minimize the hassle of having each developer setup things locally thus improving onboarding speed, ensuring everyone is working in the same environment and also simplifying work for company wide IT management.
In many of those cases there might be 2 or even 3 companies repackaging and redistributing between the original software (linker) author and final user (programmer).
Even in the land of open source things aren't that simple. Not sure if it's still a thing but there was a period when FreeBSD was trying to remove GPL from it's base packages.
You can use modified GPL code to your heart's content in a corporate setting. As all your coworkers are part of one legal entity, private use within the organization is not distribution per the terms of GPL. You have to distribute a binary to someone who can make a claim under the terms of the license before copyleft is activated. Furthermore, you only ever have to disclose source to someone with possession of a derived binary.
Let's imagine Google wanted to include Mold in Android sdk, and CI service company (like Travis or Github with their Actions) want to include Android SDK in their VM images. I would consider using of such CI service for building android app interacting with the linker software over network. Meaning everyone in the middle (Google and CI service) has to deal with license requirements.
https://gist.github.com/lleyton/9c0b75d065f37333ea9851b6cad1...
It did not workout, so they're switching to MIT.
If the authors really wanted a more permissive license, then instead of relicensing from AGPL to MIT they should have relicensed from AGPL to AGPL with linking exception. An example of a project that is GPL with linking exception is libgit2 [1]. This licensing is more permissive but still permits the author to sell commercial licenses to those making closed-source code changes.
I think the point is that the authors don't want want to continue selling licenses, as it wasn't worth the hassle. I guess `sold`, the macOS version is an exception.
If selling licenses is a hassle, then that indicates a problem with the open source ecosystem as GitHub and other code hosting websites should offer monetization tools for selling closed-source licenses directly from their web interface. I'm talking legal forms, templates, payment processors, and product tracking. Selling licenses should be easy, not a hassle.
15:55 $ du -Hs --si target/
11G target/1. Faster rust builds!
[target.x86_64-unknown-linux-gnu]
linker = "clang"
rustflags = [
"-C", "link-arg=-fuse-ld=mold",
"-C", "target-cpu=native"
]
2. Faster `makepkg` with ArchLinux, by adding "-fuse-ld=mold" to CFLAGS.
(fairly large Rust project, 24-core machine, Linux)
-- GNU Ld 2.31.1
>> cargo build --release
Compiling mfl v0.1.0 (/mnt/d/Programming/Projects/Rust/mfl/crates/mfl)
Finished release [optimized + debuginfo] target(s) in 10.14s
-- LLD-14
>> cargo build --release
Compiling mfl v0.1.0 (/mnt/d/Programming/Projects/Rust/mfl/crates/mfl)
Finished release [optimized + debuginfo] target(s) in 6.20s
-- Mold 2.0
>> cargo build --release
Compiling mfl v0.1.0 (/mnt/d/Programming/Projects/Rust/mfl/crates/mfl)
Finished release [optimized + debuginfo] target(s) in 6.02s
I did the following for each test: cargo clean
cargo build --release
touch crates/mfl/src/main.rs
cargo build --release
With the timings coming from the second build. The project links in LLVM, and the tests were done under WSL1 on Windows 10 with the files on the Windows file system, which is how the project is developed in general.Git life pro tip (that you didn't know you needed until now): You can use .git/info/exclude (present in every Git repository) as a local, private version of .gitignore. It has the same syntax as .gitignore, but isn't tracked by Git. So you could add .cargo/config.toml to .git/info/exclude, changing the linker locally without Git considering it as an untracked file. I generally use this feature to ignore files that are specific to my development setup which I don't want to list in .gitignore.
A similar one: ~/.config/git/ignore is a global private gitignore.
Great for files across repos which you always want to ignore, such as temporary files from an editor
> This repository contains a free version of the mold linker. If you are looking for a commercial version that supports macOS please visit the repository of the sold linker.
Give him a stack of cash for his work and make all well with the Universe.
It’d be so easy for them.
But how (and why not) such a fine cratsman should be rewarded? Companies (maybe of all sizes) should allocate some funds to their top dependencies/tools or something and this should be listed on their main websites. More of a cultural norm I guess?
> Mold 2.0.0 is a new major release of our high-speed linker. With this release, we've transitioned our license from AGPL to MIT, aiming to expand the user base of our linker. This was not an easy decision, as those who have been following our progress know that we've been attempting to monetize our product through an AGPL/commercial license dual-licensing scheme. Unfortunately, this approach didn't meet our expectations. The license change represents our acceptance of this reality. We don't want to persist with a strategy that didn't work well.
We have been conditioned for a very long time to not need to pay for low level developer tools and to pay for support instead. I'm surprised they even tried to license it like that.
[0] https://unix.stackexchange.com/questions/12731/usr-ucb-cc-la...
The OS/hardware maker’s primary interest is in selling more OS or hardware, so it makes sense for them to give away the tools (or their work enhancing the already-free tools) that enable more and better applications.
An independent tool vendor is in a different position, and there have always been vendors with better tools, maybe for a specialized market, or maybe just going above and beyond what comes for free, which is what Mold tries to do.
In other words, it’s clear to everyone now that the essential tools should be free, but surely not that all tools should be free!
Obviously not, since their business model changed.
I agree with the tooling being a nightmare though. It is a 80gb+ install that fails half the time.
The average cost of a developer is more than $100/hr. mold needs to make you 0.05% (not 5%, 0.05%) more productive to directly pay for itself. If mold saves you 13 seconds a day in linking time it directly pays for itself. This ignores the knock on effects of reduced build time shortening the feedback cycle which completely dwarf the direct benefits.
It is ridiculous that such dirt cheap pricing for tools is viewed as a problem. As we saw in a post yesterday [2], this is why they say there is no money is tools.
It also wasn't paywalled, meaning tons of people probably just added it as a dependency in the CI and just ignored the license restrictions because it wasn't directly part of the shipped binary. There's no good way to enforce that.
There's not anything to enforce. The AGPL allows you to run the application for any purpose. (If you modify the source, you have to make the modified source available to all users, including over the network users.)
The standard choice being free and good (best, in many cases) really can't be overstated.
Only then it started to gain momentum from people not willing to pay for Solaris Developer SDK.
In any case, I bet people using free beer tools enjoy being paid for their work, so just maybe they should also think in giving some money to the authors of those tools.
Rui's given some good talks about Mold if you want more info: https://www.youtube.com/watch?v=hAt3kCalE0Y
What takes time is rewriting stuff as you go. Running the relocation tables to insert addresses into the code is cheap. Deadstripping sections is fairly cheap, deadstripping individual basic blocks within functions takes a lot more analysis and thus time.
Deduplicating constant strings is a good idea but involves streaming them all into a hashtable of some sort. Maybe you want them to share common suffixes, more work.
Deduplicating, deadstripping, rewriting debug information takes time. Debug builds can feature many gigabytes of dwarf to rewrite.
Oddly enough that the linker is scriptable, as in you can give it a program that it interprets, doesn't seem to be a significant cost. Probably because the script in question is quite short and somewhat limited in functionality.
Historically lld was very fast because it didn't bother doing any of the debug munging or other deduplication. Lld ran fast but the output binary was big.
I'm several years out of the linker performance game now so don't know the current status. In particular I don't know where mold or lld are in terms of quality of output vs their own performance.
https://www.airs.com/blog/archives/38
"Once again, the goal is speed, in this case being faster than my second linker. That linker has been significantly slowed down over the years by adding support for ELF and for shared libraries. This support was patched in rather than being designed in. Future plans for the new linker include support for incremental linking–which is another way of increasing speed."
Just think of the apps that were written in early Unix days - simple single-purpose apps, probably just one source code file , just one obj and libc to link together, no shared libs et al.
The linker code just grew organically as new "must-have" features were added. Correctness of features was more important than speed esp. when spinning rust was a limiting factor.
From the report to the fix in less than two days.
I'm not sure how competitive it will be with lld, especially if we consider ThinLTO (which takes multiple minutes on 64-core machine) - it can make the advantages of mold insignificant.
Mold is focused on (incremental) development builds where LTO is probably not what you want anyway. For actual release builds you shouldn't really care that much about the build time.
I wish I could use things like this in my day-to-day.
Sadly, stuck on very old OSs and toolchains. And you can forget about ever using Clang! :(
Not that I agree with them, but, also, IANAL.
There are plenty of ways to reduce friction. In this case, mold could have offered a 30 day commercial license to the company to demo the linker and see if the ROI was worth it.
When I benchmarked it about a year ago (with a fairly large Rust project on a 24-core machine), incremental builds went from ~8s to ~2.7s.
[1]: https://github.com/rui314/mold/issues/190#:~:text=I%27ve%20a...
argv=( ${CMAKE:-cmake3} )
argv+=( -S %{cmake_source_dir} )
argv+=( -B %{cmake_build_dir} )
argv+=( -G Ninja )
argv+=( -D CMAKE_CXX_FLAGS='-march=native -flto' )
argv+=( -D CMAKE_INSTALL_PREFIX=%{install_home} )
argv+=( -D CMAKE_EXE_LINKER_FLAGS="-Wl,-rpath=%{openssl_root}/lib" )
argv+=( -D OPENSSL_ROOT_DIR=%{openssl_root} )
"${argv[@]}"