xeve: Fix Darwin build

This commit is contained in:
toonn 2024-06-28 15:34:59 +02:00
parent 2b430b6f10
commit d95b9673ca
No known key found for this signature in database
GPG Key ID: 89EECD463032D959
3 changed files with 113 additions and 8 deletions

View File

@ -0,0 +1,27 @@
From f3927c3cb05ffc77f62026bafd7cea1d25de1e72 Mon Sep 17 00:00:00 2001
From: toonn <toonn@toonn.io>
Date: Tue, 2 Jul 2024 19:23:11 +0200
Subject: [PATCH 1/2] CMakeLists.txt: Disable static linking on Darwin
---
CMakeLists.txt | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e0873d5..1d639c4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -64,7 +64,9 @@ if(NOT ARM)
else()
add_definitions(-DARM=1)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flax-vector-conversions")
- set(CMAKE_EXE_LINKER_FLAGS "-static")
+ if(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
+ set(CMAKE_EXE_LINKER_FLAGS "-static")
+ endif()
endif()
message("ARM=${ARM}")
--
2.44.1

View File

@ -0,0 +1,27 @@
From d1a480867c0778ee46ff0213e2b1e494afcb67fc Mon Sep 17 00:00:00 2001
From: toonn <toonn@toonn.io>
Date: Mon, 1 Jul 2024 15:19:37 +0200
Subject: [PATCH 2/2] sse2neon: Cast to variable type
The `__m128d` type corresponds to `float32x4_t` or `float64x2_t`
depending on the platform. The cast cannot explicitly use either type.
---
src_base/neon/sse2neon.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src_base/neon/sse2neon.h b/src_base/neon/sse2neon.h
index 490c0a4..3290fa3 100644
--- a/src_base/neon/sse2neon.h
+++ b/src_base/neon/sse2neon.h
@@ -6003,7 +6003,7 @@ FORCE_INLINE void _mm_storeu_si32(void *p, __m128i a)
FORCE_INLINE void _mm_stream_pd(double *p, __m128d a)
{
#if __has_builtin(__builtin_nontemporal_store)
- __builtin_nontemporal_store(a, (float32x4_t *) p);
+ __builtin_nontemporal_store(a, (__m128d *) p);
#elif defined(__aarch64__)
vst1q_f64(p, vreinterpretq_f64_m128d(a));
#else
--
2.44.1

View File

@ -18,12 +18,36 @@ stdenv.mkDerivation (finalAttrs: {
hash = "sha256-8jXntm/yFme9ZPImdW54jAr11hEsU1K+N5/7RLmITPs=";
};
patches = lib.optionals (!lib.versionOlder "0.5.0" finalAttrs.version) [
(fetchpatch2 {
url = "https://github.com/mpeg5/xeve/commit/954ed6e0494cd2438fd15c717c0146e88e582b33.patch?full_index=1";
hash = "sha256-//NtOUm1fqPFvOM955N6gF+QgmOdmuVunwx/3s/G/J8=";
})
];
patches =
lib.optionals (!lib.versionOlder "0.5.0" finalAttrs.version) (
builtins.map fetchpatch2 [
{
url = "https://github.com/mpeg5/xeve/commit/954ed6e0494cd2438fd15c717c0146e88e582b33.patch?full_index=1";
hash = "sha256-//NtOUm1fqPFvOM955N6gF+QgmOdmuVunwx/3s/G/J8=";
}
{
url = "https://github.com/mpeg5/xeve/commit/07a6f2a6d13dfaa0f73c3752f8cd802c251d8252.patch?full_index=1";
hash = "sha256-P9J7Y9O/lb/MSa5oCfft7z764AbLBLZnMmrmPEZPcws=";
}
{
url = "https://github.com/mpeg5/xeve/commit/0a0f3bd397161253b606bdbeaa518fbe019d24e1.patch?full_index=1";
hash = "sha256-PoZpE64gWkTUS4Q+SK+DH1I1Ac0UEzwwnlvpYN16hsI=";
}
{
url = "https://github.com/mpeg5/xeve/commit/e029f1619ecedbda152b8680641fa10eea9eeace.patch?full_index=1";
hash = "sha256-ooIBzNtGSjDgYvTzA8T0KB+QzsUiy14mPpoRqrHF3Pg=";
}
]
++ [
# Backport to 0.5.0 of upstream patch c564ac77c103dbba472df3e13f4733691fd499ed
./0001-CMakeLists.txt-Disable-static-linking-on-Darwin.patch
]
)
++ [
# Rejected upstream, can be dropped when a fix for
# https://github.com/mpeg5/xeve/pull/123 is in a version bump.
./0002-sse2neon-Cast-to-variable-type.patch
];
postPatch = ''
echo v$version > version.txt
@ -31,6 +55,34 @@ stdenv.mkDerivation (finalAttrs: {
nativeBuildInputs = [ cmake ];
cmakeFlags =
let
inherit (lib) cmakeBool cmakeFeature optional;
inherit (stdenv.hostPlatform) isAarch64 isDarwin;
in
optional isAarch64 (cmakeBool "ARM" true)
++ optional isDarwin (cmakeFeature "CMAKE_SYSTEM_NAME" "Darwin");
env.NIX_CFLAGS_COMPILE = builtins.toString (
builtins.map (w: "-Wno-" + w) (
[
# Patch addressing an if without a body was rejected upstream, third
# line-based comment in this thread, https://github.com/mpeg5/xeve/pull/122#pullrequestreview-2187744305
# Evaluate on version bump whether still necessary.
"empty-body"
# Evaluate on version bump whether still necessary.
"parentheses-equality"
"unknown-warning-option"
]
++ (
# Fixed upstream in 325fd9f94f3fdf0231fa931a31ebb72e63dc3498 but might
# change behavior, therefore opted to leave it out for now.
lib.optional (!lib.versionOlder "0.5.0" finalAttrs.version) "for-loop-analysis"
)
)
);
postInstall = ''
ln $dev/include/xeve/* $dev/include/
'';
@ -50,7 +102,6 @@ stdenv.mkDerivation (finalAttrs: {
mainProgram = "xeve_app";
maintainers = with lib.maintainers; [ jopejoe1 ];
platforms = lib.platforms.all;
# Currently only supports gcc and msvc as compiler, the limitation for clang gets removed in the next release, but that does not fix building on darwin.
broken = !stdenv.hostPlatform.isx86 || !stdenv.cc.isGNU;
broken = stdenv.isLinux && stdenv.isAarch64;
};
})