We do often include affiliate links to earn us some pennies. See more here.

Building Mesa from source, a guide

By - | Views: 24,545
If you are using Mesa (FOSS OpenGL/Vulkan drivers on Linux), you can be in situation when it introduces some new features upstream, but it didn't make it into your distribution yet and it can take quite a long time for that to happen. Certain games can become playable with that change, or it can be a performance optimization that speeds up already working games, or may be you simply want to test the newest Mesa itself - either way, you might be interested in running the latest development version of Mesa for various reasons. At the same time you don't want to mess up your system with an unstable graphics stack.

I started a guide on the GamingOnLinux Wiki, to explain how to build and use Mesa for playing games while keeping your system Mesa intact. It's focused on Debian (testing), but you can use same ideas and adjust it to any distribution if you use a different one. Article taken from GamingOnLinux.com.
Tags: HOWTO
12 Likes
The comments on this article are closed.
15 comments
Page: 1/2»
  Go to:

Johners Jan 13, 2017
I personally don't see why Canonical can't push the latest stable Mesa build to their users. It only makes the experience better as there have been massive improvements to Mesa over the past few years.

As for other distributions, it would be nice if they did the same as well but seeing as Ubuntu is the go to the choice for a lot of developers and end users it makes sense for them to do it at least.


Last edited by Johners on 13 January 2017 at 10:14 am UTC
tuubi Jan 13, 2017
View PC info
  • Supporter
@Johners: Ubuntu can't be bleeding edge as long as Canonical wants OEM's to consider it for preloaded systems. Software developers want a somewhat stable target as well. That's why a lot of commercial software only supports Ubuntu (LTS) releases and why basically none of it officially supports rolling release distributions. Also, gaming is still not such an important concern for Linux distros that it would significantly influence their direction.

The PPA system is a working compromise for many Ubuntu users. You don't need to restrict yourself to the official repositories.
M@GOid Jan 13, 2017
Tank you for this. I will try it latter. But for AMD users, LLVM is also a important component when running bleeding edge Mesa, especially if you are looking for fixes of bugs. Can you please do a Wiki for how to build it too?
hardpenguin Jan 13, 2017
This is amazing! Great job!
boltronics Jan 13, 2017
That's more or less the approach I use. The main difference is that I use a chroot which I enter using schroot, and expose /opt from inside it for deployment directly within the chroot. Once installed, I check all 32-bit deps are met using ldd, just to be safe. eg. `find /opt/mesa-master -type f -exec ldd {} \; | grep 'not found' | sort | uniq`

I also use `make install` to install, and am not sure why that wasn't suggested on the wiki. You only need to temporarily allow write access to the target directory (/opt/mesa-master/ in the example) which can easily be reverted afterwards - and the instructions even do this anyway with the `chown root:root` command.

In my case, everything is scripted. I also have LIBGL_DRIVERS_PATH exported from a file in /etc/profile.d/ and I add my custom library paths to a file under /etc/ld.so.conf.d/ and use ldconfig so that's one less environment variable to worry about.

I also avoid setting VK_ICD_FILENAMES by adding ICD JSON files under /etc/vulkan/icd.d, which is within the default search path and doesn't seem touched by any current Debian packages.
BlackBloodRum Jan 13, 2017
View PC info
  • Supporter Plus
Nice job Liam!

This should be a great help for noobs who haven't gotten to compiling yet :-)
Liam Dawe Jan 13, 2017
Quoting: BlackBloodRumNice job Liam Shmerl!

This should be a great help for noobs who haven't gotten to compiling yet :-)
Fixed it for you ;)

Edit: I am currently face-planting into PHP code fixing up some new admin features for GOL, so content from me will come later tonight.


Last edited by Liam Dawe on 13 January 2017 at 3:28 pm UTC
Shmerl Jan 13, 2017
Quoting: M@GOidBut for AMD users, LLVM is also a important component when running bleeding edge Mesa, especially if you are looking for fixes of bugs. Can you please do a Wiki for how to build it too?

Yeah, in theory, you might want to chase the latest developments in the kernel drivers (amdgpu for instance), libdrm and llvm. But that's a whole different level of complexity. This guide assumes that you only update Mesa itself, and all the dependencies are same as the rest of the system. I didn't try building libdrm and llvm myself yet. If I'll get to it, I'll document it on the wiki :)


Last edited by Shmerl on 13 January 2017 at 3:57 pm UTC
Shmerl Jan 13, 2017
Quoting: boltronicsThat's more or less the approach I use. The main difference is that I use a chroot which I enter using schroot, and expose /opt from inside it for deployment directly within the chroot.

Yes, chroot or even a full blown VM is probably a cleaner approach - I mention it in the guide. It's not hard to figure out how to do it, once you know the main process.

Quoting: boltronicsI also use `make install` to install, and am not sure why that wasn't suggested on the wiki. You only need to temporarily allow write access to the target directory (/opt/mesa-master/ in the example) which can easily be reverted afterwards - and the instructions even do this anyway with the `chown root:root` command. In my case, everything is scripted.

You can, but I wanted only a minimal set of files. make install would deploy more stuff, and also if you mess up your prefix by mistake, it will clutter or let alone mess up some system directories. So I'd rather avoid using it in the guide. If you script it all, there is less chance of mistakes once it's tested, then it's more reasonable to use it.

Quoting: boltronicsI also have LIBGL_DRIVERS_PATH exported from a file in /etc/profile.d/ and I add my custom library paths to a file under /etc/ld.so.conf.d/ and use ldconfig so that's one less environment variable to worry about.

I also avoid setting VK_ICD_FILENAMES by adding ICD JSON files under /etc/vulkan/icd.d, which is within the default search path and doesn't seem touched by any current Debian packages.

I didn't want to make global overrides. The whole point was to only use custom Mesa on demand, when you want it, and let the rest of the system and applications use default Mesa. If you are confident that it works well - you can always add those global overrides in /etc/profile.d/ and /etc/vulkan/icd.d as you mentioned.


Last edited by Shmerl on 13 January 2017 at 3:56 pm UTC
Shmerl Jan 13, 2017
Quoting: GuestI don't recommend trying to compile llvm yourself from bleeding edge git. If llvm 3.9 is available, just stick with that (if it's a version less, you won't have full GL4.5 support).

llvm 3.9 is available in Debian testing, yes. Using an unstable compiler is in general not the best idea, unless you really need it for some reason.


Last edited by Shmerl on 13 January 2017 at 7:14 pm UTC
While you're here, please consider supporting GamingOnLinux on:

Reward Tiers: Patreon. Plain Donations: PayPal.

This ensures all of our main content remains totally free for everyone! Patreon supporters can also remove all adverts and sponsors! Supporting us helps bring good, fresh content. Without your continued support, we simply could not continue!

You can find even more ways to support us on this dedicated page any time. If you already are, thank you!
The comments on this article are closed.