Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 685678

Summary: media-libs/mesa[opencl] fails to build with sys-devel/clang[default-libcxx]
Product: Gentoo Linux Reporter: Haelwenn (lanodan) Monnier <contact>
Component: Current packagesAssignee: Gentoo X packagers <x11>
Status: RESOLVED FIXED    
Severity: normal CC: jstein, llvm, mati865, mgorny
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 836220    
Attachments: lzma /var/tmp/portage/media-libs/mesa-18.3.6/temp/build.log
/var/tmp/portage/media-libs/mesa-18.3.6/temp/build.log.lzma: CXX="clang++ -stdlib=libc++"
patch
xz media-libs:mesa-9999:20191009-224356.log

Description Haelwenn (lanodan) Monnier 2019-05-12 05:33:16 UTC
Portage 2.3.62 (python 3.6.5-final-0, platforms/pc, gcc-8.2.0, glibc-2.28-r6, 4.19.27-gentoo-r1 x86_64)
=================================================================
                         System Settings
=================================================================
System uname: Linux-4.19.27-gentoo-r1-x86_64-AMD_FX-tm-8350_Eight-Core_Processor-with-gentoo-2.6
KiB Mem:    16377392 total,   5213864 free
KiB Swap:          0 total,         0 free
Head commit of repository gentoo: 83a7b166ebd273834a9e6e48eaae24e93685c0e1

sh bash 4.4_p23-r1
ld GNU ld (Gentoo 2.31.1 p5) 2.31.1
distcc 3.3.2 x86_64-pc-linux-gnu [disabled]
ccache version 3.6 [disabled]
app-shells/bash:          4.4_p23-r1::gentoo
dev-java/java-config:     2.2.0-r4::gentoo
dev-lang/perl:            5.26.2::gentoo
dev-lang/python:          2.7.15::gentoo, 3.6.5::gentoo
dev-util/ccache:          3.6::gentoo
dev-util/cmake:           3.9.6::gentoo
sys-apps/baselayout:      2.6-r1::gentoo
sys-apps/openrc:          0.41.2::lanodanOverlay
sys-apps/sandbox:         2.13::gentoo
sys-devel/autoconf:       2.13-r1::gentoo, 2.69-r4::gentoo
sys-devel/automake:       1.11.6-r3::gentoo, 1.14.1-r2::gentoo, 1.15.1-r2::gentoo, 1.16.1-r1::gentoo
sys-devel/binutils:       2.31.1-r4::gentoo
sys-devel/gcc:            8.2.0-r6::gentoo, 8.3.0-r1::gentoo
sys-devel/gcc-config:     2.0::gentoo
sys-devel/libtool:        2.4.6-r3::gentoo
sys-devel/make:           4.2.1-r4::gentoo
sys-kernel/linux-headers: 4.14-r1::gentoo (virtual/os-headers)
sys-libs/glibc:           2.28-r6::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: git
    sync-uri: https://anongit.gentoo.org/git/repo/gentoo.git
    priority: -1000

laurentb
    location: /var/lib/layman/laurentb
    sync-type: laymansync
    sync-uri: git://github.com/laurentb/gentoo-overlay.git
    masters: gentoo
    priority: 40

4nykey
    location: /var/lib/layman/4nykey
    sync-type: laymansync
    sync-uri: https://github.com/4nykey/4nykey.git
    masters: gentoo
    priority: 50

ArtSoftware
    location: /var/lib/layman/ArtSoftware
    sync-type: laymansync
    sync-uri: http://git.art-software.fr/ArtSoftware/portageLocalRepo.git
    masters: gentoo
    priority: 50

audio-overlay
    location: /var/lib/layman/audio-overlay
    sync-type: laymansync
    sync-uri: https://github.com/gentoo-audio/audio-overlay.git
    masters: gentoo
    priority: 50

betagarden
    location: /var/lib/layman/betagarden
    sync-type: laymansync
    sync-uri: git://anongit.gentoo.org/proj/betagarden.git
    masters: gentoo
    priority: 50

bobwya
    location: /var/lib/layman/bobwya
    sync-type: laymansync
    sync-uri: https://github.com/bobwya/miscellaneous_ebuilds.git
    masters: gentoo
    priority: 50

booboo
    location: /var/lib/layman/booboo
    sync-type: laymansync
    sync-uri: https://github.com/l29ah/booboo.git
    masters: gentoo
    priority: 50

cg
    location: /var/lib/layman/cg
    sync-type: laymansync
    sync-uri: https://github.com/brothermechanic/cg.git
    masters: gentoo
    priority: 50

chaoslab
    location: /var/lib/layman/chaoslab
    sync-type: laymansync
    sync-uri: https://gitlab.com/chaoslab/chaoslab-overlay.git
    masters: gentoo
    priority: 50

das-labor
    location: /var/lib/layman/das-labor
    sync-type: laymansync
    sync-uri: https://github.com/das-labor/labor-overlay.git
    masters: gentoo
    priority: 50

dlang
    location: /var/lib/layman/dlang
    sync-type: laymansync
    sync-uri: https://github.com/gentoo/dlang.git
    masters: gentoo
    priority: 50

dotnet
    location: /var/lib/layman/dotnet
    sync-type: laymansync
    sync-uri: https://github.com/gentoo/dotnet.git
    masters: gentoo
    priority: 50

flussence
    location: /var/lib/layman/flussence
    sync-type: laymansync
    sync-uri: https://gitlab.com/flussence/overlay.git
    masters: gentoo
    priority: 50

go-overlay
    location: /var/lib/layman/go-overlay
    sync-type: laymansync
    sync-uri: https://github.com/Dr-Terrible/go-overlay.git
    masters: gentoo
    priority: 50

guru
    location: /var/lib/layman/guru
    sync-type: laymansync
    sync-uri: https://anongit.gentoo.org/git/repo/proj/guru.git
    masters: gentoo
    priority: 50

haskell
    location: /var/lib/layman/haskell
    sync-type: laymansync
    sync-uri: https://github.com/gentoo-haskell/gentoo-haskell.git
    masters: gentoo
    priority: 50

java
    location: /var/lib/layman/java
    sync-type: laymansync
    sync-uri: git://anongit.gentoo.org/proj/java.git
    masters: gentoo
    priority: 50

jorgicio
    location: /var/lib/layman/jorgicio
    sync-type: laymansync
    sync-uri: https://github.com/jorgicio/jorgicio-gentoo.git
    masters: gentoo
    priority: 50

libressl
    location: /var/lib/layman/libressl
    sync-type: laymansync
    sync-uri: https://anongit.gentoo.org/git/repo/proj/libressl.git
    masters: gentoo
    priority: 50

lua
    location: /var/lib/layman/lua
    sync-type: laymansync
    sync-uri: https://anongit.gentoo.org/git/proj/lua.git
    masters: gentoo
    priority: 50

pentoo
    location: /var/lib/layman/pentoo
    sync-type: laymansync
    sync-uri: git://github.com/pentoo/pentoo-overlay.git
    masters: gentoo
    priority: 50

vampire
    location: /var/lib/layman/vampire
    sync-type: laymansync
    sync-uri: https://github.com/TheCrueltySage/vampire-overlay.git
    masters: gentoo
    priority: 50

lanodanOverlay
    location: /var/lib/layman/lanodanOverlay
    sync-type: laymansync
    sync-uri: https://gitlab.com/lanodan/overlay.git
    masters: gentoo lua
    priority: 100

Installed sets: @games, @graphical, @haiku-dev, @math, @office, @peertube, @prosody
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CC="clang"
CFLAGS="-Qunused-arguments -O2 -pipe -march=native -mtune=native -Wall -Wextra -Wconversion -Wsign-conversion -Wformat -Wformat-security -ggdb"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /lib/udev/rules.d/ /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 /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXX="clang++"
CXXFLAGS="-Qunused-arguments -O2 -pipe -march=native -mtune=native -Wall -Wextra -Wconversion -Wsign-conversion -Wformat -Wformat-security -ggdb"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--keep-going"
ENV_UNSET="DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN 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="-O2 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs cgroup config-protect-if-modified distlocks downgrade-backup ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch parallel-install pid-sandbox preserve-libs protect-owned python-trace sandbox sfperms sign splitdebug strict strict-keepdir unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync webrsync-gpg xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://hp2125/gentoo/ https://mirror.swordarmor.fr/gentoo https://mirrors.dotsrc.org/gentoo/ https://gentoo.osuosl.org/ http://distfiles.gentoo.org"
INSTALL_MASK="/usr/lib/systemd /usr/lib64/systemd /etc/systemd /etc/sudoers /etc/sudoers.d"
LANG="en_US.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-z,relro -Wl,-z,now"
PKGDIR="/usr/portage/packages"
PORTAGE_COMPRESS="true"
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="(cuda) (pgo) X accessibility acl acpi alsa amd64 bzip2 cacert caps ccache cjk clang crypt cryptsetup cxx d3d9 dane default-compiler-rt default-libcxx device-mapper dri egl eme-free gentoo-dev glamor gles gles1 gles2 gpg gtk3 hardened iconv icu idn iproute2 ipv6 jingle jpeg jumbo-build ldns libcxx libedit libressl libtirpc libtommath libzfs lm_sensors luajit mandoc mikmod modplug multilib multitarget ncurses nls nptl opencl opengl openmp opus pam pcre pie png portaudio qt3support readline sanitize sasl sctp seccomp smp spell ssl ssp symlink system-binutils system-boost system-cairo system-capstone system-clang system-cmark system-crontab system-ffmpeg system-harfbuzz system-heimdal system-icu system-jpeg system-jsoncpp system-libevent system-libmspack system-libs system-libvpx system-libyaml system-lua system-mitkrb5 system-qemu system-qt system-renpy system-seabios system-snappy system-sqlite system-tbb system-uulib system-wide system-wine system-zlib threads truetype udev unicode urandom usb uvm vaapi vdpau vorbis vulkan wayland xattr xcsecurity xft xinerama xtpax xwayland zfs zlib" ABI_X86="32 64" ALSA_CARDS="hda-intel" 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="cgroups conntrack contextswitch cpu df disk dns entropy fhcount fscache hddtemp interface memory processes protocols rrdtool sensors smart swap thermal uptime users wireless zfs_arc" CPU_FLAGS_X86="aes avx fma3 fma4 mmx mmxext pclmul popcnt sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 xop" CURL_SSL="libressl" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" GRUB_PLATFORMS="pc" INPUT_DEVICES="wacom libinput keyboard" KERNEL="linux" L10N="en en-US en-GB fr fr-FR fr-CA fr-CH fr-BE ja ja-JP is jbo de de-DE" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LLVM_TARGETS="AArch64 ARM Hexagon Mips MSP430 PowerPC Sparc SystemZ XCore AMDGPU BPF NVPTX Lanai RISCV" NETBEANS_MODULES="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml" NGINX_MODULES_HTTP="access autoindex charset fastcgi gzip gzip_static limit_conn limit_req map memcached metrics mirror proxy push_stream rewrite scgi split_clients ssi upstream_hash upstream_ip_hash upstream_keepalive upstream_least_conn upstream_zone userid uwsgi vhost_traffic_status headers_more stub_status" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-6 php7-1" POSTGRES_TARGETS="postgres9_5 postgres10" PYTHON_SINGLE_TARGET="python3_6" PYTHON_TARGETS="python3_6" QEMU_SOFTMMU_TARGETS="arm armeb i386 sparc x86_64" QEMU_USER_TARGETS="arm armeb i386 sparc x86_64" RUBY_TARGETS="ruby24" USERLAND="GNU" VIDEO_CARDS="radeonsi amdgpu" 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:  CPPFLAGS, CTARGET, LC_ALL, LINGUAS, MAKEOPTS, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

=================================================================
                        Package Settings
=================================================================

media-libs/mesa-18.3.6::gentoo was built with the following:
USE="classic d3d9 dri3 egl gallium gbm gles1 gles2 llvm lm_sensors pic vaapi vdpau vulkan wayland -debug -opencl -osmesa -pax_kernel (-selinux) -test -unwind -valgrind -xa -xvmc" ABI_X86="32 (64) (-x32)" VIDEO_CARDS="radeonsi (-freedreno) -i915 -i965 (-imx) -intel -nouveau -r100 -r200 -r300 -r600 -radeon (-vc4) -virgl (-vivante) -vmware"
Comment 1 Haelwenn (lanodan) Monnier 2019-05-12 05:39:37 UTC
Created attachment 576090 [details]
lzma /var/tmp/portage/media-libs/mesa-18.3.6/temp/build.log
Comment 2 Matt Turner gentoo-dev 2019-05-13 17:03:50 UTC
Please make it more apparent that you're building with clang in future reports.

The relevant error from the log is

In file included from ../mesa-18.3.6/src/gallium/state_trackers/clover/llvm/invocation.cpp:52:
../mesa-18.3.6/src/gallium/state_trackers/clover/llvm/metadata.hpp:45:23: error: no matching constructor for initialization of 'std::vector<const ::llvm::MDNode *>'
               return { n->op_begin(), n->op_end() };
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/v1/vector:495:5: note: candidate constructor not viable: no known conversion from 'llvm::NamedMDNode::const_op_iterator' (aka 'op_iterator_impl<const llvm::MDNode *, llvm::MDNode>') to 'std::__1::vector<const llvm::MDNode *, std::__1::allocator<const llvm::MDNode *> >::size_type' (aka 'unsigned int') for 1st argument
    vector(size_type __n, const_reference __x);
    ^

/me shrugs

Does it build with clang-7.1?
Comment 3 Haelwenn (lanodan) Monnier 2019-05-13 23:18:55 UTC
>Please make it more apparent that you're building with clang in future reports.

Sorry, will try to for next times.

>Does it build with clang-7.1?

Nah, still doesn't build, the error is the same (did a diff).
Comment 4 Matt Turner gentoo-dev 2019-05-14 05:47:34 UTC
USE=... default-libcxx ... libcxx

Could this be the culprit?

Can you try without those?
Comment 5 Haelwenn (lanodan) Monnier 2019-05-16 00:00:00 UTC
I tried with both CXX="clang++ -stdlib=libstdc++" and reverting the USE flags you mentionned and I'm getting some: undefined reference to `_Unwind_Resume' from nowhere, and installing llvm-libunwind or libunwind (which I didn't have because it often caused horrible issues due to the name conflict) doesn't solves it.
Comment 6 Haelwenn (lanodan) Monnier 2019-05-27 19:28:40 UTC
Okay, I cleaned my LLVM/Clang toolchain (removed USE="default-compiler-rt" too, builded llvm+clang 6 with gcc and then llvm+clang 7.1 with clang-6).
And I can confirm that mesa[opencl] builds fine with llvm+clang 7.1 and llvm+clang 6.

I guess C(XX)FLAGS instead of the USE="default-compiler-rt default-libcxx" should be recommended instead.
Comment 7 Matt Turner gentoo-dev 2019-05-27 21:36:15 UTC
Okay, so either 

1) the Mesa code isn't correct and still works with libstdc++ for some reason; or
2) libc++ has a bug
Comment 8 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2019-05-28 05:14:34 UTC
Would be nice to test it against 8.0.0.  (sorry, no resources here)
Comment 9 Haelwenn (lanodan) Monnier 2019-06-22 00:42:15 UTC
Created attachment 580334 [details]
/var/tmp/portage/media-libs/mesa-18.3.6/temp/build.log.lzma: CXX="clang++ -stdlib=libc++"

Sorry, I don't really have the ressources to have basically another gentoo setup with 8.0 to still keep on using 7.1 everywhere in a clean way.

Anyway if it can help, on the same machine and clean toolchain but CXX="clang++ -stdlib=libc++" I get a log which seems quite similar.
Comment 10 Mateusz Mikuła 2019-06-28 12:08:55 UTC
media-libs/mesa-18.3.6 still fails with Clang 8 + libcxx 8.
Comment 11 Matt Turner gentoo-dev 2019-10-09 20:24:24 UTC
Oooh! Please try this patch:

https://gitlab.freedesktop.org/mesa/mesa/merge_requests/1598.patch

(specifically patch 2/4)
Comment 12 Matt Turner gentoo-dev 2019-10-09 22:00:19 UTC
Created attachment 592354 [details, diff]
patch

Better yet, try this.
Comment 13 Haelwenn (lanodan) Monnier 2019-10-09 22:07:33 UTC
On which version of mesa should I apply it, -9999? I tried on media-libs/mesa-19.1.7::gentoo and I got "1 out of 1 hunk FAILED -- saving rejects to file src/gallium/state_trackers/clover/llvm/metadata.hpp.rej".
Comment 14 Matt Turner gentoo-dev 2019-10-09 22:15:14 UTC
(In reply to Haelwenn Monnier from comment #13)
> On which version of mesa should I apply it, -9999? I tried on
> media-libs/mesa-19.1.7::gentoo and I got "1 out of 1 hunk FAILED -- saving
> rejects to file src/gallium/state_trackers/clover/llvm/metadata.hpp.rej".

The attached patches are already in upstream git, so if you can successfully compile -9999 then we're good. Otherwise, I'd try applying them to 19.2.x.
Comment 15 Haelwenn (lanodan) Monnier 2019-10-09 23:06:48 UTC
Created attachment 592356 [details]
xz media-libs:mesa-9999:20191009-224356.log

Failed to build but my environment isn't exactly clean right now, attached the build.log anyway.

Will retry after I clean things up.
Comment 16 Matt Turner gentoo-dev 2019-11-18 05:41:35 UTC
This is fixed in 19.3.