Bug 255193

Summary: www/firefox: fails to build with llvm error
Product: Ports & Packages Reporter: xmirya
Component: Individual Port(s)Assignee: freebsd-gecko (Nobody) <gecko>
Status: New ---    
Severity: Affects Only Me Flags: bugzilla: maintainer-feedback? (gecko)
Priority: ---    
Version: Latest   
Hardware: amd64   
OS: Any   

Description xmirya 2021-04-18 18:38:09 UTC
> uname -a
FreeBSD myhost 13.0-STABLE FreeBSD 13.0-STABLE #5 stable/13-n245247-53c0fd84096: Sat Apr 17 19:47:37 CEST 2021     me@myhost:/usr/src/sys/amd64/compile/MY  amd64

OPTIONS_FILE_SET+=CANBERRA
OPTIONS_FILE_SET+=DBUS
OPTIONS_FILE_UNSET+=DEBUG
OPTIONS_FILE_SET+=FFMPEG
OPTIONS_FILE_SET+=LIBPROXY
OPTIONS_FILE_SET+=LTO
OPTIONS_FILE_SET+=OPTIMIZED_CFLAGS
OPTIONS_FILE_UNSET+=PROFILE
OPTIONS_FILE_UNSET+=TEST
OPTIONS_FILE_SET+=ALSA
OPTIONS_FILE_SET+=JACK
OPTIONS_FILE_SET+=PULSEAUDIO
OPTIONS_FILE_UNSET+=SNDIO

CFLAGS+=-O2 -pipe -march=native

---
/usr/local/bin/clang++11 -std=gnu++17 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fstack-clash-protection -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 -Wno-range-loop-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 -O3 -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -DLIBICONV_PLUG -isystem /usr/local/include -fno-exceptions -fno-strict-aliasing -fPIC -fno-rtti -ffunction-sections -fdata-sections -fno-exceptions -fno-math-errno -pipe -O2 -O2 -O3 -fomit-frame-pointer -funwind-tables  -shared -Wl,-z,defs -Wl,--warn-unresolved-symbols -Wl,--gc-sections -Wl,-h,libxul.so -o libxul.so /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 -fstack-clash-protection -Wl,-rpath-link,/usr/ports/www/firefox/work/.build/dist/bin -Wl,-rpath-link,/usr/local/lib  ../../../js/src/build/libjs_static.a /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 ../../../widget/gtk/mozwayland/libmozwayland.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 -lproxy
/usr/ports/www/firefox/work/.build/_virtualenvs/init_py3/bin/python -m mozbuild.action.check_binary --target ../../dist/bin/firefox
BUILDTASK {"argv": ["/usr/ports/www/firefox/work/firefox-88.0/python/mozbuild/mozbuild/action/check_binary.py", "--target", "../../dist/bin/firefox"], "start": 1618767092.051863, "end": 1618767092.0601516, "context": null}
strip  ../../dist/bin/firefox
gmake[5]: Leaving directory '/usr/ports/www/firefox/work/.build/browser/app'
LLVM ERROR: Cannot select: intrinsic %llvm.x86.aesni.aesenc
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0.      Running pass 'Function Pass Manager' on module '/usr/ports/www/firefox/work/.build/x86_64-unknown-freebsd/release/libgkrust.a(wgpu_bindings-a1120473880a547d.wgpu_bindings.62k6hogr-cgu.0.rcgu.o at 7003454)'.
1.      Running pass 'X86 DAG->DAG Instruction Selection' on function '@"_ZN9hashbrown3map24HashMap$LT$K$C$V$C$S$GT$7get_mut17hcdbe53e167f900f3E"'
#0 0x0000000801e84036 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/usr/local/llvm11/lib/libLLVM-11.so+0x1684036)
#1 0x0000000801e822d7 llvm::sys::RunSignalHandlers() (/usr/local/llvm11/lib/libLLVM-11.so+0x16822d7)
#2 0x0000000801e848bc (/usr/local/llvm11/lib/libLLVM-11.so+0x16848bc)
#3 0x0000000800748d60 (/lib/libthr.so.3+0x19d60)
clang++: error: unable to execute command: Abort trap (core dumped)
clang++: error: linker command failed due to signal (use -v to see invocation)
gmake[5]: *** [/usr/ports/www/firefox/work/firefox-88.0/config/rules.mk:545: libxul.so] Error 254
---

Both 87.0.1 and 88.0 fail with the same error, and AFAIR 87.0.1 built fine with rust-1.50 in March on the same system.
Comment 1 Daniel Engberg freebsd_committer 2021-04-18 20:06:31 UTC
Remove CFLAGS completely and use CPUTYPE?= in make.conf instead, does it still fail?
https://cgit.freebsd.org/src/tree/share/examples/etc/make.conf?h=stable/13#n25

Best regards,
Daniel
Comment 2 xmirya 2021-04-19 08:44:57 UTC
In terms of recompiling w/o -march - just www/firefox or together with lang/rust, devel/rust-cbindgen and devel/llvm11 (it appears to use llvm from ports)?
Comment 3 xmirya 2021-04-20 18:51:12 UTC
Recompiling just www/firefox helped, however CPUTYPE is only used for base, not ports.

www/firefox fails to build with -march=native on my machine, but builds fine with -mcpu=native -mtune=native or w/o those
Comment 4 Daniel Engberg freebsd_committer 2021-04-21 03:48:38 UTC
No it isn't, compare CFLAGS with and without CPYTUPE in make.conf (make -V CFLAGS)
Comment 5 Jan Beich freebsd_committer 2021-04-24 20:19:14 UTC
I can't reproduce with -march=native (on Skylake) alone. It seems the error is caused by -flto=thin i.e., OPTIONS_FILE_SET+=LTO