Skip to content

Instantly share code, notes, and snippets.

@skierpage
Created January 29, 2025 09:42
Show Gist options
  • Save skierpage/c3073ae2a72dd04300031b97f095d8f4 to your computer and use it in GitHub Desktop.
Save skierpage/c3073ae2a72dd04300031b97f095d8f4 to your computer and use it in GitHub Desktop.
Notes on the unwanted firefox-bin on Linux

I filed Redhat bug 2342438 that Fedora has an unneeded duplicated firefox-bin in /usr/lib64/firefox/ that is _almost the same binary as /usr/lib64/firefox/firefox.

Likewise there's an unneeded /usr/lib64/thunderbird/thunderbird-bin ([Mozilla bug 697218](https://]

Mozilla bug 658850 has patches that remove mention of firefox-bin from several places, but not the `cp -p in Makefile.in that creates it.

Where do /usr/lib64/firefox/firefox-bin and .../thunderbird-bin come from?

I searched mozilla-central source for everything ending with "-bin" or "x-bin" using the regex [^0-9a-wyz\-]-bin\b]. Here are notes on some of the results.

browser/app/Makefile.in has

ifneq (,$(filter-out WINNT,$(OS_ARCH)))

ifdef COMPILE_ENVIRONMENT
ifndef MOZ_NO_PIE_COMPAT
libs::
	cp -p $(DIST)/bin/$(MOZ_APP_NAME)$(BIN_SUFFIX) $(DIST)/bin/$(MOZ_APP_NAME)-bin$(BIN_SUFFIX)

which copies the binary to -bin as a libs target. There should be a comment explaining this line; why silently make a copy of the MOZ_APP_NAME with -bin on the end?

I looked at a Fedora package build log and in it this copy appears twice, I think because its using PGO and the first time is for an instrumented build. I couldn't figure out how the two binaries end up diverging.

So maybe the fix is not to do this copy by changing the ifdefs, and the -bin file goes away? But other parts of the build reference this file.

mozbuild/artifacts.py lists

   "{product}/{product}-bin",

under class LinuxArtifactJob.

browser/installer/package-manifest.in has various ifndefs that end up adding

#ifndef XP_MACOSX
@BINPATH@/@MOZ_APP_NAME@-bin

I think on Linux this adds firefox-bin to package-manifest.

MOZ_NO_PIE ?

browser/app/moz.build has

    if CONFIG["MOZ_NO_PIE_COMPAT"]:
        GeckoProgram(CONFIG["MOZ_APP_NAME"] + "-bin", linkage=browser_linkage)

I don't know if MOZ_NO_PIE_COMPAT is set in a Linux build.

browser/app/no-pie/NoPie.c defines a main() that reads the executable from /proc/self/exe then appends -bin to it and execv() that path. I'm pretty sure Fedora doesn't do this.

Is the "correct" binary firefox or firefox-bin ?

The firefox(1) man page in the Fedora firefox package describes

firefox is a simple shell script that will set up the environment for the actual executable, firefox-bin. ... /usr/lib64/firefox/firefox-bin - firefox executable

but the shell script wraps /usr/lib64/firefox/firefox, not firefox-bin, so these two lines should be changed. And like the Debian firefox(1) man page it should correctly documents the firefox-bin file as "Legacy executable". I filed Redhat bug 2342756.

The Debian firefox.1 man page says

  • /usr/bin/firefox - symbolic link to /usr/lib/firefox/firefox.
  • /usr/lib/firefox/firefox - Firefox executable.
  • /usr/lib/firefox/firefox-bin - Legacy executable.

But the Linux.die online man page confidently says firefox is a simple shell script that will set up the environment for the actual executable, firefox-bin.

Other things that might depend on -bin executable

I think a bunch of tests hardcode a firefox-bin. There isn't a global "If on system X then append -bin to the binary name".

build.log

I downloaded the build log from a Fedora build.

Line 356022 is the second time it copies the app to app-bin (it builds it twice because it does Profile Guided Optimization): cp -p ../../dist/bin/firefox ../../dist/bin/firefox-bin

Yet somehow one of these is altered after that.

Line 378396 it warns warning: Duplicate build-ids /builddir/build/BUILD/firefox-134.0.2-build/BUILDROOT/usr/lib64/firefox/firefox and /builddir/build/BUILD/firefox-134.0.2-build/BUILDROOT/usr/lib64/firefox/firefox-bin

I can't see any changes to either binary after that, yet they wind up different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment