Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 811162 - media-libs/opencv lto-wrapper: fatal error
Summary: media-libs/opencv lto-wrapper: fatal error
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal with 3 votes (vote)
Assignee: Paul Zander
URL:
Whiteboard:
Keywords:
: 913918 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-08-30 21:31 UTC by Austin Kilgore
Modified: 2023-11-17 19:12 UTC (History)
6 users (show)

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


Attachments
build.log (opencv-4.5.2-r1-build.log,228.47 KB, text/plain)
2021-08-30 21:32 UTC, Austin Kilgore
Details
build-2.log (opencv-4.5.2-r1-build.log,228.47 KB, text/x-log)
2021-09-01 12:47 UTC, Austin Kilgore
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Austin Kilgore 2021-08-30 21:31:49 UTC
opencv fails with lto use flag enabled.

Reproducible: Always

Steps to Reproduce:
emerge opencv with lto
Actual Results:  
faults on lto-wrapper

Expected Results:  
lto support should compile fine

Portage 3.0.22 (python 3.9.6-final-0, default/linux/amd64/17.1/no-multilib, gcc-11.2.0, glibc-2.33-r7, 5.13.13-gentoo x86_64)
=================================================================
System uname: Linux-5.13.13-gentoo-x86_64-AMD_Ryzen_9_5900HS_with_Radeon_Graphics-with-glibc2.33
KiB Mem:    15761808 total,   8699100 free
KiB Swap:          0 total,         0 free
Timestamp of repository gentoo: Mon, 30 Aug 2021 20:06:34 +0000
Head commit of repository gentoo: 864b1fdc3f283775ab804a8075754818348283d4

sh bash 5.1_p8
ld GNU ld (Gentoo 2.37_p1 p0) 2.37
app-shells/bash:          5.1_p8::gentoo
dev-lang/perl:            5.34.0-r2::gentoo
dev-lang/python:          2.7.18_p11::gentoo, 3.9.6_p1::gentoo, 3.10.0_rc1_p1::gentoo
dev-lang/rust:            1.54.0::gentoo
dev-util/cmake:           3.21.2::gentoo
sys-apps/baselayout:      2.7-r3::gentoo
sys-apps/openrc:          0.43.5::gentoo
sys-apps/sandbox:         2.24::gentoo
sys-devel/autoconf:       2.13-r1::gentoo, 2.71-r1::gentoo
sys-devel/automake:       1.16.4::gentoo
sys-devel/binutils:       2.37_p1::gentoo
sys-devel/gcc:            8.5.0-r1::gentoo, 11.2.0::gentoo
sys-devel/gcc-config:     2.4::gentoo
sys-devel/libtool:        2.4.6-r6::gentoo
sys-devel/make:           4.3::gentoo
sys-kernel/linux-headers: 5.13::gentoo (virtual/os-headers)
sys-libs/glibc:           2.33-r7::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/gentoo
    priority: -1000
    sync-git-verify-commit-signature: true

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="*"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O3 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /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 -O3 -pipe"
DISTDIR="/var/cache/distfiles"
EMERGE_DEFAULT_OPTS=" --with-bdeps y --complete-graph y"
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"
FCFLAGS="-march=native -O3 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs candy config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-march=native -O3 -pipe"
GENTOO_MIRRORS="https://gentoo.osuosl.org/"
LANG="en_US.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j16"
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"
USE="10bit 12bit 16k_voice 24-bit-color 24bpp 256-color 7z 7za 7zip 8bit X a52 aac aacplus aacs aalib acl acpi activities adns airdrop-ng airgraph-ng alsa alsa-plugin amd64 aom asm async atm bash-completion bdplus bluetooth bluray branding bzip2 cairo cdda cddb cdr cjk cli colord crypt css cuda cups curl cycles dav1d dbus declarative dri dri3 drm dts dvb dvd dvdr egl elogind encode exif fbcon ffmpeg flac fontconfig fortran frei0r ftp fuse gdbm gif gimp git gles2 gold gpm gtk gui gzip iconv icu imlib io-uring ipv6 iscsi iscsi-direct jit jpeg jpeg2k kde kipi kwallet lame lcms libglvnd libnotify libsamplerate libtirpc lm-sensors lto lxc lz4 lzma lzo lzo2 mad matroska minizip mng mono mp3 mp4 mpeg mpv mtp multipath ncurses networkmanager nls nptl numa nvidia ogg openal opengl openimageio openmp otr pam pango pcre pcre16 pda pdf pgo phonon plasma plotutils plugins png policykit ppds pulseaudio qemu qml qt5 rar raw readline scanner scripttools sdl seccomp semantic-desktop slang smp sound speex spell spice split-usr ssh ssl startup-notification svc svg svg2 szip taglib tcpd text threads tiff truetype udev udisks unicode upower usb usbredir v4l v4l2 v4lutils vaapi vbox vboxwebsrv vdpau vhost-net vhost-user-fs vhosts vim-syntax virgl virtfs virtualbox vkd3d vlc vorbis vulkan wavpack wayland webp widgets wifi wxwidgets x264 x265 xattr xcb xen xinerama xml xscreensaver xv xvid zip zlib zsh-completion zstd" ABI_X86="64" ADA_TARGET="gnat_2018" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" 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="glibc" 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" GRUB_PLATFORMS="efi-64" INPUT_DEVICES="libinput" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LLVM_TARGETS="AMDGPU NVPTX X86" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-3 php7-4" POSTGRES_TARGETS="postgres12 postgres13" PYTHON_SINGLE_TARGET="python3_9" PYTHON_TARGETS="python3_9" QEMU_SOFTMMU_TARGETS="arm x86_64 i386 aarch64" QEMU_USER_TARGETS="x86_64" RUBY_TARGETS="ruby26" USERLAND="GNU" VIDEO_CARDS="amdgpu radeonsi radeon nvidia qxl virgl virtualbox vmware" 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:  CC, CPPFLAGS, CTARGET, CXX, INSTALL_MASK, LC_ALL, LINGUAS, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, RUSTFLAGS
Comment 1 Austin Kilgore 2021-08-30 21:32:01 UTC
Created attachment 736843 [details]
build.log
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2021-08-30 21:33:46 UTC
-lpthread  -L/usr/lib64  -Wl,-rpath-link,"\$ORIGIN" && :
{standard input}: Assembler messages:
{standard input}:341978: Error: symbol `fatbinData' is already defined
lto-wrapper: fatal error: /usr/bin/x86_64-pc-linux-gnu-g++ returned 1 exit status
compilation terminated.
/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
[119/1141] /usr/bin/x86_64-pc-linux-gnu-g++ -DCVAP

It does look vaguely a bit like it could still be happening when OOMing. I did say to stop using -j16 :(
Comment 3 Austin Kilgore 2021-09-01 12:46:54 UTC
This is still an issue and it's not OOMing, I've watched my ram usage and it doesn't even build enough of the way into it for it to be running out of ram.
Comment 4 Austin Kilgore 2021-09-01 12:47:20 UTC
Created attachment 737050 [details]
build-2.log
Comment 5 Fat-Zer 2021-11-08 23:33:05 UTC
Note that the build failure is probably triggered by USE="cuda"
Comment 6 Ionen Wolkens gentoo-dev 2021-11-28 01:28:56 UTC
(In reply to Fat-Zer from comment #5)
> Note that the build failure is probably triggered by USE="cuda"
Yes, just happened to try to build this and ran into the same fatbindata/lto-wrapper error with USE="cuda lto"

Fine I USE=-cuda, but haven't looked into this further.
Comment 7 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2021-11-28 01:30:39 UTC
Seems to be a somewhat well-established CUDA + LTO incompatibility? https://forums.developer.nvidia.com/t/link-time-optimization-with-cuda-on-linux-flto/55530/6.

Seems like we should just make them mutually exclusive (or just filter it, which is probably nicer).
Comment 8 Ionen Wolkens gentoo-dev 2021-11-28 04:28:13 UTC
(In reply to Sam James from comment #7)
> Seems to be a somewhat well-established CUDA + LTO incompatibility?
> https://forums.developer.nvidia.com/t/link-time-optimization-with-cuda-on-
> linux-flto/55530/6.
> 
> Seems like we should just make them mutually exclusive (or just filter it,
> which is probably nicer).
Oh you're right, came across this before but forgot about it. Can't even compile a hello.cu with nvcc -Xcompiler -flto

fwiw if wanted to limit this only to nvcc, could add something like:
    $(multilib_native_usex cuda -DCUDA_NVCC_FLAGS="-Xcompiler;-fno-lto" '')
Built fine with USE="cuda lto" with that.

Not that this all feels particularly right when comparing to opensubdiv (cuda eclass, nvccflags, arch selection -- would need to inspect OpenCVDetectCuda.cmake to stop it from appending arches). Unfortunately my own interest in improving cuda stuff been low, I barely use/know any of these packages.
Comment 9 theaifam5 2022-06-25 23:47:28 UTC
hey everyone,

somehow adding following line, fixes the issue:
$(multilib_native_usex cuda -DCUDA_NVCC_FLAGS="-dlto" '')

maybe even this one, since it is just an alias to '-dlto':
$(multilib_native_usex cuda -DCUDA_NVCC_FLAGS="-lto" '')

of course I do not have any idea if that is correct, but hey! it compiles, even the "hello.cu" with it.

tested on media-libs/opencv-4.6.0-r1.
Comment 10 Miroslav Šulc gentoo-dev 2023-10-09 12:01:00 UTC
*** Bug 913918 has been marked as a duplicate of this bug. ***
Comment 11 Martin Rott 2023-11-17 18:23:48 UTC
with cuda-12, nvcc is failing, for the -dlto option nvcc says that there is also need to specify -code (and/or) -arch, 
so I assume for my setup should work sthg like 

$(multilib_native_usex cuda -DCUDA_NVCC_FLAGS=-dlto '')
?($(multilib_native_usex cuda -DCUDA_NVCC_FLAGS=-code=lto_89 ''))
$(multilib_native_usex cuda -DCUDA_NVCC_FLAGS=-arch=lto_89 '')
(cause having arch sm_89)

will try after moving through https://bugs.gentoo.org/915775
Comment 12 Paul Zander 2023-11-17 19:12:08 UTC
I set MYCMAKEARGS="-DCUDA_GENERATION=Lovelace -DOpenGL_GL_PREFERENCE=GLVND" for opencv that doesn't allow for lto though.

The code at https://github.com/opencv/opencv/blob/4.x/cmake/OpenCVDetectCUDA.cmake#L257C10-L257 might interfere with your plans. But outside the extra ?( ) it looks fine. As per nvcc --help you might not need -dlto.