Closed agraef closed 2 years ago
I should add that this is using the headers from gsl-2.5 on Arch.
The empty output warnings seem harmless, and can be made to go away by adding -w0
to the pure-gen command. They are apparently generated by headers containing nothing but type definitions and other stuff which isn't wrapped in Pure.
The "symbol `value' does not fit here" errors are caused by 128 bit floating point types (`float128and
__Float128) which the language-c version 0.5.0 that we use doesn't support. Support for those was added in later language-c versions, though, and I already backported those changes to our language-c version. This is already in the AUR (haskell-language-c5 package), and will be committed here along with the corresponding changes in pure-gen shortly. This makes all these errors go away. (In gsl-2.7.1, there are still a few other unrelated syntax errors due to the
gsl_spmatrix_pooltype being undefined, but I think that these are due to some mistakes in the corresponding header files, i.e., the header files not being truly self-contained. In any case they can be worked around with a
-Dgsl_spmatrix_pool=void`.)
The long double*
being mapped to double *
in the C module seems to be a genuine bug. This won't have any real consequences, as the Pure module actually accepts a void *
for any of these, and the user will have to figure out a way to produce these pointers in Pure anyway. But it would still be nice to have the proper type generated on the C side, to avoid those warnings when compiling the C module. This still needs to be addressed for now.
Yes, some of the headers clearly aren't self-contained, so a better procedure is to collect all the headers in a big header file and run pure-gen on that:
DEFS=-DGSL_DISABLE_DEPRECATED
(for x in /usr/include/gsl/*.h; do echo "#include \"$x\""; done) > mygsl.h
pure-gen $DEFS -w0 -fc-auto -s '/usr/include/gsl/*::' mygsl.h
This eliminates the issue with the undefined types. I also found that I had to add a couple of libraries in compilation to make the module load properly:
# Compile the resulting C module.
gcc $DEFS -shared -o mygsl.so mygsl.c -lgsl -lgslcblas -lcblas
The resulting module now loads fine and seems to work (running a few basic examples). There still are a few symbols which seem to be in the GSL headers but aren't actually in the library, but these can just be deleted from mygsl.pure.
Just pushed the necessary changes to pure-gen and language-c. Next I'll be looking into the long double issue.
Actually, only the const long double*
pointers were being messed up. Just fixed in git, generated C code compiles cleanly now. This resolves this bug.
As discussed on the mailing list, this example from the pure-gen manual has stopped working:
dump-ast generates a bunch of
empty output
warnings, and errors like:It's always the same kind of error message, followed by a Haskell exception. Having the parser crash with a Haskell exception is not a good thing. ;-) That might also explain why so many empty output files are created.
The resulting code is also partially broken, apparently pure-gen mistakes
long double*
fordouble *
:Always the same error again.