
On Thursday 15 November 2007 19:58, SevenThunders wrote:
Alberto Ruiz-2 wrote:
Hello,
I have had exactly the same problem with my bindings to GSL, BLAS and LAPACK. The foreign functions (!) randomly (but very frequently) produced NaN with ghc-6.8.1 -O. As usual, I first thought that I had a subtle bug related to the foreign pointers, but after a lot of refactoring, experiments, and tracing everything, I'm reasonably sure that memory is safely used. What I have found is that the same errors can be reproduced on ghc-6.6.1 with -O -fasm. So I tried -O -fvia-C on ghc-6.8.1 (which now it is not the default) and apparently everything works well. So it seems that now the ffi requires and additional and explicit -fvia-C. In any case I don't know why -fasm produces those strange NaN in precompiled foreign functions...
Alberto
Arrgh, the fix of using -fvia-C doesn't seem to be working for me. You got my hopes up for a moment :). I also am calling BLAS via C bindings. I am going to try to distill my case down to the bare minimum if possible and then provide an example. It may take a while.
Hmm, I' sorry... all seems to work well for me if I set -O -fvia-C for building the library and for final program compilation. But I will also try to find a minimum test case. In the meantime I have sent to Ian information to expose the problem with my library, although I know that such large amount of code will not be very helpful. Have you tested ghc-6.6.1 with -O -fasm?