Bug 253539 - www/firefox: fails to build with LTO enabled
Summary: www/firefox: fails to build with LTO enabled
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Only Me
Assignee: freebsd-gecko (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-02-15 16:30 UTC by iron.udjin
Modified: 2021-02-15 23:22 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 iron.udjin 2021-02-15 16:30:35 UTC
OS: 13.0-STABLE stable/13-n244516-a73aaaeb579b

When I enable LTO options, firefox fails build:

/usr/local/bin/clang++11 -std=gnu++17 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-strong -Qunused-arguments -DLIBICONV_PLUG -isystem /usr/local/include -Qunused-arguments -Wall -Wbitfield-enum-conversion -Wempty-body -Wignored-qualifiers -Woverloaded-virtual -Wpointer-arith -Wshadow-field-in-constructor-modified -Wsign-compare -Wtype-limits -Wunreachable-code -Wunreachable-code-return -Wwrite-strings -Wno-invalid-offsetof -Wclass-varargs -Wempty-init-stmt -Wfloat-overflow-conversion -Wfloat-zero-conversion -Wloop-analysis -Wc++2a-compat -Wcomma -Wimplicit-fallthrough -Wunused-function -Wunused-variable -Wstring-conversion -Wtautological-overlap-compare -Wtautological-unsigned-enum-zero-compare -Wtautological-unsigned-zero-compare -Wno-error=tautological-type-limit-compare -Wno-inline-new-delete -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=backend-plugin -Wno-error=return-std-move -Wno-error=atomic-alignment -Wno-error=deprecated-copy -Wformat -Wformat-security -Wno-gnu-zero-variadic-macro-arguments -Wno-psabi -Wno-unknown-warning-option -fno-sized-deallocation -fno-aligned-new -O2 -pipe -O2 -pipe -march=native -mtune=native -O3 -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -DLIBICONV_PLUG -isystem /usr/local/include -fno-exceptions -fno-strict-aliasing -fno-rtti -ffunction-sections -fdata-sections -fno-exceptions -fno-math-errno -pipe -O2 -O2 -O3 -fomit-frame-pointer -funwind-tables  -fPIC -shared -Wl,-z,defs -Wl,--warn-unresolved-symbols -Wl,--gc-sections -Wl,-h,libxul.so -o libxul.so /tmpfs/usr/ports/www/firefox/work/.build/toolkit/library/build/libxul_so.list  -flto=thin -Wl,-plugin-opt=-import-instr-limit=10 -Wl,-plugin-opt=new-pass-manager -Wl,-plugin-opt=-import-hot-multiplier=30 -pthread -Wl,--as-needed -fstack-protector-strong -Wl,-z,noexecstack -Wl,-z,text -Wl,-z,relro -Wl,-z,nocopyreloc -Wl,-Bsymbolic-functions -Wl,--build-id=sha1 -fstack-protector-strong -Wl,-rpath-link,/tmpfs/usr/ports/www/firefox/work/.build/dist/bin -Wl,-rpath-link,/usr/local/lib  ../../../js/src/build/libjs_static.a /tmpfs/usr/ports/www/firefox/work/.build/x86_64-unknown-freebsd/release/libgkrust.a ../../../config/external/lgpllibs/liblgpllibs.so ../../../config/external/sqlite/libmozsqlite3.so ../../../widget/gtk/mozgtk/stub/libmozgtk_stub.so   -L/usr/local/lib -licui18n -L/usr/local/lib -licuuc -licudata -laom -ldav1d -lX11 -lX11-xcb -lxcb -lXcomposite -lXcursor -lXdamage -lXext -lXfixes -lXi -lXrender -lpthread -lffi -lplds4 -lplc4 -lnspr4 -pthread -ldl -lz -lm -lnss3 -lsmime3 -lssl3 -lnssutil3 -lfreetype -lfontconfig -lutil -lpng -lwebpdemux -lwebp -lgraphite2 -lharfbuzz -levent -lvpx -lpixman-1 -ldbus-glib-1 -ldbus-1 -lgobject-2.0 -lglib-2.0 -lintl -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lxcb-shm -lpangoft2-1.0 -lXt -lgthread-2.0
ld: warning: undefined symbol: environ
>>> referenced by std.4i6l8qi9-cgu.4
>>>               std-51221f867f83fee2.std.4i6l8qi9-cgu.4.rcgu.o:(std::sys::unix::os::env::h4012e7da961963c4) in archive /tmpfs/usr/ports/www/firefox/work/.build/x86_64-unknown-freebsd/release/libgkrust.a
>>> referenced by std.4i6l8qi9-cgu.8
>>>               std-51221f867f83fee2.std.4i6l8qi9-cgu.8.rcgu.o:(std::sys::unix::process::process_inner::_$LT$impl$u20$std..sys..unix..process..process_common..Command$GT$::spawn::h150bb45ff1056f1c) in archive /tmpfs/usr/ports/www/firefox/work/.build/x86_64-unknown-freebsd/release/libgkrust.a
>>> referenced by std.4i6l8qi9-cgu.8
>>>               std-51221f867f83fee2.std.4i6l8qi9-cgu.8.rcgu.o:(std::sys::unix::process::process_inner::_$LT$impl$u20$std..sys..unix..process..process_common..Command$GT$::do_exec::h18490b6b7e7a764d) in archive /tmpfs/usr/ports/www/firefox/work/.build/x86_64-unknown-freebsd/release/libgkrust.a
>>> referenced 2 more times

ld: error: undefined hidden symbol: JS::SetHostCleanupFinalizationRegistryCallback(JSContext*, void (*)(JSFunction*, JSObject*, void*), void*)
>>> referenced by Unified_cpp_xpcom_base0.cpp
>>>               lto.tmp:(mozilla::CycleCollectedJSContext::~CycleCollectedJSContext())
>>> referenced by Unified_cpp_xpcom_base0.cpp
>>>               lto.tmp:(mozilla::CycleCollectedJSContext::Initialize(JSRuntime*, unsigned int))

ld: error: undefined hidden symbol: JS_SetContextPrivate(JSContext*, void*)
>>> referenced by Unified_cpp_xpcom_base0.cpp
>>>               lto.tmp:(mozilla::CycleCollectedJSContext::~CycleCollectedJSContext())
>>> referenced by Unified_cpp_xpcom_base0.cpp
>>>               lto.tmp:(mozilla::CycleCollectedJSContext::Initialize(JSRuntime*, unsigned int))

ld: error: undefined hidden symbol: JS_DestroyContext(JSContext*)
>>> referenced by Unified_cpp_xpcom_base0.cpp
>>>               lto.tmp:(mozilla::CycleCollectedJSContext::~CycleCollectedJSContext())
>>> referenced by Unified_cpp_netwerk_base0.cpp
>>>               lto.tmp:(mozilla::net::ProxyAutoConfig::SetupJS())
>>> referenced by Unified_cpp_netwerk_base0.cpp
>>>               lto.tmp:(mozilla::net::ProxyAutoConfig::SetupJS())
>>> referenced 1 more times

ld: error: undefined hidden symbol: JS_NewContext(unsigned int, JSRuntime*)
>>> referenced by Unified_cpp_xpcom_base0.cpp
>>>               lto.tmp:(mozilla::CycleCollectedJSContext::Initialize(JSRuntime*, unsigned int))
>>> referenced by Unified_cpp_netwerk_base0.cpp
>>>               lto.tmp:(mozilla::net::ProxyAutoConfig::SetupJS())

ld: error: undefined hidden symbol: JS::SetJobQueue(JSContext*, JS::JobQueue*)
>>> referenced by Unified_cpp_xpcom_base0.cpp
>>>               lto.tmp:(mozilla::CycleCollectedJSContext::Initialize(JSRuntime*, unsigned int))

ld: error: undefined hidden symbol: JS::SetPromiseRejectionTrackerCallback(JSContext*, void (*)(JSContext*, bool, JS::Handle<JSObject*>, JS::PromiseRejectionHandlingState, void*), void*)
>>> referenced by Unified_cpp_xpcom_base0.cpp
>>>               lto.tmp:(mozilla::CycleCollectedJSContext::Initialize(JSRuntime*, unsigned int))

ld: error: undefined hidden symbol: JS::AddPersistentRoot(JS::RootingContext*, JS::RootKind, JS::PersistentRooted<JS::detail::RootListEntry*>*)
>>> referenced by Unified_cpp_xpcom_base0.cpp
>>>               lto.tmp:(mozilla::CycleCollectedJSContext::Initialize(JSRuntime*, unsigned int))
>>> referenced by Unified_cpp_xpcom_base0.cpp
>>>               lto.tmp:(mozilla::CycleCollectedJSContext::Initialize(JSRuntime*, unsigned int))
>>> referenced by Unified_cpp_xpcom_base0.cpp
>>>               lto.tmp:(mozilla::CycleCollectedJSContext::Initialize(JSRuntime*, unsigned int))
>>> referenced 35 more times

ld: error: undefined hidden symbol: JS::GetPromiseID(JS::Handle<JSObject*>)
>>> referenced by Unified_cpp_xpcom_base0.cpp
>>>               lto.tmp:(mozilla::CycleCollectedJSContext::PromiseRejectionTrackerCallback(JSContext*, bool, JS::Handle<JSObject*>, JS::PromiseRejectionHandlingState, void*))
>>> referenced by Unified_cpp_xpcom_base0.cpp
>>>               lto.tmp:(mozilla::CycleCollectedJSContext::NotifyUnhandledRejections::Run())
>>> referenced by Unified_cpp_xpcom_base0.cpp
>>>               lto.tmp:(mozilla::CycleCollectedJSContext::NotifyUnhandledRejections::Cancel())
>>> referenced 1 more times

ld: error: undefined hidden symbol: JS::GetPromiseResult(JS::Handle<JSObject*>)
>>> referenced by Unified_cpp_xpcom_base0.cpp
>>>               lto.tmp:(mozilla::CycleCollectedJSContext::PromiseRejectionTrackerCallback(JSContext*, bool, JS::Handle<JSObject*>, JS::PromiseRejectionHandlingState, void*))
>>> referenced by Unified_cpp_xpcom_base0.cpp
>>>               lto.tmp:(mozilla::CycleCollectedJSContext::NotifyUnhandledRejections::Run())
>>> referenced by Unified_cpp_dom_promise0.cpp
>>>               lto.tmp:(mozilla::dom::PromiseDebugging::GetState(mozilla::dom::GlobalObject&, JS::Handle<JSObject*>, mozilla::dom::PromiseDebuggingStateHolder&, mozilla::ErrorResult&))
>>> referenced 2 more times

ld: error: undefined hidden symbol: JS::CurrentGlobalOrNull(JSContext*)
>>> referenced by Unified_cpp_xpcom_base0.cpp
>>>               lto.tmp:(mozilla::CycleCollectedJSContext::enqueuePromiseJob(JSContext*, JS::Handle<JSObject*>, JS::Handle<JSObject*>, JS::Handle<JSObject*>, JS::Handle<JSObject*>))
>>> referenced by Unified_cpp_xpcom_base2.cpp
>>>               lto.tmp:(nsSystemInfo::GetProcessInfo(JSContext*, mozilla::dom::Promise**))
>>> referenced by Unified_cpp_intl_l10n0.cpp
>>>               lto.tmp:(mozilla::intl::Localization::FormatValues(JSContext*, mozilla::dom::Sequence<mozilla::dom::OwningUTF8StringOrL10nIdArgs> const&, mozilla::ErrorResult&))
>>> referenced 2220 more times

ld: error: undefined hidden symbol: JS::HeapObjectPostWriteBarrier(JSObject**, JSObject*, JSObject*)
>>> referenced by Unified_cpp_xpcom_base0.cpp
>>>               lto.tmp:(mozilla::CycleCollectedJSContext::enqueuePromiseJob(JSContext*, JS::Handle<JSObject*>, JS::Handle<JSObject*>, JS::Handle<JSObject*>, JS::Handle<JSObject*>))
>>> referenced by Unified_cpp_xpcom_base0.cpp
>>>               lto.tmp:(mozilla::CycleCollectedJSContext::enqueuePromiseJob(JSContext*, JS::Handle<JSObject*>, JS::Handle<JSObject*>, JS::Handle<JSObject*>, JS::Handle<JSObject*>))
>>> referenced by Unified_cpp_xpcom_base0.cpp
>>>               lto.tmp:(mozilla::CycleCollectedJSContext::enqueuePromiseJob(JSContext*, JS::Handle<JSObject*>, JS::Handle<JSObject*>, JS::Handle<JSObject*>, JS::Handle<JSObject*>))
>>> referenced 4228 more times

ld: error: undefined hidden symbol: JS::GetPromiseUserInputEventHandlingState(JS::Handle<JSObject*>)
>>> referenced by Unified_cpp_xpcom_base0.cpp
>>>               lto.tmp:(mozilla::CycleCollectedJSContext::enqueuePromiseJob(JSContext*, JS::Handle<JSObject*>, JS::Handle<JSObject*>, JS::Handle<JSObject*>, JS::Handle<JSObject*>))

ld: error: undefined hidden symbol: JS::JobQueueMayNotBeEmpty(JSContext*)
>>> referenced by Unified_cpp_xpcom_base0.cpp
>>>               lto.tmp:(mozilla::CycleCollectedJSContext::PerformMicroTaskCheckPoint(bool))
>>> referenced by Unified_cpp_xpcom_base0.cpp
>>>               lto.tmp:(mozilla::CycleCollectedJSContext::DispatchToMicroTask(already_AddRefed<mozilla::MicroTaskRunnable>))
>>> referenced by Unified_cpp_dom_workers0.cpp
>>>               lto.tmp:(mozilla::dom::WorkerJSContext::DispatchToMicroTask(already_AddRefed<mozilla::MicroTaskRunnable>))
>>> referenced 1 more times

ld: error: undefined hidden symbol: JS::JobQueueIsEmpty(JSContext*)
>>> referenced by Unified_cpp_xpcom_base0.cpp
>>>               lto.tmp:(mozilla::CycleCollectedJSContext::PerformMicroTaskCheckPoint(bool))
>>> referenced by Unified_cpp_xpcom_base0.cpp
>>>               lto.tmp:(mozilla::CycleCollectedJSContext::PerformDebuggerMicroTaskCheckpoint())

ld: error: undefined hidden symbol: js::MallocArena
>>> referenced by Unified_cpp_xpcom_base0.cpp
>>>               lto.tmp:(mozilla::CycleCollectedJSContext::saveJobQueue(JSContext*))
>>> referenced by Unified_cpp_netwerk_base0.cpp
>>>               lto.tmp:(mozilla::Vector<JS::Value, 8ul, js::TempAllocPolicy>::growStorageBy(unsigned long))
>>> referenced by Unified_cpp_netwerk_base0.cpp
>>>               lto.tmp:(mozilla::Vector<JS::Value, 8ul, js::TempAllocPolicy>::growStorageBy(unsigned long))
>>> referenced 78 more times

ld: error: undefined hidden symbol: JS_ReportOutOfMemory(JSContext*)
>>> referenced by Unified_cpp_xpcom_base0.cpp
>>>               lto.tmp:(mozilla::CycleCollectedJSContext::saveJobQueue(JSContext*))
>>> referenced by Unified_cpp_netwerk_base0.cpp
>>>               lto.tmp:(mozilla::net::Dashboard::GetSockets(mozilla::net::SocketData*))
>>> referenced by Unified_cpp_netwerk_base0.cpp
>>>               lto.tmp:(mozilla::net::Dashboard::GetHttpConnections(mozilla::net::HttpData*))
>>> referenced 597 more times

ld: error: undefined hidden symbol: JS::IsIdleGCTaskNeeded(JSRuntime*)
>>> referenced by Unified_cpp_xpcom_base0.cpp
>>>               lto.tmp:(mozilla::CycleCollectedJSContext::AfterProcessTask(unsigned int))

ld: error: undefined hidden symbol: JS::ClearKeptObjects(JSContext*)
>>> referenced by Unified_cpp_xpcom_base0.cpp
>>>               lto.tmp:(mozilla::CycleCollectedJSContext::AfterProcessMicrotasks())

ld: error: undefined hidden symbol: JS::GetPromiseIsHandled(JS::Handle<JSObject*>)
>>> referenced by Unified_cpp_xpcom_base0.cpp
>>>               lto.tmp:(mozilla::CycleCollectedJSContext::NotifyUnhandledRejections::Run())
>>> referenced by Unified_cpp_xpcom_base0.cpp
>>>               lto.tmp:(mozilla::CycleCollectedJSContext::NotifyUnhandledRejections::Run())

ld: error: undefined hidden symbol: JS::GCCellPtr::outOfLineKind() const
>>> referenced by Unified_cpp_xpcom_base0.cpp
>>>               lto.tmp:(NoteWeakMapChildrenTracer::onChild(JS::GCCellPtr const&))
>>> referenced by Unified_cpp_xpcom_base0.cpp
>>>               lto.tmp:(NoteWeakMapChildrenTracer::onChild(JS::GCCellPtr const&))
>>> referenced by Unified_cpp_xpcom_base0.cpp
>>>               lto.tmp:(NoteWeakMapChildrenTracer::onChild(JS::GCCellPtr const&))
>>> referenced 829 more times

ld: 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[5]: *** [/tmpfs/usr/ports/www/firefox/work/firefox-85.0.2/config/rules.mk:545: libxul.so] Error 1
gmake[5]: Leaving directory '/tmpfs/usr/ports/www/firefox/work/.build/toolkit/library/build'
gmake[4]: *** [/tmpfs/usr/ports/www/firefox/work/firefox-85.0.2/config/recurse.mk:72: toolkit/library/build/target] Error 2
gmake[4]: Leaving directory '/tmpfs/usr/ports/www/firefox/work/.build'
gmake[3]: *** [/tmpfs/usr/ports/www/firefox/work/firefox-85.0.2/config/recurse.mk:34: compile] Error 2
gmake[3]: Leaving directory '/tmpfs/usr/ports/www/firefox/work/.build'
gmake[2]: *** [/tmpfs/usr/ports/www/firefox/work/firefox-85.0.2/config/rules.mk:355: all] Error 2
gmake[2]: Leaving directory '/tmpfs/usr/ports/www/firefox/work/.build'
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/www/firefox
*** Error code 1

Stop.
make: stopped in /usr/ports/www/firefox

===>>> make build failed for www/firefox
===>>> Aborting update
Comment 1 Christoph Moench-Tegeder freebsd_committer freebsd_triage 2021-02-15 17:02:18 UTC
pinging @pkubaj, as he added that option and reported it to be working on 13 in bug #253036
Comment 2 Daniel Engberg freebsd_committer freebsd_triage 2021-02-15 17:05:05 UTC
Do you have anything set in make.conf as some switches looks a bit funky for being set by ports. I think this will come down to compiler compatbility (GCC vs LLVM/clang) in the end however.
Comment 3 iron.udjin 2021-02-15 17:24:33 UTC
In my /etc/make.conf I have only: CFLAGS+= -O2 -pipe -march=native -mtune=native
Nothing more related compiler.
Comment 4 Piotr Kubaj freebsd_committer freebsd_triage 2021-02-15 18:41:07 UTC
I indeed noticed that Firefox with LTO doesn't build in Poudriere, but builds straight from ports.

For now, IMO it's to leave this option available because it definitely works and Firefox with LTO works properly as well.

I'll try to narrow down this issue.
Comment 5 iron.udjin 2021-02-15 23:20:08 UTC
Latest version of firefox (86.0,2) builds fine with LTO enabled. We can close this issue.
Comment 6 Piotr Kubaj freebsd_committer freebsd_triage 2021-02-15 23:22:50 UTC
(In reply to iron.udjin from comment #5)
Great!

Now I wonder if it will be feasible to get PGO to work :)