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

Bug 301337

Summary: virtual/opengl doesn't have to depend on media-libs/mesa
Product: Gentoo Linux Reporter: stshine <pu.stshine>
Component: Current packagesAssignee: Gentoo X packagers <x11>
Status: CONFIRMED ---    
Severity: enhancement CC: cardoe, chewi, dan, enrico.tagliavini, lu_zero, m.seifert
Priority: Low Keywords: PullRequest
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: https://github.com/gentoo/gentoo/pull/35556
https://bugs.gentoo.org/show_bug.cgi?id=890334
Whiteboard:
Package list:
Runtime testing required: ---

Description stshine 2010-01-18 06:32:05 UTC
When I try to emerge wine with 'opengl' USE flag, the dependency requires media-libs/mesa. But my video card is GT8600, and nvidia-drivers proved opengl toolkit by itself. So I copied /usr/include/GL/* header files from source package of mesa , and then USE="opengl" emerge -O wine, and everything works fine, so I don't have to install those libdrm thing. I hope there would be a ebuild like opengl-headers.

Reproducible: Always
Comment 1 Tomáš Chvátal (RETIRED) gentoo-dev 2010-01-21 17:52:11 UTC
That won't happen easily because those headers are quite fragile.

I am leaving it open if someone in X11 team have free time and will be willing to work on it.
Comment 2 Matt Turner gentoo-dev 2012-08-11 18:06:54 UTC
CC'd nvidia-drivers and ati-drivers maintainers, since this bug would benefit you.

It seems to me like proprietary drivers + OpenGL headers would satisfy this virtual, and would allow you to not have to have Mesa installed at all.

Maybe you guys are interested in working on this.
Comment 3 Doug Goldstein (RETIRED) gentoo-dev 2012-08-11 18:39:25 UTC
Its definitely something I would consider doing, the effort involved won't be a small task from a testing perspective.
Comment 4 Enrico Tagliavini 2012-08-14 15:01:06 UTC
Sorry guys I'm not more the ati-drivers maintainer, I sold my AMD powered laptop
Comment 5 Doug Goldstein (RETIRED) gentoo-dev 2012-11-19 00:57:59 UTC
So the rough idea is this:

Add media-libs/khronos-headers which has copies of the Khronos headers.
Add virtual/opengl-headers which has: DEPEND="|| ( media-libs/mesa media-libs/khronos-headers )"
Change virtual/opengl to have RDEPEND="|| ( media-libs/mesa media-libs/opengl-apple x11-drivers/nvidia-drivers x11-drivers/ati-drivers )"

Some options are to not add opengl-headers and instead have virtual/opengl:

RDEPEND="|| (
    media-libs/mesa
    media-libs/opengl-apple
    ( media-libs/khronos-headers
      || (
         x11-drivers/nvidia-drivers
         x11-drivers/ati-drivers
      )
    )"


I'd also like to get rid of the headers that eselect-opengl provides, glext.h and glxext.h and let mesa install its own and let khronos-headers install them as well.
Comment 6 Matt Turner gentoo-dev 2013-01-01 19:30:38 UTC
(In reply to comment #5)
> So the rough idea is this:
> 
> Add media-libs/khronos-headers which has copies of the Khronos headers.
> Add virtual/opengl-headers which has: DEPEND="|| ( media-libs/mesa
> media-libs/khronos-headers )"
> Change virtual/opengl to have RDEPEND="|| ( media-libs/mesa
> media-libs/opengl-apple x11-drivers/nvidia-drivers x11-drivers/ati-drivers )"
> 
> Some options are to not add opengl-headers and instead have virtual/opengl:
> 
> RDEPEND="|| (
>     media-libs/mesa
>     media-libs/opengl-apple
>     ( media-libs/khronos-headers
>       || (
>          x11-drivers/nvidia-drivers
>          x11-drivers/ati-drivers
>       )
>     )"
> 
> 
> I'd also like to get rid of the headers that eselect-opengl provides,
> glext.h and glxext.h and let mesa install its own and let khronos-headers
> install them as well.

Sounds good. Go for it! :)
Comment 7 stshine 2013-04-28 09:59:16 UTC
(In reply to comment #5)
> So the rough idea is this:
> 
> Add media-libs/khronos-headers which has copies of the Khronos headers.
> Add virtual/opengl-headers which has: DEPEND="|| ( media-libs/mesa
> media-libs/khronos-headers )"
> Change virtual/opengl to have RDEPEND="|| ( media-libs/mesa
> media-libs/opengl-apple x11-drivers/nvidia-drivers x11-drivers/ati-drivers )"
> 
> Some options are to not add opengl-headers and instead have virtual/opengl:
> 
> RDEPEND="|| (
>     media-libs/mesa
>     media-libs/opengl-apple
>     ( media-libs/khronos-headers
>       || (
>          x11-drivers/nvidia-drivers
>          x11-drivers/ati-drivers
>       )
>     )"
> 
> 
> I'd also like to get rid of the headers that eselect-opengl provides,
> glext.h and glxext.h and let mesa install its own and let khronos-headers
> install them as well.

Hi,I made a little study and found that both NVIDIA's and AMD's offered these opengl headers (gl.h, glext.h, glx.h, glxext.h) by themselves.
Hope If this would be useful.
Comment 8 Michael Seifert 2014-09-22 09:07:03 UTC
(In reply to Doug Goldstein from comment #5)
> So the rough idea is this:
> 
> Add media-libs/khronos-headers which has copies of the Khronos headers.
> Add virtual/opengl-headers which has: DEPEND="|| ( media-libs/mesa
> media-libs/khronos-headers )"
> Change virtual/opengl to have RDEPEND="|| ( media-libs/mesa
> media-libs/opengl-apple x11-drivers/nvidia-drivers x11-drivers/ati-drivers )"
> 
> Some options are to not add opengl-headers and instead have virtual/opengl:
> 
> RDEPEND="|| (
>     media-libs/mesa
>     media-libs/opengl-apple
>     ( media-libs/khronos-headers
>       || (
>          x11-drivers/nvidia-drivers
>          x11-drivers/ati-drivers
>       )
>     )"
> 
> 
> I'd also like to get rid of the headers that eselect-opengl provides,
> glext.h and glxext.h and let mesa install its own and let khronos-headers
> install them as well.

I'd rather go for the separate virtual/opengl-headers ebuild. It is the cleaner solution and more in line with other packages, such as sys-kernel/linux-headers.

Why is it necessary to add media-libs/khronos-headers? Shouldn't virtual/opengl-headers simply depend on all ebuilds that provide the needed headers?

Cross-compile environments would also benefit from this change: Whenever an ebuild depends on virtual/opengl, the package currently tries to pull mesa and x11-libs, which might not be available for the compile target (e.g. Windows).
By the way, dev-util/mingw64-runtime-3.2.0-r1 also provides the OpenGL headers.
Comment 9 om3i 2015-12-04 07:51:58 UTC
If anyone interested, minimum files needed from mesa for opengl on nvidia-drivers:

/usr/include/GL/gl.h
/usr/include/GL/glext.h
/usr/include/GL/glcorearb.h

/usr/include/GL/glx.h
/usr/include/GL/glxext.h

/usr/include/GL/internal/dri_interface.h

/usr/lib64/pkgconfig/dri.pc
/usr/lib64/pkgconfig/gl.pc

/usr/lib64/libGL.so -> /usr/lib64/opengl/nvidia/lib/libGL.so
/usr/lib64/libGL.so.1 -> /usr/lib64/opengl/nvidia/lib/libGL.so.1
Comment 10 Matt Turner gentoo-dev 2020-08-12 04:05:31 UTC
Now that USE=libglvnd is use.force'd, this is probably trivial to accomplish.

The only concern that comes to mind is whether users might need to add media-libs/mesa to @world in order to keep it installed. Not a big issue though.
Comment 11 Maciej Mrozowski gentoo-dev 2020-10-14 00:22:20 UTC
So, what's the approach?
Can we just replace mesa with libglvnd in virtual/opengl?
Comment 12 Matt Turner gentoo-dev 2020-10-14 01:03:51 UTC
(In reply to Maciej Mrozowski from comment #11)
> So, what's the approach?
> Can we just replace mesa with libglvnd in virtual/opengl?

Someone should give it a try and see what breaks. Then after they've fixed the breakage they should make a pull request.
Comment 13 Bug Bugs 2020-12-13 04:17:11 UTC
I guess GL/internal/dri_interface.h includes should be replaced with "local" includes for packages which uses them, e.g. x11-base/xorg-server:
glx/glxdricommon.c
glx/glxdriswrast.c
glx/glxdri2.c

(should be safe to copy dri_interface.h from mesa into include/ )

Also, pkgconfig/dri.pc should be provided by an different package, but I'm not sure should it be media-libs/libglvnd.

AFAIKT pretty much everything else in my system compiles and work fine w/o media-libs/mesa.
Comment 14 Bug Bugs 2021-02-02 17:27:24 UTC
Unfortunately some out-of-tree apps wants libgbm.so (Electron for example). The only provider in Gentoo is mesa, while libgbm usually a separate package in other distros.

I managed to build mesa with only "gbm" flag enabled and using hack. I also got missing parts with it:
$ equery f mesa
 * Searching for mesa ...
 * Contents of media-libs/mesa-21.0.0_rc3:
/usr
/usr/include
/usr/include/GL
/usr/include/GL/internal
/usr/include/GL/internal/dri_interface.h
/usr/include/gbm.h
/usr/lib
/usr/lib/libgbm.so -> libgbm.so.1
/usr/lib/libgbm.so.1 -> libgbm.so.1.0.0
/usr/lib/libgbm.so.1.0.0
/usr/lib/pkgconfig
/usr/lib/pkgconfig/dri.pc
/usr/lib/pkgconfig/gbm.pc
/usr/lib64
/usr/lib64/libgbm.so -> libgbm.so.1
/usr/lib64/libgbm.so.1 -> libgbm.so.1.0.0
/usr/lib64/libgbm.so.1.0.0
/usr/lib64/pkgconfig
/usr/lib64/pkgconfig/dri.pc
/usr/lib64/pkgconfig/gbm.pc
/usr/share
/usr/share/doc
/usr/share/doc/mesa-21.0.0_rc3
/usr/share/doc/mesa-21.0.0_rc3/README.rst.bz2
/usr/share/drirc.d
/usr/share/drirc.d/00-mesa-defaults.conf

The hack (because mesa disables dri backend when no drivers asked, and then failing to link):
$ cat /etc/portage/patches/media-libs/mesa/build-gbm-only.patch 
--- a/meson.build
+++ b/meson.build
@@ -176,6 +176,8 @@ if dri_drivers.contains('auto')
     error('Unknown OS @0@. Please pass -Ddri-drivers to set driver options. Patches gladly accepted to fix this.'.format(
           host_machine.system()))
   endif
+else
+  dri_drivers = ['nvidia']
 endif
 
 with_dri_i915 = dri_drivers.contains('i915')


Similar bug already filed: #760546

Maybe makes sense to provide separate libgbm package and replace all media-libs/mesa[gbm] dependencies with it? Then media-libs/mesa[egl] with media-libs/libglvnd and we'll be fine.
Comment 15 Matt Turner gentoo-dev 2021-02-02 18:55:20 UTC
> Maybe makes sense to provide separate libgbm package and replace all media-libs/mesa[gbm] dependencies with it? Then media-libs/mesa[egl] with media-libs/libglvnd and we'll be fine.

That sounds like the wrong solution, especially for out-of-tree packages. Just depend on mesa[gbm]. virtual/opengl isn't there to provide libgbm.