Hi,

Here are two things that might help you get faster builds.

TL;DR:

1. On Linux, make sure you have lld installed, because it's a *much* faster
linker than gold, and it's now used by default if installed.

2. Upgrade your sccache to version 0.2.7 to get faster rebuilds of changed
Rust files.


DETAILS:

1. lld was made the default linker on Linux (when installed) in
https://bugzilla.mozilla.org/show_bug.cgi?id=1473436. Thank you, glandium!

If you don't already have it installed, run `mach bootstrap`  to get a copy
in ~/.mozbuild/clang/bin/, which you can then add to your PATH.
Alternatively `mach artifact toolchain --from-build linux64-clang` will
download lld (and other clang tools) under the current directory.

To confirm that lld is being used, look for this output from configure:

  checking for linker... lld

On other platforms, lld is not yet the default but you *might* be able to
use it.

On Windows, again use `mach bootstrap` and add this to your mozconfig:

  export LINKER=lld-link

This used to cause problems with debugging (bug 1458109) but that has since
been fixed.

On Mac, if you have lld installed, add this to your mozconfig:

  export LDFLAGS=-fuse-ld=lld

but it might cause build errors, such as "No rule to make target
`libmozavutil_dylib.list', needed by `libmozavutil.dylib`".

https://bugzilla.mozilla.org/show_bug.cgi?id=1384434 is the tracking bug
for making lld the default on all platforms. Any bugs filed about problems
should block that bug.

Also, if you are building a Rust-only project, something like this might
work (on Linux; I'm not sure about other builds):

  RUSTFLAGS="-Clinker=clang -Clink-arg=-fuse-ld=lld" cargo build

See https://github.com/rust-lang/rust/issues/50584#issuecomment-398988026
for an example improvement.

https://github.com/rust-lang/rust/issues/39915 is the issue for making lld
the default linker for Rust.

On non-Linux platforms, I recommend testing with the resulting builds
before you place full confidence in them.


2. When the Rust compiler is invoked with incremental compilation (which
happens in any Firefox build that doesn't have --enable-release) sccache
0.2.7 will skip the file, which is good because incremental compilation has
much the same effect, and sccache used to cause significant slowdowns in
the cases where a cache miss occurred. Thank you to ted for this
improvement!

For example, on my fast Linux box, if I `touch` servo/components/style/
stylist.rs and rebuild (resulting in an sccache cache hit), I get these
times:
- old sccache disabled: 28s
- old sccache enabled: 25s
- new sccache enabled: 28s

I.e. sccache's new behaviour causes a tiny slowdown.

But if I insert a comment at the top of that file (resulting in an sccache
cache miss), I get these times:
- old sccache disabled: 37s
- old sccache enabled: 1m53s(!)
- new sccache enabled: 37s

I.e. sccache's new behaviour is a big win. And this "make a small change
and recompile" case is extremely common.

See https://github.com/mozilla/sccache/issues/257 for more details.

Nick
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to