Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 943159

Summary: www-client/firefox-132.0.1-r1: Wrong error message about missing lld for clang and lto
Product: Gentoo Linux Reporter: Klaus Kusche <klaus.kusche>
Component: Current packagesAssignee: Mozilla Gentoo Team <mozilla>
Status: RESOLVED FIXED    
Severity: normal CC: carlphilippreh, kangie, klaus.kusche, mackal.cook, mattst88
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=943116
https://bugs.gentoo.org/show_bug.cgi?id=943109
Whiteboard:
Package list:
Runtime testing required: ---

Description Klaus Kusche 2024-11-09 19:59:58 UTC
Emerging www-client/firefox-132.0.1-r1 fails with

 * Building firefox with lto and requires the sys-devel/lld or sys-devel/mold linker!
 * ERROR: www-client/firefox-132.0.1-r1::gentoo failed (setup phase):
 *   Please fix your toolchain configuration.

My relevant settings are the following:

* Default toolchain is gcc and ld (not lld!)

* I do have -flto in my CFLAGS, CXXFLAGS and LDFLAGS,
because I want both gcc and clang to compile with lto by default.
But I don't have any -fuse-ld= in my ...FLAGS
(because having any fixed -fuse-ld= together with -flto
would cause either the ebuilds using gcc or the ebuilds using clang to fail)

* Clang and lld is installed

* USE=default-lld is set for clang-common, so clang should always use lld,
even without having -fuse-ld=lld in ...FLAGS,
and even with ld being the default linker.

* USE=clang and USE=lto is set for firefox

As far as I can tell, with all previous firefox ebuilds this worked as desired
(and should have worked even without USE=default-lld for clang),
i.e. firefox was compiled and linked with clang, lto and lld,
due to the following piece of code in src_configure(),
which explicitely sets the linker to lld if clang and lto is used,
independently of the default toolchain linker.

if use lto ; then
  if use clang ; then
  # Upstream only supports lld or mold when using clang.
    if tc-ld-is-mold ; then
      # mold expects the -flto line from *FLAGS configuration, bgo#923119
      append-ldflags "-flto=thin"
      mozconfig_add_options_ac "using ld=mold due to system selection" --enable-linker=mold
    else
      mozconfig_add_options_ac "forcing ld=lld due to USE=clang and USE=lto" --enable-linker=lld
    fi

firefox-132.0.1-r1 also contains these lines in src_configure(),
so it would choose lld for linking anyway,
but it tests the default toolchain linker in pkg_setup()
long before setting the desired lld linker for USE=clang and USE=lto,
and fails with the message above if the default linker is not lld.
Comment 1 Michael Cook 2024-11-09 20:19:08 UTC
Pretty sure tc-ld-is-lld is calling probably checking with GCC.

I did end up setting up a /etc/portage/env with `LDFLAGS="${LDFLAGS} -fuse-ld=lld"` and built fine.

Personally I would favor removing the tc-ld-is-lld check and just depend on the ebuild fixing the toolchain itself, I'm not aware of this ever being an issue, but I could be wrong.
Comment 2 Klaus Kusche 2024-11-09 20:32:43 UTC
I removed the check from the ebuild and ran the ebuild again. 
It finished successfully, and looking at the running processes,
it compiled with clang, linked with lld, 
and had the thinlto options set for both.
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-11-12 00:18:38 UTC
(In reply to Michael Cook from comment #1)
> Personally I would favor removing the tc-ld-is-lld check and just depend on
> the ebuild fixing the toolchain itself, I'm not aware of this ever being an
> issue, but I could be wrong.

See the discussion in bug 943109.
Comment 4 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-11-12 00:18:59 UTC
I think this issue is sorted now, see comments in bug 943116.
Comment 5 Klaus Kusche 2024-11-12 09:54:21 UTC
The current firefox-132.0.1-r1.ebuild ebuild works for me. 
Fixed at least for my settings.