Skip to content

Instantly share code, notes, and snippets.

@mxvin
Last active August 2, 2023 15:45
Show Gist options
  • Save mxvin/0ac8f517cf2b7174e1068be13e1dd1fa to your computer and use it in GitHub Desktop.
Save mxvin/0ac8f517cf2b7174e1068be13e1dd1fa to your computer and use it in GitHub Desktop.
[OpenCL & OpenGL] orca icd (legacy) & libgl amdgpu-pro ver 21.20 for GCN 2.0 - PKGBUILD

amdgpu-pro version 21.20 is already deleted from repo.radeon.com/amdgpu This version known as the latest working version available for GCN 2.0 :

refs

originally from https://aur.archlinux.org/pkgbase/amdgpu-pro-installer with git tag 21.20_1271047-2. Thanks Andrew Shark

also https://aur.archlinux.org/packages/opencl-legacy-amdgpu-pro. Thanks HotrodMaster

This PKGBUILD only install opencl and opengl stack. For more of amdgpu-pro, use upstream amdgpu-pro-installer AUR

# Modified to only install OpenGL & OpenCL stack only
# Parts of OpenCL script is from https://aur.archlinux.org/packages/opencl-legacy-amdgpu-pro. Thanks HotrodMaster
# Author: Janusz Lewandowski <[email protected]>
# Contributor: David McFarland <[email protected]>
# Maintainer: Andrew Shark <ashark @at@ linuxcomp.ru>
# Autogenerated from AMD's Packages file
# with https://github.com/Ashark/archlinux-amdgpu-pro/blob/master/gen-PKGBUILD.py
major=21.20
minor=1271047
ubuntu_ver=20.04
pkgbase=amdgpu-pro-installer
pkgname=(
amdgpu-pro-libgl
lib32-amdgpu-pro-libgl
opencl-legacy-amdgpu-pro
lib32-opencl-legacy-amdgpu-pro
)
pkgver=${major}_${minor}
pkgrel=2
arch=('x86_64')
url=https://www.amd.com/en/support/kb/release-notes/rn-amdgpu-unified-linux-21-20
license=('custom: multiple')
groups=('Radeon_Software_for_Linux')
makedepends=('wget')
DLAGENTS='https::/usr/bin/wget --referer https://www.amd.com/en/support/kb/release-notes/rn-amdgpu-unified-linux-21-20 -N %u'
source=(https://drivers.amd.com/drivers/linux/amdgpu-pro-${major}-${minor}-ubuntu-${ubuntu_ver}.tar.xz
progl
progl.bash-completion)
sha256sums=(8ea051de8c9c6814eb45ce18d102e639bb6edb5786e948b50c5105e3e21978f9
feb74796c3152cbafaba89d96e68a152f209bd3058c7eb0413cbe1ab0764e96f
e32801c38b475cd8df17a407726b86db3de26410f563d688325b4d4314fc5354)
# extracts a debian package
# $1: deb file to extract
extract_deb() {
local tmpdir="$(basename "${1%.deb}")"
rm -Rf "$tmpdir"
mkdir "$tmpdir"
cd "$tmpdir"
ar x "$1"
tar -C "${pkgdir}" -xf data.tar.xz
}
# move ubuntu specific /usr/lib/x86_64-linux-gnu to /usr/lib
# $1: debian package library dir (goes from opt/amdgpu or opt/amdgpu-pro and from x86_64 or i386)
# $2: arch package library dir (goes to usr/lib or usr/lib32)
move_libdir() {
local deb_libdir="$1"
local arch_libdir="$2"
if [ -d "${pkgdir}/${deb_libdir}" ]; then
if [ ! -d "${pkgdir}/${arch_libdir}" ]; then
mkdir -p "${pkgdir}/${arch_libdir}"
fi
mv -t "${pkgdir}/${arch_libdir}/" "${pkgdir}/${deb_libdir}"/*
find ${pkgdir} -type d -empty -delete
fi
}
# move copyright file to proper place and remove debian changelog
move_copyright() {
find ${pkgdir}/usr/share/doc -name "changelog.Debian.gz" -delete
mkdir -p ${pkgdir}/usr/share/licenses/${pkgname}
find ${pkgdir}/usr/share/doc -name "copyright" -exec mv {} ${pkgdir}/usr/share/licenses/${pkgname} \;
find ${pkgdir}/usr/share/doc -type d -empty -delete
}
package_amdgpu-pro-libgl () {
pkgdesc="AMDGPU Pro OpenGL driver"
license=('custom: AMDGPU-PRO EULA')
provides=('libgl')
depends=("libdrm" "libx11" "libxcb" "libxdamage" "libxext" "libxfixes" "libxxf86vm")
backup=(etc/amd/amdapfxx.blb)
extract_deb "${srcdir}"/amdgpu-pro-${major}-${minor}-ubuntu-${ubuntu_ver}/libegl1-amdgpu-pro_${major}-${minor}_amd64.deb
extract_deb "${srcdir}"/amdgpu-pro-${major}-${minor}-ubuntu-${ubuntu_ver}/libgl1-amdgpu-pro-appprofiles_${major}-${minor}_all.deb
extract_deb "${srcdir}"/amdgpu-pro-${major}-${minor}-ubuntu-${ubuntu_ver}/libgl1-amdgpu-pro-dri_${major}-${minor}_amd64.deb
extract_deb "${srcdir}"/amdgpu-pro-${major}-${minor}-ubuntu-${ubuntu_ver}/libgl1-amdgpu-pro-ext_${major}-${minor}_amd64.deb
extract_deb "${srcdir}"/amdgpu-pro-${major}-${minor}-ubuntu-${ubuntu_ver}/libgl1-amdgpu-pro-glx_${major}-${minor}_amd64.deb
extract_deb "${srcdir}"/amdgpu-pro-${major}-${minor}-ubuntu-${ubuntu_ver}/libglapi1-amdgpu-pro_${major}-${minor}_amd64.deb
extract_deb "${srcdir}"/amdgpu-pro-${major}-${minor}-ubuntu-${ubuntu_ver}/libgles2-amdgpu-pro_${major}-${minor}_amd64.deb
move_copyright
# extra_commands:
move_libdir "usr/lib/x86_64-linux-gnu" "usr/lib"
move_libdir "opt/amdgpu-pro/lib/x86_64-linux-gnu" "usr/lib/amdgpu-pro"
move_libdir "opt/amdgpu-pro/lib/xorg" "usr/lib/amdgpu-pro/xorg"
move_libdir "opt/amdgpu/share/drirc.d" "usr/share/drirc.d"
sed -i "s|/opt/amdgpu-pro/lib/x86_64-linux-gnu|#/usr/lib/amdgpu-pro # commented to prevent problems of booting with amdgpu-pro, use progl script|" "${pkgdir}"/etc/ld.so.conf.d/10-amdgpu-pro-x86_64.conf
install -Dm755 "${srcdir}"/progl "${pkgdir}"/usr/bin/progl
install -Dm755 "${srcdir}"/progl.bash-completion "${pkgdir}"/usr/share/bash-completion/completions/progl
# For some reason, applications started with normal OpenGL (i.e. without ag pro) crashes at launch if this conf file is presented, so hide it for now, until I find out the reason of that.
mv "${pkgdir}"/usr/share/drirc.d/10-amdgpu-pro.conf "${pkgdir}"/usr/share/drirc.d/10-amdgpu-pro.conf.hide
}
package_lib32-amdgpu-pro-libgl () {
pkgdesc="AMDGPU Pro OpenGL driver (32-bit)"
license=('custom: AMDGPU-PRO EULA')
provides=('lib32-libgl')
depends=("amdgpu-pro-libgl=${major}_${minor}-${pkgrel}" "lib32-libdrm" "lib32-libx11" "lib32-libxcb" "lib32-libxdamage" "lib32-libxext" "lib32-libxfixes" "lib32-libxxf86vm")
backup=(etc/amd/amdrc etc/ld.so.conf.d/10-amdgpu-pro-i386.conf)
extract_deb "${srcdir}"/amdgpu-pro-${major}-${minor}-ubuntu-${ubuntu_ver}/libegl1-amdgpu-pro_${major}-${minor}_i386.deb
extract_deb "${srcdir}"/amdgpu-pro-${major}-${minor}-ubuntu-${ubuntu_ver}/libgl1-amdgpu-pro-dri_${major}-${minor}_i386.deb
extract_deb "${srcdir}"/amdgpu-pro-${major}-${minor}-ubuntu-${ubuntu_ver}/libgl1-amdgpu-pro-ext_${major}-${minor}_i386.deb
extract_deb "${srcdir}"/amdgpu-pro-${major}-${minor}-ubuntu-${ubuntu_ver}/libgl1-amdgpu-pro-glx_${major}-${minor}_i386.deb
extract_deb "${srcdir}"/amdgpu-pro-${major}-${minor}-ubuntu-${ubuntu_ver}/libglapi1-amdgpu-pro_${major}-${minor}_i386.deb
extract_deb "${srcdir}"/amdgpu-pro-${major}-${minor}-ubuntu-${ubuntu_ver}/libgles2-amdgpu-pro_${major}-${minor}_i386.deb
move_copyright
# extra_commands:
rm "${pkgdir}"/etc/amd/amdrc "${pkgdir}"/opt/amdgpu-pro/lib/xorg/modules/extensions/libglx.so "${pkgdir}"/opt/amdgpu/share/drirc.d/10-amdgpu-pro.conf
move_libdir "usr/lib/i386-linux-gnu" "usr/lib32"
move_libdir "opt/amdgpu-pro/lib/i386-linux-gnu" "usr/lib32/amdgpu-pro"
sed -i "s|/opt/amdgpu-pro/lib/i386-linux-gnu|#/usr/lib32/amdgpu-pro # commented to prevent problems of booting with amdgpu-pro, use progl32 script|" "${pkgdir}"/etc/ld.so.conf.d/10-amdgpu-pro-i386.conf
}
patch64() {
touch ${pkgdir}/etc/OpenCL/vendors/amdocl-orca.icd
echo libamdocl-orca.so >> ${pkgdir}/etc/OpenCL/vendors/amdocl-orca.icd
touch ${pkgdir}/etc/OpenCL/vendors/amdocl-orca-ld-64.icd
echo /usr/lib/libamdocl-orca64.so >> ${pkgdir}/etc/OpenCL/vendors/amdocl-orca-ld-64.icd
ln -s /usr/lib/libamdocl-orca64.so ${pkgdir}/usr/lib/libamdocl-orca.so
}
patch32() {
touch ${pkgdir}/etc/OpenCL/vendors/amdocl-orca-ld-32.icd
echo /usr/lib32/libamdocl-orca32.so >> ${pkgdir}/etc/OpenCL/vendors/amdocl-orca-ld-32.icd
ln -s /usr/lib32/libamdocl-orca32.so ${pkgdir}/usr/lib32/libamdocl-orca.so
}
package_opencl-legacy-amdgpu-pro () {
pkgdesc="Legacy non-free AMD OpenCL ICD Loaders (PAL)"
license=('custom: AMDGPU-PRO EULA')
conflicts=('opencl-amd')
provides=("opencl-orca-amdgpu-pro-icd" "opencl-driver")
optdepends=('clinfo' 'rocm-opencl-runtime')
extract_deb "${srcdir}"/amdgpu-pro-${major}-${minor}-ubuntu-${ubuntu_ver}/opencl-orca-amdgpu-pro-icd_${major}-${minor}_amd64.deb
move_libdir "opt/amdgpu-pro/lib/x86_64-linux-gnu" "usr/lib"
move_copyright
patch64
}
package_lib32-opencl-legacy-amdgpu-pro () {
pkgdesc="Legacy non-free AMD OpenCL ICD Loaders (PAL) (32-bit)"
license=('custom: AMDGPU-PRO EULA')
depends=("opencl-legacy-amdgpu-pro")
conflicts=('opencl-amd')
provides=("lib32-opencl-orca-amdgpu-pro-icd" "lib32-opencl-driver")
extract_deb "${srcdir}"/amdgpu-pro-${major}-${minor}-ubuntu-${ubuntu_ver}/opencl-orca-amdgpu-pro-icd_${major}-${minor}_i386.deb
move_libdir "opt/amdgpu-pro/lib/i386-linux-gnu" "usr/lib32"
move_copyright
patch32
}
#!/bin/bash
# This script applies amdgpu-pro OpenGL driver for specific application.
# For example, running "$ progl davinci-resolve" will start DR with AMDGPU PRO driver.
# You can test the difference (GL_VENDOR, GL_RENDERER, GL_VERSION) with glmark2 utility.
progl() {
export LD_LIBRARY_PATH="/usr/lib/amdgpu-pro/:${LD_LIBRARY_PATH}"
# export LIBGL_DRIVERS_PATH="/usr/lib/dri/" # unneeded, because already a system path
}
progl32() {
export LD_LIBRARY_PATH="/usr/lib32/amdgpu-pro/:${LD_LIBRARY_PATH}"
# export LIBGL_DRIVERS_PATH="/usr/lib32/dri/" # unneeded, because already a system path
}
# export dri_driver="amdgpu" # Do not know if needed, there is already a file in drirc.d, is not it sufficient?
if [[ $(basename $0) == progl ]]; then
progl
elif [[ $(basename $0) == progl32 ]]; then
progl32
else
echo "Unknown function"
exit 1
fi
# applied variables, now execute the rest of the command
"$@"
_have progl && complete -F _command progl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment