这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions packages/mesa/0013-detect-sve-sve2-support.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
https://github.com/llvm/llvm-project/issues/114987
https://github.com/termux/termux-packages/issues/24544

--- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
+++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
@@ -88,6 +88,23 @@
#include "lp_bld_misc.h"
#include "lp_bld_debug.h"

+#if __has_include(<sys/auxv.h>)
+#include <sys/auxv.h>
+#define HAVE_SYS_AUXV 1
+#ifndef AT_HWCAP
+#define AT_HWCAP 16
+#endif
+#ifndef AT_HWCAP2
+#define AT_HWCAP2 26
+#endif
+#ifndef HWCAP_SVE
+#define HWCAP_SVE (1 << 22)
+#endif
+#ifndef HWCAP2_SVE2
+#define HWCAP2_SVE2 (1 << 1)
+#endif
+#endif
+
static void lp_run_atexit_for_destructors(void);

namespace {
@@ -446,6 +463,29 @@
MAttrs.push_back("-lasx");
#endif
#endif
+
+#if DETECT_ARCH_AARCH64 && defined(HAVE_SYS_AUXV)
+ // Guess SVE/SVE2 support on ARM64
+ bool has_sve = getauxval(AT_HWCAP) & HWCAP_SVE;
+ bool has_sve2 = getauxval(AT_HWCAP2) & HWCAP2_SVE2;
+ MAttrs.push_back(has_sve ? "+sve" : "-sve");
+ MAttrs.push_back(has_sve2 ? "+sve2" : "-sve2");
+#endif
+
+ // Allow adding extra MAttrs through envs
+ char *env_extra_mattrs = getenv("GALLIVM_EXTRA_MATTRS");
+ if (env_extra_mattrs != NULL) {
+ char *dup = strdup(env_extra_mattrs);
+ if (dup != NULL) {
+ char *state;
+ char *token = strtok_r(dup, ",", &state);
+ while (token) {
+ MAttrs.push_back(token);
+ token = strtok_r(NULL, ",", &state);
+ }
+ free(dup);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe set pointer to NULL after free pointer

Copy link
Member Author

@licy183 licy183 May 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I don't think it is necessary. dup is declared as a local variable and only can be used inside the if (env_extra_mattrs != NULL) { scope.

+ }
+ }
}

void
1 change: 1 addition & 0 deletions packages/mesa/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ TERMUX_PKG_LICENSE="MIT"
TERMUX_PKG_LICENSE_FILE="docs/license.rst"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION="25.1.1"
TERMUX_PKG_REVISION=1
_LLVM_MAJOR_VERSION=$(. $TERMUX_SCRIPTDIR/packages/libllvm/build.sh; echo "${LLVM_MAJOR_VERSION}")
_LLVM_MAJOR_VERSION_NEXT=$((_LLVM_MAJOR_VERSION + 1))
TERMUX_PKG_SRCURL=https://archive.mesa3d.org/mesa-${TERMUX_PKG_VERSION}.tar.xz
Expand Down