Skip to content

Commit

Permalink
fpylll: fix on Darwin
Browse files Browse the repository at this point in the history
fplll and fpylll both assume support for 128-bit floating point
numbers (long double), which aarch64-darwin does not have.
  • Loading branch information
Feyorsh committed Oct 30, 2023
1 parent 41ff52b commit 7e419ac
Show file tree
Hide file tree
Showing 5 changed files with 445 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
From f83e93b63c8959dc4d944d521fe16ba502dc3ed6 Mon Sep 17 00:00:00 2001
From: George Huebner <huebnerg3@gmail.com>
Date: Sun, 29 Oct 2023 19:00:03 -0500
Subject: [PATCH] disable long doubles on aarch64-darwin

---
fplll/defs.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fplll/defs.h b/fplll/defs.h
index bfc4158d..0e85dc0f 100644
--- a/fplll/defs.h
+++ b/fplll/defs.h
@@ -19,7 +19,7 @@
#ifndef FPLLL_DEFS_H
#define FPLLL_DEFS_H

-#ifndef __CYGWIN__
+#if !defined(__CYGWIN__) && !(defined(__APPLE__) && defined(__aarch64__))
#define FPLLL_WITH_LONG_DOUBLE
#endif

--
2.42.0

4 changes: 4 additions & 0 deletions pkgs/development/libraries/fplll/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ stdenv.mkDerivation rec {
sha256 = "sha256-taSS7jpVyjVfNe6kSuUDXMD2PgKmtG64V5MjZyQzorI=";
};

patches = [
./0001-disable-long-double-on-aarch64-darwin.patch
];

nativeBuildInputs = [
pkg-config
gettext
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
From 93f491930a219c95ddb6203bc2e7ab1a095217ab Mon Sep 17 00:00:00 2001
From: George Huebner <huebnerg3@gmail.com>
Date: Fri, 27 Oct 2023 13:50:57 -0500
Subject: [PATCH] disable long double on aarch64-darwin

Apple Silicon does not have support for long doubles, so they need to
be disabled.
---
setup.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/setup.py b/setup.py
index 274836f..27941c4 100755
--- a/setup.py
+++ b/setup.py
@@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-

import os
+import platform
import subprocess
import sys
import io
@@ -195,7 +196,7 @@ class build_ext(_build_ext, object):
# Ideally this would check the fplll headers explicitly for the
# the FPLLL_WITH_LONG_DOUBLE define, but for now it suffices to
# say that long double support is disabled on Cygwin
- return not sys.platform.startswith("cygwin")
+ return not ((sys.platform.startswith("cygwin") or ("macOS" in (_ := platform.platform()) and "arm" in _)))


# EXTENSIONS
--
2.42.0

Loading

0 comments on commit 7e419ac

Please sign in to comment.