2016-09-22 02:42:16 +01:00
|
|
|
{ stdenv, fetchurl, elfutils, mesa_noglu
|
|
|
|
, xorg, patchelf, openssl, libdrm, libudev
|
|
|
|
, libxcb, libxshmfence, epoxy, perl, zlib
|
2016-10-28 03:10:44 +01:00
|
|
|
, fetchFromGitHub, ncurses
|
2016-09-22 02:42:16 +01:00
|
|
|
, libsOnly ? false, kernel ? null
|
|
|
|
}:
|
|
|
|
|
|
|
|
assert (!libsOnly) -> kernel != null;
|
|
|
|
|
|
|
|
with stdenv.lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
kernelDir = if libsOnly then null else kernel.dev;
|
|
|
|
|
|
|
|
inherit (mesa_noglu) driverLink;
|
|
|
|
|
|
|
|
bitness = if stdenv.is64bit then "64" else "32";
|
|
|
|
|
|
|
|
libArch =
|
|
|
|
if stdenv.system == "i686-linux" then
|
|
|
|
"i386-linux-gnu"
|
|
|
|
else if stdenv.system == "x86_64-linux" then
|
|
|
|
"x86_64-linux-gnu"
|
|
|
|
else throw "amdgpu-pro is Linux only. Sorry. The build was stopped.";
|
|
|
|
|
|
|
|
libReplaceDir = "/usr/lib/${libArch}";
|
|
|
|
|
2016-10-28 03:10:44 +01:00
|
|
|
ncurses5 = ncurses.override { abiVersion = "5"; };
|
|
|
|
|
2016-09-22 02:42:16 +01:00
|
|
|
in stdenv.mkDerivation rec {
|
|
|
|
|
2017-04-08 19:34:26 +01:00
|
|
|
version = "17.10";
|
2016-09-22 02:42:16 +01:00
|
|
|
pname = "amdgpu-pro";
|
2017-04-08 19:34:26 +01:00
|
|
|
build = "${version}-401251";
|
2016-09-22 02:42:16 +01:00
|
|
|
|
|
|
|
libCompatDir = "/run/lib/${libArch}";
|
|
|
|
|
|
|
|
name = pname + "-" + version + (optionalString (!libsOnly) "-${kernelDir.version}");
|
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url =
|
2016-10-28 03:10:44 +01:00
|
|
|
"https://www2.ati.com/drivers/linux/ubuntu/amdgpu-pro-${build}.tar.xz";
|
2017-04-08 19:34:26 +01:00
|
|
|
sha256 = "004n0df8acjpjz72z3bjxb2a0b7qwln13jlknfn7xxqvhhwwy40a";
|
2016-10-28 03:10:44 +01:00
|
|
|
curlOpts = "--referer http://support.amd.com/en-us/kb-articles/Pages/AMD-Radeon-GPU-PRO-Linux-Beta-Driver%e2%80%93Release-Notes.aspx";
|
2016-10-27 02:50:56 +01:00
|
|
|
};
|
|
|
|
|
2016-09-22 02:42:16 +01:00
|
|
|
hardeningDisable = [ "pic" "format" ];
|
|
|
|
|
|
|
|
inherit libsOnly;
|
|
|
|
|
|
|
|
postUnpack = ''
|
|
|
|
cd $sourceRoot
|
|
|
|
mkdir root
|
|
|
|
cd root
|
2016-10-28 03:10:44 +01:00
|
|
|
for deb in ../*_all.deb ../*_i386.deb '' + optionalString stdenv.is64bit "../*_amd64.deb" + ''; do echo $deb; ar p $deb data.tar.xz | tar -xJ; done
|
2016-09-22 02:42:16 +01:00
|
|
|
sourceRoot=.
|
|
|
|
'';
|
|
|
|
|
|
|
|
modulePatches = [
|
2017-01-28 21:10:50 +00:00
|
|
|
./patches/0001-disable-firmware-copy.patch
|
|
|
|
./patches/0002-linux-4.9-fixes.patch
|
|
|
|
./patches/0003-Change-seq_printf-format-for-64-bit-context.patch
|
|
|
|
./patches/0004-fix-warnings-for-Werror.patch
|
2016-09-22 02:42:16 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
patchPhase = optionalString (!libsOnly) ''
|
|
|
|
pushd usr/src/amdgpu-pro-${build}
|
2016-10-28 03:10:44 +01:00
|
|
|
for patch in $modulePatches
|
2016-10-27 02:50:56 +01:00
|
|
|
do
|
|
|
|
echo $patch
|
|
|
|
patch -f -p1 < $patch || true
|
|
|
|
done
|
2016-09-22 02:42:16 +01:00
|
|
|
popd
|
|
|
|
'';
|
|
|
|
|
|
|
|
preBuild = optionalString (!libsOnly) ''
|
2017-01-28 21:10:50 +00:00
|
|
|
pushd usr/src/amdgpu-pro-${build}
|
|
|
|
makeFlags="$makeFlags M=$(pwd)"
|
|
|
|
patchShebangs pre-build.sh
|
|
|
|
./pre-build.sh ${kernel.version}
|
|
|
|
popd
|
2016-09-22 02:42:16 +01:00
|
|
|
'';
|
|
|
|
|
2017-01-28 21:10:50 +00:00
|
|
|
modules = [
|
|
|
|
"amd/amdgpu/amdgpu.ko"
|
|
|
|
"amd/amdkcl/amdkcl.ko"
|
|
|
|
"ttm/amdttm.ko"
|
|
|
|
];
|
|
|
|
|
|
|
|
postBuild = optionalString (!libsOnly)
|
|
|
|
(concatMapStrings (m: "xz usr/src/amdgpu-pro-${build}/${m}\n") modules);
|
|
|
|
|
|
|
|
NIX_CFLAGS_COMPILE = "-Werror";
|
2016-09-22 02:42:16 +01:00
|
|
|
|
|
|
|
makeFlags = optionalString (!libsOnly)
|
|
|
|
"-C ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build modules";
|
|
|
|
|
|
|
|
depLibPath = makeLibraryPath [
|
|
|
|
stdenv.cc.cc.lib xorg.libXext xorg.libX11 xorg.libXdamage xorg.libXfixes zlib
|
2016-10-28 03:10:44 +01:00
|
|
|
xorg.libXxf86vm libxcb libxshmfence epoxy openssl libdrm elfutils libudev ncurses5
|
2016-09-22 02:42:16 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out
|
2016-10-28 03:10:44 +01:00
|
|
|
|
2016-09-22 02:42:16 +01:00
|
|
|
cp -r etc $out/etc
|
2016-10-28 03:10:44 +01:00
|
|
|
cp -r lib $out/lib
|
|
|
|
|
|
|
|
pushd usr
|
|
|
|
cp -r lib/${libArch}/* $out/lib
|
|
|
|
'' + optionalString (!libsOnly) ''
|
|
|
|
cp -r src/amdgpu-pro-${build}/firmware $out/lib/firmware
|
|
|
|
'' + ''
|
|
|
|
cp -r share $out/share
|
|
|
|
popd
|
|
|
|
|
|
|
|
pushd opt/amdgpu-pro
|
|
|
|
'' + optionalString (!stdenv.is64bit) ''
|
|
|
|
cp -r bin $out/bin
|
|
|
|
'' + ''
|
|
|
|
cp -r include $out/include
|
|
|
|
cp -r lib/${libArch}/* $out/lib
|
|
|
|
'' + optionalString (!libsOnly) ''
|
|
|
|
mv lib/xorg $out/lib/xorg
|
|
|
|
'' + ''
|
|
|
|
popd
|
|
|
|
|
2017-01-28 21:10:50 +00:00
|
|
|
'' + optionalString (!libsOnly)
|
|
|
|
(concatMapStrings (m:
|
|
|
|
"install -Dm444 usr/src/amdgpu-pro-${build}/${m}.xz $out/lib/modules/${kernel.modDirVersion}/kernel/drivers/gpu/drm/${m}.xz\n") modules)
|
|
|
|
+ ''
|
2016-10-28 03:10:44 +01:00
|
|
|
mv $out/etc/vulkan $out/share
|
2016-09-22 02:42:16 +01:00
|
|
|
interpreter="$(cat $NIX_CC/nix-support/dynamic-linker)"
|
|
|
|
libPath="$out/lib:$out/lib/gbm:$depLibPath"
|
2016-10-28 03:10:44 +01:00
|
|
|
'' + optionalString (!stdenv.is64bit) ''
|
|
|
|
for prog in clinfo modetest vbltest kms-universal-planes kms-steal-crtc modeprint amdgpu_test kmstest proptest; do
|
|
|
|
patchelf --interpreter "$interpreter" --set-rpath "$libPath" "$out/bin/$prog"
|
2016-09-22 02:42:16 +01:00
|
|
|
done
|
2016-10-28 03:10:44 +01:00
|
|
|
'' + ''
|
|
|
|
ln -s ${makeLibraryPath [ncurses5]}/libncursesw.so.5 $out/lib/libtinfo.so.5
|
2016-09-22 02:42:16 +01:00
|
|
|
'';
|
|
|
|
|
2016-10-28 03:10:44 +01:00
|
|
|
# we'll just set the full rpath on everything to avoid having to track down dlopen problems
|
2016-09-22 02:42:16 +01:00
|
|
|
postFixup = assert (stringLength libReplaceDir == stringLength libCompatDir); ''
|
|
|
|
libPath="$out/lib:$out/lib/gbm:$depLibPath"
|
2016-10-28 03:10:44 +01:00
|
|
|
for lib in `find "$out/lib/" -name '*.so*' -type f`; do
|
|
|
|
patchelf --set-rpath "$libPath" "$lib"
|
2016-09-22 02:42:16 +01:00
|
|
|
done
|
|
|
|
for lib in libEGL.so.1 libGL.so.1.2 ${optionalString (!libsOnly) "xorg/modules/extensions/libglx.so"} dri/amdgpu_dri.so; do
|
2016-10-28 03:10:44 +01:00
|
|
|
perl -pi -e 's:${libReplaceDir}:${libCompatDir}:g' "$out/lib/$lib"
|
2016-09-22 02:42:16 +01:00
|
|
|
done
|
2016-10-28 03:10:44 +01:00
|
|
|
substituteInPlace "$out/share/vulkan/icd.d/amd_icd${bitness}.json" --replace "/opt/amdgpu-pro/lib/${libArch}" "$out/lib"
|
2016-09-22 02:42:16 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
patchelf
|
|
|
|
perl
|
|
|
|
];
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
description = "AMDGPU-PRO drivers";
|
|
|
|
homepage = http://support.amd.com/en-us/kb-articles/Pages/AMDGPU-PRO-Beta-Driver-for-Vulkan-Release-Notes.aspx ;
|
|
|
|
license = licenses.unfree;
|
|
|
|
platforms = platforms.linux;
|
|
|
|
maintainers = with maintainers; [ corngood ];
|
|
|
|
# Copied from the nvidia default.nix to prevent a store collision.
|
|
|
|
priority = 4;
|
|
|
|
};
|
|
|
|
}
|