Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 877475 - >=www-client/firefox-102.3.0 - musl build fails at __cxa_finalize when building libmozgtk.so
Summary: >=www-client/firefox-102.3.0 - musl build fails at __cxa_finalize when buildi...
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Mozilla Gentoo Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-10-17 18:45 UTC by Andrew Athalye
Modified: 2023-10-19 07:44 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
Build Log Illustrating the Failure (build.log.xz,775.48 KB, application/x-xz)
2022-10-17 20:51 UTC, Andrew Athalye
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Athalye 2022-10-17 18:45:00 UTC
When building Firefox 102.3.0esr from source using ld.bfd 2.38, python 3.10.8, rust 1.62.1::musl, clang 14.0.6-r1, and gcc 12.2.0, Firefox build fails due to an undefined reference to "__cxa_finalize" in /usr/lib/crtbeginS.o.

This appears to have something to do with the linker flag "--no-as-needed" specified in /widget/gtk/mozgtk/moz.build in the Firefox source tree.

When this is removed, Firefox does build successfully, however a cursory "ldd /usr/lib/firefox/libmozgtk.so" reveals that it has no dynamic dependencies, and thus the --no-as-needed is necessary for a proper build.

Since libmozgtk.so contains no actual code, it is simple to fix this by just creating a file with the necessary dependencies or copying a correct libmozgtk.so from the binary releases available at mozilla.org.

The symbol __cxa_finalize is defined in libc.so, so I'm not sure why the linker isn't able to find it, however I unfortunately don't have much time to debug the issue tonight, and there is no other pertinent information in the build logs.

The command line that failed is "/usr/bin/x86_64-gentoo-linux-musl-
gcc -fPIC -ffunction-sections -fdata-sections -fno-math-errno -pt
hread -pipe -O2 -fomit-frame-pointer -funwind-tables -shared -Wl,
-z,defs -Wl,--gc-sections -Wl,-h,libmozgtk.so -o libmozgtk.so moz
gtk.o   -lpthread -fuse-ld=mold -Wl,-O1 -Wl,--as-needed -Wl,-z,re
lro -Wl,-z,now -Wl,--compress-debug-sections=zlib -Wl,-rpath=/usr
/lib/firefox,--enable-new-dtags -fuse-ld=bfd -Wl,-z,noexecstack -
Wl,-z,text -Wl,-z,relro -Wl,-z,nocopyreloc -Wl,-Bsymbolic-functio
ns -fstack-protector-strong -Wl,-rpath-link,/var/tmp/portage/www-
client/firefox-102.3.0/work/firefox_build/dist/bin -Wl,-rpath-lin
k,/usr/lib -Wl,--no-as-needed -lgtk-3 -lgdk-3 -Wl,
--as-needed"

-fuse-ld=mold doesn't actually make a difference here - Firefox overrides it later on anyway, and if I did force GCC to use mold it would still fail with the same error.

--
Firefox is being built with USE="dbus eme-free hardened hwaccel jack openh264 screencast selinux system-av1 system-harfbuzz system-icu system-jpeg system-libevent system-libvpx system-webp wayland -clang -debug -geckodriver -gmp-autoupdate -libproxy -lto -pgo -pulseaudio -sndio -system-png -system-python-libs -wifi"

The build was conducted with SELinux set to permissive (setenforce 0) to ensure that SELinux strict was not the issue.
--
emerge --info
Portage 3.0.38.1 (python 3.10.8-final-0, default/linux/amd64/17.0/musl/hardened/selinux, gcc-12.2.0, musl-1.2.3, 5.19.10-gentoo x86_64)
=================================================================
System uname: Linux-5.19.10-gentoo-x86_64-12th_Gen_Intel-R-_Core-TM-_i7-1260P-with-libc
KiB Mem:    32577560 total,  26970644 free
KiB Swap:    8388288 total,   8388288 free
Timestamp of repository gentoo: Mon, 17 Oct 2022 11:00:01 +0000
Head commit of repository gentoo: 4d7df37c334a6420d1382c956feb966710a2a4be
Timestamp of repository guru: Sat, 15 Oct 2022 17:49:14 +0000
Head commit of repository guru: 5a3e637f762a633c45b935ea981ed81587caa386

Timestamp of repository musl: Sat, 15 Oct 2022 17:49:05 +0000
Head commit of repository musl: b7cb287ba8a02c7610135e7fbb3fe05ad9b3081f

sh bash 5.1_p16-r1
ld GNU ld (Gentoo 2.38 p4) 2.38
app-misc/pax-utils:        1.3.5::gentoo
app-shells/bash:           5.1_p16-r1::gentoo
dev-lang/perl:             5.34.1-r3::gentoo
dev-lang/python:           3.10.8::gentoo
dev-lang/rust:             1.62.1::musl
dev-lang/rust-bin:         1.64.0::gentoo
dev-util/cmake:            3.23.3::gentoo
dev-util/meson:            0.62.2::gentoo
sec-policy/selinux-base:   2.20220520-r1::gentoo
sys-apps/baselayout:       2.8::gentoo
sys-apps/openrc:           0.45.2-r1::gentoo
sys-apps/sandbox:          2.29::gentoo
sys-devel/autoconf:        2.13-r2::gentoo, 2.71-r1::gentoo
sys-devel/automake:        1.16.5::gentoo
sys-devel/binutils:        2.38-r2::gentoo
sys-devel/binutils-config: 5.4.1::gentoo
sys-devel/clang:           14.0.6-r1::gentoo
sys-devel/gcc:             12.2.0::gentoo
sys-devel/gcc-config:      2.5-r1::gentoo
sys-devel/libtool:         2.4.7::gentoo
sys-devel/lld:             14.0.6::gentoo
sys-devel/llvm:            14.0.6-r2::gentoo
sys-devel/make:            4.3::gentoo
sys-kernel/linux-headers:  5.15-r3::gentoo (virtual/os-headers)
sys-libs/libselinux:       3.4::gentoo
sys-libs/musl:             1.2.3::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000
    sync-rsync-verify-metamanifest: yes
    sync-rsync-extra-opts: 
    sync-rsync-verify-jobs: 1
    sync-rsync-verify-max-age: 24

guru
    location: /var/db/repos/guru
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/guru.git
    masters: gentoo

local
    location: /var/db/repos/local
    masters: gentoo

musl
    location: /var/db/repos/musl
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/musl.git
    masters: gentoo

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="@FREE @BINARY-REDISTRIBUTABLE MSttfEULA"
CBUILD="x86_64-gentoo-linux-musl"
CFLAGS="-march=native -O2 -pipe"
CHOST="x86_64-gentoo-linux-musl"
CONFIG_PROTECT="/etc /usr/lib/libreoffice/program/sofficerc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-march=native -O2 -pipe"
DISTDIR="/var/cache/distfiles"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR XDG_STATE_HOME"
FCFLAGS="-march=native -O2 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg-live config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync network-sandbox news parallel-fetch preserve-libs protect-owned qa-unresolved-soname-deps sandbox selinux sesandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-march=native -O2 -pipe"
GENTOO_MIRRORS="rsync://mirror.bytemark.co.uk/gentoo/ rsync://rsync.mirrorservice.org/distfiles.gentoo.org/ rsync://rsync.gtlib.gatech.edu/gentoo rsync://mirrors.rit.edu/gentoo/"
INSTALL_MASK="charset.alias /usr/share/locale/locale.alias"
LANG="ru.UTF-8"
LDFLAGS="-fuse-ld=mold -Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j4"
PKGDIR="/var/cache/binpkgs"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
SHELL="/bin/fish"
USE="X acl ada alsa amd64 audit bluetooth branding bzip2 cairo caps cli crypt cups dbus dri dvd egl elogind flac gif gles2 gnome-keyring gtk gtk3 hardened iconv icu ipv6 jack jpeg kms lcms libglvnd libnotify libtirpc mp3 mpeg ncurses nls nptl ogg opengl openmp opus pam pcre pdf peer_perms pie pipewire png policykit readline sdl seccomp selinux spell split-usr ssl ssp svg test-rust text tiff truetype ubac udisks unicode usb v4l vaapi vorbis vulkan wayland x264 xattr xml xtpax xvid zlib zstd" ABI_X86="64" ADA_TARGET="gcc_12_2_0" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext sse sse2" ELIBC="musl" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput" KERNEL="linux" L10N="ru ru-RU fr fr-FRE en en-US" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-4 php8-0" POSTGRES_TARGETS="postgres12 postgres13" PYTHON_SINGLE_TARGET="python3_10" PYTHON_TARGETS="python3_10" RUBY_TARGETS="ruby27" USERLAND="GNU" VIDEO_CARDS="amdgpu fbdev intel nouveau radeon radeonsi vesa dummy v4l" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq proto steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  ADDR2LINE, AR, ARFLAGS, AS, ASFLAGS, CC, CCLD, CONFIG_SHELL, CPP, CPPFLAGS, CTARGET, CXX, CXXFILT, ELFEDIT, EMERGE_DEFAULT_OPTS, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, LC_ALL, LD, LEX, LFLAGS, LIBTOOL, LINGUAS, MAKE, MAKEFLAGS, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, RANLIB, READELF, RUSTFLAGS, SIZE, STRINGS, STRIP, YACC, YFLAGS
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-10-17 18:46:39 UTC
- Please include the full build.log;
- Please verify it doesn't actually happen when dropping -fuse-ld=mold, as I've seen an odd build failure like this before even when people insisted it wasn't being used. It doesn't help the Mozilla build system is fragile.
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-10-17 18:46:56 UTC
Also, instead, please use dev-lang/rust from ::gentoo (not dev-lang/rust-bin).
Comment 3 Andrew Athalye 2022-10-17 20:49:52 UTC
I attempted a build with the suggested setup, and the same error occurred. This is with rust-1.64.0::gentoo and without -fuse-ld=mold. I am currently unable to upload the build log because I receive "Internal Server Error"
Comment 4 Andrew Athalye 2022-10-17 20:51:47 UTC
Created attachment 824621 [details]
Build Log Illustrating the Failure
Comment 5 Andrew Athalye 2022-10-17 20:52:33 UTC
It looks like the original problem with submitting the build log was permissions-based, but it should be available now. Searching "__cxa_finalize" brings up the line that caused the eventual failure, but since I had -j4 enabled there are a lot of lines after it.
Comment 6 ernsteiswuerfel archtester 2023-10-18 21:08:07 UTC
firefox-115.3.1 builds fine for me on current stable musl-1.2.3-r7 + clang-16.0.6.

This bug probably can be closed.
Comment 7 Joonas Niilola gentoo-dev 2023-10-19 07:44:18 UTC
And 102 is removed, too.