Closed Bug 1746462 Opened 4 years ago Closed 3 years ago

Give the mold linker a spin

Categories

(Firefox Build System :: Toolchains, task)

task

Tracking

(firefox106 fixed)

RESOLVED FIXED
106 Branch
Tracking Status
firefox106 --- fixed

People

(Reporter: gsvelto, Assigned: andi)

References

Details

Attachments

(1 file)

The mold linker just hit its 1.0 release.

It claims to be able to link Firefox and be significantly faster than lld. Filing this to remind me to give it a spin.

FWIW, linking libxul on my machine with gold vs. lld vs. mold with the same flags:

limited to  gold     lld   mold
  1 core    15.99s   9.25s 7.38s
  2 cores  unchanged 5.49s 3.88s
  4 cores  unchanged 4.44s 2.67s
  6 cores  unchanged 3.74s 2.09s
  8 cores  unchanged 3.58s 1.76s
 unlimited unchanged 2.27s 0.73s

With hints from https://maskray.me/blog/2021-12-19-why-isnt-ld.lld-faster :

                          no build-id   no build-id
limited to  lld   mold    lld   mold    lld -Wl,-O0
  1 core    9.25s 7.38s   6.44s 6.35s   3.41s
  2 cores   5.49s 3.88s   4.09s 3.40s   2.32s
  4 cores   4.44s 2.67s   3.53s 2.36s   2.10s
  6 cores   3.74s 2.09s   3.08s 1.89s   1.94s
  8 cores   3.58s 1.76s   2.92s 1.55s   1.88s
 unlimited  2.27s 0.73s   2.12s 0.70s   1.65s

Oddly enough, mold linker fails while building libxul.so

/usr/lib/llvm/13/bin/x86_64-pc-linux-gnu-clang++ -std=gnu++17 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fstack-clash-protection -Qunused-arguments -Qunused-arguments -Wall -Wbitfield-enum-conversion -Wdeprecated-this-capture -Wempty-body -Wformat-type-confusion -Wignored-qualifiers -Wpointer-arith -Wshadow-field-in-constructor-modified -Wsign-compare -Wtype-limits -Wno-error=tautological-type-limit-compare -Wunreachable-code -Wunreachable-code-return -Wunused-but-set-parameter -Wno-invalid-offsetof -Wclass-varargs -Wempty-init-stmt -Wfloat-overflow-conversion -Wfloat-zero-conversion -Wloop-analysis -Wno-range-loop-analysis -Wc++2a-compat -Wcomma -Wenum-compare-conditional -Wimplicit-fallthrough -Wstring-conversion -Wno-inline-new-delete -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=backend-plugin -Wno-error=free-nonheap-object -Wno-error=return-std-move -Wno-error=atomic-alignment -Wno-error=deprecated-copy -Wformat -Wformat-security -Wno-gnu-zero-variadic-macro-arguments -Wno-psabi -Wno-unknown-warning-option -fno-sized-deallocation -fno-aligned-new -march=native -pipe -fno-stack-protector -fno-exceptions -fPIC -fno-rtti -ffunction-sections -fdata-sections -fno-exceptions -fno-math-errno -pthread -pipe -O3 -fomit-frame-pointer -funwind-tables  -shared -Wl,-z,defs -Wl,--gc-sections -Wl,-h,libxul.so -o libxul.so /var/tmp/portage/www-client/firefox-98.0/work/firefox_build/toolkit/library/build/libxul_so.list  -flto=thin -Wl,-plugin-opt=-import-instr-limit=10 -Wl,-plugin-opt=-import-hot-multiplier=30 -lpthread -Wl,-O1 -Wl,--as-needed -Wl,--compress-debug-sections=zlib -Wl,-rpath=/usr/lib64/firefox,--enable-new-dtags -fuse-ld=mold -Wl,-z,noexecstack -Wl,-z,text -Wl,-z,relro -Wl,-z,nocopyreloc -Wl,-Bsymbolic-functions -fstack-protector-strong -fstack-clash-protection -Wl,-rpath-link,/var/tmp/portage/www-client/firefox-98.0/work/firefox_build/dist/bin -Wl,-rpath-link,/usr/lib  ../../../js/src/build/libjs_static.a /var/tmp/portage/www-client/firefox-98.0/work/firefox_build/86_64-unknown-linux-gnu/release/libgkrust.a ../../../security/sandbox/linux/libmozsandbox.so ../../../config/external/lgpllibs/liblgpllibs.so ../../../config/external/sqlite/libmozsqlite3.so ../../../widget/gtk/mozgtk/libmozgtk.so ../../../widget/gtk/mozwayland/libmozwayland.so -Wl,--version-script,symverscript  -licui18n -licuuc -licudata -lasound -lrt -lm -ldl -lpthread -lc -lffi -lplds4 -lplc4 -lnspr4 -lz -lssl3 -lsmime3 -lnss3 -lnssutil3 -lfreetype -lfontconfig -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lgraphite2 -lwebpdemux -lwebp -levent -lvpx -lpixman-1 -ldbus-glib-1 -ldbus-1

Error

mold: fatal: /var/tmp/portage/www-client/firefox-98.0/work/firefox_build/toolkit/library/build/libxul_so.list:1022: INPUT("../../../media/libaom/entropy.o")
                                                                                                                   ^ library not found: ../../../media/libaom/entropy.o

though ../../../media/libaom/entropy.o exists relative to cwd (where clang is invoked from)

Resolve the aforementioned error. Was due to insufficient ulimits. Though PGO+LTO build still fails due to relocation errors

relocation R_X86_64_GOTPCREL against Gecko_ReleaseAtom out of range
Assignee: nobody → bpostelnicu
Status: NEW → ASSIGNED
Attachment #9256244 - Attachment description: WIP: Bug 1746462 - add support for --enable-linker=mold → Bug 1746462 - add support for --enable-linker=mold on linux. r=glandium
Pushed by bpostelnicu@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/27ad8fddd96d add support for --enable-linker=mold on linux. r=glandium
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 106 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: