avy: fixes to work with clang and musl

+149 -1
+19 -1
pkgs/applications/science/logic/avy/default.nix
··· 12 12 }; 13 13 14 14 buildInputs = [ cmake zlib boost.out boost.dev ]; 15 - NIX_CFLAGS_COMPILE = [ "-Wno-narrowing" ]; 15 + NIX_CFLAGS_COMPILE = [ "-Wno-narrowing" ] 16 + # Squelch endless stream of warnings on same few things 17 + ++ stdenv.lib.optionals stdenv.cc.isClang [ 18 + "-Wno-empty-body" 19 + "-Wno-tautological-compare" 20 + "-Wc++11-compat-deprecated-writable-strings" 21 + "-Wno-deprecated" 22 + ]; 23 + 24 + prePatch = '' 25 + sed -i -e '1i#include <stdint.h>' abc/src/bdd/dsd/dsd.h 26 + substituteInPlace abc/src/bdd/dsd/dsd.h --replace \ 27 + '((Child = Dsd_NodeReadDec(Node,Index))>=0);' \ 28 + '((intptr_t)(Child = Dsd_NodeReadDec(Node,Index))>=0);' 29 + 30 + patch -p1 -d minisat -i ${./minisat-fenv.patch} 31 + patch -p1 -d glucose -i ${./glucose-fenv.patch} 32 + ''; 33 + 16 34 patches = 17 35 [ ./0001-no-static-boost-libs.patch 18 36 ];
+65
pkgs/applications/science/logic/avy/glucose-fenv.patch
··· 1 + From d6e0cb60270e8653bda3f339e3a07ce2cd2d6eb0 Mon Sep 17 00:00:00 2001 2 + From: Will Dietz <w@wdtz.org> 3 + Date: Tue, 17 Oct 2017 23:01:36 -0500 4 + Subject: [PATCH] glucose: use fenv to set double precision 5 + 6 + --- 7 + core/Main.cc | 8 ++++++-- 8 + simp/Main.cc | 8 ++++++-- 9 + utils/System.h | 2 +- 10 + 3 files changed, 13 insertions(+), 5 deletions(-) 11 + 12 + diff --git a/core/Main.cc b/core/Main.cc 13 + index c96aadd..994132b 100644 14 + --- a/core/Main.cc 15 + +++ b/core/Main.cc 16 + @@ -96,8 +96,12 @@ int main(int argc, char** argv) 17 + // printf("This is MiniSat 2.0 beta\n"); 18 + 19 + #if defined(__linux__) 20 + - fpu_control_t oldcw, newcw; 21 + - _FPU_GETCW(oldcw); newcw = (oldcw & ~_FPU_EXTENDED) | _FPU_DOUBLE; _FPU_SETCW(newcw); 22 + + fenv_t fenv; 23 + + 24 + + fegetenv(&fenv); 25 + + fenv.__control_word &= ~0x300; /* _FPU_EXTENDED */ 26 + + fenv.__control_word |= 0x200; /* _FPU_DOUBLE */ 27 + + fesetenv(&fenv); 28 + printf("c WARNING: for repeatability, setting FPU to use double precision\n"); 29 + #endif 30 + // Extra options: 31 + diff --git a/simp/Main.cc b/simp/Main.cc 32 + index 4f4772d..70c2e4b 100644 33 + --- a/simp/Main.cc 34 + +++ b/simp/Main.cc 35 + @@ -97,8 +97,12 @@ int main(int argc, char** argv) 36 + 37 + 38 + #if defined(__linux__) 39 + - fpu_control_t oldcw, newcw; 40 + - _FPU_GETCW(oldcw); newcw = (oldcw & ~_FPU_EXTENDED) | _FPU_DOUBLE; _FPU_SETCW(newcw); 41 + + fenv_t fenv; 42 + + 43 + + fegetenv(&fenv); 44 + + fenv.__control_word &= ~0x300; /* _FPU_EXTENDED */ 45 + + fenv.__control_word |= 0x200; /* _FPU_DOUBLE */ 46 + + fesetenv(&fenv); 47 + printf("WARNING: for repeatability, setting FPU to use double precision\n"); 48 + #endif 49 + // Extra options: 50 + diff --git a/utils/System.h b/utils/System.h 51 + index 004d498..a768e99 100644 52 + --- a/utils/System.h 53 + +++ b/utils/System.h 54 + @@ -22,7 +22,7 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA 55 + #define Glucose_System_h 56 + 57 + #if defined(__linux__) 58 + -#include <fpu_control.h> 59 + +#include <fenv.h> 60 + #endif 61 + 62 + #include "glucose/mtl/IntTypes.h" 63 + -- 64 + 2.14.2 65 +
+65
pkgs/applications/science/logic/avy/minisat-fenv.patch
··· 1 + From 7f1016ceab9b0f57a935bd51ca6df3d18439b472 Mon Sep 17 00:00:00 2001 2 + From: Will Dietz <w@wdtz.org> 3 + Date: Tue, 17 Oct 2017 22:57:02 -0500 4 + Subject: [PATCH] use fenv instead of non-standard fpu_control 5 + 6 + --- 7 + core/Main.cc | 8 ++++++-- 8 + simp/Main.cc | 8 ++++++-- 9 + utils/System.h | 2 +- 10 + 3 files changed, 13 insertions(+), 5 deletions(-) 11 + 12 + diff --git a/core/Main.cc b/core/Main.cc 13 + index 2b0d97b..8ad95fb 100644 14 + --- a/core/Main.cc 15 + +++ b/core/Main.cc 16 + @@ -78,8 +78,12 @@ int main(int argc, char** argv) 17 + // printf("This is MiniSat 2.0 beta\n"); 18 + 19 + #if defined(__linux__) 20 + - fpu_control_t oldcw, newcw; 21 + - _FPU_GETCW(oldcw); newcw = (oldcw & ~_FPU_EXTENDED) | _FPU_DOUBLE; _FPU_SETCW(newcw); 22 + + fenv_t fenv; 23 + + 24 + + fegetenv(&fenv); 25 + + fenv.__control_word &= ~0x300; /* _FPU_EXTENDED */ 26 + + fenv.__control_word |= 0x200; /* _FPU_DOUBLE */ 27 + + fesetenv(&fenv); 28 + printf("WARNING: for repeatability, setting FPU to use double precision\n"); 29 + #endif 30 + // Extra options: 31 + diff --git a/simp/Main.cc b/simp/Main.cc 32 + index 2804d7f..39bfb71 100644 33 + --- a/simp/Main.cc 34 + +++ b/simp/Main.cc 35 + @@ -79,8 +79,12 @@ int main(int argc, char** argv) 36 + // printf("This is MiniSat 2.0 beta\n"); 37 + 38 + #if defined(__linux__) 39 + - fpu_control_t oldcw, newcw; 40 + - _FPU_GETCW(oldcw); newcw = (oldcw & ~_FPU_EXTENDED) | _FPU_DOUBLE; _FPU_SETCW(newcw); 41 + + fenv_t fenv; 42 + + 43 + + fegetenv(&fenv); 44 + + fenv.__control_word &= ~0x300; /* _FPU_EXTENDED */ 45 + + fenv.__control_word |= 0x200; /* _FPU_DOUBLE */ 46 + + fesetenv(&fenv); 47 + printf("WARNING: for repeatability, setting FPU to use double precision\n"); 48 + #endif 49 + // Extra options: 50 + diff --git a/utils/System.h b/utils/System.h 51 + index 1758192..c0ad13a 100644 52 + --- a/utils/System.h 53 + +++ b/utils/System.h 54 + @@ -22,7 +22,7 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA 55 + #define Minisat_System_h 56 + 57 + #if defined(__linux__) 58 + -#include <fpu_control.h> 59 + +#include <fenv.h> 60 + #endif 61 + 62 + #include "mtl/IntTypes.h" 63 + -- 64 + 2.14.2 65 +