Bug 279140 - www/firefox: Version 126.0_2,2 fails to build with LTO
Summary: www/firefox: Version 126.0_2,2 fails to build with LTO
Status: Closed Not Accepted
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Only Me
Assignee: Christoph Moench-Tegeder
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-05-18 20:29 UTC by makoto90
Modified: 2024-06-17 21:16 UTC (History)
3 users (show)

See Also:
bugzilla: maintainer-feedback? (gecko)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description makoto90 2024-05-18 20:29:44 UTC
In Freebsd 14.0-p6, poudriere fails to build firefox-126.0_2,2. 
Log:
ld.lld: warning: Linking two modules of different data layouts: '/wrkdirs/usr/ports/www/firefox/work/.build/toolkit/library/build/../../../tools/profiler/Unified_cpp_tools_profiler0.o' is 'e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128' whereas '/wrkdirs/usr/ports/www/firefox/work/.build/x86_64-unknown-freebsd/release/libgkrust.a(gecko_profiler-2cbfbde1e8f07db6.gecko_profiler.c060a87e5129ab9e-cgu.0.rcgu.o at 150992188)' is 'e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128'


ld.lld: error: Invalid record (Producer: 'LLVM18.1.2-rust-1.78.0-stable' Reader: 'LLVM 17.0.6')
ld.lld: error: Invalid record (Producer: 'LLVM18.1.2-rust-1.78.0-stable' Reader: 'LLVM 17.0.6')
ld.lld: error: Invalid record (Producer: 'LLVM18.1.2-rust-1.78.0-stable' Reader: 'LLVM 17.0.6')
ld.lld: error: Invalid record (Producer: 'LLVM18.1.2-rust-1.78.0-stable' Reader: 'LLVM 17.0.6')
ld.lld: error: Invalid record (Producer: 'LLVM18.1.2-rust-1.78.0-stable' Reader: 'LLVM 17.0.6')
ld.lld: error: Invalid record (Producer: 'LLVM18.1.2-rust-1.78.0-stable' Reader: 'LLVM 17.0.6')
ld.lld: error: Invalid record (Producer: 'LLVM18.1.2-rust-1.78.0-stable' Reader: 'LLVM 17.0.6')
ld.lld: error: Invalid record (Producer: 'LLVM18.1.2-rust-1.78.0-stable' Reader: 'LLVM 17.0.6')
ld.lld: error: Invalid record (Producer: 'LLVM18.1.2-rust-1.78.0-stable' Reader: 'LLVM 17.0.6')
ld.lld: error: Invalid record (Producer: 'LLVM18.1.2-rust-1.78.0-stable' Reader: 'LLVM 17.0.6')
ld.lld: error: Invalid record (Producer: 'LLVM18.1.2-rust-1.78.0-stable' Reader: 'LLVM 17.0.6')
ld.lld: error: Invalid record (Producer: 'LLVM18.1.2-rust-1.78.0-stable' Reader: 'LLVM 17.0.6')
ld.lld: error: Invalid record (Producer: 'LLVM18.1.2-rust-1.78.0-stable' Reader: 'LLVM 17.0.6')
ld.lld: error: Invalid record (Producer: 'LLVM18.1.2-rust-1.78.0-stable' Reader: 'LLVM 17.0.6')
ld.lld: error: Invalid record (Producer: 'LLVM18.1.2-rust-1.78.0-stable' Reader: 'LLVM 17.0.6')
ld.lld: error: Invalid record (Producer: 'LLVM18.1.2-rust-1.78.0-stable' Reader: 'LLVM 17.0.6')
ld.lld: error: Invalid record (Producer: 'LLVM18.1.2-rust-1.78.0-stable' Reader: 'LLVM 17.0.6')
ld.lld: error: Invalid record (Producer: 'LLVM18.1.2-rust-1.78.0-stable' Reader: 'LLVM 17.0.6')
ld.lld: error: Invalid record (Producer: 'LLVM18.1.2-rust-1.78.0-stable' Reader: 'LLVM 17.0.6')
ld.lld: error: Invalid record (Producer: 'LLVM18.1.2-rust-1.78.0-stable' Reader: 'LLVM 17.0.6')
ld.lld: error: too many errors emitted, stopping now (use --error-limit=0 to see all errors)
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[3]: *** [/wrkdirs/usr/ports/www/firefox/work/firefox-126.0/config/rules.mk:541: libxul.so] Error 1
gmake[3]: Leaving directory '/wrkdirs/usr/ports/www/firefox/work/.build/toolkit/library/build'
gmake[2]: *** [/wrkdirs/usr/ports/www/firefox/work/firefox-126.0/config/recurse.mk:72: toolkit/library/build/target] Error 2
gmake[2]: Leaving directory '/wrkdirs/usr/ports/www/firefox/work/.build'
gmake[1]: *** [/wrkdirs/usr/ports/www/firefox/work/firefox-126.0/config/recurse.mk:34: compile] Error 2
gmake[1]: Leaving directory '/wrkdirs/usr/ports/www/firefox/work/.build'
gmake: *** [/wrkdirs/usr/ports/www/firefox/work/firefox-126.0/config/rules.mk:361: all] Error 2
*** Error code 1

Stop.
make: stopped in /usr/ports/www/firefox
=>> Cleaning up wrkdir
===>  Cleaning for firefox-126.0_2,2
build of www/firefox | firefox-126.0_2,2 ended at Sat May 18 16:13:11 -04 2024
build time: 02:01:30
!!! build failure encountered !!!
Comment 1 Olivier Certner freebsd_committer freebsd_triage 2024-05-18 21:20:15 UTC
I had the same problem.  You are compiling Firefox with option LTO, which has been broken since Rust's last update.  The new Rust indeed relies on LLVM 18, which apparently produces LTO output unrecognized by LLVM 17.

Two possible workarounds:
- Either disable LTO and rebuild.
- Or keep LTO, and alter bsd.gecko.mk so that LLVM 18 is used.

I'm writing this from a Firefox recently built with the second alternative.
Comment 2 makoto90 2024-05-18 22:00:07 UTC
(In reply to Olivier Certner from comment #1)
Hi. Yes, I enabled the LTO flag. Where is located bsd.gecko.mk? Thanks for your help.
Comment 3 Olivier Certner freebsd_committer freebsd_triage 2024-05-18 22:03:51 UTC
(In reply to makoto90 from comment #2)

From the root of the ports tree, it is at 'Mk/bsd.gecko.mk'. Just substitute 'llvm:17' by 'llvm:18' there.
Comment 4 makoto90 2024-05-18 23:12:59 UTC
(In reply to Olivier Certner from comment #3)
Thanks for your answer. I was looking for this file, but I couldn't find it anywhere.
Comment 5 Nuno Teixeira freebsd_committer freebsd_triage 2024-05-21 12:59:38 UTC
(In reply to Olivier Certner from comment #3)

Hello Olivier,

Shoudn't bsd.gecko.mk updated from llvm:min=17 to llvm:18 ?

From git commit history, llvm is updated dependending on rust.

Thanks
Comment 6 Olivier Certner freebsd_committer freebsd_triage 2024-06-17 08:13:24 UTC
(In reply to Nuno Teixeira from comment #5)

Not being part of gecko@, I simply don't know.  When I commented above, 'bsd.gecko.mk' contained 'llvm:17', which was changed to 'llvm:min=17' by Christoph Moench-Tegeder (cmt), the commit messages implying that ESR versions of Firefox and Thunderbird initially didn't build with LLVM 18 but were made to with ports tree patches.

So:
1. With the current ports tree, directly modifying 'Mk/bsd.gecko.mk' is not needed anymore, one can use 'DEFAULT_VERSIONS+=llvm=18' in its '/etc/make.conf'.
2. Christoph Moench-Tegeder is probably a (the?) good interlocutor for answering your question. So assigning this PR to him in the meantime.

For Christoph: If you are not the right assignee, do you know who could be?

Thanks and regards.
Comment 7 Christoph Moench-Tegeder freebsd_committer freebsd_triage 2024-06-17 21:16:55 UTC
LTO is OFF by default because it keeps breaking (and because it uses so much build time that I could never recoup that during actual usage). If you insist on using non-default options, it's up to you to deal with DEFAULT_VERSIONS, but don't complain if stuff breaks in other places with that.