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.
@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

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