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

Bug 692206 (use-libglvnd)

Summary: [Tracker] Unmasking libglvnd USE flag
Product: Gentoo Linux Reporter: Maik <hhfeuer>
Component: Current packagesAssignee: Gentoo X packagers <x11>
Status: IN_PROGRESS ---    
Severity: enhancement CC: alexander, devurandom, joost, krinpaus, marek.bartosiewicz, mike, waltercool
Priority: Normal Keywords: Tracker
Version: unspecified   
Hardware: All   
OS: All   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on: 692212, 698736, 699054, 606924, 692168, 692170, 692208, 692210, 695650, 695652, 697972, 698168    
Bug Blocks:    
Attachments: Patch against cogl-1.22.2.ebuild removing test useflag.

Description Maik 2019-08-15 10:41:11 UTC
I'm creating this bug entry to keep track of those ebuilds having fixed dependency on eselect-opengl so need changes to be able to switch to libglvnd systemwide.
Comment 1 sunmoon1997 2019-08-21 14:31:26 UTC
I have a personal overlay doing exactly this which works for me. 

My setup:
$ lspci -v | grep -i 'VGA'
00:02.0 VGA compatible controller: Intel Corporation UHD Graphics 630 (Desktop 9 Series) (prog-if 00 [VGA controller])
01:00.0 VGA compatible controller: NVIDIA Corporation TU104 [GeForce RTX 2070 SUPER] (rev a1) (prog-if 00 [VGA controller])

$ cat /etc/X11/xorg.conf.d/01-nvidia-offload.conf 
Section "ServerLayout"
    Identifier "layout"
    Option "AllowNVIDIAGPUScreens"
EndSection

$ glxinfo | grep -E 'OpenGL (vendor|renderer)'
OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) UHD Graphics 630 (Coffeelake 3x8 GT2) 

$ __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0 __GLX_VENDOR_LIBRARY_NAME=nvidia glxinfo  | grep -i nvidia
server glx vendor string: NVIDIA Corporation
client glx vendor string: NVIDIA Corporation
OpenGL vendor string: NVIDIA Corporation
OpenGL core profile version string: 4.6.0 NVIDIA 435.17
OpenGL core profile shading language version string: 4.60 NVIDIA
OpenGL version string: 4.6.0 NVIDIA 435.17
OpenGL shading language version string: 4.60 NVIDIA
OpenGL ES profile version string: OpenGL ES 3.2 NVIDIA 435.17

This is really an *amazing* moment! 

Many thanks to Arfrever Frehtes Taifersar Arahesis for sharing this.
Comment 2 sunmoon1997 2019-08-21 14:37:40 UTC
Sorry, I meant Maik in previous comment.:)
Comment 3 Christian Xia 2019-08-22 04:02:56 UTC
(In reply to sunmoon1997 from comment #1)
> I have a personal overlay doing exactly this which works for me. 
> 
> My setup:
> $ lspci -v | grep -i 'VGA'
> 00:02.0 VGA compatible controller: Intel Corporation UHD Graphics 630
> (Desktop 9 Series) (prog-if 00 [VGA controller])
> 01:00.0 VGA compatible controller: NVIDIA Corporation TU104 [GeForce RTX
> 2070 SUPER] (rev a1) (prog-if 00 [VGA controller])
> 
> $ cat /etc/X11/xorg.conf.d/01-nvidia-offload.conf 
> Section "ServerLayout"
>     Identifier "layout"
>     Option "AllowNVIDIAGPUScreens"
> EndSection
> 
> $ glxinfo | grep -E 'OpenGL (vendor|renderer)'
> OpenGL vendor string: Intel Open Source Technology Center
> OpenGL renderer string: Mesa DRI Intel(R) UHD Graphics 630 (Coffeelake 3x8
> GT2) 
> 
> $ __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0
> __GLX_VENDOR_LIBRARY_NAME=nvidia glxinfo  | grep -i nvidia
> server glx vendor string: NVIDIA Corporation
> client glx vendor string: NVIDIA Corporation
> OpenGL vendor string: NVIDIA Corporation
> OpenGL core profile version string: 4.6.0 NVIDIA 435.17
> OpenGL core profile shading language version string: 4.60 NVIDIA
> OpenGL version string: 4.6.0 NVIDIA 435.17
> OpenGL shading language version string: 4.60 NVIDIA
> OpenGL ES profile version string: OpenGL ES 3.2 NVIDIA 435.17
> 
> This is really an *amazing* moment! 
> 
> Many thanks to Arfrever Frehtes Taifersar Arahesis for sharing this.

Hello, could you share your personal overlay for this?

I tried to modify some related ebuilds, but I failed to get them work due to conflicts between app-eselect/eselect-opengl and media-libs/mesa.
Comment 4 sunmoon1997 2019-08-22 13:14:14 UTC
(In reply to Christian Xia from comment #3)
> (In reply to sunmoon1997 from comment #1)
...
> 
> Hello, could you share your personal overlay for this?
> 
> I tried to modify some related ebuilds, but I failed to get them work due to
> conflicts between app-eselect/eselect-opengl and media-libs/mesa.

Here is my personal repo[1]. I also added a step by step guide for enabling libglvnd for nvidia-drivers and xorg-server.

[1]: https://github.com/LuoJinghua/gentoo-overlay
Comment 5 Christian Xia 2019-08-22 15:42:39 UTC
(In reply to sunmoon1997 from comment #4)
> (In reply to Christian Xia from comment #3)
> > (In reply to sunmoon1997 from comment #1)
> ...
> > 
> > Hello, could you share your personal overlay for this?
> > 
> > I tried to modify some related ebuilds, but I failed to get them work due to
> > conflicts between app-eselect/eselect-opengl and media-libs/mesa.
> 
> Here is my personal repo[1]. I also added a step by step guide for enabling
> libglvnd for nvidia-drivers and xorg-server.
> 
> [1]: https://github.com/LuoJinghua/gentoo-overlay

Works like a charm! Thank you for your help :)

BTW, you've missed to submit some xorg-server-1.21 related patches to x11-base/xorg-server-1.20.5.

Fortunately, I've found these missing patches from xorg-server source repo commits.
Comment 6 Maik 2019-09-03 12:21:26 UTC
Created attachment 588884 [details, diff]
Patch against cogl-1.22.2.ebuild removing test useflag.

I've taken a deeper look at the ebuild and this seems quite absurd. It has dependencies to mesa[classic] and eselect-opengl when USE="test" but tests are disabled anyway with RESTRICT=test because those always fail(ed). Moreover, it uses
LIBGL_DRIVERS_PATH="${EROOT}/usr/$(get_libdir)/mesa", looks like some leftover from ancient times. At least I wouldn't know how that path could be used nowadays.
Conclusion: tests doesn't work anyway, is unmaintained, so just remove it. Attaching a patch doing so.
Comment 7 Maik 2019-09-03 12:22:11 UTC
Sorry wrong bug.
Comment 8 Marek Bartosiewicz 2019-09-10 09:03:33 UTC
@sunmoon1997
Could you update your overlay for nvidia-drivers-435.21?
Comment 9 Maik 2019-09-10 09:07:22 UTC
x11-drivers/nvidia-drivers-435.21 from official portage already contains the patch.
See bug #692170
Comment 10 Marek Bartosiewicz 2019-09-10 10:13:30 UTC
I'm not sure why, but I also needed to reemerge libepoxy before xorg-server.
Comment 11 Marek Bartosiewicz 2019-09-10 10:50:45 UTC
Seems to be working, can't confirm 100% as I'm logged in remotely right now. This is Dell Precision 5510:

[     4.391] (II) modeset(0): glamor X acceleration enabled on Mesa DRI Intel(R) HD Graphics P530 (Skylake GT2)
[     4.391] (II) modeset(0): glamor initialized
[     4.392] (II) modeset(0): Output eDP-1 has no monitor section
[     4.392] (II) modeset(0): Output DP-1 has no monitor section
[     4.396] (II) modeset(0): Output HDMI-1 has no monitor section
[     4.396] (II) modeset(0): Output DP-2 has no monitor section
[     4.400] (II) modeset(0): Output HDMI-2 has no monitor section
[     4.401] (II) modeset(0): EDID for output eDP-1
[     4.401] (II) modeset(0): Manufacturer: SHP  Model: 143e  Serial#: 0
[     4.401] (II) modeset(0): Year: 2015  Week: 40
[     4.401] (II) modeset(0): EDID Version: 1.4
[     4.401] (II) modeset(0): Digital Display Input
[     4.401] (II) modeset(0): 8 bits per channel
[     4.401] (II) modeset(0): Digital interface is DisplayPort
[     4.401] (II) modeset(0): Max Image Size [cm]: horiz.: 35  vert.: 19
[     4.401] (II) modeset(0): Gamma: 2.20
[     4.401] (II) modeset(0): No DPMS capabilities specified
[     4.401] (II) modeset(0): Supported color encodings: RGB 4:4:4 YCrCb 4:4:4
[     4.401] (II) modeset(0): Default color space is primary color space
[     4.401] (II) modeset(0): First detailed timing is preferred mode
[     4.401] (II) modeset(0): Preferred mode is native pixel format and refresh rate
...
[     4.410] (==) NVIDIA(G0): Depth 24, (==) framebuffer bpp 32
[     4.410] (==) NVIDIA(G0): RGB weight 888
[     4.410] (==) NVIDIA(G0): Default visual is TrueColor
[     4.410] (==) NVIDIA(G0): Using gamma correction (1.0, 1.0, 1.0)
[     4.410] (**) Option "AllowNVIDIAGpuScreens"
[     4.411] (**) NVIDIA(G0): Enabling 2D acceleration
[     4.411] (II) Loading sub module "glxserver_nvidia"
[     4.411] (II) LoadModule: "glxserver_nvidia"
[     4.411] (II) Loading /usr/lib64/xorg/modules/extensions/libglxserver_nvidia.so
[     4.454] (II) Module glxserver_nvidia: vendor="NVIDIA Corporation"
[     4.454]    compiled for 1.6.99.901, module version = 1.0.0
[     4.454]    Module class: X.Org Server Extension
[     4.454] (II) NVIDIA GLX Module  435.21  Sun Aug 25 08:14:27 CDT 2019
[     4.454] (II) NVIDIA: The X server supports PRIME Render Offload.
[     4.456] (II) NVIDIA(G0): NVIDIA GPU Quadro M1000M (GM107GL-A) at PCI:1:0:0 (GPU-0)
[     4.456] (--) NVIDIA(G0): Memory: 2097152 kBytes
[     4.456] (--) NVIDIA(G0): VideoBIOS: 82.07.82.00.29
[     4.456] (II) NVIDIA(G0): Detected PCI Express Link width: 16X
[     4.456] (II) NVIDIA(G0): Validated MetaModes:
[     4.456] (II) NVIDIA(G0):     "NULL"
[     4.456] (**) NVIDIA(G0): Virtual screen size configured to be 3840 x 2160
[     4.456] (WW) NVIDIA(G0): Unable to get display device for DPI computation.
[     4.456] (==) NVIDIA(G0): DPI set to (75, 75); computed from built-in default
[     4.456] (II) NVIDIA: Using 6144.00 MB of virtual memory for indirect memory
[     4.456] (II) NVIDIA:     access.
[     4.487] (II) NVIDIA(G0): Setting mode "NULL"
[     4.491] (==) NVIDIA(G0): Disabling shared memory pixmaps
[     4.491] (==) NVIDIA(G0): Backing store enabled
[     4.491] (==) NVIDIA(G0): Silken mouse enabled
[     4.491] (==) NVIDIA(G0): DPMS enabled
[     4.491] (II) Loading sub module "dri2"
[     4.491] (II) LoadModule: "dri2"
[     4.491] (II) Module "dri2" already built-in
[     4.491] (II) NVIDIA(G0): [DRI2] Setup complete
[     4.491] (II) NVIDIA(G0): [DRI2]   VDPAU driver: nvidia
[     4.494] (==) modeset(0): Backing store enabled
[     4.494] (==) modeset(0): Silken mouse enabled
[     4.555] (II) modeset(0): Initializing kms color map for depth 24, 8 bpc.
[     4.555] (==) modeset(0): DPMS enabled
[     4.556] (II) modeset(0): [DRI2] Setup complete
[     4.556] (II) modeset(0): [DRI2]   DRI driver: i965
[     4.556] (II) modeset(0): [DRI2]   VDPAU driver: i965
[     4.556] (II) Initializing extension Generic Event Extension
[     4.556] (II) Initializing extension SHAPE
[     4.556] (II) Initializing extension MIT-SHM
[     4.556] (II) Initializing extension XInputExtension
[     4.556] (II) Initializing extension XTEST
[     4.556] (II) Initializing extension BIG-REQUESTS
[     4.556] (II) Initializing extension SYNC
[     4.556] (II) Initializing extension XKEYBOARD
[     4.556] (II) Initializing extension XC-MISC
[     4.556] (II) Initializing extension XFIXES
[     4.556] (II) Initializing extension RENDER
[     4.556] (II) Initializing extension RANDR
[     4.556] (II) Initializing extension COMPOSITE
[     4.556] (II) Initializing extension DAMAGE
[     4.556] (II) Initializing extension MIT-SCREEN-SAVER
[     4.556] (II) Initializing extension DOUBLE-BUFFER
[     4.556] (II) Initializing extension RECORD
[     4.556] (II) Initializing extension DPMS
[     4.556] (II) Initializing extension Present
[     4.556] (II) Initializing extension DRI3
[     4.556] (II) Initializing extension X-Resource
[     4.556] (II) Initializing extension XVideo
[     4.556] (II) Initializing extension XVideo-MotionCompensation
[     4.556] (II) Initializing extension GLX
[     4.557] (II) Initializing extension GLX
[     4.557] (II) Indirect GLX disabled.
[     4.570] (II) AIGLX: Loaded and initialized i965
[     4.570] (II) GLX: Initialized DRI2 GL provider for screen 0
[     4.570] (II) Initializing extension XFree86-VidModeExtension
[     4.570] (II) Initializing extension XFree86-DGA
[     4.570] (II) Initializing extension XFree86-DRI
[     4.570] (II) Initializing extension DRI2
[     4.570] (II) Initializing extension NV-GLX
[     4.570] (II) Initializing extension NV-CONTROL
[     4.576] (II) modeset(0): Damage tracking initialized
[     4.576] (II) modeset(0): Setting screen physical size to 1016 x 571
Comment 12 Marek Bartosiewicz 2019-09-10 11:13:31 UTC
Also, is this caused by libglvnd and eselect-opengl removal?

Emerging (3 of 11) dev-python/pycairo-1.18.1::gentoo
 * pycairo-1.18.1.tar.gz BLAKE2B SHA512 size ;-) ...                                                                                                                                                                                  [ ok ]
>>> Unpacking source...
>>> Unpacking pycairo-1.18.1.tar.gz to /var/tmp/portage/dev-python/pycairo-1.18.1/work
>>> Source unpacked in /var/tmp/portage/dev-python/pycairo-1.18.1/work
>>> Preparing source in /var/tmp/portage/dev-python/pycairo-1.18.1/work/pycairo-1.18.1 ...
>>> Source prepared.
>>> Configuring source in /var/tmp/portage/dev-python/pycairo-1.18.1/work/pycairo-1.18.1 ...
>>> Source configured.
>>> Compiling source in /var/tmp/portage/dev-python/pycairo-1.18.1/work/pycairo-1.18.1 ...
 * python2_7: running distutils-r1_run_phase distutils-r1_python_compile
python2.7 setup.py build
running build
running build_py
creating /var/tmp/portage/dev-python/pycairo-1.18.1/work/pycairo-1.18.1-python2_7/lib/cairo
copying cairo/__init__.py -> /var/tmp/portage/dev-python/pycairo-1.18.1/work/pycairo-1.18.1-python2_7/lib/cairo
copying cairo/__init__.pyi -> /var/tmp/portage/dev-python/pycairo-1.18.1/work/pycairo-1.18.1-python2_7/lib/cairo
copying cairo/py.typed -> /var/tmp/portage/dev-python/pycairo-1.18.1/work/pycairo-1.18.1-python2_7/lib/cairo
warning: build_py: byte-compiling is disabled, skipping.

running build_ext
Package egl was not found in the pkg-config search path.
Perhaps you should add the directory containing `egl.pc'
to the PKG_CONFIG_PATH environment variable
Package 'egl', required by 'cairo', not found
Command '['pkg-config', '--cflags-only-I', 'cairo']' returned non-zero exit status 1
Comment 13 Maik 2019-09-10 12:04:46 UTC
Might be. Like mentioned in https://bugs.gentoo.org/606924#c20 the mesa maintainers are currently soting out the pkgconfig files.
I'm on stable, so I have mesa-19.0.8 which provides the pkconfig files for egl etc. Might be subject to change and incomplete if you're on unstable.
Comment 14 Marek Bartosiewicz 2019-09-10 12:13:30 UTC
Yeah, I also had to reemerge cairo. It wasn't picked up by revdep-rebuild for some reason.
Comment 15 Maik 2019-09-10 12:16:08 UTC
Rather odd, I didn't have to reemerge anything. Did you switch gcc version recently?
Comment 16 Marek Bartosiewicz 2019-09-10 12:23:28 UTC
Nope, this is a new install with gcc-9.2.
@world was rebuild completely before I started to emerge xorg and nvidia-drivers. Had to do this in stages, because changing USE flags.
Comment 17 Marek Bartosiewicz 2019-09-11 08:27:45 UTC
Another configure failure:

Checking for libarchive wrapper for reading zip files and more    : yes
Checking for SDL2                                                 : yes
Checking for OSS                                                  : disabled
Checking for RSound audio output                                  : disabled
Checking for sndio audio input/output                             : disabled
Checking for PulseAudio audio output                              : yes
Checking for JACK audio output                                    : disabled
Checking for OpenAL audio output                                  : yes
Checking for OpenSL ES audio output                               : disabled
Checking for ALSA audio output                                    : yes
Checking for CoreAudio audio output                               : disabled
Checking for AudioUnit output for iOS                             : no
Checking for WASAPI audio output                                  : os-win32 not found
Checking for Cocoa                                                : disabled
Checking for DRM                                                  : yes
Checking for DRM Prime ffmpeg support                             : yes
Checking for GBM                                                  : disabled
Checking for wayland-scanner                                      : disabled
Checking for wayland-protocols                                    : disabled
Checking for Wayland                                              : disabled
Checking for X11                                                  : yes
Checking for Xv video output                                      : yes
Checking for OpenGL Cocoa Backend                                 : disabled
Checking for OpenGL X11 Backend                                   : yes
Checking for OpenGL X11 EGL Backend                               : no ('egl' not found)
You manually enabled the feature 'egl-x11', but the autodetection check failed.
 * ERROR: media-video/mpv-0.29.1-r1::gentoo failed (configure phase):
 *   configure failed
 *
 * Call stack:
 *     ebuild.sh, line  125:  Called src_configure
 *   environment, line 4201:  Called waf-utils_src_configure '--confdir=/etc/mpv' '--docdir=/usr/share/doc/mpv-0.29.1-r1' '--htmldir=/usr/share/doc/mpv-0.29.1-r1/html' '--disable-libmpv-shared' '--disable-libmpv-static' '--disable-static-build' '--disable-optimize' '--disable-debug-build' '--enable-html-build' '--disable-pdf-build' '--disable-cplugins' '--disable-zsh-comp' '--disable-test' '--disable-android' '--enable-iconv' '--disable-libsmbclient' '--enable-lua' '--disable-javascript' '--enable-libass' '--enable-libass-osd' '--enable-zlib' '--enable-libbluray' '--enable-dvdread' '--enable-dvdnav' '--disable-cdda' '--enable-uchardet' '--disable-rubberband' '--disable-lcms2' '--disable-vapoursynth' '--disable-vapoursynth-lazy' '--enable-libarchive' '--enable-libavdevice' '--enable-sdl2' '--disable-oss-audio' '--disable-rsound' '--disable-sndio' '--enable-pulse' '--disable-jack' '--enable-openal' '--disable-opensles' '--enable-alsa' '--disable-coreaudio' '--disable-cocoa' '--enable-drm' '--disable-gbm' '--disable-wayland-scanner' '--disable-wayland-protocols' '--disable-wayland' '--enable-x11' '--enable-xv' '--disable-gl-cocoa' '--enable-gl-x11' '--enable-egl-x11' '--disable-egl-drm' '--disable-gl-wayland' '--enable-vdpau' '--enable-vdpau-gl-x11' '--enable-vaapi' '--enable-vaapi-x11' '--disable-vaapi-wayland' '--disable-vaapi-drm' '--disable-caca' '--enable-jpeg' '--enable-shaderc' '--disable-rpi' '--disable-plain-gl' '--disable-mali-fbdev' '--enable-vulkan' '--disable-cuda-hwaccel' '--disable-tv' '--disable-tv-v4l2' '--disable-libv4l2' '--disable-audio-input' '--disable-dvbin' '--disable-apple-remote' '--enable-vaapi-glx' '--enable-vaapi-x-egl' '--disable-build-date'
 *   environment, line 5158:  Called die
 * The specific snippet of code:
 *       env "${CMD[@]}" || die "configure failed"
 *
 * If you need support, post the output of `emerge --info '=media-video/mpv-0.29.1-r1::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=media-video/mpv-0.29.1-r1::gentoo'`.
 * The complete build log is located at '/var/tmp/portage/media-video/mpv-0.29.1-r1/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/media-video/mpv-0.29.1-r1/temp/environment'.
 * Working directory: '/var/tmp/portage/media-video/mpv-0.29.1-r1/work/mpv-0.29.1'
 * S: '/var/tmp/portage/media-video/mpv-0.29.1-r1/work/mpv-0.29.1'
Comment 18 Marek Bartosiewicz 2019-09-11 08:30:41 UTC
Checking for OpenGL X11 Backend
==>
#include <X11/Xlib.h>
#include <GL/glx.h>
#include <stddef.h>

int main(int argc, char *argv[]) {
  glXCreateContext(NULL, NULL, NULL, True);
  glXQueryExtensionsString(NULL, 0);
  glXGetProcAddressARB("");
  glXGetCurrentDisplay();
  return 0;
}

<==
[1/2] Compiling build/.conf_check_8669a28b591d91ad04fdcd46293a7f95/test.c

['x86_64-pc-linux-gnu-gcc', '-O2', '-pipe', '-march=native', '-ftree-vectorize', '-D_ISOC99_SOURCE', '-D_GNU_SOURCE', '-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64', '-D_LARGEFILE64_SOURCE', '-std=c99', '-Wall', '-Werror=implicit-function-declaration', '-Wno-error=deprecated-declarations', '-Wno-error=unused-function', '-Wempty-body', '-Wdisabled-optimization', '-Wstrict-prototypes', '-Wno-format-zero-length', '-Werror=format-security', '-Wno-redundant-decls', '-Wvla', '-Wall', '-Wundef', '-Wmissing-prototypes', '-Wshadow', '-Wno-switch', '-Wparentheses', '-Wpointer-arith', '-Wno-pointer-sign', '-Wno-unused-result', '-pthread', '-DDEFAULT_DVD_DEVICE="/dev/sr0"', '-DDEFAULT_CDROM_DEVICE="/dev/sr0"', '-DHAVE_GPL=1', '-DHAVE_LIBAF=1', '-DHAVE_CPLAYER=1', '-DHAVE_LIBDL=1', '-DHAVE_ASM=1', '-DHAVE_LIBM=1', '-DHAVE_POSIX=1', '-DHAVE_POSIX_OR_MINGW=1', '-DHAVE_PTHREADS=1', '-DHAVE_GNUC=1', '-DHAVE_STDATOMIC=1', '-DHAVE_ATOMICS=1', '-DHAVE_LIBRT=1', '-DHAVE_ICONV=1', '-DHAVE_POSIX_SPAWN_NATIVE=1', '-DHAVE_POSIX_SPAWN=1', '-DHAVE_GLOB_POSIX=1', '-DHAVE_GLOB=1', '-DHAVE_FCHMOD=1', '-DHAVE_VT_H=1', '-DHAVE_GBM_H=1', '-DHAVE_GLIBC_THREAD_NAME=1', '-DHAVE_LINUX_FSTATFS=1', '-DHAVE_51=1', '-DHAVE_LUA=1', '-DHAVE_LIBASS=1', '-DHAVE_LIBASS_OSD=1', '-DHAVE_ZLIB=1', '-DHAVE_LIBBLURAY=1', '-DHAVE_DVDREAD=1', '-DHAVE_DVDNAV=1', '-DHAVE_DVDREAD_COMMON=1', '-DHAVE_UCHARDET=1', '-DHAVE_LIBARCHIVE=1', '-DHAVE_SDL2=1', '-DHAVE_PULSE=1', '-DHAVE_OPENAL=1', '-DHAVE_ALSA=1', '-DHAVE_DRM=1', '-DHAVE_DRMPRIME=1', '-DHAVE_X11=1', '-DHAVE_XV=1', '../test.c', '-c', '-o/var/tmp/portage/media-video/mpv-0.29.1-r1/work/mpv-0.29.1/build/.conf_check_8669a28b591d91ad04fdcd46293a7f95/testbuild/test.c.1.o']
[2/2] Linking build/.conf_check_8669a28b591d91ad04fdcd46293a7f95/testbuild/testprog

['x86_64-pc-linux-gnu-gcc', '-O2', '-pipe', '-march=native', '-ftree-vectorize', '-Wl,-O1', '-Wl,--as-needed', '-pthread', 'test.c.1.o', '-o/var/tmp/portage/media-video/mpv-0.29.1-r1/work/mpv-0.29.1/build/.conf_check_8669a28b591d91ad04fdcd46293a7f95/testbuild/testprog', '-Wl,-Bstatic', '-Wl,-Bdynamic', '-lX11', '-lXss', '-lXext', '-lXinerama', '-lXrandr', '-ldl', '-Wl,-O1', '-Wl,--as-needed']
err: test.c.1.o:test.c:function main: error: undefined reference to 'glXCreateContext'
test.c.1.o:test.c:function main: error: undefined reference to 'glXQueryExtensionsString'
test.c.1.o:test.c:function main: error: undefined reference to 'glXGetProcAddressARB'
test.c.1.o:test.c:function main: error: undefined reference to 'glXGetCurrentDisplay'
collect2: error: ld returned 1 exit status

from /var/tmp/portage/media-video/mpv-0.29.1-r1/work/mpv-0.29.1: Test does not build: Traceback (most recent call last):
  File "/var/tmp/portage/media-video/mpv-0.29.1-r1/work/mpv-0.29.1/.waf3-2.0.9-10a533182bd85c3f45a157fb5d62db50/waflib/Configure.py", line 324, in run_build
    bld.compile()
  File "/var/tmp/portage/media-video/mpv-0.29.1-r1/work/mpv-0.29.1/.waf3-2.0.9-10a533182bd85c3f45a157fb5d62db50/waflib/Build.py", line 176, in compile
    raise Errors.BuildError(self.producer.error)
waflib.Errors.BuildError: Build failed
 -> task in 'testprog' failed with exit status 1 (run with -v to display more information)

from /var/tmp/portage/media-video/mpv-0.29.1-r1/work/mpv-0.29.1: The configuration failed
==>
#include <X11/Xlib.h>
#include <GL/glx.h>
#include <stddef.h>

int main(int argc, char *argv[]) {
  glXCreateContext(NULL, NULL, NULL, True);
  glXQueryExtensionsString(NULL, 0);
  glXGetProcAddressARB("");
  glXGetCurrentDisplay();
  return 0;
}

<==
[1/2] Compiling build/.conf_check_4db92c8d471d8cf0f1d8867d6293555b/test.c

['x86_64-pc-linux-gnu-gcc', '-O2', '-pipe', '-march=native', '-ftree-vectorize', '-D_ISOC99_SOURCE', '-D_GNU_SOURCE', '-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64', '-D_LARGEFILE64_SOURCE', '-std=c99', '-Wall', '-Werror=implicit-function-declaration', '-Wno-error=deprecated-declarations', '-Wno-error=unused-function', '-Wempty-body', '-Wdisabled-optimization', '-Wstrict-prototypes', '-Wno-format-zero-length', '-Werror=format-security', '-Wno-redundant-decls', '-Wvla', '-Wall', '-Wundef', '-Wmissing-prototypes', '-Wshadow', '-Wno-switch', '-Wparentheses', '-Wpointer-arith', '-Wno-pointer-sign', '-Wno-unused-result', '-pthread', '-DDEFAULT_DVD_DEVICE="/dev/sr0"', '-DDEFAULT_CDROM_DEVICE="/dev/sr0"', '-DHAVE_GPL=1', '-DHAVE_LIBAF=1', '-DHAVE_CPLAYER=1', '-DHAVE_LIBDL=1', '-DHAVE_ASM=1', '-DHAVE_LIBM=1', '-DHAVE_POSIX=1', '-DHAVE_POSIX_OR_MINGW=1', '-DHAVE_PTHREADS=1', '-DHAVE_GNUC=1', '-DHAVE_STDATOMIC=1', '-DHAVE_ATOMICS=1', '-DHAVE_LIBRT=1', '-DHAVE_ICONV=1', '-DHAVE_POSIX_SPAWN_NATIVE=1', '-DHAVE_POSIX_SPAWN=1', '-DHAVE_GLOB_POSIX=1', '-DHAVE_GLOB=1', '-DHAVE_FCHMOD=1', '-DHAVE_VT_H=1', '-DHAVE_GBM_H=1', '-DHAVE_GLIBC_THREAD_NAME=1', '-DHAVE_LINUX_FSTATFS=1', '-DHAVE_51=1', '-DHAVE_LUA=1', '-DHAVE_LIBASS=1', '-DHAVE_LIBASS_OSD=1', '-DHAVE_ZLIB=1', '-DHAVE_LIBBLURAY=1', '-DHAVE_DVDREAD=1', '-DHAVE_DVDNAV=1', '-DHAVE_DVDREAD_COMMON=1', '-DHAVE_UCHARDET=1', '-DHAVE_LIBARCHIVE=1', '-DHAVE_SDL2=1', '-DHAVE_PULSE=1', '-DHAVE_OPENAL=1', '-DHAVE_ALSA=1', '-DHAVE_DRM=1', '-DHAVE_DRMPRIME=1', '-DHAVE_X11=1', '-DHAVE_XV=1', '../test.c', '-c', '-o/var/tmp/portage/media-video/mpv-0.29.1-r1/work/mpv-0.29.1/build/.conf_check_4db92c8d471d8cf0f1d8867d6293555b/testbuild/test.c.1.o']
[2/2] Linking build/.conf_check_4db92c8d471d8cf0f1d8867d6293555b/testbuild/testprog

['x86_64-pc-linux-gnu-gcc', '-O2', '-pipe', '-march=native', '-ftree-vectorize', '-Wl,-O1', '-Wl,--as-needed', '-pthread', 'test.c.1.o', '-o/var/tmp/portage/media-video/mpv-0.29.1-r1/work/mpv-0.29.1/build/.conf_check_4db92c8d471d8cf0f1d8867d6293555b/testbuild/testprog', '-Wl,-Bstatic', '-Wl,-Bdynamic', '-lGL', '-lX11', '-lXss', '-lXext', '-lXinerama', '-lXrandr', '-ldl', '-Wl,-O1', '-Wl,--as-needed']
yes
-----------------------------------------------------------------
Checking for OpenGL X11 EGL Backend
['x86_64-pc-linux-gnu-pkg-config', 'egl', '--libs', '--cflags', 'egl']
err: Package egl was not found in the pkg-config search path.
Perhaps you should add the directory containing `egl.pc'
to the PKG_CONFIG_PATH environment variable
Package 'egl', required by 'virtual:world', not found
Package 'egl', required by 'virtual:world', not found

from /var/tmp/portage/media-video/mpv-0.29.1-r1/work/mpv-0.29.1: The configuration failed
no ('egl' not found)
Comment 19 Maik 2019-09-11 08:52:14 UTC
Which mesa version/use flags?
Please post the output of
emerge -pv mesa
Comment 20 Marek Bartosiewicz 2019-09-11 10:10:35 UTC
[ebuild   R    ] media-libs/mesa-19.2.0_rc2::gentoo  USE="X classic dri3 egl gallium gbm libglvnd llvm opencl vaapi vdpau vulkan -d3d9 -debug -gles1 -gles2 -lm_sensors -osmesa -pax_kernel (-selinux) -test -unwind -valgrind -vulkan-overlay -wayland -xa -xvmc" ABI_X86="(64) -32 (-x32)" VIDEO_CARDS="i965 intel (-freedreno) -i915 -iris (-lima) -nouveau (-panfrost) -r100 -r200 -r300 -r600 -radeon -radeonsi (-vc4) -virgl (-vivante) -vmware" 0 KiB
Comment 21 Maik 2019-09-11 10:15:00 UTC
Ok, that clarifies it. All your breaking packages have nothing to do with USE="libglvnd" but this one:
https://bugzilla.redhat.com/show_bug.cgi?id=1744292
Please file a bug against the mesa package.
Comment 22 Marek Bartosiewicz 2019-09-12 16:22:03 UTC
PRIME render offload works beautifully:

marek@precision ~/GOG Games/Sunless Skies/game $ __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia ./Sunless\ Skies.x86_64 
Set current directory to /home/marek/GOG Games/Sunless Skies/game
Found path: /home/marek/GOG Games/Sunless Skies/game/Sunless Skies.x86_64
Mono path[0] = '/home/marek/GOG Games/Sunless Skies/game/Sunless Skies_Data/Managed'
Mono config path = '/home/marek/GOG Games/Sunless Skies/game/Sunless Skies_Data/Mono/etc'
Preloaded 'ScreenSelector.so'
Unable to preload the following plugins:
	ScreenSelector.so
Display 0 'eDP-1 16"': 3840x2160 (primary device).
Logging to /home/marek/.config/unity3d/Failbetter Games/Sunless Skies/Player.log
marek@precision ~/GOG Games/Sunless Skies/game $ mc

marek@precision ~/GOG Games/Sunless Skies/game $ cat /home/marek/.config/unity3d/Failbetter\ Games/Sunless\ Skies/Player.log 
Desktop is 3840 x 2160 @ 60 Hz
Initialize engine version: 2018.2.21f1 (a122f5dc316d)
GfxDevice: creating device client; threaded=1
Renderer: Quadro M1000M/PCIe/SSE2
Vendor:   NVIDIA Corporation
Version:  4.5.0 NVIDIA 435.21
GLES:     0
 GL_AMD_multi_draw_indirect GL_AMD_seamless_cubemap_per_texture 
(...)

When I omit __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia then Intel card with Mesa 3D is selected.
Comment 23 Marek Bartosiewicz 2019-09-19 03:25:48 UTC
Is this the time to remove the overlay? Are patches in the main portage tree?

Calculating dependencies... done!
[ebuild  N     ] app-eselect/eselect-opengl-1.3.1-r4::gentoo  3 KiB
[ebuild     U #] media-libs/libglvnd-1.1.1-r1::gentoo [1.1.1::gentoo] ABI_X86="32 (64) (-x32)" 1 808 KiB
[ebuild   R    ] x11-base/xorg-server-1.20.5:0/1.20.5::ljh  USE="glamor ipv6 suid systemd udev xorg xvfb -debug -dmx -doc (-elogind) -kdrive (-libglvnd*) -libressl -minimal (-selinux) -static-libs -unwind -wayland -xcsecurity -xephyr -xnest" 5 984 KiB
[ebuild     U  ] dev-libs/libical-3.0.6:0/3::gentoo [3.0.5:0/3::gentoo] USE="berkdb introspection%* vala%* -doc -examples -static-libs -test (-glib%)" 860 KiB
[ebuild     UD ] media-libs/freeglut-3.0.0::gentoo [3.2.0::gentoo] USE="-debug -static-libs" ABI_X86="(64) -32 (-x32)" 410 KiB
[ebuild     U  ] gnome-base/gnome-desktop-3.32.2:3/17::gentoo [3.30.2.3:3/17::gentoo] USE="introspection (seccomp) udev -debug -gtk-doc% -test" 700 KiB
[blocks B      ] app-eselect/eselect-opengl ("app-eselect/eselect-opengl" is blocking x11-base/xorg-server-1.20.5, media-libs/mesa-19.2.0_rc3)
[blocks B      ] app-eselect/eselect-opengl ("app-eselect/eselect-opengl" is blocking x11-drivers/nvidia-drivers-435.21)
Comment 24 Matt Turner gentoo-dev 2019-09-19 03:58:52 UTC
(In reply to Marek Bartosiewicz from comment #23)
> Is this the time to remove the overlay? Are patches in the main portage tree?

Everything except the patch for media-libs/cogl. And I discovered that both libglvnd and mesa[libglvnd] are installing gl.pc, so we're getting that fixed in upstream Mesa, and it'll be in the 19.2.0 release.

So my plan is to unmask libglvnd in 19.2.0 and if everything goes well, force the flag on in 19.3.0 (and then at some point remove the flag and leave it always enabled)
Comment 25 Marek Bartosiewicz 2019-09-19 06:38:38 UTC
Thanks.

>> And I discovered that both libglvnd and mesa[libglvnd] are installing gl.pc

Which one should be installed?

 * media-libs/mesa-19.2.0_rc3:0::gentoo
 *      /usr/lib/pkgconfig/gl.pc
 *      /usr/lib64/pkgconfig/gl.pc
 *
 * Package 'media-libs/libglvnd-1.1.1-r1' NOT merged due to file
 * collisions. If necessary, refer to your elog messages for the whole
 * content of the above message.
Comment 26 Marek Bartosiewicz 2019-09-19 07:22:33 UTC
Strange:

checking for UDEV... yes
checking for udev_monitor_filter_add_match_tag... yes
checking for udev_enumerate_add_match_tag... yes
checking for DBUS... yes
checking for HAL... no
checking for glibc...... yes
checking for clock_gettime... yes
checking for a useful monotonic clock ...... yes
checking whether to track client ids... yes
checking for DRI2PROTO... yes
checking for DRI3PROTO... yes
checking for sigaction... yes
checking for XSHMFENCE... yes
configure: DRI3 enabled
checking for LIBDRM... yes
checking for XLIB... yes
checking for GL... no
configure: error: Package requirements (glproto >= 1.4.17 gl >= 9.2.0) were not met:

Package dependency requirement 'gl >= 9.2.0' could not be satisfied.
Package 'gl' has version '1.2', required version is '>= 9.2.0'

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables GL_CFLAGS
and GL_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
Comment 27 Marek Bartosiewicz 2019-09-19 07:23:56 UTC
This is x11-base/xorg-server-1.20.5::gentoo
Comment 28 Marek Bartosiewicz 2019-09-19 07:36:00 UTC
I needed to reemerge mesa, sorry for the noise. Removing overlays isn't so simple :)
All is good now.

[ebuild   R   #] media-libs/libglvnd-1.1.1-r1::gentoo  ABI_X86="32 (64) (-x32)" 1 808 KiB
[ebuild   R    ] media-libs/mesa-19.2.0_rc3::gentoo  USE="X classic dri3 egl gallium gbm libglvnd llvm opencl vaapi vdpau vulkan -d3d9 -debug -gles1 -gles2 -lm-sensors -osmesa -pax_kernel (-selinux) -test -unwind -valgrind -vulkan-overlay -wayland -xa -xvmc" ABI_X86="32 (64) (-x32)" VIDEO_CARDS="i965 intel (-freedreno) -i915 -iris (-lima) -nouveau (-panfrost) -r100 -r200 -r300 -r600 -radeon -radeonsi (-vc4) -virgl (-vivante) -vmware" 0 KiB
[ebuild   R    ] x11-base/xorg-server-1.20.5:0/1.20.5::gentoo  USE="glamor ipv6 libglvnd suid systemd udev xorg xvfb -debug -dmx -doc (-elogind) -kdrive -libressl -minimal (-selinux) -static-libs -unwind -wayland -xcsecurity -xephyr -xnest" 0 KiB
[ebuild   R    ] x11-drivers/nvidia-drivers-435.21:0/435::gentoo  USE="X acpi driver gtk3 kms libglvnd multilib uvm -compat -static-libs -tools -wayland" ABI_X86="32 (64) (-x32)"  0 KiB
Comment 29 Marek Bartosiewicz 2019-09-19 07:47:22 UTC
Unfortunately seems that not all xorg patches are included, as prime render offload is disabled:

[     5.945] (**) Option "AllowNVIDIAGpuScreens"
[     5.945] (**) NVIDIA(G0): Enabling 2D acceleration
[     5.945] (II) Loading sub module "glxserver_nvidia"
[     5.945] (II) LoadModule: "glxserver_nvidia"
[     5.945] (II) Loading /usr/lib64/xorg/modules/extensions/libglxserver_nvidia.so
[     5.980] (II) Module glxserver_nvidia: vendor="NVIDIA Corporation"
[     5.980] (II) NVIDIA GLX Module  435.21  Sun Aug 25 08:14:27 CDT 2019
[     5.980] (II) NVIDIA: The X server does not support PRIME Render Offload.
Comment 30 Marek Bartosiewicz 2019-09-19 08:23:47 UTC
I added back 1.12 xorg-server patches from this overlay:
https://github.com/LuoJinghua/gentoo-overlay/tree/master/x11-base/xorg-server/files

as portage user patches:
 * Applying xorg-server-1.21-autobind-gpu.patch ...                                                                                                                                                                                   [ ok ]
 * Applying xorg-server-1.21-multigpu-00-7f962c70.patch ...                                                                                                                                                                           [ ok ]
 * Applying xorg-server-1.21-multigpu-01-37a36a6b.patch ...                                                                                                                                                                           [ ok ]
 * Applying xorg-server-1.21-multigpu-02-8b67ec7c.patch ...                                                                                                                                                                           [ ok ]
 * Applying xorg-server-1.21-multigpu-03-56c0a71f.patch ...                                                                                                                                                                           [ ok ]
 * Applying xorg-server-1.21-multigpu-04-b4231d69.patch ...                                                                                                                                                                           [ ok ]
 * User patches applied.

And I have PRIME offloading back:

[     6.136] (**) Option "AllowNVIDIAGpuScreens"
[     6.136] (**) NVIDIA(G0): Enabling 2D acceleration
[     6.136] (II) Loading sub module "glxserver_nvidia"
[     6.136] (II) LoadModule: "glxserver_nvidia"
[     6.136] (II) Loading /usr/lib64/xorg/modules/extensions/libglxserver_nvidia.so
[     6.183] (II) Module glxserver_nvidia: vendor="NVIDIA Corporation"
[     6.183] (II) NVIDIA GLX Module  435.21  Sun Aug 25 08:14:27 CDT 2019
[     6.183] (II) NVIDIA: The X server supports PRIME Render Offload.


That's why I was asking about those patches in main portage tree :)
Comment 31 Matt Turner gentoo-dev 2019-09-19 15:43:14 UTC
(In reply to Marek Bartosiewicz from comment #30) 
> That's why I was asking about those patches in main portage tree :)

That's separate from enabling glvnd (but valuable).

(In reply to Marek Bartosiewicz from comment #25)
> Thanks.
> 
> >> And I discovered that both libglvnd and mesa[libglvnd] are installing gl.pc
> 
> Which one should be installed?
> 
>  * media-libs/mesa-19.2.0_rc3:0::gentoo
>  *      /usr/lib/pkgconfig/gl.pc
>  *      /usr/lib64/pkgconfig/gl.pc
>  *
>  * Package 'media-libs/libglvnd-1.1.1-r1' NOT merged due to file
>  * collisions. If necessary, refer to your elog messages for the whole
>  * content of the above message.

The one from libglvnd. The fix for Mesa is now upstream (https://gitlab.freedesktop.org/mesa/mesa/commit/a1de3011f380b6ffd5583708b58e3f86d8d45ea9) and will be in the next RC for 19.2.0.
Comment 32 Alexander Tsoy 2019-09-25 20:03:42 UTC
(In reply to Matt Turner from comment #31)
...
> The one from libglvnd. The fix for Mesa is now upstream
> (https://gitlab.freedesktop.org/mesa/mesa/commit/
> a1de3011f380b6ffd5583708b58e3f86d8d45ea9) and will be in the next RC for
> 19.2.0.
This change was reverted in 19.2.0 :(
https://cgit.freedesktop.org/mesa/mesa/commit/?h=19.2&id=e59e9cd58a95d8dc9b06d09f2abed96ba7b1a1b9
Comment 33 Alexander Tsoy 2019-09-25 20:15:53 UTC
(In reply to Alexander Tsoy from comment #32)
Or maybe they just fail to make pkg.generate() conditional (if not with_glvnd or glvnd_missing_pc_files)?
Comment 34 Matt Turner gentoo-dev 2019-09-25 20:55:09 UTC
(In reply to Alexander Tsoy from comment #33)
> (In reply to Alexander Tsoy from comment #32)
> Or maybe they just fail to make pkg.generate() conditional (if not
> with_glvnd or glvnd_missing_pc_files)?

Yeah, it's just to handle the case where you have libglvnd that doesn't have the pkgconfig files. We don't want to end up in a state where no one is providing the files.

Shouldn't affect us though. glvnd 1.2.0 is in tree.

Go forth and test.
Comment 35 Alexander Tsoy 2019-09-25 21:51:09 UTC
(In reply to Matt Turner from comment #34)
> Go forth and test.
I already tested mesa-19.2.0 with libglvnd-1.2.0 before commenting here and still got file collision. OK, I'd better open a separate bug for this.
Comment 36 Matt Turner gentoo-dev 2019-09-25 22:16:36 UTC
I'm planning to commit a fix for cogl tonight and then unmask the libglvnd flag in a few days.
Comment 37 Marek Bartosiewicz 2019-09-29 05:54:20 UTC
What about these? Shall I report them as bugs? 

I have:
[ebuild   R    ] media-libs/mesa-19.2.0::gentoo  USE="X classic dri3 egl gallium gbm libglvnd llvm opencl vaapi vdpau vulkan -d3d9 -debug -gles1 -gles2 -lm-sensors -osmesa -pax_kernel (-selinux) -test -unwind -valgrind -vulkan-overlay -wayland -xa -xvmc" ABI_X86="32 (64) (-x32)" VIDEO_CARDS="i965 intel (-freedreno) -i915 -iris (-lima) -nouveau (-panfrost) -r100 -r200 -r300 -r600 -radeon -radeonsi (-vc4) -virgl (-vivante) -vmware"

Newest i3-gaps fails, also I can't reinstall pango:

checking for x86_64-pc-linux-gnu-pkg-config... /usr/bin/x86_64-pc-linux-gnu-pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for LIBSN... yes
checking for XCB... yes
checking for XCB_UTIL... yes
checking for XCB_UTIL_CURSOR... yes
checking for XCB_UTIL_KEYSYMS... yes
checking for XCB_UTIL_WM... yes
checking for XCB_UTIL_XRM... yes
checking for XKBCOMMON... yes
checking for YAJL... yes
checking for LIBPCRE... yes
checking for PANGOCAIRO... no
configure: error: Package requirements (cairo >= 1.14.4 pangocairo) were not met:

Package 'gl', required by 'cairo', not found
Package 'gl', required by 'cairo', not found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables PANGOCAIRO_CFLAGS
and PANGOCAIRO_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

pango:
DHAVE_FREETYPE    -O2 -pipe -march=native -ftree-vectorize -Wall -c -o testboundaries_ucd.o /var/tmp/portage/x11-libs/pango-1.42.4-r2/work/pango-1.42.4/tests/testboundaries_ucd.c
x86_64-pc-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I/var/tmp/portage/x11-libs/pango-1.42.4-r2/work/pango-1.42.4/tests -I..  -DSRCDIR=\"/var/tmp/portage/x11-libs/pango-1.42.4-r2/work/pango-1.42.4/tests\" -I/var/tmp/portage/x11-libs/pango-1.42.4-r2/work/pango-1.42.4 -DG_DISABLE_CAST_CHECKS -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/lib64/libffi-3.3_rc0/include -pthread  -I/usr/include/freetype2 -I/usr/include/uuid   -I/usr/include/freetype2   -DHAVE_X -DHAVE_XFT -DHAVE_FREETYPE    -O2 -pipe -march=native -ftree-vectorize -Wall -c -o testcolor.o /var/tmp/portage/x11-libs/pango-1.42.4-r2/work/pango-1.42.4/tests/testcolor.c
x86_64-pc-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I/var/tmp/portage/x11-libs/pango-1.42.4-r2/work/pango-1.42.4/tests -I..  -DSRCDIR=\"/var/tmp/portage/x11-libs/pango-1.42.4-r2/work/pango-1.42.4/tests\" -I/var/tmp/portage/x11-libs/pango-1.42.4-r2/work/pango-1.42.4 -DG_DISABLE_CAST_CHECKS -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/lib64/libffi-3.3_rc0/include -pthread  -I/usr/include/freetype2 -I/usr/include/uuid   -I/usr/include/freetype2   -DHAVE_X -DHAVE_XFT -DHAVE_FREETYPE    -O2 -pipe -march=native -ftree-vectorize -Wall -c -o testscript.o /var/tmp/portage/x11-libs/pango-1.42.4-r2/work/pango-1.42.4/tests/testscript.c
x86_64-pc-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I/var/tmp/portage/x11-libs/pango-1.42.4-r2/work/pango-1.42.4/tests -I..  -DSRCDIR=\"/var/tmp/portage/x11-libs/pango-1.42.4-r2/work/pango-1.42.4/tests\" -I/var/tmp/portage/x11-libs/pango-1.42.4-r2/work/pango-1.42.4 -DG_DISABLE_CAST_CHECKS -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/lib64/libffi-3.3_rc0/include -pthread  -I/usr/include/freetype2 -I/usr/include/uuid   -I/usr/include/freetype2   -DHAVE_X -DHAVE_XFT -DHAVE_FREETYPE    -O2 -pipe -march=native -ftree-vectorize -Wall -c -o markup-parse.o /var/tmp/portage/x11-libs/pango-1.42.4-r2/work/pango-1.42.4/tests/markup-parse.c
make[2]: *** No rule to make target '../pango/libpangocairo-1.0.la', needed by 'markup-parse'.  Stop.
make[2]: *** Waiting for unfinished jobs....
In file included from /var/tmp/portage/x11-libs/pango-1.42.4-r2/work/pango-1.42.4/tests/markup-parse.c:33:
/var/tmp/portage/x11-libs/pango-1.42.4-r2/work/pango-1.42.4/pango/pangocairo.h:26:10: fatal error: cairo.h: No such file or directory
   26 | #include <cairo.h>
      |          ^~~~~~~~~
compilation terminated.
make[2]: *** [Makefile:922: markup-parse.o] Error 1
make[2]: Leaving directory '/var/tmp/portage/x11-libs/pango-1.42.4-r2/work/pango-1.42.4-abi_x86_64.amd64/tests'
make[1]: *** [Makefile:574: all-recursive] Error 1
make[1]: Leaving directory '/var/tmp/portage/x11-libs/pango-1.42.4-r2/work/pango-1.42.4-abi_x86_64.amd64'
make: *** [Makefile:473: all] Error 2
Comment 38 Aidan Harris 2019-09-29 17:23:24 UTC
Marek, I think you might be seeing https://bugs.gentoo.org/645540

The only thing that could be a libglvnd issue here is:

> Package 'gl', required by 'cairo', not found

This is probably a red-herring though. I've just unmasked libglvnd in my profile and so far nothing has exploded (it actually fixed a couple of issues I was having so thank you to everyone that's worked on this).
Comment 39 Marek Bartosiewicz 2019-09-29 18:07:31 UTC
(In reply to Aidan Harris from comment #38)
> Marek, I think you might be seeing https://bugs.gentoo.org/645540
> 

Ah, thanks, I wasn't aware of that bug report. I'll try to reemerge those packages.
Comment 40 Marek Bartosiewicz 2019-09-30 05:31:32 UTC
Seems that I do have an ongoing problem with my system, namely I see the

Package 'gl', required by 'cairo', not found

failure on some more packages now. I tried to rebuild @world during the night and as of now, packages that failed are:

vte
gobject-introspection
librsvg
harfbuzz

and of course pango.

I'm at ~300 package out of 933 packages, will try to --resume --skipfirst.
Comment 41 Marek Bartosiewicz 2019-09-30 09:27:33 UTC
Yes!

Failing packages started emerging again during emerge -e @world:

completed emerge (2 of 105) media-libs/harfbuzz-2.6.1
completed emerge (4 of 105) x11-libs/pango-1.42.4-r2
completed emerge (5 of 105) dev-cpp/pangomm-2.42.0
completed emerge (9 of 105) x11-wm/i3-gaps-4.17.1

I suspect that reemerging those helped:
completed emerge (4 of 132) dev-util/vulkan-headers-1.1.114
completed emerge (19 of 132) media-libs/vulkan-layers-1.1.106

and of course other dependencies.
Comment 42 Rick Harris 2019-10-14 08:36:35 UTC
As per comment #17 media-libs/mesa[libglvnd] breaks media-video/mpv.

This is because the egl.pc file provided by media-libs/mesa vs. the egl.pc file provided by media-libs/libglvnd differ wildly.

For media-video/mpv it's just the 'Version:' string, but for other compiles it may well fail missing 'Requires' and 'Libs'.

== media-libs/mesa egl.pc ==
prefix=/usr
libdir=${prefix}/lib
includedir=${prefix}/include

Name: egl
Description: Mesa EGL Library
Version: 19.2.1
Requires.private: x11, xext, xdamage >=  1.1, xfixes, x11-xcb, xcb, xcb-glx >=  1.8.1, xcb-dri2 >=  1.8, xxf86vm, libdrm >=  2.4.75
Libs: -L${libdir} -lEGL
Libs.private: -lpthread -pthread -lm -ldl
Cflags: -I${includedir}



== media-libs/libglvnd egl.pc ==
prefix=/usr
exec_prefix=${prefix}
libdir=/usr/lib64
includedir=${prefix}/include

Name: egl
Description: EGL library and headers
Version: 1.5
Libs: -L${libdir} -lEGL
Cflags: -I${includedir}
Comment 43 Miroslaw Mieszczak 2019-10-18 10:52:02 UTC
There is same thing for other programs. For example tigervnc is depend on gl.pc provided by libglvnd or mesa.
It require version >=9.2, while libglvnd provide version 1.2.
Comment 44 Alexander Tsoy 2019-10-18 12:04:49 UTC
(In reply to Rick Harris from comment #42)
> As per comment #17 media-libs/mesa[libglvnd] breaks media-video/mpv.
Comment #17 was a different issue. But AFAIS mpv with USE="opengl wayland" would indeed fail to build (according to wscript):

        'name': '--gl-wayland',
        'desc': 'OpenGL Wayland Backend',
        'deps': 'wayland',
        'groups': [ 'gl' ],
        'func': check_pkg_config('wayland-egl', '>= 9.0.0',
                                 'egl',         '>= 9.0.0')

Please open a separate bug report if you can reproduce this build failure. I don't have wayland on any of my system yet.
Comment 45 Rick Harris 2019-10-29 16:08:50 UTC
(In reply to Alexander Tsoy from comment #44)
> (In reply to Rick Harris from comment #42)
> > As per comment #17 media-libs/mesa[libglvnd] breaks media-video/mpv.
> Comment #17 was a different issue. But AFAIS mpv with USE="opengl wayland"
> would indeed fail to build (according to wscript):
> 
>         'name': '--gl-wayland',
>         'desc': 'OpenGL Wayland Backend',
>         'deps': 'wayland',
>         'groups': [ 'gl' ],
>         'func': check_pkg_config('wayland-egl', '>= 9.0.0',
>                                  'egl',         '>= 9.0.0')
> 
> Please open a separate bug report if you can reproduce this build failure. I
> don't have wayland on any of my system yet.

Issue was fixed by /usr/portage/media-video/mpv/files/mpv-0.29.1-egl-bound.patch to use lower egl.pc version provided by libglvnd.

But we now have a new bug introduced by upstream mesa-19.2.2 and libglvnd-1.2.0 that causes xorg-server build failure as seen here in the comments -> https://aur.archlinux.org/packages/xorg-server-git/
Comment 46 Rick Harris 2019-10-29 16:47:34 UTC
Can confirm applying the patches for xorg-server and libglvnd listed at https://gitlab.freedesktop.org/xorg/xserver/issues/914 fix the issue.
Comment 47 Rick Harris 2019-11-01 23:58:47 UTC
media-video/vlc-3.0.8*[vaapi] fails to build with libglvnd needs following patch backported from master https://github.com/videolan/vlc/commit/995dfaf01b2a50f292f9c709845aa66e78444af5
Comment 48 Marek Bartosiewicz 2019-11-04 07:34:11 UTC
Hi, I'm not sure where to report this.
After libglvnd unmasking and recent removal of glamor USE flag I can't reemerge xorg-server, it fails with:

/bin/sh ../libtool  --tag=CC   --mode=compile x86_64-pc-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I../include    -Wall -Wpointer-arith -Wmissing-declarations -Wformat=2 -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wbad-function-cast -Wold-style-definition -Wdeclaration-after-statement -Wunused -Wuninitialized -Wshadow -Wmissing-noreturn -Wmissing-format-attribute -Wredundant-decls -Wlogical-op -Wimplicit -Wnonnull -Winit-self -Wmain -Wmissing-braces -Wsequence-point -Wreturn-type -Wtrigraphs -Warray-bounds -Wwrite-strings -Waddress -Wint-to-pointer-cast -Wpointer-to-int-cast -fno-strict-aliasing -DHAVE_DIX_CONFIG_H -Wall -Wpointer-arith -Wmissing-declarations -Wformat=2 -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wbad-function-cast -Wold-style-definition -Wdeclaration-after-statement -Wunused -Wuninitialized -Wshadow -Wmissing-noreturn -Wmissing-format-attribute -Wredundant-decls -Wlogical-op -Wimplicit -Wnonnull -Winit-self -Wmain -Wmissing-braces -Wsequence-point -Wreturn-type -Wtrigraphs -Warray-bounds -Wwrite-strings -Waddress -Wint-to-pointer-cast -Wpointer-to-int-cast -fno-strict-aliasing -fno-strict-aliasing -D_DEFAULT_SOURCE -D_BSD_SOURCE -DHAS_FCHOWN -DHAS_STICKY_DIR_BIT -I/usr/include/pixman-1 -I/usr/include/X11/dri -I/usr/include/libdrm -I/usr/include/freetype2  -I../include -I../include -I../Xext -I../composite -I../damageext -I../xfixes -I../Xi -I../mi -I../miext/sync -I../miext/shadow  -I../miext/damage -I../render -I../randr -I../fb -I../dbe -I../present -fvisibility=hidden  -O2 -pipe -march=native -ftree-vectorize -pthread -c -o glamor_lines.lo glamor_lines.c
In file included from /usr/include/EGL/eglplatform.h:122,
                 from /usr/include/epoxy/egl_generated.h:11,
                 from /usr/include/epoxy/egl.h:46,
                 from glamor_priv.h:43,
                 from glamor.c:37:
/usr/include/X11/Xlib.h:222:2: error: conflicting types for ‘GC’
  222 | *GC;
      |  ^~
In file included from glamor.h:34,
                 from glamor_priv.h:32,
                 from glamor.c:37:
../include/gcstruct.h:282:3: note: previous declaration of ‘GC’ was here
  282 | } GC;
      |   ^~
In file included from /usr/include/EGL/eglplatform.h:122,
                 from /usr/include/epoxy/egl_generated.h:11,
                 from /usr/include/epoxy/egl.h:46,
                 from glamor_priv.h:43,
                 from glamor_core.c:36:
/usr/include/X11/Xlib.h:222:2: error: conflicting types for ‘GC’
  222 | *GC;
      |  ^~
In file included from glamor.h:34,
                 from glamor_priv.h:32,
                 from glamor_core.c:36:
../include/gcstruct.h:282:3: note: previous declaration of ‘GC’ was here
  282 | } GC;
      |   ^~
In file included from /usr/include/EGL/eglplatform.h:122,
                 from /usr/include/epoxy/egl_generated.h:11,
                 from /usr/include/epoxy/egl.h:46,
                 from glamor_priv.h:43,
                 from glamor_composite_glyphs.c:25:
/usr/include/X11/Xlib.h:222:2: error: conflicting types for ‘GC’
  222 | *GC;
      |  ^~
In file included from glamor.h:34,
                 from glamor_priv.h:32,
                 from glamor_composite_glyphs.c:25:
../include/gcstruct.h:282:3: note: previous declaration of ‘GC’ was here
  282 | } GC;
      |   ^~
In file included from /usr/include/EGL/eglplatform.h:122,
                 from /usr/include/epoxy/egl_generated.h:11,
                 from /usr/include/epoxy/egl.h:46,
                 from glamor_priv.h:43,
                 from glamor_font.c:23:
/usr/include/X11/Xlib.h:222:2: error: conflicting types for ‘GC’
  222 | *GC;
      |  ^~
In file included from glamor.h:34,
                 from glamor_priv.h:32,
                 from glamor_font.c:23:
../include/gcstruct.h:282:3: note: previous declaration of ‘GC’ was here
  282 | } GC;
      |   ^~
In file included from /usr/include/EGL/eglplatform.h:122,
                 from /usr/include/epoxy/egl_generated.h:11,
                 from /usr/include/epoxy/egl.h:46,
                 from glamor_priv.h:43,
                 from glamor_copy.c:23:
/usr/include/X11/Xlib.h:222:2: error: conflicting types for ‘GC’
  222 | *GC;
      |  ^~
In file included from glamor.h:34,
                 from glamor_priv.h:32,
                 from glamor_copy.c:23:
../include/gcstruct.h:282:3: note: previous declaration of ‘GC’ was here
  282 | } GC;
      |   ^~
In file included from /usr/include/EGL/eglplatform.h:122,
                 from /usr/include/epoxy/egl_generated.h:11,
                 from /usr/include/epoxy/egl.h:46,
                 from glamor_priv.h:43,
                 from glamor_image.c:23:
/usr/include/X11/Xlib.h:222:2: error: conflicting types for ‘GC’
  222 | *GC;
      |  ^~
In file included from glamor.h:34,
                 from glamor_priv.h:32,
                 from glamor_image.c:23:
../include/gcstruct.h:282:3: note: previous declaration of ‘GC’ was here
  282 | } GC;
      |   ^~
make[1]: *** [Makefile:767: glamor_core.lo] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [Makefile:767: glamor.lo] Error 1
In file included from /usr/include/EGL/eglplatform.h:122,
                 from /usr/include/epoxy/egl_generated.h:11,
                 from /usr/include/epoxy/egl.h:46,
                 from glamor_priv.h:43,
                 from glamor_dash.c:23:
/usr/include/X11/Xlib.h:222:2: error: conflicting types for ‘GC’
  222 | *GC;
      |  ^~
In file included from glamor.h:34,
                 from glamor_priv.h:32,
                 from glamor_dash.c:23:
../include/gcstruct.h:282:3: note: previous declaration of ‘GC’ was here
  282 | } GC;
      |   ^~
make[1]: *** [Makefile:767: glamor_composite_glyphs.lo] Error 1
make[1]: *** [Makefile:767: glamor_font.lo] Error 1
make[1]: *** [Makefile:767: glamor_copy.lo] Error 1
make[1]: *** [Makefile:767: glamor_image.lo] Error 1
make[1]: *** [Makefile:767: glamor_dash.lo] Error 1
libtool: compile:  x86_64-pc-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I../include -Wall -Wpointer-arith -Wmissing-declarations -Wformat=2 -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wbad-function-cast -Wold-style-definition -Wdeclaration-after-statement -Wunused -Wuninitialized -Wshadow -Wmissing-noreturn -Wmissing-format-attribute -Wredundant-decls -Wlogical-op -Wimplicit -Wnonnull -Winit-self -Wmain -Wmissing-braces -Wsequence-point -Wreturn-type -Wtrigraphs -Warray-bounds -Wwrite-strings -Waddress -Wint-to-pointer-cast -Wpointer-to-int-cast -fno-strict-aliasing -DHAVE_DIX_CONFIG_H -Wall -Wpointer-arith -Wmissing-declarations -Wformat=2 -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wbad-function-cast -Wold-style-definition -Wdeclaration-after-statement -Wunused -Wuninitialized -Wshadow -Wmissing-noreturn -Wmissing-format-attribute -Wredundant-decls -Wlogical-op -Wimplicit -Wnonnull -Winit-self -Wmain -Wmissing-braces -Wsequence-point -Wreturn-type -Wtrigraphs -Warray-bounds -Wwrite-strings -Waddress -Wint-to-pointer-cast -Wpointer-to-int-cast -fno-strict-aliasing -fno-strict-aliasing -D_DEFAULT_SOURCE -D_BSD_SOURCE -DHAS_FCHOWN -DHAS_STICKY_DIR_BIT -I/usr/include/pixman-1 -I/usr/include/X11/dri -I/usr/include/libdrm -I/usr/include/freetype2 -I../include -I../include -I../Xext -I../composite -I../damageext -I../xfixes -I../Xi -I../mi -I../miext/sync -I../miext/shadow -I../miext/damage -I../render -I../randr -I../fb -I../dbe -I../present -fvisibility=hidden -O2 -pipe -march=native -ftree-vectorize -pthread -c glamor_lines.c  -fPIC -DPIC -o .libs/glamor_lines.o
In file included from /usr/include/EGL/eglplatform.h:122,
                 from /usr/include/epoxy/egl_generated.h:11,
                 from /usr/include/epoxy/egl.h:46,
                 from glamor_priv.h:43,
                 from glamor_lines.c:23:
/usr/include/X11/Xlib.h:222:2: error: conflicting types for ‘GC’
  222 | *GC;
      |  ^~
In file included from glamor.h:34,
                 from glamor_priv.h:32,
                 from glamor_lines.c:23:
../include/gcstruct.h:282:3: note: previous declaration of ‘GC’ was here
  282 | } GC;
      |   ^~
make[1]: *** [Makefile:767: glamor_lines.lo] Error 1
make[1]: Leaving directory '/var/tmp/portage/x11-base/xorg-server-1.20.5/work/xorg-server-1.20.5/glamor'
make: *** [Makefile:816: all-recursive] Error 1
 * ERROR: x11-base/xorg-server-1.20.5::gentoo failed (compile phase):
 *   emake failed

Is this relevant?

https://gitlab.freedesktop.org/xorg/xserver/issues/914
Comment 49 Marek Bartosiewicz 2019-11-04 10:25:24 UTC
Patches from https://gitlab.freedesktop.org/xorg/xserver/issues/914 helped :)
Comment 50 Pablo Cholaky 2019-11-11 05:46:25 UTC
(In reply to Marek Bartosiewicz from comment #49)
> Patches from https://gitlab.freedesktop.org/xorg/xserver/issues/914 helped :)

I guess you meant patches for libglvnd and xorg-server.

After those patches, did libglvnd worked for you? I mean, trying to use your secondary videocard?
Comment 51 Marek Bartosiewicz 2019-11-11 06:47:25 UTC
Yes, you need to patch both of them, and yes, Nvidia prime offload still worls OK for me.
Comment 52 J. Roeleveld 2019-11-12 16:58:42 UTC
Could you please list which patches need to go where to make this work?

Many thanks,

Joost
Comment 53 Alexander Tsoy 2019-11-12 17:15:43 UTC
(In reply to J. Roeleveld from comment #52)
> Could you please list which patches need to go where to make this work?
xorg-server (1.20*):
https://gitlab.freedesktop.org/xorg/xserver/commit/642c1f83b9ed2452ceb20457a4423a8f52a7a8c4.patch

libglvnd (I think only the last patch is really needed, and according to discussion in MR it will not be merged as is):
https://gitlab.freedesktop.org/glvnd/libglvnd/commit/6f52473dac08c44b081b792874b4ce73122096da.patch
https://gitlab.freedesktop.org/glvnd/libglvnd/commit/51233cc52cbcbe25f8461830913c06f5b5bc9508.patch
https://gitlab.freedesktop.org/glvnd/libglvnd/merge_requests/193.patch
Comment 54 Marek Bartosiewicz 2019-11-12 18:03:39 UTC
Yeah, exactly.
I used /etc/portage/patches/ functionality and put those in media-libs/ x11-base/ subdirectories.
Comment 55 Marek Bartosiewicz 2019-11-12 18:06:13 UTC
For Nvidia Optimus / Prime offload you need:

ls -la /etc/portage/patches/x11-base/xorg-server-1.20.5/

drwxr-xr-x 1 root root   682 11-04 09:43 .
drwxr-xr-x 1 root root    36 09-19 10:17 ..
-rw-r--r-- 1 root root   961 11-04 09:36 0001-meson-bump-gl-1.2.patch
-rw-r--r-- 1 root root  2339 11-04 09:37 0001-replace-MESA_EGL_NO_X11_HEADERS-hack-with-upstream-E.patch
-rw-r--r-- 1 root root 11183 09-10 11:21 xorg-server-1.21-autobind-gpu.patch
-rw-r--r-- 1 root root  8425 09-10 11:21 xorg-server-1.21-multigpu-00-7f962c70.patch
-rw-r--r-- 1 root root  2868 09-10 11:21 xorg-server-1.21-multigpu-01-37a36a6b.patch
-rw-r--r-- 1 root root  3746 09-10 11:21 xorg-server-1.21-multigpu-02-8b67ec7c.patch
-rw-r--r-- 1 root root  3859 09-10 11:21 xorg-server-1.21-multigpu-03-56c0a71f.patch
-rw-r--r-- 1 root root  1064 09-10 11:21 xorg-server-1.21-multigpu-04-b4231d69.patch

and

ls -la /etc/portage/patches/media-libs/libglvnd/

drwxr-xr-x 1 root root  202 11-04 11:13 .
drwxr-xr-x 1 root root   16 11-04 11:12 ..
-rw-r--r-- 1 root root 2780 11-04 11:13 193.patch
-rw-r--r-- 1 root root 2485 11-04 11:13 51233cc52cbcbe25f8461830913c06f5b5bc9508.patch
-rw-r--r-- 1 root root  770 11-04 11:13 6f52473dac08c44b081b792874b4ce73122096da.patch