Skip to content

Instantly share code, notes, and snippets.

@craimasjien
Last active February 3, 2026 10:51
Show Gist options
  • Select an option

  • Save craimasjien/4519283aa2c170b93aff00b9f75aa7bf to your computer and use it in GitHub Desktop.

Select an option

Save craimasjien/4519283aa2c170b93aff00b9f75aa7bf to your computer and use it in GitHub Desktop.
Installing bleeding-edge mesa on Fedora

Building Bleeding-Edge Mesa RPMs on Fedora

This guide walks you through building and installing the latest development version of Mesa on Fedora using mock to generate proper RPM packages. I've been using this method since December 2025 and have perfected it along the way. I'm very satisfied with the results. Make sure to put the script itself and the .spec file in a folder and run the script.

MAKE SURE YOU READ AND UNDERSTAND THE SCRIPT, NEVER RUN SOMETHING OFF THE INTERNET WITHOUT UNDERSTANDING THE CONTENT. I AM NOT RESPONSIBLE FOR ANY DAMAGE TO YOUR SYSTEM

Who is this guide for? This guide is written for all experience levels, including beginners. Each step includes explanations of what and why, so you can learn as you go.


Why This Approach?

Instead of installing Mesa to an isolated directory or manually compiling, this approach builds proper RPM packages using mock. This means:

  • Proper package management — Your custom Mesa integrates with dnf, so updates, removals, and dependency tracking work correctly.
  • Clean build environment — Mock builds packages in an isolated chroot, ensuring reproducible builds without polluting your system.
  • Multi-arch support — The script builds both x86_64 and i386 packages for full compatibility.
  • Easy updates — Just re-run the script to build and install the latest version.

Prerequisites

Install Build Dependencies

Before you start, install the tools required to build Mesa RPMs:

sudo dnf install mock rpm-build rpmdevtools

What are these packages?

  • mock — A tool that builds RPMs in a clean, isolated chroot environment.
  • rpm-build — Provides the rpmbuild command for creating RPM packages.
  • rpmdevtools — Utilities for RPM development.

Configure Mock Permissions

Add your user to the mock group so you can run mock without root:

sudo usermod -aG mock $USER

Important: You'll need to log out and back in (or reboot) for this group change to take effect.


Building Mesa

The build-bleeding-edge.sh script handles everything: cloning the source, generating tarballs, building SRPMs, compiling with mock, and installing the resulting packages.

Build the Latest Development Version

To build from the latest commit on the main branch:

./build-bleeding-edge.sh

This will:

  1. Clone or update the Mesa source repository
  2. Generate a source tarball from the latest commit
  3. Build an SRPM (Source RPM)
  4. Use mock to build x86_64 and i386 RPMs
  5. Install the resulting packages with dnf

Build a Specific Version

If you prefer a specific release or release candidate:

./build-bleeding-edge.sh --tag mesa-25.1.0

Or for a release candidate:

./build-bleeding-edge.sh --tag mesa-26.0.0-rc2

To browse available versions, visit the Mesa tags page.


What the Script Does

Step Description
Clone/Update Clones Mesa source to mesa-src/ or pulls latest changes
Checkout Switches to the specified tag or main branch
Tarball Creates a source tarball using git archive
SRPM Builds a source RPM using the spec file
Mock Build Builds binary RPMs for x86_64 and i386 in clean chroots
Install Installs all built RPMs using dnf install --allowerasing

What does --allowerasing do? This flag tells dnf to replace existing Mesa packages with your newly built ones, even if it means removing conflicting packages first.


Build Output

After a successful build, you'll find the RPM packages in:

results/<version>-<commit>/

For example:

results/26.0.0-4339cf0/

This directory contains all the built RPMs for both architectures.


Verifying the Installation

After installation, verify that your custom Mesa is active:

Check Vulkan Version

vulkaninfo | grep "Vulkan Instance Version"

Example output:

WARNING: radv is not a conformant Vulkan implementation, testing use only.
Vulkan Instance Version: 1.4.309

Check OpenGL Version

glxinfo | grep "OpenGL version"

Example output:

OpenGL version string: 4.6 (Compatibility Profile) Mesa 26.0.0-devel (git-4339cf0aff)

Tip: The version string should show git- followed by a commit hash if you built from main, or the tag version if you built from a release tag.


Reverting to Official Packages

Since this approach uses proper RPM packages, reverting to Fedora's official Mesa is straightforward:

sudo dnf distro-sync mesa*

This will replace your custom packages with the versions from Fedora's repositories.


Updating Mesa

To update to a newer version, simply re-run the script:

./build-bleeding-edge.sh

The script will pull the latest changes and build new packages.


Summary

You've now built and installed a bleeding-edge version of Mesa on Fedora using proper RPM packages. This approach gives you the latest Mesa features while maintaining full compatibility with Fedora's package management system.

#!/bin/bash
SRC_DIR="$(pwd)/mesa-src"
WORKDIR="$(pwd)"
COMMIT_HASH=""
BUILD_DIR=""
SRPM_PATH=""
GIT_TAG=""
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
-t|--tag)
GIT_TAG="$2"
shift 2
;;
-h|--help)
echo "Usage: $0 [-t|--tag <git-tag>]"
echo " -t, --tag Specify a git tag to build from (default: latest from main)"
exit 0
;;
*)
echo "Unknown option: $1"
echo "Use -h or --help for usage information"
exit 1
;;
esac
done
sudo -v
while true; do sudo -v; sleep 60; done &
SUDO_PID=$!
# Check if mesa source directory exists, clone if not
if [ ! -d "$SRC_DIR" ]; then
echo "Mesa source directory not found. Cloning repository..."
if ! git clone --recurse-submodules https://gitlab.freedesktop.org/mesa/mesa.git "$SRC_DIR"; then
echo "Error: Failed to clone Mesa repository"
kill $SUDO_PID 2>/dev/null
exit 1
fi
echo "Repository cloned successfully"
elif [ ! -d "$SRC_DIR/.git" ]; then
echo "Error: $SRC_DIR exists but is not a git repository"
kill $SUDO_PID 2>/dev/null
exit 1
fi
cd $SRC_DIR
if [ -n "$GIT_TAG" ]; then
echo "Fetching tags..."
if ! output=$(git fetch --tags 2>&1); then
echo "Error: Failed to fetch tags"
echo "$output"
exit 1
fi
echo "Checking out tag: $GIT_TAG..."
if ! output=$(git checkout "$GIT_TAG" 2>&1); then
echo "Error: Failed to checkout tag '$GIT_TAG'"
echo "$output"
exit 1
fi
else
echo "Switching to main branch..."
if ! output=$(git checkout main 2>&1); then
echo "Error: Failed to switch to main branch"
echo "$output"
exit 1
fi
echo "Pulling latest changes..."
if ! output=$(git pull 2>&1); then
echo "Error: Failed to pull latest changes"
echo "$output"
exit 1
fi
fi
COMMIT_HASH=$(git rev-parse --short HEAD)
# Parse version info from tag or use defaults for bleeding edge
if [ -n "$GIT_TAG" ]; then
# Strip "mesa-" prefix from tag if present (e.g., "mesa-26.0.0-rc2" -> "26.0.0-rc2")
TAG_WITHOUT_PREFIX="${GIT_TAG#mesa-}"
# Extract version number (X.Y.Z) and optional suffix (e.g., rc2)
# Tag format: mesa-X.Y.Z or mesa-X.Y.Z-suffix
if [[ "$TAG_WITHOUT_PREFIX" =~ ^([0-9]+\.[0-9]+\.[0-9]+)(-(.+))?$ ]]; then
MESA_VERSION="${BASH_REMATCH[1]}"
RELEASE_SUFFIX="${BASH_REMATCH[3]:-1}" # Default to "1" for final releases
else
echo "Warning: Could not parse version from tag '$GIT_TAG', using tag as-is"
MESA_VERSION="26.0.0"
RELEASE_SUFFIX="$TAG_WITHOUT_PREFIX"
fi
TARBALL_NAME="$GIT_TAG"
else
# For bleeding edge, use hardcoded version with commit hash
MESA_VERSION="26.0.0"
RELEASE_SUFFIX="$COMMIT_HASH"
TARBALL_NAME="mesa-${MESA_VERSION}-${RELEASE_SUFFIX}"
fi
BUILD_DIR="$WORKDIR/build"
mkdir -p $BUILD_DIR
if [ -n "$GIT_TAG" ]; then
echo "Generating tarball for tag $GIT_TAG (version $MESA_VERSION, release $RELEASE_SUFFIX)..."
git archive --format=tar.gz --prefix=$GIT_TAG/ HEAD > $WORKDIR/$GIT_TAG.tar.gz
else
echo "Generating tarball for version $MESA_VERSION-$RELEASE_SUFFIX..."
git archive --format=tar.gz --prefix=$TARBALL_NAME/ HEAD > $WORKDIR/$TARBALL_NAME.tar.gz
fi
cd $WORKDIR
# Update spec file with version info
sed -i "s/^Version:.*/Version: ${MESA_VERSION}/" mesa26.spec
sed -i "s/^%global shortcommit.*/%global shortcommit ${RELEASE_SUFFIX}/" mesa26.spec
sed -i "s/^Source0:.*/Source0: ${TARBALL_NAME}.tar.gz/" mesa26.spec
build_srpm() {
rpmbuild -bs mesa26.spec --define "_sourcedir $PWD" --define "_topdir $BUILD_DIR"
}
echo "Generating SRPM..."
if ! build_srpm; then
echo "Error: Failed to generate SRPM"
echo $output
exit 1
fi
echo "SRPM generated successfully"
SRPM_PATH="${BUILD_DIR}/SRPMS/mesa-${MESA_VERSION}-${RELEASE_SUFFIX}.fc43.src.rpm"
build_x64() {
mock -r fedora-43-x86_64 --resultdir="${BUILD_DIR}/x64" "${SRPM_PATH}"
}
build_x86() {
mock -r fedora-43-i386 --resultdir="${BUILD_DIR}/x86" "${SRPM_PATH}"
}
OUTPUT_DIR="${WORKDIR}/results/${MESA_VERSION}-${RELEASE_SUFFIX}/"
if ! [ -f ${BUILD_DIR}/.build-complete.lock ]; then
# Run both simultaneously
echo "Building x86_64 RPMs..."
build_x64 &
X64_PID=$!
wait $X64_PID
echo "Building i386 RPMs..."
build_x86 &
X86_PID=$!
wait $X86_PID
touch ${BUILD_DIR}/.build-complete.lock
else
echo "Build already successfully completed, skipping..."
fi
mkdir -p ${OUTPUT_DIR}
echo ${OUTPUT_DIR}
find "${BUILD_DIR}/x64" -maxdepth 1 -name "*.rpm" ! -name "*.src.rpm" -exec mv {} "${OUTPUT_DIR}" \;
find "${BUILD_DIR}/x86" -maxdepth 1 -name "*.rpm" ! -name "*.src.rpm" -exec mv {} "${OUTPUT_DIR}" \;
echo "Installing Mesa $MESA_VERSION-$RELEASE_SUFFIX..."
sudo dnf install -y --allowerasing ${OUTPUT_DIR}/*.rpm
echo "Install complete, cleaning up..."
kill $SUDO_PID 2>/dev/null
rm -rf ${BUILD_DIR}
echo "Done"
%bcond_without videocodecs
%global source_date_epoch_from_changelog 0
%ifnarch s390x
%global with_hardware 1
%global with_nvk 1
%global with_radeonsi 1
%global with_vmware 1
%global with_vulkan_hw 1
%global with_va 1
%if !0%{?rhel}
%global with_r300 1
%global with_r600 1
%global with_opencl 1
%endif
%global base_vulkan %{?with_vulkan_hw:,amd}%{!?with_vulkan_hw:%{nil}}
%endif
%ifnarch %{ix86}
%if !0%{?rhel}
%global with_teflon 1
%endif
%endif
%ifarch %{ix86} x86_64
%global with_crocus 1
%global with_iris 1
%global intel_platform_vulkan %{?with_vulkan_hw:,intel,intel_hasvk}%{!?with_vulkan_hw:%{nil}}
%if !0%{?rhel}
%global with_i915 1
%endif
%global with_intel_nullhw 1
%endif
%ifarch x86_64
%if !0%{?with_vulkan_hw}
%global with_intel_vk_rt 1
%endif
%endif
%ifarch aarch64 x86_64 %{ix86}
%if !0%{?rhel}
%global with_asahi 1
# disabled: DirectX-Headers >= 1.618.1 required, F43 has 1.615.0
#%%global with_d3d12 1
%global with_etnaviv 1
%global with_lima 1
%global with_tegra 1
%global with_vc4 1
%global with_v3d 1
%endif
%global with_freedreno 1
%global with_kmsro 1
%global with_panfrost 1
%if 0%{?with_asahi}
%global asahi_platform_vulkan %{?with_vulkan_hw:,asahi}%{!?with_vulkan_hw:%{nil}}
%endif
%global extra_platform_vulkan %{?with_vulkan_hw:,broadcom,freedreno,panfrost,imagination}%{!?with_vulkan_hw:%{nil}}
%endif
%if !0%{?rhel}
%global with_libunwind 1
%global with_lmsensors 1
%global with_virtio 1
%endif
%ifarch %{valgrind_arches}
%bcond_without valgrind
%else
%bcond_with valgrind
%endif
%global vulkan_drivers swrast%{?base_vulkan}%{?intel_platform_vulkan}%{?asahi_platform_vulkan}%{?extra_platform_vulkan}%{?with_nvk:,nouveau}%{?with_virtio:,virtio}%{?with_d3d12:,microsoft-experimental}
## additional functionality not in the fedora standard packages
%global with_vulkan_overlay 1
%global with_gallium_extra_hud 1
%if 0%{?with_nvk} && 0%{?rhel}
%global vendor_nvk_crates 1
%endif
%global shortcommit rc2
Name: mesa
Summary: Mesa graphics libraries
Version: 26.0.0
Release: %{shortcommit}%{?dist}
License: MIT AND BSD-3-Clause AND SGI-B-2.0
URL: http://www.mesa3d.org
Source0: mesa-26.0.0-rc2.tar.gz
# src/gallium/auxiliary/postprocess/pp_mlaa* have an ... interestingly worded license.
# Source1 contains email correspondence clarifying the license terms.
# Fedora opts to ignore the optional part of clause 2 and treat that code as 2 clause BSD.
# Patch10: gnome-shell-glthread-disable.patch
BuildRequires: meson >= 1.3.0
BuildRequires: gcc
BuildRequires: gcc-c++
BuildRequires: gettext
%if 0%{?with_hardware}
BuildRequires: kernel-headers
BuildRequires: systemd-devel
%endif
# We only check for the minimum version of pkgconfig(libdrm) needed so that the
# SRPMs for each arch still have the same build dependencies. See:
# https://bugzilla.redhat.com/show_bug.cgi?id=1859515
BuildRequires: pkgconfig(libdrm) >= 2.4.97
%if 0%{?with_libunwind}
BuildRequires: pkgconfig(libunwind)
%endif
BuildRequires: pkgconfig(expat)
BuildRequires: pkgconfig(zlib) >= 1.2.3
BuildRequires: pkgconfig(libzstd)
BuildRequires: pkgconfig(wayland-scanner)
BuildRequires: pkgconfig(wayland-protocols) >= 1.8
BuildRequires: pkgconfig(wayland-client) >= 1.11
BuildRequires: pkgconfig(wayland-server) >= 1.11
BuildRequires: pkgconfig(wayland-egl-backend) >= 3
BuildRequires: pkgconfig(x11)
BuildRequires: pkgconfig(xext)
BuildRequires: pkgconfig(xdamage) >= 1.1
BuildRequires: pkgconfig(xfixes)
BuildRequires: pkgconfig(xcb-glx) >= 1.8.1
BuildRequires: pkgconfig(xxf86vm)
BuildRequires: pkgconfig(xcb)
BuildRequires: pkgconfig(x11-xcb)
BuildRequires: pkgconfig(xcb-dri2) >= 1.8
BuildRequires: pkgconfig(xcb-dri3)
BuildRequires: pkgconfig(xcb-present)
BuildRequires: pkgconfig(xcb-sync)
BuildRequires: pkgconfig(xshmfence) >= 1.1
BuildRequires: pkgconfig(dri2proto) >= 2.8
BuildRequires: pkgconfig(glproto) >= 1.4.14
BuildRequires: pkgconfig(xcb-xfixes)
BuildRequires: pkgconfig(xcb-randr)
BuildRequires: pkgconfig(xrandr) >= 1.3
BuildRequires: bison
BuildRequires: flex
BuildRequires: libdisplay-info-devel
%if 0%{?with_lmsensors}
BuildRequires: lm_sensors-devel
%endif
%if 0%{?with_va}
BuildRequires: pkgconfig(libva) >= 0.38.0
%endif
BuildRequires: pkgconfig(libelf)
BuildRequires: pkgconfig(libglvnd) >= 1.3.2
BuildRequires: llvm-devel >= 7.0.0
%if 0%{?with_teflon}
BuildRequires: flatbuffers-devel
BuildRequires: flatbuffers-compiler
BuildRequires: xtensor-devel
%endif
%if 0%{?with_opencl} || 0%{?with_nvk} || 0%{?with_asahi} || 0%{?with_panfrost}
BuildRequires: clang-devel
BuildRequires: pkgconfig(libclc)
BuildRequires: pkgconfig(SPIRV-Tools)
BuildRequires: pkgconfig(LLVMSPIRVLib)
%endif
%if 0%{?with_opencl} || 0%{?with_nvk}
BuildRequires: bindgen
%if 0%{?rhel}
BuildRequires: rust-toolset
%else
BuildRequires: cargo-rpm-macros
%endif
%endif
%if 0%{?with_nvk}
BuildRequires: cbindgen
BuildRequires: (crate(paste) >= 1.0.14 with crate(paste) < 2)
BuildRequires: (crate(proc-macro2) >= 1.0.56 with crate(proc-macro2) < 2)
BuildRequires: (crate(quote) >= 1.0.25 with crate(quote) < 2)
BuildRequires: (crate(syn/clone-impls) >= 2.0.15 with crate(syn/clone-impls) < 3)
BuildRequires: (crate(unicode-ident) >= 1.0.6 with crate(unicode-ident) < 2)
Buildrequires: rust-rustc-hash-devel
%endif
%if %{with valgrind}
BuildRequires: pkgconfig(valgrind)
%endif
BuildRequires: python3-devel
BuildRequires: python3-mako
BuildRequires: python3-ply
BuildRequires: python3-pycparser
BuildRequires: python3-pyyaml
BuildRequires: vulkan-headers
BuildRequires: glslang
%if 0%{?with_vulkan_hw}
BuildRequires: pkgconfig(vulkan)
%endif
%if 0%{?with_d3d12}
BuildRequires: pkgconfig(DirectX-Headers) >= 1.614.1
%endif
## vulkan hud requires
%if 0%{?with_vulkan_overlay}
BuildRequires: glslang
%endif
%description
%{summary}.
%package filesystem
Summary: Mesa driver filesystem
Provides: mesa-dri-filesystem = %{?epoch:%{epoch}:}%{version}-%{release}
Obsoletes: mesa-omx-drivers < %{?epoch:%{epoch}:}%{version}-%{release}
Obsoletes: mesa-libd3d < %{?epoch:%{epoch}:}%{version}-%{release}
Obsoletes: mesa-libd3d-devel < %{?epoch:%{epoch}:}%{version}-%{release}
%description filesystem
%{summary}.
%package libGL
Summary: Mesa libGL runtime libraries
Requires: libglvnd-glx%{?_isa} >= 1:1.3.2
Recommends: %{name}-dri-drivers%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}
%if 0%{?fedora} > 41
Obsoletes: %{name}-libOSMesa < 25.1.0~rc2-1
%endif
%description libGL
%{summary}.
%package libGL-devel
Summary: Mesa libGL development package
Requires: (%{name}-libGL%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release} if %{name}-libGL%{?_isa})
Requires: libglvnd-devel%{?_isa} >= 1:1.3.2
Provides: libGL-devel
Provides: libGL-devel%{?_isa}
Recommends: gl-manpages
%if 0%{?fedora} > 41
Obsoletes: %{name}-libOSMesa-devel <= 25.1.0~rc2-1
%endif
%description libGL-devel
%{summary}.
%package libEGL
Summary: Mesa libEGL runtime libraries
Requires: libglvnd-egl%{?_isa} >= 1:1.3.2
Requires: %{name}-libgbm%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}
Recommends: %{name}-dri-drivers%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}
%description libEGL
%{summary}.
%package libEGL-devel
Summary: Mesa libEGL development package
Requires: (%{name}-libEGL%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release} if %{name}-libEGL%{?_isa})
Requires: libglvnd-devel%{?_isa} >= 1:1.3.2
Requires: %{name}-khr-devel%{?_isa}
Provides: libEGL-devel
Provides: libEGL-devel%{?_isa}
%description libEGL-devel
%{summary}.
%package dri-drivers
Summary: Mesa-based DRI drivers
Requires: %{name}-filesystem%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}
%if 0%{?with_va}
Recommends: %{name}-va-drivers%{?_isa}
%endif
Obsoletes: %{name}-libglapi < 25.0.0~rc2-1
Provides: %{name}-libglapi >= 25.0.0~rc2-1
%description dri-drivers
%{summary}.
%if 0%{?with_va}
%package va-drivers
Summary: Mesa-based VA-API video acceleration drivers
Requires: %{name}-filesystem%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}
Obsoletes: %{name}-vaapi-drivers < 22.3.0-0.24
%description va-drivers
%{summary}.
%endif
%package libgbm
Summary: Mesa gbm runtime library
Provides: libgbm
Provides: libgbm%{?_isa}
Recommends: %{name}-dri-drivers%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}
# If mesa-dri-drivers are installed, they must match in version. This is here to prevent using
# older mesa-dri-drivers together with a newer mesa-libgbm and its dependants.
# See https://bugzilla.redhat.com/show_bug.cgi?id=2193135 .
Requires: (%{name}-dri-drivers%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release} if %{name}-dri-drivers%{?_isa})
%description libgbm
%{summary}.
%package libgbm-devel
Summary: Mesa libgbm development package
Requires: %{name}-libgbm%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}
Provides: libgbm-devel
Provides: libgbm-devel%{?_isa}
%description libgbm-devel
%{summary}.
%if 0%{?with_opencl}
%package libOpenCL
Summary: Mesa OpenCL runtime library
Requires: (ocl-icd%{?_isa} or OpenCL-ICD-Loader%{?_isa})
Requires: libclc%{?_isa}
Requires: %{name}-libgbm%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}
Requires: opencl-filesystem
%description libOpenCL
%{summary}.
%package libOpenCL-devel
Summary: Mesa OpenCL development package
Requires: %{name}-libOpenCL%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}
%description libOpenCL-devel
%{summary}.
%endif
%if 0%{?with_teflon}
%package libTeflon
Summary: Mesa TensorFlow Lite delegate
%description libTeflon
%{summary}.
%files libTeflon
%{_libdir}/libteflon.so
%endif
%if 0%{?with_d3d12}
%package dxil-devel
Summary: Mesa SPIR-V to DXIL binary
Requires: %{name}-filesystem%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}
%description dxil-devel
Development tools for translating SPIR-V shader code to DXIL for Direct3D 12
%endif
%package vulkan-drivers
Summary: Mesa Vulkan drivers
Requires: vulkan%{_isa}
Requires: %{name}-filesystem%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}
Obsoletes: mesa-vulkan-devel < %{?epoch:%{epoch}:}%{version}-%{release}
%description vulkan-drivers
The drivers with support for the Vulkan API.
%prep
%autosetup -n mesa-26.0.0-%{shortcommit} -p1
# cp %{SOURCE1} docs/
%build
# ensure standard Rust compiler flags are set
export RUSTFLAGS="%build_rustflags"
%if 0%{?with_nvk}
export MESON_PACKAGE_CACHE_DIR="%{cargo_registry}/"
# So... Meson can't actually find them without tweaks
%define inst_crate_nameversion() %(basename %{cargo_registry}/%{1}-*)
%define rewrite_wrap_file() wrapfile=$(ls subprojects/%{1}*.wrap | head -n1) && extracted_dir=$(basename $(find /usr/share/cargo/registry/ -maxdepth 1 -type d -name '%{1}-*' | head -n1)) && sed -i -e '/^source_filename/d' -e '/^source_url/d' -e "s/^directory = .*/directory = ${extracted_dir}/" "$wrapfile"
%rewrite_wrap_file proc-macro2
%rewrite_wrap_file quote
%rewrite_wrap_file syn
%rewrite_wrap_file unicode-ident
%rewrite_wrap_file paste
%endif
# We've gotten a report that enabling LTO for mesa breaks some games. See
# https://bugzilla.redhat.com/show_bug.cgi?id=1862771 for details.
# Disable LTO for now
%define _lto_cflags %{nil}
%meson \
-Dplatforms=x11,wayland \
%if 0%{?with_hardware}
-Dgallium-drivers=softpipe,llvmpipe,virgl,nouveau%{?with_r300:,r300}%{?with_crocus:,crocus}%{?with_i915:,i915}%{?with_iris:,iris}%{?with_vmware:,svga}%{?with_radeonsi:,radeonsi}%{?with_r600:,r600}%{?with_asahi:,asahi}%{?with_freedreno:,freedreno}%{?with_etnaviv:,etnaviv}%{?with_tegra:,tegra}%{?with_vc4:,vc4}%{?with_v3d:,v3d}%{?with_lima:,lima}%{?with_panfrost:,panfrost}%{?with_vulkan_hw:,zink}%{?with_d3d12:,d3d12} \
%else
-Dgallium-drivers=softpipe,llvmpipe,virgl \
%endif
-Dgallium-va=%{?with_va:enabled}%{!?with_va:disabled} \
-Dgallium-mediafoundation=disabled \
-Dteflon=%{?with_teflon:true}%{!?with_teflon:false} \
%if 0%{?with_opencl}
-Dgallium-rusticl=true \
%endif
-Dgallium-extra-hud=%{?with_gallium_extra_hud:true}%{!?with_gallium_extra_hud:false} \
-Dvulkan-drivers=%{?vulkan_drivers} \
-Dvulkan-layers=device-select%{?with_intel_nullhw:,intel-nullhw}%{?with_vulkan_overlay:,overlay} \
-Dgles1=enabled \
-Dgles2=enabled \
-Dopengl=true \
-Dgbm=enabled \
-Dglx=dri \
-Degl=enabled \
-Dglvnd=enabled \
-Dintel-rt=%{?with_intel_vk_rt:enabled}%{!?with_intel_vk_rt:disabled} \
-Dmicrosoft-clc=disabled \
-Dllvm=enabled \
-Dshared-llvm=enabled \
-Dvalgrind=%{?with_valgrind:enabled}%{!?with_valgrind:disabled} \
-Dbuild-tests=false \
%if !0%{?with_libunwind}
-Dlibunwind=disabled \
%endif
%if !0%{?with_lmsensors}
-Dlmsensors=disabled \
%endif
-Dandroid-libbacktrace=disabled \
%ifarch %{ix86}
-Dglx-read-only-text=true \
%endif
%if %{with videocodecs}
-Dvideo-codecs=all \
%endif
%{nil}
%meson_build
%install
%meson_install
# likewise glvnd
rm -vf %{buildroot}%{_libdir}/libGLX_mesa.so
rm -vf %{buildroot}%{_libdir}/libEGL_mesa.so
# XXX can we just not build this
rm -vf %{buildroot}%{_libdir}/libGLES*
%if ! 0%{?with_asahi}
# This symlink is unconditionally created when any kmsro driver is enabled
# We don't want this one so delete it
rm -vf %{buildroot}%{_libdir}/dri/apple_dri.so
%endif
# glvnd needs a default provider for indirect rendering where it cannot
# determine the vendor
ln -s %{_libdir}/libGLX_mesa.so.0 %{buildroot}%{_libdir}/libGLX_system.so.0
# this keeps breaking, check it early. note that the exit from eu-ftr is odd.
# With glvnd, Mesa produces libGLX_mesa.so.0, not libGL.so
pushd %{buildroot}%{_libdir}
for i in libGLX_mesa.so.0 ; do
eu-findtextrel $i && exit 1
done
popd
%files filesystem
%dir %{_libdir}/dri
%dir %{_datadir}/drirc.d
%files libGL
%{_libdir}/libGLX_mesa.so.0*
%{_libdir}/libGLX_system.so.0*
%files libGL-devel
%dir %{_includedir}/GL
%dir %{_includedir}/GL/internal
%{_includedir}/GL/internal/dri_interface.h
%{_libdir}/pkgconfig/dri.pc
%files libEGL
%{_datadir}/glvnd/egl_vendor.d/50_mesa.json
%{_libdir}/libEGL_mesa.so.0*
%files libEGL-devel
%dir %{_includedir}/EGL
%{_includedir}/EGL/eglext_angle.h
%{_includedir}/EGL/eglmesaext.h
%files libgbm
%{_libdir}/libgbm.so.1
%{_libdir}/libgbm.so.1.*
%files libgbm-devel
%{_libdir}/libgbm.so
%{_includedir}/gbm.h
%{_includedir}/gbm_backend_abi.h
%{_libdir}/pkgconfig/gbm.pc
%if 0%{?with_opencl}
%files libOpenCL
%{_libdir}/libRusticlOpenCL.so.*
%{_sysconfdir}/OpenCL/vendors/rusticl.icd
%files libOpenCL-devel
%{_libdir}/libRusticlOpenCL.so
%endif
%files dri-drivers
%{_datadir}/drirc.d/00-mesa-defaults.conf
%{_libdir}/libgallium-*.so
%{_libdir}/gbm/dri_gbm.so
%{_libdir}/dri/kms_swrast_dri.so
%{_libdir}/dri/libdril_dri.so
%{_libdir}/dri/swrast_dri.so
%{_libdir}/dri/virtio_gpu_dri.so
%if 0%{?with_hardware}
%if 0%{?with_r300}
%{_libdir}/dri/r300_dri.so
%endif
%if 0%{?with_radeonsi}
%if 0%{?with_r600}
%{_libdir}/dri/r600_dri.so
%endif
%{_libdir}/dri/radeonsi_dri.so
%endif
%ifarch %{ix86} x86_64
%{_libdir}/dri/crocus_dri.so
%{_libdir}/dri/iris_dri.so
%if 0%{?with_i915}
%{_libdir}/dri/i915_dri.so
%endif
%endif
%ifarch aarch64 x86_64 %{ix86}
%if 0%{?with_asahi}
%{_libdir}/dri/apple_dri.so
%{_libdir}/dri/asahi_dri.so
%endif
%if 0%{?with_d3d12}
%{_libdir}/dri/d3d12_dri.so
%endif
%{_libdir}/dri/ingenic-drm_dri.so
%{_libdir}/dri/imx-drm_dri.so
%{_libdir}/dri/imx-lcdif_dri.so
%{_libdir}/dri/kirin_dri.so
%{_libdir}/dri/komeda_dri.so
%{_libdir}/dri/mali-dp_dri.so
%{_libdir}/dri/mcde_dri.so
%{_libdir}/dri/mxsfb-drm_dri.so
%{_libdir}/dri/rcar-du_dri.so
%{_libdir}/dri/stm_dri.so
%endif
%if 0%{?with_vc4}
%{_libdir}/dri/vc4_dri.so
%endif
%if 0%{?with_v3d}
%{_libdir}/dri/v3d_dri.so
%endif
%if 0%{?with_freedreno}
%{_libdir}/dri/kgsl_dri.so
%{_libdir}/dri/msm_dri.so
%endif
%if 0%{?with_etnaviv}
%{_libdir}/dri/etnaviv_dri.so
%endif
%if 0%{?with_tegra}
%{_libdir}/dri/tegra_dri.so
%endif
%if 0%{?with_lima}
%{_libdir}/dri/lima_dri.so
%endif
%if 0%{?with_panfrost}
%{_libdir}/dri/panfrost_dri.so
%{_libdir}/dri/panthor_dri.so
%endif
%{_libdir}/dri/nouveau_dri.so
%if 0%{?with_vmware}
%{_libdir}/dri/vmwgfx_dri.so
%endif
%endif
%if 0%{?with_kmsro}
%{_libdir}/dri/armada-drm_dri.so
%{_libdir}/dri/exynos_dri.so
%{_libdir}/dri/gm12u320_dri.so
%{_libdir}/dri/hdlcd_dri.so
%{_libdir}/dri/hx8357d_dri.so
%{_libdir}/dri/ili9163_dri.so
%{_libdir}/dri/ili9225_dri.so
%{_libdir}/dri/ili9341_dri.so
%{_libdir}/dri/ili9486_dri.so
%{_libdir}/dri/imx-dcss_dri.so
%{_libdir}/dri/mediatek_dri.so
%{_libdir}/dri/meson_dri.so
%{_libdir}/dri/mi0283qt_dri.so
%{_libdir}/dri/panel-mipi-dbi_dri.so
%{_libdir}/dri/pl111_dri.so
%{_libdir}/dri/repaper_dri.so
%{_libdir}/dri/rockchip_dri.so
%{_libdir}/dri/rzg2l-du_dri.so
%{_libdir}/dri/ssd130x_dri.so
%{_libdir}/dri/st7586_dri.so
%{_libdir}/dri/st7735r_dri.so
%{_libdir}/dri/sti_dri.so
%{_libdir}/dri/sun4i-drm_dri.so
%{_libdir}/dri/udl_dri.so
%{_libdir}/dri/vkms_dri.so
%{_libdir}/dri/zynqmp-dpsub_dri.so
%endif
%if 0%{?with_vulkan_hw}
%{_libdir}/dri/zink_dri.so
%endif
%if 0%{?with_va}
%files va-drivers
%{_libdir}/dri/nouveau_drv_video.so
%if 0%{?with_r600}
%{_libdir}/dri/r600_drv_video.so
%endif
%if 0%{?with_radeonsi}
%{_libdir}/dri/radeonsi_drv_video.so
%endif
%if 0%{?with_d3d12}
%{_libdir}/dri/d3d12_drv_video.so
%endif
%{_libdir}/dri/virtio_gpu_drv_video.so
%endif
%if 0%{?with_d3d12}
%files dxil-devel
%{_bindir}/spirv2dxil
%{_libdir}/libspirv_to_dxil.a
%{_libdir}/libspirv_to_dxil.so
%endif
%files vulkan-drivers
%if 0%{?with_nvk}
%if 0%{?vendor_nvk_crates}
%license cargo-vendor.txt
%endif
%endif
%{_libdir}/libvulkan_lvp.so
%{_datadir}/vulkan/icd.d/lvp_icd.*.json
%{_libdir}/libVkLayer_MESA_device_select.so
%{_datadir}/vulkan/implicit_layer.d/VkLayer_MESA_device_select.json
%if 0%{?with_virtio}
%{_libdir}/libvulkan_virtio.so
%{_datadir}/vulkan/icd.d/virtio_icd.*.json
%endif
%if 0%{?with_intel_nullhw}
%{_libdir}/libVkLayer_INTEL_nullhw.so
%{_datadir}/vulkan/explicit_layer.d/VkLayer_INTEL_nullhw.json
%endif
%if 0%{?with_vulkan_hw}
%{_libdir}/libvulkan_radeon.so
%{_datadir}/drirc.d/00-radv-defaults.conf
%{_datadir}/vulkan/icd.d/radeon_icd.*.json
%if 0%{?with_nvk}
%{_libdir}/libvulkan_nouveau.so
%{_datadir}/vulkan/icd.d/nouveau_icd.*.json
%endif
%if 0%{?with_d3d12}
%{_libdir}/libvulkan_dzn.so
%{_datadir}/vulkan/icd.d/dzn_icd.*.json
%endif
%ifarch %{ix86} x86_64
%{_libdir}/libvulkan_intel.so
%{_datadir}/vulkan/icd.d/intel_icd.*.json
%{_libdir}/libvulkan_intel_hasvk.so
%{_datadir}/vulkan/icd.d/intel_hasvk_icd.*.json
%endif
%ifarch aarch64 x86_64 %{ix86}
%if 0%{?with_asahi}
%{_libdir}/libvulkan_asahi.so
%{_datadir}/vulkan/icd.d/asahi_icd.*.json
%endif
%{_libdir}/libvulkan_broadcom.so
%{_datadir}/vulkan/icd.d/broadcom_icd.*.json
%{_libdir}/libvulkan_freedreno.so
%{_datadir}/vulkan/icd.d/freedreno_icd.*.json
%{_libdir}/libvulkan_panfrost.so
%{_datadir}/vulkan/icd.d/panfrost_icd.*.json
%{_libdir}/libvulkan_powervr_mesa.so
%{_datadir}/vulkan/icd.d/powervr_mesa_icd.*.json
%endif
%endif
%if 0%{?with_vulkan_overlay}
%{_bindir}/mesa-overlay-control.py
%{_libdir}/libVkLayer_MESA_overlay.so
%{_datadir}/vulkan/explicit_layer.d/VkLayer_MESA_overlay.json
%endif
%changelog
@Retro8bit
Copy link

Retro8bit commented May 13, 2025

Great guide, worked perfectly for me on Fedora 41 using an AMD GPU. I really like the approach you took.

One thing I will point out though is that the path that was provided for the VK_DRIVER_FILES var was incorrect for me.
Yours:
/opt/mesa-git/share/vulkan/icd/radeon_icd.x86_64.json
Mine:
/opt/mesa-git/share/vulkan/icd.d/radeon_icd.x86_64.json
The icd directory is named icd.d when I compiled and installed Mesa from source.

@craimasjien
Copy link
Author

Great guide, worked perfectly for me on Fedora 41 using an AMD GPU. I really like the approach you took.

One thing I will point out though is that the path that was provided for the VK_DRIVER_FILES var was incorrect for me. Yours: /opt/mesa-git/share/vulkan/icd/radeon_icd.x86_64.json Mine: /opt/mesa-git/share/vulkan/icd.d/radeon_icd.x86_64.json The icd directory is named icd.d when I compiled and installed Mesa from source.

Thanks! I’m happy it worked out. You’re right! I’ve corrected the paths. Thanks!

@RnClank42
Copy link

Hi, thanks for the guide! do you have a guide to uninstall later for when the official release somewhat catches up?

@craimasjien
Copy link
Author

craimasjien commented Jun 18, 2025 via email

@RnClank42
Copy link

Hey @RnClank42! Thanks! Uninstalling is quite simply done doing either of these things: 1. Simply remove (or comment out) the lines in /etc/environment and reboot. This will tell the OS to use the system installed mesa package. 2. Run sudo ninja uninstall to remove the files installed by meson. Don’t forget to also do the steps in step 1, as this might break your system if the files are removed but the environment variables still point to them.

Thanks!

@zelfir
Copy link

zelfir commented Sep 24, 2025

I've currently an error during Meson setup telling me the llvm dependency is not matching on Fedora 42.
I'm trying with the Masa branch mesa-25.2.3 and I got this
meson.build:1829:21: ERROR: Dependency lookup for LLVMSPIRVLib with method 'pkgconfig' failed: Invalid version, need 'LLVMSPIRVLib' ['>= 20.1'] found '15.0.0.0'.
Any way to workaround the LLVM dependency while keeping the version installed on the system ?

@AnthonyHorton
Copy link

Thanks, a very useful guide. It worked well for me on Fedora 42, with the only issue being that I had to add -Dvideo-codecs=h264dec,h264enc,h265dec,h265enc,vc1dec to the meson setup options so that the drivers would be built with hardware video encoding support.

I needed that in order to get Steam VR to connect to my Meta Quest 3, which was the reason I wanted the latest mesa in the first place.

@craimasjien
Copy link
Author

Thanks, a very useful guide. It worked well for me on Fedora 42, with the only issue being that I had to add -Dvideo-codecs=h264dec,h264enc,h265dec,h265enc,vc1dec to the meson setup options so that the drivers would be built with hardware video encoding support.

I needed that in order to get Steam VR to connect to my Meta Quest 3, which was the reason I wanted the latest mesa in the first place.

Thanks for your reply! This is helpful information, I will add it to the guide. Can you tell me what happens if you run vainfo from the command line? It's part of the libva-utils package. I noticed that for me, libva still uses the system Mesa version instead of the git version.

vainfo
Trying display: wayland
libva info: VA-API version 1.22.0
libva info: Trying to open /usr/lib64/dri-nonfree/radeonsi_drv_video.so
libva info: Trying to open /usr/lib64/dri-freeworld/radeonsi_drv_video.so
libva info: Trying to open /usr/lib64/dri/radeonsi_drv_video.so
libva info: Found init function __vaDriverInit_1_22
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.22 (libva 2.22.0)
vainfo: Driver version: Mesa Gallium driver 25.1.9 for AMD Radeon RX 9070 XT (radeonsi, gfx1201, LLVM 20.1.8, DRM 3.64, 6.17.4-200.fc42.x86_64)
vainfo: Supported profile and entrypoints
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD
      VAProfileAV1Profile0            : VAEntrypointVLD
      VAProfileAV1Profile0            : VAEntrypointEncSlice
      VAProfileNone                   : VAEntrypointVideoProc

@craimasjien
Copy link
Author

craimasjien commented Oct 25, 2025

Found it, apparently you can set LIBVA_DRIVER_NAME and LIBVA_DRIVERS_PATH and it will pick up on that. I will add that to the guide as well. Your comment @AnthonyHorton made me think that having vainfo use the same mesa drivers would make sense if you include the different video codecs to the compilation.

After setting both I get the following output

export LIBVA_DRIVERS_PATH=/opt/mesa-git/lib64/dri
export LIBVA_DRIVER_NAME=radeonsi

vainfo
Trying display: wayland
libva info: VA-API version 1.22.0
libva info: User environment variable requested driver 'radeonsi'
libva info: Trying to open /opt/mesa-git/lib64/dri/radeonsi_drv_video.so
libva info: Found init function __vaDriverInit_1_22
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.22 (libva 2.22.0)
vainfo: Driver version: Mesa Gallium driver 25.2.5 for AMD Radeon RX 9070 XT (radeonsi, gfx1201, LLVM 20.1.8, DRM 3.64, 6.17.4-200.fc42.x86_64)
vainfo: Supported profile and entrypoints
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointEncSlice
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointEncSlice
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileNone                   : VAEntrypointVideoProc

@dan0v
Copy link

dan0v commented Jan 19, 2026

I AI slopped an interactive bash script to follow these steps to install, or update the installed mesa-git version (including suggested improvements in the comments above). Gist here.

@craimasjien
Copy link
Author

@dan0v, @AnthonyHorton , @zelfir @RnClank42 @Retro8bit I've updated the guide and provided a bash script that I've made over the course of a couple of months to perfect the installation method. Please try it out and let me know what you think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment