Closed awvwgk closed 1 year ago
The OSX build can be fixed by adding a custom fenv.h
, which implements the missing floating point functionality in the OSX C-library:
/**@file src/fenv.h */
#pragma once
#include_next <fenv.h>
#if defined(__APPLE__) && defined(__MACH__)
// Public domain polyfill for feenableexcept on OS X
// http://www-personal.umich.edu/~williams/archive/computation/fe-handling-example.c
inline int feenableexcept(unsigned int excepts)
{
static fenv_t fenv;
unsigned int new_excepts = excepts & FE_ALL_EXCEPT;
// previous masks
unsigned int old_excepts;
if (fegetenv(&fenv)) {
return -1;
}
old_excepts = fenv.__control & FE_ALL_EXCEPT;
// unmask
fenv.__control &= ~new_excepts;
fenv.__mxcsr &= ~(new_excepts << 7);
return fesetenv(&fenv) ? -1 : old_excepts;
}
inline int fedisableexcept(unsigned int excepts)
{
static fenv_t fenv;
unsigned int new_excepts = excepts & FE_ALL_EXCEPT;
// all previous masks
unsigned int old_excepts;
if (fegetenv(&fenv)) {
return -1;
}
old_excepts = fenv.__control & FE_ALL_EXCEPT;
// mask
fenv.__control |= new_excepts;
fenv.__mxcsr |= new_excepts << 7;
return fesetenv(&fenv) ? -1 : old_excepts;
}
#endif
Unfortunately, the polyfill for the floating point exceptions only works for OSX/x86_64 but not OSX/arm64
Considering the floating point runtime checking was intended as a debugging tool to figure out why this routine does not work the way it should, the import to <cfenv>
is best removed and the subsequent function calls too.
We're grateful to you trying out compatibility with MacOS. Are there any other compilation failures?
Removing the <cfenv>
header should enable me to cross-compile for MacOS/arm64. Maybe this patch will work (see https://github.com/conda-forge/scine-molassembler-feedstock/pull/4)
diff --git a/src/Molassembler/DistanceGeometry/TetrangleSmoothing.cpp b/src/Molassembler/DistanceGeometry/TetrangleSmoothing.cpp
index 83cb413d..e7cb9196 100644
--- a/src/Molassembler/DistanceGeometry/TetrangleSmoothing.cpp
+++ b/src/Molassembler/DistanceGeometry/TetrangleSmoothing.cpp
@@ -11,7 +11,6 @@
#include "Molassembler/Temple/Invoke.h"
#include <Eigen/Dense>
-#include <cfenv>
namespace Scine {
namespace Molassembler {
@@ -865,7 +864,6 @@ struct TetrangleLimits {
};
unsigned tetrangleSmooth(Eigen::Ref<Eigen::MatrixXd> bounds) {
- feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
const unsigned N = bounds.cols();
@@ -929,7 +927,6 @@ unsigned tetrangleSmooth(Eigen::Ref<Eigen::MatrixXd> bounds) {
++iterations;
} while(changedSomething);
- fedisableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
return iterations;
}
Are there any other compilation failures?
I have a collection of patches as well as some custom CMake finders to get molassembler to compile and use the correct libraries. Most of those are already posted here in the issue tracker.
This is fixed in release 2.0.0.
Compilation fails with clang 13 on MacOS. I'm aware that you don't support MacOS, however the compilation still fails which is worth reporting.
CMake configuration
System info