Overclock.net › Forums › Software, Programming and Coding › Operating Systems › Linux, Unix › Guide: Building Mesa 17.0.x on Debian 9.1.0
New Posts  All Forums:Forum Nav:

Guide: Building Mesa 17.0.x on Debian 9.1.0

post #1 of 3
Thread Starter 
I've updated my instructions for how to build the 17.0 branch of Mesa using a fresh install of Debian 9.1.0. This is for what is currently the latest release of Debian, but it is for the last release of the one-behind-current branch of Mesa (17.1). This is because Mesa 17.1 requires libdrm 2.4.75 or later, and Debian 9 is stuck with 2.4.74. You could install the libdrm2 package from testing if you're dying for Mesa 17.1. It's not currently in backports.

In any case, this short tutorial will get you going with 17.0.7. The guide assumes you're on a 64-bit machine doing a 64-bit build. The process for the 32-bit build is identical except you should be doing it with a 32-bit install of Debian and references to "64" would need to be "32" during the post-compile move/install phase.

Step 0) Technically optional but strongly suggested: I suggest you compile in a virtual machine with a fresh install of Debian 9.1.0 instead of relying on your main system. If something goes wrong, it won't toast your machine. You'll have to do this anyway if you want to cross-compile for 32-bit from a 64-bit system so you may as well do it for your native build too and keep things clean. Cross compiling is technically supported without resorting to a virtual machine, but I've found things move a lot more smoothly by not trying to invoke that build method. You'll need to have both 32-bit and 64-bit libs on a 64-bit system if you use any 3D applications that are 32-bit like Steam or older games.

Step 1) Fix bash auto-completion (a quality-of-life feature missing by default in Debian 9)
sudo apt-get -y install bash-completion
source /etc/bash_completion

Step 2) Satisfy Mesa build dependencies
sudo apt-get -y install build-essential
sudo apt-get -y install libdrm-dev libva-dev libvdpau-dev libclc-dev libxvmc-dev zlib1g
sudo apt-get -y build-dep mesa

Step 3) Fix missing symlink to llvm-config. Debian 9 comes with llvm 3.9, so that is what we'll use. It's new enough to compile all of the pieces of mesa we plan to use.
sudo ln -s /usr/bin/llvm-config-3.9 /usr/bin/llvm-config

Step 4) Fetch the Mesa source code for the latest 17.0 branch release. This will forevermore be 17.0.7 since it's the end of that branch. It's dated June 2017 so still pretty recent.
sudo apt-get install -y git
mkdir ~/mesa
git clone -b 17.0 git://anongit.freedesktop.org/mesa/mesa ~/mesa

Step 5) Configure and build Mesa
cd ~/mesa
autoreconf -vfi
./configure --prefix=/usr --enable-driglx-direct --enable-gles1 --enable-gles2 --enable-glx-tls --with-dri-driverdir=/usr/lib/dri --with-platforms='drm x11' --with-gallium-drivers=radeonsi,swrast --enable-texture-float --enable-shared-glapi --enable-glx --enable-gbm --enable-openmax --enable-xa --enable-osmesa --with-radeonsi-llvm-compiler --enable-sysfs --enable-vdpau --enable-xvmc --enable-nine
time make -j8

Notes: You could make install at this point if you compiled mesa with your target machine, but it's better to not overwrite your system's libraries. You would ideally be using a virtual machine to compile with anyway. The number after the -j switch defines how many threads to use for compiling. Some of the configure options are hard to track down, but I found a similar guide published by Nick Congleton at some point between when I published my first build guide last year and now. He had added some of those comfigure flags which seem to enable various features I hadn't previously known about.

Step 6) Squish the resulting libraries together
cd ~/mesa/lib
mv gallium/* .
rmdir gallium

Step 7) Move the libraries from your virtual machine to your target machine and install them into a permanent location. I currently use tar to archive the libs, move the archive using sftp, and extract the archive into a permanent folder on the target system. That said, there are any number of ways to do it so I leave that decision to you. If you archive the libs, make sure you use an archiver that understands symlinks or else you will not end up with a working copy on the target system.

I like to store the libs at:
/usr/lib/mesa/VERSION/BITNESS

Ex:
/usr/lib/mesa/17.0.7/64
/usr/lib/mesa/17.0.7/32

I use tar to compress them like:
cd ~/mesa/lib
tar -caf ~/mesa_17.0.7_64.tar.gz *

And I decompress them like:
sudo tar -C /usr/lib/mesa/17.0.7/64 -xf ~/mesa_17.0.7_64.tar.gz

Step 8) Launch a program using your custom libraries instead of the system libraries. I'll demonstrate with glxinfo so you can see if acceleration is working and what OpenGL version is reported as being supported. You could just as easily launch steam here or a game like darkplaces. I suggest putting this all into a shell script since the exported variables only survive during the terminal session they're defined in.

MESAVER=17.0.7
export LIBGL_DRIVERS_PATH=/usr/lib/mesa/${MESAVER}/64:/usr/lib/mesa/${MESAVER}/32
export LD_LIBRARY_PATH=/usr/lib/mesa/${MESAVER}/64:/usr/lib/mesa/${MESAVER}/32
export EGL_DRIVERS_PATH=/usr/lib/mesa/${MESAVER}/64:/usr/lib/mesa/${MESAVER}/32
glxinfo | grep OpenGL
Edited by Particle - 8/15/17 at 6:35am
post #2 of 3
Thread Starter 
I just built Mesa 17.3.0-rc5 on Debian 9.2. It requires a few changes:

Regular Dependencies:
sudo apt-get -y install libdrm-dev libva-dev libvdpau-dev libclc-dev libxvmc-dev zlib1g zlib1g-dev

Bad Dependencies
libdrm-dev must be updated before you will be able to build anything newer than Mesa 17.0. You'll have to pull this from Sid or build it yourself. I did this the "bad" way by pulling the packages from Sid's repos and installing them directly using dpkg. Doing this through apt would be a vastly superior approach, but I've not had luck with source pinning in Apt. Once these packages are installed manually, it will be necessary to pull future updates for them manually! They will no longer update through apt since newer versions will never be published to Stretch's repos.

https://packages.debian.org/sid/libdrm-dev

Required packages:
libdrm2_2.4.88-1_amd64.deb
libdrm2_2.4.88-1_i386.deb
libdrm-common_2.4.88-1_all.deb
libdrm-amdgpu1_2.4.88-1_amd64.deb
libdrm-amdgpu1_2.4.88-1_i386.deb
libdrm-intel1_2.4.88-1_amd64.deb
libdrm-intel1_2.4.88-1_i386.deb
libdrm-nouveau2_2.4.88-1_amd64.deb
libdrm-nouveau2_2.4.88-1_i386.deb
libdrm-radeon1_2.4.88-1_amd64.deb
libdrm-radeon1_2.4.88-1_i386.deb
libdrm-dev_2.4.88-1_amd64.deb
libdrm-dev_2.4.88-1_i386.deb

You can probably omit the 32-bit packages if your system isn't multi-arch. I have Steam installed, so I had to update both.

Once these things were installed, I was able to build mesa 17.3.0-rc5 successfully.
post #3 of 3
I'd also like to point out that the dri3 framework can break certain things (you may notice FPS locked to 60 in all applications randomly after switching to Mesa17 with dri3)
You can disable dri3 if you run into problems by putting:
Code:
LIBGL_DRI3_DISABLE=1
in /etc/environment.
    
CPUMotherboardGraphicsRAM
Core i7 920 D0 4.2ghz HT (1.3625v) Asus R3E 2xGTX 460 (non SLi, no overclock) 6x2gb G.skill @ 6-8-6-24-1T 
Hard DriveOptical DriveOSMonitor
WD-VR 300GBx1, 2xWD 1tb,2x60gb Agility Some crappy combo burner... Arch x64 3xDell U2410f rev A02 
KeyboardPowerCaseMouse
X-Armor U9BL TT Toughpower 1200w (NTB more efficient) Mountain Mods Pinnacle 24 CYO Roccat Kone (R.I.P. A4Tech x7) 
Mouse Pad
Steelpad Experience I-1 
  hide details  
Reply
    
CPUMotherboardGraphicsRAM
Core i7 920 D0 4.2ghz HT (1.3625v) Asus R3E 2xGTX 460 (non SLi, no overclock) 6x2gb G.skill @ 6-8-6-24-1T 
Hard DriveOptical DriveOSMonitor
WD-VR 300GBx1, 2xWD 1tb,2x60gb Agility Some crappy combo burner... Arch x64 3xDell U2410f rev A02 
KeyboardPowerCaseMouse
X-Armor U9BL TT Toughpower 1200w (NTB more efficient) Mountain Mods Pinnacle 24 CYO Roccat Kone (R.I.P. A4Tech x7) 
Mouse Pad
Steelpad Experience I-1 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Linux, Unix
Overclock.net › Forums › Software, Programming and Coding › Operating Systems › Linux, Unix › Guide: Building Mesa 17.0.x on Debian 9.1.0