about summary refs log tree commit diff
path: root/pkgs/by-name/xe
diff options
context:
space:
mode:
authortoonn2024-06-28 15:34:59 +0200
committertoonn2024-07-30 00:17:15 +0200
commitd95b9673ca7e89fdd164df9f2d50e97e199fdc08 (patch)
tree4dedac51fcb80e56918859a14851251d8d5889bf /pkgs/by-name/xe
parent2b430b6f10da043bf4297a302c90a61a2bf8630a (diff)
xeve: Fix Darwin build
Diffstat (limited to 'pkgs/by-name/xe')
-rw-r--r--pkgs/by-name/xe/xeve/0001-CMakeLists.txt-Disable-static-linking-on-Darwin.patch27
-rw-r--r--pkgs/by-name/xe/xeve/0002-sse2neon-Cast-to-variable-type.patch27
-rw-r--r--pkgs/by-name/xe/xeve/package.nix67
3 files changed, 113 insertions, 8 deletions
diff --git a/pkgs/by-name/xe/xeve/0001-CMakeLists.txt-Disable-static-linking-on-Darwin.patch b/pkgs/by-name/xe/xeve/0001-CMakeLists.txt-Disable-static-linking-on-Darwin.patch
new file mode 100644
index 000000000000..7f4c49562bdc
--- /dev/null
+++ b/pkgs/by-name/xe/xeve/0001-CMakeLists.txt-Disable-static-linking-on-Darwin.patch
@@ -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
+
diff --git a/pkgs/by-name/xe/xeve/0002-sse2neon-Cast-to-variable-type.patch b/pkgs/by-name/xe/xeve/0002-sse2neon-Cast-to-variable-type.patch
new file mode 100644
index 000000000000..b9a9995c8e2e
--- /dev/null
+++ b/pkgs/by-name/xe/xeve/0002-sse2neon-Cast-to-variable-type.patch
@@ -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
+
diff --git a/pkgs/by-name/xe/xeve/package.nix b/pkgs/by-name/xe/xeve/package.nix
index 0788061df416..f8acbee0acc0 100644
--- a/pkgs/by-name/xe/xeve/package.nix
+++ b/pkgs/by-name/xe/xeve/package.nix
@@ -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;
   };
 })