about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/mesa/default.nix
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2024-02-26 16:20:28 +0100
committerAlyssa Ross <hi@alyssa.is>2024-02-26 16:20:28 +0100
commit647438344bfc1f77791391e2b4f98eef865c63dc (patch)
treeef580867fc6cc413940e4330d939cf1afda082cb /nixpkgs/pkgs/development/libraries/mesa/default.nix
parentb084c6a0fab7f32c904c5c8e8db8dddcefbe507f (diff)
parente3474e1d1e53b70e2b2af73ea26d6340e82f6b8b (diff)
downloadnixlib-647438344bfc1f77791391e2b4f98eef865c63dc.tar
nixlib-647438344bfc1f77791391e2b4f98eef865c63dc.tar.gz
nixlib-647438344bfc1f77791391e2b4f98eef865c63dc.tar.bz2
nixlib-647438344bfc1f77791391e2b4f98eef865c63dc.tar.lz
nixlib-647438344bfc1f77791391e2b4f98eef865c63dc.tar.xz
nixlib-647438344bfc1f77791391e2b4f98eef865c63dc.tar.zst
nixlib-647438344bfc1f77791391e2b4f98eef865c63dc.zip
Merge commit 'e3474e1d1e53'
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/mesa/default.nix')
-rw-r--r--nixpkgs/pkgs/development/libraries/mesa/default.nix93
1 files changed, 57 insertions, 36 deletions
diff --git a/nixpkgs/pkgs/development/libraries/mesa/default.nix b/nixpkgs/pkgs/development/libraries/mesa/default.nix
index 38b73f56cab6..dff2f0021d46 100644
--- a/nixpkgs/pkgs/development/libraries/mesa/default.nix
+++ b/nixpkgs/pkgs/development/libraries/mesa/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, lib, fetchurl, fetchpatch, buildPackages
+{ stdenv, lib, fetchurl, fetchpatch, fetchCrate, buildPackages
 , meson, pkg-config, ninja
 , intltool, bison, flex, file, python3Packages, wayland-scanner
 , expat, libdrm, xorg, wayland, wayland-protocols, openssl
@@ -10,6 +10,7 @@
   if stdenv.isLinux then
     [
       "d3d12" # WSL emulated GPU (aka Dozen)
+      "kmsro" # special "render only" driver for GPUs without a display controller
       "nouveau" # Nvidia
       "radeonsi" # new AMD (GCN+)
       "r300" # very old AMD
@@ -38,6 +39,7 @@
     [
       "amd" # AMD (aka RADV)
       "microsoft-experimental" # WSL virtualized GPU (aka DZN/Dozen)
+      "nouveau-experimental" # Nouveau (aka NVK)
       "swrast" # software renderer (aka Lavapipe)
     ]
     ++ lib.optionals (stdenv.hostPlatform.isAarch -> lib.versionAtLeast stdenv.hostPlatform.parsed.cpu.version "6") [
@@ -66,6 +68,7 @@
 , enableOpenCL ? stdenv.isLinux && stdenv.isx86_64
 , enablePatentEncumberedCodecs ? true
 , jdupes
+, rustPlatform
 , rust-bindgen
 , rustc
 , spirv-llvm-translator
@@ -74,20 +77,12 @@
 , udev
 }:
 
-/** Packaging design:
-  - The basic mesa ($out) contains headers and libraries (GLU is in libGLU now).
-    This or the mesa attribute (which also contains GLU) are small (~ 2 MB, mostly headers)
-    and are designed to be the buildInput of other packages.
-  - DRI drivers are compiled into $drivers output, which is much bigger and
-    depends on LLVM. These should be searched at runtime in
-    "/run/opengl-driver{,-32}/lib/*" and so are kind-of impure (given by NixOS).
-    (I suppose on non-NixOS one would create the appropriate symlinks from there.)
-  - libOSMesa is in $osmesa (~4 MB)
-*/
+# When updating this package, please verify at least these build (assuming x86_64-linux):
+# nix build .#mesa .#pkgsi686Linux.mesa .#pkgsCross.aarch64-multiplatform.mesa .#pkgsMusl.mesa
 
 let
-  version = "23.3.5";
-  hash = "sha256-acyxJ4ZB/1utccoPhmGIrrGpKq3E27nTX1CuvsW4tQ8=";
+  version = "24.0.1";
+  hash = "sha256-84cZKwjEccVFWQ3RIjCio0MkSAS1/oZv7GrqAuq1dhM=";
 
   # Release calendar: https://www.mesa3d.org/release-calendar.html
   # Release frequency: https://www.mesa3d.org/releasing.html#schedule
@@ -98,6 +93,37 @@ let
   haveWayland = lib.elem "wayland" eglPlatforms;
   haveZink = lib.elem "zink" galliumDrivers;
   haveDozen = (lib.elem "d3d12" galliumDrivers) || (lib.elem "microsoft-experimental" vulkanDrivers);
+
+  rustDeps = [
+    {
+      pname = "proc-macro2";
+      version = "1.0.70";
+      hash = "sha256-e4ZgyZUTu5nAtaH5QVkLelqJQX/XPj/rWkzf/g2c+1g=";
+    }
+    {
+      pname = "quote";
+      version = "1.0.33";
+      hash = "sha256-VWRCZJO0/DJbNu0/V9TLaqlwMot65YjInWT9VWg57DY=";
+    }
+    {
+    pname = "syn";
+      version = "2.0.39";
+      hash = "sha256-Mjen2L/omhVbhU/+Ao65mogs3BP3fY+Bodab3uU63EI=";
+    }
+    {
+      pname = "unicode-ident";
+      version = "1.0.12";
+      hash = "sha256-KX8NqYYw6+rGsoR9mdZx8eT1HIPEUUyxErdk2H/Rlj8=";
+    }
+  ];
+
+  copyRustDep = dep: ''
+    cp -R --no-preserve=mode,ownership ${fetchCrate dep} subprojects/${dep.pname}-${dep.version}
+    cp -R subprojects/packagefiles/${dep.pname}/* subprojects/${dep.pname}-${dep.version}/
+  '';
+
+  copyRustDeps = lib.concatStringsSep "\n" (builtins.map copyRustDep rustDeps);
+
 self = stdenv.mkDerivation {
   pname = "mesa";
   inherit version;
@@ -113,22 +139,8 @@ self = stdenv.mkDerivation {
     inherit hash;
   };
 
-  # TODO:
-  #  revive ./dricore-gallium.patch when it gets ported (from Ubuntu), as it saved
-  #  ~35 MB in $drivers; watch https://launchpad.net/ubuntu/+source/mesa/+changelog
   patches = [
-    # fixes pkgsMusl.mesa build
-    ./musl.patch
-
     ./opencl.patch
-
-    # Backports to fix build
-    # FIXME: remove when applied upstream
-
-    # Fix build on macOS
-    ./backports/0001-dri-added-build-dependencies-for-systems-using-non-s.patch
-    ./backports/0002-util-Update-util-libdrm.h-stubs-to-allow-loader.c-to.patch
-    ./backports/0003-glx-fix-automatic-zink-fallback-loading-between-hw-a.patch
   ];
 
   postPatch = ''
@@ -141,6 +153,8 @@ self = stdenv.mkDerivation {
       "get_option('datadir')" "'${placeholder "out"}/share'"
     substituteInPlace src/amd/vulkan/meson.build --replace \
       "get_option('datadir')" "'${placeholder "out"}/share'"
+
+    ${copyRustDeps}
   '';
 
   outputs = [ "out" "dev" "drivers" ]
@@ -152,15 +166,15 @@ self = stdenv.mkDerivation {
     # in case anything wants to use it at some point
     ++ lib.optional haveDozen "spirv2dxil";
 
-  # FIXME: this fixes rusticl/iris segfaulting on startup, _somehow_.
-  # Needs more investigating.
+  # Keep build-ids so drivers can use them for caching, etc.
+  # Also some drivers segfault without this.
   separateDebugInfo = true;
 
+  # Needed to discover llvm-config for cross
   preConfigure = ''
     PATH=${llvmPackages.libllvm.dev}/bin:$PATH
   '';
 
-  # TODO: Figure out how to enable opencl without having a runtime dependency on clang
   mesonFlags = [
     "--sysconfdir=/etc"
     "--datadir=${placeholder "drivers"}/share" # Vendor files
@@ -212,21 +226,23 @@ self = stdenv.mkDerivation {
     "-Dopencl-spirv=true"
 
     # Rusticl, new OpenCL frontend
-    "-Dgallium-rusticl=true" "-Drust_std=2021"
+    "-Dgallium-rusticl=true"
     "-Dclang-libdir=${llvmPackages.clang-unwrapped.lib}/lib"
   ]  ++ lib.optionals (!withValgrind) [
     "-Dvalgrind=disabled"
   ]  ++ lib.optionals (!withLibunwind) [
     "-Dlibunwind=disabled"
   ] ++ lib.optional enablePatentEncumberedCodecs
-    "-Dvideo-codecs=h264dec,h264enc,h265dec,h265enc,vc1dec"
+    "-Dvideo-codecs=all"
   ++ lib.optional (vulkanLayers != []) "-D vulkan-layers=${builtins.concatStringsSep "," vulkanLayers}";
 
+  strictDeps = true;
+
   buildInputs = with xorg; [
     expat glslang llvmPackages.libllvm libglvnd xorgproto
     libX11 libXext libxcb libXt libXfixes libxshmfence libXrandr
     libffi libvdpau libelf libXvMC
-    libpthreadstubs openssl /*or another sha1 provider*/
+    libpthreadstubs openssl
     zstd
   ] ++ lib.optionals withLibunwind [
     libunwind
@@ -240,15 +256,20 @@ self = stdenv.mkDerivation {
     ++ lib.optional haveDozen directx-headers;
 
   depsBuildBuild = [ pkg-config ]
-    ++ lib.optional enableOpenCL buildPackages.stdenv.cc;
+    # Adding this unconditionally makes x86_64-darwin pick up an older toolchain, as
+    # we explicitly call Mesa with 11.0 stdenv, but buildPackages is still 10.something,
+    # and Mesa can't build with that.
+    # FIXME: figure this out, or figure out how to get rid of Mesa on Darwin,
+    # whichever is easier.
+    ++ lib.optional (!stdenv.isDarwin) buildPackages.stdenv.cc;
 
   nativeBuildInputs = [
     meson pkg-config ninja
     intltool bison flex file
     python3Packages.python python3Packages.mako python3Packages.ply
     jdupes glslang
-  ] ++ lib.optionals enableOpenCL [ rust-bindgen rustc ]
-    ++ lib.optional haveWayland wayland-scanner;
+    rustc rust-bindgen rustPlatform.bindgenHook
+  ] ++ lib.optional haveWayland wayland-scanner;
 
   propagatedBuildInputs = with xorg; [
     libXdamage libXxf86vm