Running DRM/DRI/Mesa/DDX/Xorg from git on Debian Sid

A lot of the guides out there on how to build the entire X stack from scratch are missing steps or are only for part of the stack. This assumes you’re on Radeon, substitute appropriately for Intel or NVidia (download different driver, use different options with Mesa).

Please note: I haven’t been able to get i386 on amd64 builds to work yet, so if you need to run 32 bit apps on 64 bit, stick with your distro’s build for everything, don’t mix and match.

To get the source:

sudo apt-get build-dep libdrm mesa xserver-xorg-video-ati xorg-server
sudo apt-get install git llvm-3.4-dev libelf-dev linux-headers-`uname -r` build-essential
mkdir xorg && cd xorg
git clone git://anongit.freedesktop.org/git/xorg/util/macros
git clone git://anongit.freedesktop.org/git/xorg/proto/x11proto
git clone git://anongit.freedesktop.org/git/mesa/drm
git clone git://anongit.freedesktop.org/git/xorg/lib/libXau
git clone git://anongit.freedesktop.org/xorg/xserver
git clone git://anongit.freedesktop.org/git/mesa/mesa
git clone git://anongit.freedesktop.org/git/xorg/driver/glamor
git clone git://anongit.freedesktop.org/xorg/driver/xf86-video-ati
git clone git://anongit.freedesktop.org/xorg/driver/xf86-input-evdev

LLVM version
Mesa requires LLVM 3.4 or newer, and Debian Sid is still on 3.3 as default. Until this is fixed, make sure the package llvm-3.3 is not installed, and do ln -s /usr/bin/llvm-config-3.4 /usr/bin/llvm-config

Modify the environment
Add to /etc/environment:

LIBGL_DRIVERS_PATH=/opt/xorg/lib/dri/
R600_DEBUG=sb

Add to /etc/X11/xorg.conf:

Section "Files"
        ModulePath "/opt/xorg/lib/xorg/modules,/usr/lib/xorg/modules"
EndSection

Section "Module"
  Load "dri2"
  Load "glamoregl"
EndSection

… and in the Device section for your video card add Option "AccelMethod" "glamor" and make sure Driver is set to "radeon".

Create /etc/ld.so.conf.d/0-xorg-git.conf:

/opt/xorg/lib

Build the code

export PKG_CONFIG_PATH=/opt/xorg/lib/pkgconfig:\
/opt/xorg/share/pkgconfig:${PKG_CONFIG_PATH}
export LD_LIBRARY_PATH=/opt/xorg/lib:${LD_LIBRARY_PATH}
export LD_RUN_PATH=/opt/xorg/lib:${LD_RUN_PATH}
export LDFLAGS=-L/opt/xorg/lib CPPFLAGS=-I/opt/xorg/include
export ACLOCAL="/usr/bin/aclocal -I /opt/xorg/share/aclocal"

cd macros
./autogen.sh --prefix=/opt/xorg
sudo make install
cd ..

cd x11proto
./autogen.sh --prefix=/opt/xorg
sudo make install
cd ..

cd drm
./autogen.sh --prefix=/opt/xorg
make -j4
sudo make install
cd ..

cd libXau
./autogen.sh --prefix=/opt/xorg
make -j4
sudo make install
cd ..

cd xserver
./autogen.sh --prefix=/opt/xorg --enable-xorg --disable-dmx --disable-xvfb --disable-xnest --disable-xwin
make -j4
sudo make install
cd ..
sudo chown root /opt/xorg/bin/Xorg
sudo chmod u+s /opt/xorg/bin/Xorg
sudo ldconfig
sudo ln -s /usr/bin/xkbcomp /opt/xorg/bin/xkbcomp
sudo ln -s /usr/share/X11/xkb/rules /opt/xorg/share/X11/xkb/rules

cd mesa
export DRI_DRIVERS="radeon,r200"
export GALLIUM_DRIVERS="r300,r600,radeonsi,swrast"
./autogen.sh --prefix=/opt/xorg --with-dri-drivers=$DRI_DRIVERS --with-gallium-drivers=$GALLIUM_DRIVERS --with-egl-platforms=x11,drm --enable-gbm --enable-shared-glapi --enable-glx-tls --enable-driglx-direct --enable-gles1 --enable-gles2 --enable-r600-llvm-compiler --enable-xorg --enable-xa --enable-gallium-egl --enable-gallium-gbm --enable-texture-float
make -j4
sudo make install
cd ..

cd glamor
./autogen.sh --prefix=/opt/xorg
make -j4
sudo make install
cd ..

cd xf86-video-ati
./autogen.sh --prefix=/opt/xorg --enable-glamor
make -j4
sudo make install
cd ..

cd xf86-input-evdev
./autogen.sh --prefix=/opt/xorg
make -j4
sudo make install
cd ..

All you have to do now is tell your XDM to use /opt/xorg/bin/Xorg and then restart it. The Xserver puts its log in /opt/xorg/var/log/Xorg.0.log

Written by
Open Source software architect and technologist. He's just this guy, you know? Follow him him on Google+.
Published in
Transmissions from the Little Blue Marble

Published June 30th, 2013

Comments

2 Responses

When you specify a directory as the target, it creates a link named after the original in that directory. Although, yes, I should change it to clarify.

Thanks for the detailed guide. I managed to get that setup running in a second attempt with a Southern Islands card. One minor nitpick: your link to xkbcomp is missing the right link name, I think.

Leave a Reply