mold icon indicating copy to clipboard operation
mold copied to clipboard

Firefox: elfhack failure

Open ishitatsuyuki opened this issue 3 years ago • 5 comments

Steps to reproduce

  1. git clone https://github.com/mozilla/gecko-dev.git
  2. Install Rust (Version used: rustc 1.62.0-nightly (4dd8b420c 2022-05-01))
  3. Put the following in mozconfig
ac_add_options --enable-release --disable-cargo-incremental
export RUSTC_OPT_LEVEL=2
mk_add_options AUTOCLOBBER=1
  1. mold -run ./mach build -j16

Error message

 6:36.50 ===
 6:36.50 === If you get failures below, please file a bug describing the error
 6:36.50 === and your environment (compiler and linker versions), and
 6:36.50 === provide the pre-elfhacked library as an attachment.
 6:36.50 === Use --disable-elf-hack until this is fixed.
 6:36.50 ===
 6:36.50 ===
 6:36.50 === If you get failures below, please file a bug describing the error
 6:36.50 === and your environment (compiler and linker versions), and
 6:36.51 === provide the pre-elfhacked library as an attachment.
 6:36.51 === Use --disable-elf-hack until this is fixed.
 6:36.51 ===
 6:36.51   0x0000000000000019 (INIT_ARRAY)   0xd230
 6:36.51 test-array.so:   0x000000000000000c (INIT)         0x7020
 6:36.58 test-ctors.so: gmake[4]: *** [Makefile:28: test-array.so] Segmentation fault (core dumped)
 6:36.58 gmake[4]: *** Waiting for unfinished jobs....
 6:36.59 gmake[4]: *** [Makefile:28: test-ctors.so] Segmentation fault (core dumped)
 6:36.59 gmake[3]: *** [/home/ishitatsuyuki/gecko-dev/config/recurse.mk:99: build/unix/elfhack/libs] Error 2
 6:36.59 gmake[2]: *** [/home/ishitatsuyuki/gecko-dev/config/recurse.mk:34: libs] Error 2
 6:36.59 gmake[1]: *** [/home/ishitatsuyuki/gecko-dev/config/rules.mk:352: default] Error 2
 6:36.59 gmake: *** [client.mk:63: build] Error 2

Given the message, this might be upstream abusing linker options in some way. In that case, I'll forward this issue to the upstream instead.

Internal note: the files from the run above are available on the build server.

ishitatsuyuki avatar May 02 '22 15:05 ishitatsuyuki

Yes, elfhack certainly is abusing linker options in some way. Or abusing something, I'm not sure what.

Feels like the kind of thing that should either be part of the linker proper (half of that tool looks like things the linker already does), or be catapulted into the sun.

Alcaro avatar May 02 '22 17:05 Alcaro

elfhack is a very hacky tool, so even though most build failures should be on us, it looks like it's more like their fault than ours. Please upstream the issue and paste a link here.

I'm not also sure if elfhack is still relevant. The tool was created 12 years ago to optimize the Firefox executable at the time for the computers of the era. Computer has changed a lot since then. Most notably, most people are now using SSDs instead of spinning hard drives. Minimizing the number of "disk seeks" is no longer as important as it was. For example, writing .dynamic to a separate place than the file header is probably just fine. The access pattern of .ctors is probably also fine.

The use of elfhack should be evaluated IMHO. We might be able to stop using that tool.

rui314 avatar May 03 '22 02:05 rui314

Just looking at the build scripts, it seems elf-hack is disabled when lld is used. I'll ask the devs to do the same for mold.

ishitatsuyuki avatar May 20 '22 10:05 ishitatsuyuki

Thanks. Please paste a URL if you report the issue to Mozilla so that we can track the issue on our side as well.

rui314 avatar May 20 '22 11:05 rui314

For future reference, the patch that is yet to have elfhack disabled is on Phabricator, fixing this feature request on Bugzilla. I also tested and was able to compile Firefox with mold by disabling elfhack.

ndren avatar Jun 03 '22 16:06 ndren

The patch for mold support in mozbuild and disabling elfhack by default is now merged.

ishitatsuyuki avatar Sep 09 '22 14:09 ishitatsuyuki