mesa: restore OpenCL support

Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
Co-authored-by: Simon Bruder <simon@sbruder.de>
main
Troels Henriksen 5 years ago committed by Michael Weiss
parent 29d96b23c7
commit b41d29dd31
No known key found for this signature in database
GPG Key ID: 5BE487C4D4771D83
  1. 29
      pkgs/development/libraries/mesa/default.nix
  2. 12
      pkgs/development/libraries/mesa/opencl-install-dir.patch
  3. 70
      pkgs/development/libraries/mesa/opencl.patch

@ -13,6 +13,8 @@
, withValgrind ? !stdenv.isDarwin && lib.meta.availableOn stdenv.hostPlatform valgrind-light, valgrind-light
, enableGalliumNine ? stdenv.isLinux
, enableOSMesa ? stdenv.isLinux
, enableOpenCL ? stdenv.isLinux && stdenv.isx86_64
, libclc
}:
/** Packaging design:
@ -53,7 +55,7 @@ self = stdenv.mkDerivation {
# ~35 MB in $drivers; watch https://launchpad.net/ubuntu/+source/mesa/+changelog
patches = [
./missing-includes.patch # dev_t needs sys/stat.h, time_t needs time.h, etc.-- fixes build w/musl
./opencl-install-dir.patch
./opencl.patch
./disk_cache-include-dri-driver-path-in-cache-key.patch
# Fix `-Werror=int-conversion` pthread warnings on musl.
# TODO: Remove when https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6121 is merged and available
@ -88,7 +90,8 @@ self = stdenv.mkDerivation {
outputs = [ "out" "dev" "drivers" ]
++ lib.optional enableOSMesa "osmesa"
++ lib.optional stdenv.isLinux "driversdev";
++ lib.optional stdenv.isLinux "driversdev"
++ lib.optional enableOpenCL "opencl";
# TODO: Figure out how to enable opencl without having a runtime dependency on clang
mesonFlags = [
@ -118,6 +121,9 @@ self = stdenv.mkDerivation {
"-Dmicrosoft-clc=disabled" # Only relevant on Windows (OpenCL 1.2 API on top of D3D12)
] ++ optionals stdenv.isLinux [
"-Dglvnd=true"
] ++ optionals enableOpenCL [
"-Dgallium-opencl=icd" # Enable the gallium OpenCL frontend
"-Dclang-libdir=${llvmPackages.clang-unwrapped.lib}/lib"
];
buildInputs = with xorg; [
@ -128,6 +134,7 @@ self = stdenv.mkDerivation {
] ++ lib.optionals (elem "wayland" eglPlatforms) [ wayland wayland-protocols ]
++ lib.optionals stdenv.isLinux [ libomxil-bellagio libva-minimal ]
++ lib.optionals stdenv.isDarwin [ libunwind ]
++ lib.optionals enableOpenCL [ libclc llvmPackages.clang llvmPackages.clang-unwrapped ]
++ lib.optional withValgrind valgrind-light;
depsBuildBuild = [ pkg-config ];
@ -162,7 +169,7 @@ self = stdenv.mkDerivation {
if [ -n "$(shopt -s nullglob; echo "$out"/lib/lib*_mesa*)" ]; then
# Move other drivers to a separate output
mv $out/lib/lib*_mesa* $drivers/lib
mv -t $drivers/lib $out/lib/lib*_mesa*
fi
# Update search path used by glvnd
@ -175,6 +182,17 @@ self = stdenv.mkDerivation {
for js in $drivers/share/vulkan/icd.d/*.json; do
substituteInPlace "$js" --replace "$out" "$drivers"
done
'' + optionalString enableOpenCL ''
# Move OpenCL stuff
mkdir -p $opencl/lib
mv -t "$opencl/lib/" \
$out/lib/gallium-pipe \
$out/lib/libMesaOpenCL*
# We construct our own .icd file that contains an absolute path.
rm -r $out/etc/OpenCL
mkdir -p $opencl/etc/OpenCL/vendors/
echo $opencl/lib/libMesaOpenCL.so > $opencl/etc/OpenCL/vendors/mesa.icd
'' + lib.optionalString enableOSMesa ''
# move libOSMesa to $osmesa, as it's relatively big
mkdir -p $osmesa/lib
@ -209,7 +227,10 @@ self = stdenv.mkDerivation {
done
'';
NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin "-fno-common";
NIX_CFLAGS_COMPILE = optionals stdenv.isDarwin [ "-fno-common" ] ++ lib.optionals enableOpenCL [
"-UPIPE_SEARCH_DIR"
"-DPIPE_SEARCH_DIR=\"${placeholder "opencl"}/lib/gallium-pipe\""
];
passthru = {
inherit libdrm;

@ -1,12 +0,0 @@
diff --git a/src/gallium/targets/opencl/meson.build b/src/gallium/targets/opencl/meson.build
index 317ad8dab4a..5567308caf0 100644
--- a/src/gallium/targets/opencl/meson.build
+++ b/src/gallium/targets/opencl/meson.build
@@ -68,6 +68,6 @@ if with_opencl_icd
input : 'mesa.icd.in',
output : 'mesa.icd',
install : true,
- install_dir : join_paths(get_option('sysconfdir'), 'OpenCL', 'vendors'),
+ install_dir : join_paths(get_option('prefix'), 'etc', 'OpenCL', 'vendors'),
)
endif

@ -0,0 +1,70 @@
diff --git a/meson_options.txt b/meson_options.txt
index a7030aba31e..1d2d8814992 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -18,6 +18,12 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
+option(
+ 'clang-libdir',
+ type : 'string',
+ value : '',
+ description : 'Locations to search for clang libraries.'
+)
option(
'platforms',
type : 'array',
diff --git a/src/gallium/targets/opencl/meson.build b/src/gallium/targets/opencl/meson.build
index b77826b6e1e..14fa9ba7177 100644
--- a/src/gallium/targets/opencl/meson.build
+++ b/src/gallium/targets/opencl/meson.build
@@ -30,6 +30,7 @@ if with_ld_version_script
endif
llvm_libdir = dep_llvm.get_variable(cmake : 'LLVM_LIBRARY_DIR', configtool: 'libdir')
+clang_libdir = get_option('clang-libdir')
opencl_libname = with_opencl_icd ? 'MesaOpenCL' : 'OpenCL'
polly_dep = null_dep
@@ -60,19 +61,19 @@ else
endif
if not (dep_clang.found() and dep_clang_usable)
dep_clang = [
- cpp.find_library('clangCodeGen', dirs : llvm_libdir),
- cpp.find_library('clangFrontendTool', dirs : llvm_libdir),
- cpp.find_library('clangFrontend', dirs : llvm_libdir),
- cpp.find_library('clangDriver', dirs : llvm_libdir),
- cpp.find_library('clangSerialization', dirs : llvm_libdir),
- cpp.find_library('clangParse', dirs : llvm_libdir),
- cpp.find_library('clangSema', dirs : llvm_libdir),
- cpp.find_library('clangAnalysis', dirs : llvm_libdir),
- cpp.find_library('clangAST', dirs : llvm_libdir),
- cpp.find_library('clangASTMatchers', dirs : llvm_libdir),
- cpp.find_library('clangEdit', dirs : llvm_libdir),
- cpp.find_library('clangLex', dirs : llvm_libdir),
- cpp.find_library('clangBasic', dirs : llvm_libdir),
+ cpp.find_library('clangCodeGen', dirs : clang_libdir),
+ cpp.find_library('clangFrontendTool', dirs : clang_libdir),
+ cpp.find_library('clangFrontend', dirs : clang_libdir),
+ cpp.find_library('clangDriver', dirs : clang_libdir),
+ cpp.find_library('clangSerialization', dirs : clang_libdir),
+ cpp.find_library('clangParse', dirs : clang_libdir),
+ cpp.find_library('clangSema', dirs : clang_libdir),
+ cpp.find_library('clangAnalysis', dirs : clang_libdir),
+ cpp.find_library('clangAST', dirs : clang_libdir),
+ cpp.find_library('clangASTMatchers', dirs : clang_libdir),
+ cpp.find_library('clangEdit', dirs : clang_libdir),
+ cpp.find_library('clangLex', dirs : clang_libdir),
+ cpp.find_library('clangBasic', dirs : clang_libdir),
polly_dep, polly_isl_dep,
]
# check clang once more
@@ -120,6 +121,6 @@ if with_opencl_icd
input : 'mesa.icd.in',
output : 'mesa.icd',
install : true,
- install_dir : join_paths(get_option('sysconfdir'), 'OpenCL', 'vendors'),
+ install_dir : join_paths(get_option('prefix'), 'etc', 'OpenCL', 'vendors'),
)
endif
Loading…
Cancel
Save