Skip to content

libGL: use headers from glvnd#118479

Merged
gebner merged 28 commits intoNixOS:stagingfrom
gebner:glvndheaders
Apr 9, 2021
Merged

libGL: use headers from glvnd#118479
gebner merged 28 commits intoNixOS:stagingfrom
gebner:glvndheaders

Conversation

@gebner
Copy link
Copy Markdown
Member

@gebner gebner commented Apr 4, 2021

Motivation for this change

Currently, libGL depends on the dev output of mesa, which in turn depends on the mesa drivers. This e.g. causes many programs to include all mesa drivers in their closure: #118410

This PR changes the libGL stub to use the GL headers from libglvnd instead, thus removing the mesa build dependency.
See also #44831 and #100712 (this does not completely solve the mesa issue, since some packages still need to depend on mesa directly)

I've quickly built and tested a few packages and could not find any regressions: alacritty, blender, chromium (still references mesa though), mpv (also references mesa)
Suggestions for other packages to test are welcome (i.e., what do you expect to break).

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@gebner gebner added the 6.topic: closure size The final size of a derivation, including its dependencies label Apr 4, 2021
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. labels Apr 4, 2021
@gebner
Copy link
Copy Markdown
Member Author

gebner commented Apr 4, 2021

Mmmh, gtk3 no longer builds after rebasing to staging..

@ofborg ofborg bot requested review from Ma27, Synthetica9 and primeos April 4, 2021 16:58
@ofborg ofborg bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. and removed 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. labels Apr 4, 2021
@gebner
Copy link
Copy Markdown
Member Author

gebner commented Apr 4, 2021

There's quite a few packages that depend on mesa because require libgbm. This is still a bit of a problem because mesa.dev still depends on the mesa drivers. Maybe it would be good to extract libgbm to a separate derivation, or make extra outputs for gbm and gbmdev.

EDIT: this has been fixed in the meantime. mesa.dev no longer depends on mesa.drivers.

@r-rmcgibbo
Copy link
Copy Markdown

Result of nixpkgs-review pr 118479 at d0a5ac03 run on x86_64-linux 1

663 packages marked as broken and skipped:
  • adobe-reader
  • adoptopenjdk-hotspot-bin-13
  • adoptopenjdk-hotspot-bin-14
  • adoptopenjdk-jre-hotspot-bin-13
  • adoptopenjdk-jre-hotspot-bin-14
  • adoptopenjdk-jre-openj9-bin-13
  • adoptopenjdk-jre-openj9-bin-14
  • adoptopenjdk-openj9-bin-13
  • adoptopenjdk-openj9-bin-14
  • agdaPackages.iowa-stdlib
  • ...
2 packages failed to build:
8248 packages skipped due to time constraints:
  • AusweisApp2
  • DisnixWebService
  • EmptyEpsilon
  • Fabric (python38Packages.Fabric)
  • MIDIVisualizer
  • OSCAR
  • R
  • SDL
  • SDL2
  • SDL2_gfx
  • ...
82 packages built successfully:
  • adoptopenjdk-bin (adoptopenjdk-hotspot-bin-11 ,openjdk11-bootstrap)
  • openjdk8-bootstrap (adoptopenjdk-hotspot-bin-8)
  • asciidoctor
  • at-spi2-atk
  • at-spi2-core
  • atk (gnome2.atk ,gnome3.atk)
  • cairo (gnome2.cairo)
  • cargo
  • epoxy
  • freeoffice
  • gdk-pixbuf
  • git
  • glpng
  • libsoup (gnome2.libsoup)
  • pango (gnome2.pango)
  • gnome3.gnome-session-ctl
  • gobject-introspection (gnome3.gobject-introspection)
  • gsettings-desktop-schemas (gnome3.gsettings-desktop-schemas)
  • gtk3 (gnome3.gtk ,gtk3-x11)
  • libgudev (gnome3.libgudev)
  • librsvg (gnome3.librsvg)
  • tracker (gnome3.tracker)
  • harfbuzz
  • hipchat
  • iconnamingutils
  • json-glib
  • kisslicer
  • lasem
  • libGL
  • libGLU (mesa_glu)
  • libass
  • libdevil
  • libinput
  • libmanette
  • libnotify
  • libqrtr-glib
  • libva
  • libwacom
  • openconnect (openconnect_gnutls)
  • python38Packages.GitPython
  • python38Packages.aiohttp
  • python38Packages.aiohttp-cors
  • python38Packages.arrow
  • python38Packages.brotlipy
  • python38Packages.construct
  • python38Packages.cryptography
  • python38Packages.dateparser
  • python38Packages.dbus-python
  • python38Packages.jeepney
  • python38Packages.keyring
  • python38Packages.oauthlib
  • python38Packages.poetry
  • python38Packages.pycairo
  • python38Packages.pyftpdlib
  • python38Packages.pygobject3
  • python38Packages.pyjwt
  • python38Packages.pyopenssl
  • python38Packages.requests-toolbelt (python38Packages.requests_toolbelt)
  • python38Packages.requests_oauthlib
  • python38Packages.secretstorage
  • python38Packages.service-identity
  • python38Packages.trio
  • python38Packages.trustme
  • python39Packages.GitPython
  • python39Packages.aiohttp
  • python39Packages.aiohttp-cors
  • python39Packages.arrow
  • python39Packages.brotlipy
  • python39Packages.construct
  • python39Packages.cryptography
  • python39Packages.dateparser
  • python39Packages.jeepney
  • python39Packages.pycairo
  • python39Packages.pyopenssl
  • python39Packages.secretstorage
  • python39Packages.service-identity
  • python39Packages.trio
  • python39Packages.trustme
  • scrolls
  • softmaker-office
  • stoken
  • wrapGAppsHook
11 suggestions:
  • warning: missing-patch-comment

    Please add a comment on the line above, explaining the purpose of this patch.
    Near pkgs/applications/window-managers/sway/default.nix:24:5:

       |
    24 |     (substituteAll {
       |     ^
    
  • warning: missing-patch-comment

    Please add a comment on the line above, explaining the purpose of this patch.
    Near pkgs/development/libraries/gtk/3.x.nix:83:5:

       |
    83 |     (fetchpatch {
       |     ^
    
  • warning: missing-patch-comment

    Please add a comment on the line above, explaining the purpose of this patch.
    Near pkgs/applications/window-managers/sway/default.nix:22:5:

       |
    22 |     ./load-configuration-from-etc.patch
       |     ^
    
  • warning: unused-argument

    Unused argument: gmp.
    Near pkgs/development/libraries/gtk/4.x.nix:32:3:

       |
    32 | , gmp
       |   ^
    
  • warning: unused-argument

    Unused argument: x11Support.
    Near pkgs/development/libraries/gtk/3.x.nix:37:3:

       |
    37 | , x11Support ? stdenv.isLinux
       |   ^
    
  • warning: license-missing

    Package is missing a license.

    Near pkgs/development/libraries/mesa/stubs.nix:14:3:

       |
    14 |   buildCommand = if stdenv.hostPlatform.isDarwin then ''
       |   ^
    
  • warning: missing-patch-comment

    Please add a comment on the line above, explaining the purpose of this patch.
    Near pkgs/development/libraries/gtk/3.x.nix:81:5:

       |
    81 |     ./patches/3.0-immodules.cache.patch
       |     ^
    
  • warning: missing-patch-comment

    Please add a comment on the line above, explaining the purpose of this patch.
    Near pkgs/applications/window-managers/sway/default.nix:21:5:

       |
    21 |     ./sway-config-no-nix-store-references.patch
       |     ^
    
  • warning: unused-argument

    Unused argument: gmp.
    Near pkgs/development/libraries/gtk/3.x.nix:31:3:

       |
    31 | , gmp
       |   ^
    
  • warning: unused-argument

    Unused argument: x11Support.
    Near pkgs/development/libraries/gtk/4.x.nix:39:3:

       |
    39 | , x11Support ? stdenv.isLinux
       |   ^
    
  • warning: maintainers-missing

    Package does not have a maintainer. Consider adding yourself?

    Near pkgs/development/libraries/mesa/stubs.nix:14:3:

       |
    14 |   buildCommand = if stdenv.hostPlatform.isDarwin then ''
       |   ^
    

Note that build failures may predate this PR, and could be nondeterministic or hardware dependent.
Please exercise your independent judgement.

@gebner gebner force-pushed the glvndheaders branch 2 times, most recently from b5b8632 to 0674348 Compare April 5, 2021 10:06
@gebner
Copy link
Copy Markdown
Member Author

gebner commented Apr 5, 2021

I've now also added a commit that breaks the dependency of mesa.dev on mesa.drivers. Packages that use libxatracker now need to depend on mesa.driversdev. (AFAICT this library is almost unused.)

Copy link
Copy Markdown
Member

@primeos primeos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall the diff and idea LGTM but I have trouble to properly review this in terms of (potential) breakages.

IMO the libGL and mesa commits should also have a description that explains the rationale, impact, etc. (like "Motivation for this change" for this PR) so that that information doesn't get lost (should be in the Git history too). Depending on how long this takes to review we could also merge (some of) the other commits independently or split them into a separate PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That self part looks a bit strange to me. IIRC it should also be possible to add mesa to the arguments and use:

Suggested change
disallowedRequisites = [ llvmPackages.llvm self.drivers ];
disallowedRequisites = [ llvmPackages.llvm mesa.drivers ];

Not sure what's better though...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case I think you need to be more careful with overriding, passing the overridden version in.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A dedicated output (driversdev) for just xatracker.pc seems a bit strange to me. The name of the output is a bit misleading, the actual xatracker headers are in the dev output (I assume), and this part is difficult to review as we don't know which packages this might break (without running a full nixpkgs-review).

Copy link
Copy Markdown
Member

@primeos primeos Apr 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the other part that's difficult to review. I haven't diffed mesa.dev and libglvnd.dev (yet) but if mesa.dev provides additional (or even just slightly different headers, e.g. due to older versions - wich seems very likely) this could potentially cause a lot of breakages (and due to the version change alone). Is there any official documentation for this and do we know what other distros do?

@primeos
Copy link
Copy Markdown
Member

primeos commented Apr 5, 2021

@vcunat what's your opinion on this?

There's quite a few packages that depend on mesa because require libgbm. This is still a bit of a problem because mesa.dev still depends on the mesa drivers. Maybe it would be good to extract libgbm to a separate derivation, or make extra outputs for gbm and gbmdev.

I was wondering about that too. Two additional Mesa outputs certainly have a cost in terms of complexity but then again a separate libgbm package would be nice. But in any case we should avoid adding that to this PR as things are already complicated enough (a dedicated issue(/PR) would IMO be nice though).

@gebner
Copy link
Copy Markdown
Member Author

gebner commented Apr 5, 2021

the libGL and mesa commits should also have a description that explains the rationale, impact, etc.

Ok, I'll add a rationale to the commit messages.

Depending on how long this takes to review we could also merge (some of) the other commits independently or split them into a separate PR.

I don't think there is any subset of this PR that can be reviewed more easily. Both the mesa and libglvnd changes affect every package that depends on opengl. The other commits just fix the resulting issues.

this part is difficult to review as we don't know which packages this might break (without running a full nixpkgs-review).

I'm happy for suggestions on how to better test this PR. Rebuilding almost all of nixpkgs locally is probably not feasible.

but if mesa.dev provides additional (or even just slightly different headers, e.g. due to older versions - wich seems very likely) this could potentially cause a lot of breakages (and due to the version change alone).

I would not expect any issues here. If you use the nonfree nvidia drivers, you also compile against different headers (i.e., compile against mesa and link against nvidia). That seems to work well.

Also note that we link applications against libglvnd, not mesa. Even if the mesa headers provided more functions, applications couldn't use them because they don't exist in the libglvnd library.

A dedicated output (driversdev) for just xatracker.pc seems a bit strange to me.

This was the easiest way to untangle the dependencies. The xatracker.pc file is the only one that contains references to both the dev output (because of the headers), and to the drivers output (because of the llvm dependency).

Would you prefer to move the xa_*.h and d3dadapter/* headers to the driversdev output as well?

@gebner gebner requested a review from ttuegel as a code owner April 5, 2021 16:44
@github-actions github-actions bot added the 6.topic: qt/kde Object-oriented framework for GUI creation label Apr 5, 2021
@ofborg ofborg bot added 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. and removed 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. labels Apr 5, 2021
@vcunat
Copy link
Copy Markdown
Member

vcunat commented Apr 5, 2021

First, defaulting to generic headers instead of mesa's was on my wishlist long ago already, so I do like that – at least in principle, but the risks didn't seem high at a glance. One advantage is that after that mesa will become relatively cheap to update normally (directly in nixpkgs master). E.g. on top of your current PR a mesa update does:

$ ./maintainers/scripts/rebuild-amount.sh HEAD
Estimating rebuild amount by counting changed Hydra jobs.
   1386 x86_64-darwin
    725 x86_64-linux

I'm happy for suggestions on how to better test this PR. Rebuilding almost all of nixpkgs locally is probably not feasible.

We can have a Hydra jobset for this branch. I can set it up myself when you think it's a good moment. I hope most issues would be visible as build failures.

This was the easiest way to untangle the dependencies. The xatracker.pc file is the only one that contains references to both the dev output (because of the headers), and to the drivers output (because of the llvm dependency).

I still feel like missing something here. Why do the packages retain (transitive) dependency to .drivers in case they don't need libxatracker? If a package keeps runtime reference to foo.dev, I'd typically consider it a mistake, though in some cases it may be hard to fix (/cc #118410).

@gebner
Copy link
Copy Markdown
Member Author

gebner commented Apr 5, 2021

If a package keeps runtime reference to foo.dev, I'd typically consider it a mistake, though in some cases it may be hard to fix (/cc #118410).

It's indeed a mistake, albeit a regular one: see #98755 for another recent case. You also need to dev output to compile C programs that use mesa as a dependency. It's nice if you don't have to download (unused) mesa drivers and a (second) copy of LLVM for that.

I can set it up myself when you think it's a good moment.

I'm not sure if we should also move the headers to the driversdev output (instead of just the pkg-config file). Aside from that, I'd say this is PR is ready.

@gebner
Copy link
Copy Markdown
Member Author

gebner commented Apr 8, 2021

@vcunat I've rebased the PR to staging and moved the corresponding headers to the driversdev output as well. I think it would be a good time for the hydra jobset now.

@vcunat
Copy link
Copy Markdown
Member

vcunat commented Apr 8, 2021

I hope it won't hit many issues that are regressions in master..staging; if so, we'd better "change base" for the purpose of testing. Here's the jobset: https://hydra.nixos.org/eval/1661526

@github-actions github-actions bot added the 6.topic: pantheon The Pantheon desktop environment label Apr 9, 2021
@gebner
Copy link
Copy Markdown
Member Author

gebner commented Apr 9, 2021

I've fixed all the new failures (compared to master) that seem to be mesa-related.

@gebner gebner merged commit a8aeef7 into NixOS:staging Apr 9, 2021
@jtojnar jtojnar mentioned this pull request Apr 12, 2021
10 tasks
vcunat added a commit that referenced this pull request Apr 21, 2021
vcunat added a commit that referenced this pull request Apr 21, 2021
It's probably fallout from PR #118479.  Whole `mate` builds for me now.
vcunat added a commit that referenced this pull request Apr 21, 2021
autoPatchelf wasn't finding some libraries anymore.
It was probably fallout from PR #118479.
@primeos primeos mentioned this pull request May 24, 2021
10 tasks
@primeos primeos mentioned this pull request Jun 18, 2021
11 tasks
@primeos primeos mentioned this pull request Nov 26, 2021
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: closure size The final size of a derivation, including its dependencies 6.topic: pantheon The Pantheon desktop environment 6.topic: qt/kde Object-oriented framework for GUI creation 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants