diff --git a/ports/mesa/build.sh b/ports/mesa/build.sh index 4156ed5b..86715646 100755 --- a/ports/mesa/build.sh +++ b/ports/mesa/build.sh @@ -7,7 +7,6 @@ DEPENDENCIES=('zlib' 'zstd' 'expat') CONFIGURE_OPTIONS=( '-Dprefix=/usr' '-Dosmesa=true' - '-Dgallium-drivers=softpipe' '-Dvulkan-drivers=[]' '-Dplatforms=[]' '-Dglx=disabled' @@ -15,7 +14,50 @@ CONFIGURE_OPTIONS=( ) configure() { - meson setup --reconfigure --cross-file "$MESON_CROSS_FILE" "${CONFIGURE_OPTIONS[@]}" build || exit 1 + llvm_version='20.1.8' + llvm_root="../../llvm/llvm-$llvm_version-$BANAN_ARCH" + + gallium_driver=softpipe + + if [ -d "$llvm_root" ]; then + llvm_lib=$(realpath "$llvm_root/build/lib") + + mkdir -p subprojects/llvm + + wrap_file='subprojects/llvm/meson.build' + echo "project('llvm', ['cpp'])" >$wrap_file + echo "" >>$wrap_file + echo "cpp = meson.get_compiler('cpp')" >>$wrap_file + echo "" >>$wrap_file + echo "_deps = []" >>$wrap_file + echo "_search = '$llvm_lib'" >>$wrap_file + echo "foreach d : [" >>$wrap_file + for path in $llvm_lib/libLLVM*.a; do + name=$(basename $path) + echo " '${name:3:-2}'," >>$wrap_file + done + echo " ]" >>$wrap_file + echo " _deps += cpp.find_library(d, dirs : _search)" >>$wrap_file + echo "endforeach" >>$wrap_file + echo "" >>$wrap_file + echo "dep_llvm = declare_dependency(" >>$wrap_file + echo " include_directories : include_directories(" >>$wrap_file + echo " '$(realpath $llvm_root/llvm/include)'," >>$wrap_file + echo " '$(realpath $llvm_root/build/include)'," >>$wrap_file + echo " )," >>$wrap_file + echo " dependencies : _deps," >>$wrap_file + echo " version : '$llvm_version'," >>$wrap_file + echo ")" >>$wrap_file + + gallium_driver=llvmpipe + fi + + meson setup \ + --reconfigure \ + --cross-file "$MESON_CROSS_FILE" \ + "${CONFIGURE_OPTIONS[@]}" \ + "-Dgallium-drivers=$gallium_driver" \ + build || exit 1 } build() { diff --git a/ports/mesa/patches/0005-dont-use-drm-with-llvm.patch b/ports/mesa/patches/0005-dont-use-drm-with-llvm.patch new file mode 100644 index 00000000..566d8648 --- /dev/null +++ b/ports/mesa/patches/0005-dont-use-drm-with-llvm.patch @@ -0,0 +1,21 @@ +diff -ru mesa-25.0.7-banan_os/src/gallium/drivers/llvmpipe/lp_texture.c mesa-25.0.7-x86_64/src/gallium/drivers/llvmpipe/lp_texture.c +--- mesa-25.0.7-banan_os/src/gallium/drivers/llvmpipe/lp_texture.c 2025-05-28 18:20:23.000000000 +0300 ++++ mesa-25.0.7-x86_64/src/gallium/drivers/llvmpipe/lp_texture.c 2025-08-03 19:16:20.254971098 +0300 +@@ -59,7 +59,7 @@ + #include "frontend/sw_winsys.h" + #include "git_sha1.h" + +-#ifndef _WIN32 ++#if !defined(_WIN32) && !defined(__banan_os__) + #include "drm-uapi/drm_fourcc.h" + #endif + +@@ -1713,7 +1713,7 @@ + case PIPE_RESOURCE_PARAM_LAYER_STRIDE: + *value = lpr->img_stride[level]; + return true; +-#ifndef _WIN32 ++#if !defined(_WIN32) && !defined(__banan_os__) + case PIPE_RESOURCE_PARAM_MODIFIER: + *value = lpr->dmabuf ? DRM_FORMAT_MOD_LINEAR : DRM_FORMAT_MOD_INVALID; + return true;