etterna: fix build on aarch64-linux (#458263)

This commit is contained in:
Sandro
2025-11-07 17:52:42 +00:00
committed by GitHub
4 changed files with 80 additions and 16 deletions
+1 -1
View File
@@ -207,7 +207,7 @@ stdenv'.mkDerivation (finalAttrs: {
++ lib.optional stdenv.cc.isClang "-DPYTHON_LINKFLAGS=" # Clang doesn't support "-export-dynamic"
++ lib.optionals stdenv.hostPlatform.isDarwin [
"-DLIBDIR=/does-not-exist"
"-DSSE2NEON_INCLUDE_DIR=${sse2neon}/lib"
"-DSSE2NEON_INCLUDE_DIR=${sse2neon}/include"
];
preConfigure = ''
@@ -0,0 +1,61 @@
From 778cb2ed0d56614fd06d2129398799e46ff51720 Mon Sep 17 00:00:00 2001
From: Marcin Serwin <marcin@serwin.dev>
Date: Mon, 3 Nov 2025 22:25:10 +0100
Subject: [PATCH] Add aarch64-linux support
Signed-off-by: Marcin Serwin <marcin@serwin.dev>
---
src/Etterna/Models/Misc/StageStats.cpp | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/src/Etterna/Models/Misc/StageStats.cpp b/src/Etterna/Models/Misc/StageStats.cpp
index 0c70cf25ae..671717505d 100644
--- a/src/Etterna/Models/Misc/StageStats.cpp
+++ b/src/Etterna/Models/Misc/StageStats.cpp
@@ -19,8 +19,9 @@
#include "Etterna/Singletons/GameManager.h"
#include "Etterna/Models/NoteData/NoteDataUtil.h"
-#if !( defined(_WIN32) || defined(__APPLE__))
- #include <cpuid.h> //We only use cpuid.h on Linux :)
+#if !( defined(_WIN32) || defined(__APPLE__)) \
+ && (defined(__x86_64__) || defined(__i386__))
+ #include <cpuid.h> //We only use cpuid.h on x86 Linux :)
#endif
#ifdef _WIN32
@@ -236,6 +237,8 @@ getCpuHash()
#else // !DARWIN
+#if defined(__x86_64__) || defined(__i386__)
+
uint16_t
getCpuHash()
{
@@ -248,6 +251,22 @@ getCpuHash()
return hash;
}
+
+#else // !x86
+
+uint16_t
+getCpuHash()
+{
+ // https://www.kernel.org/doc/html/v6.17/arch/arm64/cpu-feature-registers.html
+ uint64_t midr = 0;
+ asm("mrs %0, MIDR_EL1" : "=r"(midr));
+
+ // Only leave implementer, variant, and architecture bits.
+ // See https://developer.arm.com/documentation/ddi0601/2025-09/AArch64-Registers/MIDR-EL1--Main-ID-Register?lang=en
+ return midr >> 16;
+}
+
+#endif // !x86
#endif // !DARWIN
std::string
--
2.51.0
+10 -1
View File
@@ -27,7 +27,12 @@ stdenv.mkDerivation (finalAttrs: {
hash = "sha256-ZCQt99Qcov/7jGfrSmX9WftaP2U2B1d1APK1mxrUDBs=";
};
patches = [ ./fix-download-manager.patch ];
patches = [
./fix-download-manager.patch
# https://github.com/etternagame/etterna/pull/1396
./0001-Add-aarch64-linux-support.patch
];
nativeBuildInputs = [
cmake
@@ -105,5 +110,9 @@ stdenv.mkDerivation (finalAttrs: {
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ alikindsys ];
mainProgram = "etterna";
platforms = [
"x86_64-linux"
"aarch64-linux"
];
};
})
+8 -14
View File
@@ -1,7 +1,6 @@
{
lib,
fetchFromGitHub,
pkg-config,
stdenv,
}:
@@ -16,24 +15,19 @@ stdenv.mkDerivation (finalAttrs: {
hash = "sha256-vb9k+KjiGodVngza0R18LjfPTlsqFbzqXZqefm6KHj0=";
};
postPatch = ''
# remove warning about gcc < 10
substituteInPlace sse2neon.h --replace-fail "#warning \"GCC versions" "// "
'';
doCheck = true;
nativeBuildInputs = [ pkg-config ];
installPhase = ''
runHook preInstall
dontInstall = true;
# use postBuild instead of installPhase, because the build
# in itself doesn't produce any ($out) output
postBuild = ''
mkdir -p $out/lib
install -m444 sse2neon.h $out/lib/
install -Dm644 sse2neon.h $out/include/sse2neon.h
runHook postInstall
'';
meta = {
description = "Mono library that provides a GDI+-compatible API on non-Windows operating systems";
homepage = "https://www.mono-project.com/docs/gui/libgdiplus/";
description = "C/C++ header file that converts Intel SSE intrinsics to Arm/Aarch64 NEON intrinsics";
homepage = "https://github.com/DLTcollab/sse2neon";
platforms = lib.platforms.unix;
license = lib.licenses.mit;
maintainers = [ lib.maintainers.gador ];