Package: firefox Version: 117.0-1 Hello,
I am working to get the Firefox build working with LTO on unstable, i.e. with DEB_BUILD_MAINT_OPTIONS=optimize=+lto set in the environment. There are three main issues I encountered, which are described and addressed below. 1. Webrender / glslopt crash ----begin build log excerpt---- [webrender 0.62.0] cargo:rerun-if-changed=res/brush_yuv_image.glsl [webrender 0.62.0] cargo:rerun-if-changed=res/cs_conic_gradient.glsl [webrender 0.62.0] cargo:rerun-if-changed=res/cs_clip_image.glsl [webrender 0.62.0] Optimizing shader ShaderOptimizationInput { shader_name: "cs_line_decoration", config: "", gl_version: Gl } error: failed to run custom build command for `webrender v0.62.0 (/tmp/firefox-117.0/gfx/wr/webrender)` Caused by: process didn't exit successfully: `/tmp/firefox-117.0/build-browser/release/build/webrender-503c370365efbdbf/build-script-build` (signal: 11, SIGSEGV: invalid memory reference) ----end build log excerpt---- Webrender is invoking "glslopt" here, and the latter has a history of crashing in multithreaded scenarios. This has supposedly been fixed long ago, but LTO seems to draw out some unresolved aspect of the issue. I have filed a bug report on this with the upstream: https://github.com/jamienicol/glsl-optimizer/issues/9 Here are some historical references, for background: https://bugzilla.mozilla.org/show_bug.cgi?id=1637148 https://bugzilla.redhat.com/show_bug.cgi?id=1883904 https://github.com/servo/servo/issues/27039 Since this crash does not occur in a non-LTO build, my workaround is simply to remove LTO flags from the Rust part of the build, by adding perl -pi -e 's/-flto(=\w+)?//g; s/-ffat-lto-objects//g' \ build-browser/toolkit/library/rust/backend.mk to the end of the "stamps/configure-$(PRODUCT)::" rule in debian/rules. 2. --param flag syntax This one had me confused at first: ----begin build log excerpt---- make[3]: Entering directory '/tmp/firefox-117.0/build-browser/security/sandbox/linux' security/sandbox/linux/libmozsandbox.so rm -f libmozsandbox.so /usr/bin/g++ -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-strong -Wdate-time -D_FORTIFY_SOURCE=2 -fno-sized-deallocation -fno-aligned-new -O2 -ffile-prefix-map=/tmp/firefox-117.0=. -flto=auto -ffat-lto-objects -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -fno-exceptions -fPIC -fno-rtti -ffunction-sections -fdata-sections -fno-exceptions -fno-math-errno -pthread -pipe -gdwarf-4 -freorder-blocks -O2 -fomit-frame-pointer -funwind-tables -shared -Wl,-z,defs -Wl,-h,libmozsandbox.so -o libmozsandbox.so safe_sprintf.o icu_utf.o trap.o syscall_wrappers.o Unified_cpp_sandbox_linux0.o Unified_cpp_sandbox_linux1.o Unified_cpp_sandbox_linux2.o Unified_cpp_sandbox_linux3.o -lpthread -flto=auto -ffat-lto-objects -Wl,-z,relro -Wl,--as-needed -Wl,--reduce-memory-overheads -Wl,--stats -Wl,-z,pack-relative-relocs -Wl,-z,noexecstack -Wl,-z,text -Wl,-z,relro -Wl,-z,nocopyreloc -Wl,-Bsymbolic-functions -Wl,--build-id=sha1 -fstack-protector-strong '--param lto-partitions=1' -Wl,-rpath-link,/tmp/firefox-117.0/build-browser/dist/bin -Wl,-rpath-link,/usr/lib -lplds4 -lplc4 -lnspr4 -lrt g++: error: unrecognized command-line option '--param lto-partitions=1'; did you mean '--param lto-partitions='? make[3]: *** [/tmp/firefox-117.0/config/rules.mk:526: libmozsandbox.so] Error 1 make[3]: Leaving directory '/tmp/firefox-117.0/build-browser/security/sandbox/linux' make[2]: *** [/tmp/firefox-117.0/config/recurse.mk:72: security/sandbox/linux/target] Error 2 make[2]: Leaving directory '/tmp/firefox-117.0/build-browser' make[1]: *** [/tmp/firefox-117.0/config/recurse.mk:34: compile] Error 2 make[1]: Leaving directory '/tmp/firefox-117.0/build-browser' make: *** [/tmp/firefox-117.0/config/rules.mk:361: default] Error 2 ----end build log excerpt---- Note that the flag being passed in is '--param lto-partitions=1', as a single string containing a space. This is incorrect syntax; it needs to be passed in as '--param' + 'lto-partitions=1'. Fixed by this source patch: ----begin patch---- --- a/security/sandbox/linux/moz.build +++ b/security/sandbox/linux/moz.build @@ -117,7 +117,7 @@ if CONFIG["CC_TYPE"] in ("clang", "gcc") # forcing there to be only one partition. for f in CONFIG["OS_CXXFLAGS"]: if f.startswith("-flto") and CONFIG["CC_TYPE"] != "clang": - LDFLAGS += ["--param lto-partitions=1"] + LDFLAGS += ["--param", "lto-partitions=1"] DEFINES["NS_NO_XPCOM"] = True DisableStlWrapping() ----end patch---- This should probably be pushed upstream. 3. dh_dwz unknown opcode error ----begin build log excerpt---- make[2]: Entering directory '/tmp/firefox-117.0' dh_dwz -X libxul dwz: debian/firefox/usr/lib/firefox/libmozavcodec.so: Unknown DWARF DW_OP_0 referenced from DIE at [325272] dwz: debian/firefox/usr/lib/firefox/libmozavutil.so: Unknown DWARF DW_OP_0 referenced from DIE at [3f546] dwz: debian/firefox/usr/lib/firefox/libmozavutil.so: Unknown DWARF DW_OP_0 referenced from DIE at [3f546] dwz: debian/firefox/usr/lib/firefox/libmozsqlite3.so: DWARF compression not beneficial - old size 1647652 new size 1661321 dwz: debian/firefox/usr/lib/firefox/libmozavcodec.so: Unknown DWARF DW_OP_0 referenced from DIE at [325272] dwz: debian/firefox/usr/lib/firefox/libipcclientcerts.so: DWARF compression not beneficial - old size 2613256 new size 2630714 dh_dwz: error: dwz -mdebian/firefox/usr/lib/debug/.dwz/x86_64-linux-gnu/firefox.debug -M/usr/lib/debug/.dwz/x86_64-linux-gnu/firefox.debug -- debian/firefox/usr/lib/firefox/crashreporter debian/firefox/usr/lib/firefox/firefox debian/firefox/usr/lib/firefox/glxtest debian/firefox/usr/lib/firefox/gmp-clearkey/0.1/libclearkey.so debian/firefox/usr/lib/firefox/libipcclientcerts.so debian/firefox/usr/lib/firefox/liblgpllibs.so debian/firefox/usr/lib/firefox/libmozavcodec.so debian/firefox/usr/lib/firefox/libmozavutil.so debian/firefox/usr/lib/firefox/libmozgtk.so debian/firefox/usr/lib/firefox/libmozsandbox.so debian/firefox/usr/lib/firefox/libmozsqlite3.so debian/firefox/usr/lib/firefox/libmozwayland.so debian/firefox/usr/lib/firefox/minidump-analyzer debian/firefox/usr/lib/firefox/pingsender debian/firefox/usr/lib/firefox/plugin-container debian/firefox/usr/lib/firefox/vaapitest returned exit code 1 dh_dwz: error: Aborting due to earlier error make[2]: *** [debian/rules:321: override_dh_dwz] Error 25 make[2]: Leaving directory '/tmp/firefox-117.0' make[1]: *** [debian/rules:340: install] Error 2 make[1]: Leaving directory '/tmp/firefox-117.0' make: *** [debian/rules:340: binary] Error 2 dpkg-buildpackage: error: fakeroot debian/rules binary subprocess returned exit status 2 ----end build log excerpt---- Not sure why those two libraries are causing trouble, but I resolved it by adding "-X libmozav" to the dh_dwz invocation. With these three fixes, the Firefox build with LTO enabled completes successfully. --Daniel -- Daniel Richard G. || sk...@iskunk.org My ASCII-art .sig got a bad case of Times New Roman.