Skip to content

Instantly share code, notes, and snippets.

@craimasjien
Last active October 25, 2025 18:34
Show Gist options
  • Save craimasjien/4519283aa2c170b93aff00b9f75aa7bf to your computer and use it in GitHub Desktop.
Save craimasjien/4519283aa2c170b93aff00b9f75aa7bf to your computer and use it in GitHub Desktop.
Installing bleeding-edge mesa on Fedora

Installing Bleeding-Edge Mesa on Fedora

This guide walks you through installing the latest development version of Mesa (similar to mesa-git on Arch Linux) on Fedora, while keeping the system-provided Mesa version intact. This approach helps avoid breaking dependencies or rendering your system unusable due to driver conflicts.

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?

Unlike some guides that replace system libraries, this one installs Mesa to an isolated location (/opt/mesa-git).

Why use /opt? /opt is a standard directory on Linux for optional or third-party software that isn't managed by your system's package manager. By installing Mesa here, you keep your system's original Mesa untouched and safe. This makes it easy to test, update, or remove your custom Mesa without risking your system's stability.

This means:

  • You retain your working Fedora Mesa packages.
  • You can test and use the bleeding-edge version without risking system stability.
  • You can at any time pull the latest changes and repeat these steps to update to the latest version available.

Prerequisites

Before you start, you need to install all the tools and libraries required to build Mesa from source.

sudo dnf builddep mesa

This will prompt you to install a large number of development packages. Review them carefully before confirming. These are needed so that Mesa can be compiled from its source code.


Cloning the Mesa Source

Mesa's source code is hosted on GitLab. You'll need to download ("clone") it to your computer.

cd ~/dev/   # or any other folder you prefer
git clone https://gitlab.freedesktop.org/mesa/mesa.git
cd mesa

By default, this checks out the latest development version.

Checkout a Specific Version

If you prefer a specific version:

git checkout mesa-25.1.0

To browse available versions, visit the Mesa tags page.


Building Mesa

We'll build Mesa using a custom prefix to avoid overwriting system libraries.

What does "prefix" mean? The prefix is the directory where the compiled software will be installed. By setting it to /opt/mesa-git, you make sure your custom Mesa doesn't interfere with the system version.

meson setup build/ \
  -Dprefix=/opt/mesa-git \
  -Dplatforms=x11,wayland \
  -Dvulkan-drivers=amd

Note: Replace amd with the Vulkan driver that matches your GPU. Valid options include intel, nouveau, swrast, auto, or all.

Explanation of Build Flags

Flag Description
-Dprefix Specifies the installation directory (in our case /opt/mesa-git).
-Dplatforms Build support for, amongst other backends, X11 and Wayland.
-Dvulkan-drivers Vulkan drivers to include (e.g. intel, amd, etc.)

You can then compile Mesa:

meson compile -C build/

Installing Mesa

Install the compiled Mesa build:

sudo meson install -C build/

This requires sudo because we're installing into /opt, which is a system directory only writable by administrators.

After installation, Mesa will reside in /opt/mesa-git.


Configuring the Environment

To use your custom Mesa build, you must configure the system to prioritize the new libraries.

What is /etc/environment? /etc/environment is a system-wide configuration file that sets environment variables for all users and programs. By editing this file, you tell your system to use your custom Mesa libraries and drivers by default.

Persistent Setup

Edit /etc/environment:

sudo nano /etc/environment

Add or update the following lines:

LD_LIBRARY_PATH="/opt/mesa-git/lib64:$LD_LIBRARY_PATH"
OCL_ICD_VENDORS="/opt/mesa-git/etc/OpenCL/vendors"
VK_DRIVER_FILES="/opt/mesa-git/share/vulkan/icd.d/radeon_icd.x86_64.json"

What do these variables do?

  • LD_LIBRARY_PATH tells the system where to look for shared libraries (like Mesa's).
  • OCL_ICD_VENDORS tells OpenCL programs where to find vendor-specific drivers.
  • VK_DRIVER_FILES tells Vulkan programs which driver files to use.

Replace radeon_icd.x86_64.json with the appropriate file for your hardware. To find it, run:

ls /opt/mesa-git/share/vulkan/icd.d/

Testing

If you want to test your Mesa build before applying it system-wide, you can temporarily set the environment variables in your current terminal session:

export LD_LIBRARY_PATH="/opt/mesa-git/lib64:$LD_LIBRARY_PATH"
export OCL_ICD_VENDORS="/opt/mesa-git/etc/OpenCL/vendors"
export VK_DRIVER_FILES="/opt/mesa-git/share/vulkan/icd.d/radeon_icd.x86_64.json"

Tip: These export commands only affect the current terminal window. Once you close it, your system will go back to using the default Mesa.

Then check if Mesa is being used:

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 25.2.0-devel (git-4339cf0aff)

If both commands return output from your custom Mesa build, you're all set! Feel free to now reboot and repeat the steps in this section to see if they were applied correctly by /etc/environment.


Summary

You've now installed and configured a bleeding-edge version of Mesa on Fedora without overwriting your system libraries. This setup is ideal for testing, development, or gaming with the latest Mesa features while preserving system stability.

Known Issues

  • This will work fine for applications that are ran natively. For sandboxed applications like Snaps and Flatpaks this might cause problems if they need hardware acceleration. Since I don't use flatpaks or Snaps I will not be trying to figure out how to overcome the issues. If you know how to fix it feel free to reach out.
@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

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