sys-devel/llvm-11.0.0 fails to compile when tensorflow is installed. Error: [1017/2113] /usr/bin/x86_64-pc-linux-gnu-g++ -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib/Analysis -I/var/tmp/portage/sys-devel/llvm-11.0.0/work/llvm/lib/Analysis -I/usr/include/libxml2 -I/include -Iinclude -I/var/tmp/portage/sys-devel/llvm-11.0.0/work/llvm/include -DNDEBUG -march=native -O2 -pipe -fPIC -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment -fdiagnostics-color -ffunction-sections -fdata-sections -std=c++14 -MD -MT lib/Analysis/CMakeFiles/LLVMAnalysis.dir/TFUtils.cpp.o -MF lib/Analysis/CMakeFiles/LLVMAnalysis.dir/TFUtils.cpp.o.d -o lib/Analysis/CMakeFiles/LLVMAnalysis.dir/TFUtils.cpp.o -c /var/tmp/portage/sys-devel/llvm-11.0.0/work/llvm/lib/Analysis/TFUtils.cpp FAILED: lib/Analysis/CMakeFiles/LLVMAnalysis.dir/TFUtils.cpp.o /usr/bin/x86_64-pc-linux-gnu-g++ -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib/Analysis -I/var/tmp/portage/sys-devel/llvm-11.0.0/work/llvm/lib/Analysis -I/usr/include/libxml2 -I/include -Iinclude -I/var/tmp/portage/sys-devel/llvm-11.0.0/work/llvm/include -DNDEBUG -march=native -O2 -pipe -fPIC -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment -fdiagnostics-color -ffunction-sections -fdata-sections -std=c++14 -MD -MT lib/Analysis/CMakeFiles/LLVMAnalysis.dir/TFUtils.cpp.o -MF lib/Analysis/CMakeFiles/LLVMAnalysis.dir/TFUtils.cpp.o.d -o lib/Analysis/CMakeFiles/LLVMAnalysis.dir/TFUtils.cpp.o -c /var/tmp/portage/sys-devel/llvm-11.0.0/work/llvm/lib/Analysis/TFUtils.cpp /var/tmp/portage/sys-devel/llvm-11.0.0/work/llvm/lib/Analysis/TFUtils.cpp:20:10: fatal error: tensorflow/c/c_api.h: No such file or directory #include "tensorflow/c/c_api.h" Bug details and patch which works for me and can be treated as a workaround in attachments. emerge --info Portage 3.0.8 (python 3.7.9-final-0, default/linux/amd64/17.1/desktop/plasma, gcc-8.4.0, glibc-2.32-r2, 5.8.13-gentoo x86_64) ================================================================= System uname: Linux-5.8.13-gentoo-x86_64-Intel-R-_Core-TM-_i9-9900K_CPU_@_3.60GHz-with-gentoo-2.7 KiB Mem: 32815756 total, 10056724 free KiB Swap: 134217724 total, 129501436 free Timestamp of repository gentoo: Mon, 12 Oct 2020 19:00:01 +0000 Head commit of repository gentoo: d760b499a6081410e6125dae00c236d5404a60a1 sh bash 5.0_p18 ld GNU ld (Gentoo 2.34 p6) 2.34.0 app-shells/bash: 5.0_p18::gentoo dev-java/java-config: 2.3.1::gentoo dev-lang/perl: 5.30.3-r1::gentoo dev-lang/python: 2.7.18-r4::gentoo, 3.6.11-r2::gentoo, 3.7.9::gentoo, 3.8.6::gentoo, 3.9.0::gentoo, 3.10.0_alpha1::gentoo dev-util/cmake: 3.18.4::gentoo sys-apps/baselayout: 2.7::gentoo sys-apps/openrc: 0.42.1::gentoo sys-apps/sandbox: 2.20::gentoo sys-devel/autoconf: 2.13-r1::gentoo, 2.69-r5::gentoo sys-devel/automake: 1.11.6-r3::gentoo, 1.16.2::gentoo sys-devel/binutils: 2.34-r2::gentoo, 2.35.1::gentoo sys-devel/gcc: 8.4.0-r1::gentoo, 9.3.0-r1::gentoo, 10.2.0-r2::gentoo sys-devel/gcc-config: 2.3.2::gentoo sys-devel/libtool: 2.4.6-r6::gentoo sys-devel/make: 4.3::gentoo sys-kernel/linux-headers: 5.8::gentoo (virtual/os-headers) sys-libs/glibc: 2.32-r2::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-verify-max-age: 24 sync-rsync-verify-jobs: 1 sync-rsync-extra-opts: myrepo location: /var/db/repos/myrepo strict-misc-digests: false sync-openpgp-key-refresh: no masters: gentoo ACCEPT_KEYWORDS="amd64 ~amd64" ACCEPT_LICENSE="@FREE" CBUILD="x86_64-pc-linux-gnu" CFLAGS="-march=native -O2 -pipe" CHOST="x86_64-pc-linux-gnu" CONFIG_PROTECT="/etc /usr/lib64/libreoffice/program/sofficerc /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/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c" 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" FCFLAGS="-march=native -O2 -pipe" FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs 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 -O2 -pipe" GENTOO_MIRRORS="rsync://ftp.vectranet.pl/gentoo/ http://ftp.vectranet.pl/gentoo/ ftp://ftp.vectranet.pl/gentoo/" LANG="pl_PL.utf8" LDFLAGS="-Wl,-O1 -Wl,--as-needed" MAKEOPTS="-j17" 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="X a52 aac acl acpi activities alsa amd64 berkdb bluetooth branding bzip2 cairo cdda cdr cli crypt cuda cups dbus declarative dri dts dvd dvdr elogind emboss encode examples exif flac fortran gdbm gif gpm gtk gui iconv icu ipv6 jpeg kde kipi kwallet lcms libglvnd libnotify libtirpc mad mng mp3 mp4 mpeg multilib ncurses nls nptl ogg opencl opengl openmp pam pango pcre pdf phonon plasma png policykit ppds pulseaudio python qml qt5 readline sdl seccomp semantic-desktop spell split-usr ssl startup-notification svg tcpd tiff truetype udev udisks unicode upower usb vorbis widgets wxwidgets x264 xattr xcb xml xv xvid zlib" 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 wacom" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-2 php7-3 php7-4" POSTGRES_TARGETS="postgres10 postgres11" PYTHON_SINGLE_TARGET="python3_7" PYTHON_TARGETS="python2_7 python3_7" RUBY_TARGETS="ruby25 ruby26" USERLAND="GNU" VIDEO_CARDS="nvidia" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account" Unset: CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, LINGUAS, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Created attachment 665026 [details] error log
Created attachment 665029 [details, diff] This is just workaround that works for me based on https://github.com/llvm/llvm-project/commit/e72d792c147ee506e337401e20c0f23042cc43fe.patch
same here
Could you try if adding '-DLLVM_HAVE_TF_API=OFF' to mycmakeargs would work as well? I don't have TF installed (obviously), and it doesn't seem that I have enough free space to install it right now ;-).
(without the backported patch)
(In reply to Michał Górny from comment #4) > Could you try if adding '-DLLVM_HAVE_TF_API=OFF' to mycmakeargs would work > as well? I don't have TF installed (obviously), and it doesn't seem that I > have enough free space to install it right now ;-). @Michał Górny, You mean creating my ebuild for it but with something like this: rc_configure() { local mycmakeargs=( $(-DLLVM_HAVE_TF_API=OFF) ) cmake-utils_src_configure } ?
(In reply to Marcin from comment #6) > (In reply to Michał Górny from comment #4) > > Could you try if adding '-DLLVM_HAVE_TF_API=OFF' to mycmakeargs would work > > as well? I don't have TF installed (obviously), and it doesn't seem that I > > have enough free space to install it right now ;-). > > @Michał Górny, > > You mean creating my ebuild for it but with something like this: > > rc_configure() { > local mycmakeargs=( > $(-DLLVM_HAVE_TF_API=OFF) > ) > > cmake-utils_src_configure > } > > ? OK, I see that there is: multilib_src_configure() { local ffi_cflags ffi_ldflags if use libffi; then ffi_cflags=$($(tc-getPKG_CONFIG) --cflags-only-I libffi) ffi_ldflags=$($(tc-getPKG_CONFIG) --libs-only-L libffi) fi local libdir=$(get_libdir) local mycmakeargs=( in ebuild file. I'll add flag there and let you know. However it means that my lvvm will be build without TF so I prefer my patch in such case.
(In reply to Michał Górny from comment #4) > Could you try if adding '-DLLVM_HAVE_TF_API=OFF' to mycmakeargs would work > as well? I don't have TF installed (obviously), and it doesn't seem that I > have enough free space to install it right now ;-). I added this flag: /var/db/repos # diff gentoo/sys-devel/llvm/llvm-11.0.0.ebuild myrepo/sys-devel/llvm/llvm-11.0.0.ebuild 385a386 > -DLLVM_HAVE_TF_API=OFF But still it tries to find tensorflow and fails. This is because when it finds that TF is instaled then LLVM_HAVE_TF_API is set back to ON: set(LLVM_HAVE_TF_API "ON" CACHE BOOL "Full Tensorflow API available") There is no variable that could condition this code execution. Condition is only fact if there is TF installed or not. It looks for me that the best way would be to extend my workaround patch with some additional variable in CMakeLists that could be used for that and for enabling/disabling TF support. This variable would need local use flag for llvm (not sure how to do it for now, so I can't propose full solution; I need some time for that). I may be wrong as I'm not experienced in such things for Gentoo.
confirm failure with tensorflow installed. tested -DLLVM_HAVE_TF_API=OFF and it does not help. tested with patch from https://bugs.gentoo.org/748444#c2 and -DTENSORFLOW_C_LIB_PATH=NO and it builds. a bit strange to use type=PATH var as a bool, but it works =)
<@perfinion> so the actual issue might be that i put all the headers for TF in /usr/include/tensorflow/ so it ends up as /usr/include/tensorflow/tensorflow/c/c_api.h, cuz i have to put all the other bundled ones in /usr/include/tensorflow/external <@perfinion> once i manage to use the system libs for everything in TF, i could move it to just include/tf/tf/c/c_api.h, but uh thats a _long_ road still so if adding TF support is desired here ^ is the description of current state of things. otherwise patch + configure knob to disable it unconditionally. I'll try to put this in rust-1.47.0 as well.
(In reply to Georgy Yakovlev from comment #9) > tested with patch from https://bugs.gentoo.org/748444#c2 and > -DTENSORFLOW_C_LIB_PATH=NO and it builds. > a bit strange to use type=PATH var as a bool, but it works =) Do you mean the 'workaround' patch attached here, or the upstream patch linked?
Also, do you actually need to pass anything? FWICS the variable is not set anywhere, so it will be empty → if will evaluate to false.
Created attachment 668855 [details, diff] 0001-backport-D88371-guard-find_library-tensorflow_c_api.patch Patch does not apply to 11.0.0, so I rebased it a bit. It's just rebased upstream patch with no extras. Works with rust too. https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b4fb6fc0f73b4b4145236b56355c35070c3b529a
forgot to clarify, just adding the patch is enough, no extra args needed.
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=20ab0d476f1f2467cb35a863d36e21dfb48f075b commit 20ab0d476f1f2467cb35a863d36e21dfb48f075b Author: Michał Górny <mgorny@gentoo.org> AuthorDate: 2020-10-28 08:08:41 +0000 Commit: Michał Górny <mgorny@gentoo.org> CommitDate: 2020-10-28 08:37:35 +0000 sys-devel/llvm: Backport tensorflow automagic dep fix Backport patch fixing CMakeLists.txt not to use tensorflow automagically. This also fixes build failure due to our TF packages being incompatible. TF is now always-off. Thanks to Georgy Yakovlev for rebasing and testing the patch. Closes: https://bugs.gentoo.org/748444 Signed-off-by: Michał Górny <mgorny@gentoo.org> ...88371-guard-find_library-tensorflow_c_api.patch | 55 ++++++++++++++++++++++ sys-devel/llvm/llvm-11.0.0.ebuild | 6 +++ 2 files changed, 61 insertions(+)