Coder Social home page Coder Social logo

pure-gen compilation troubles about pure-lang HOT 4 CLOSED

agraef avatar agraef commented on May 30, 2024
pure-gen compilation troubles

from pure-lang.

Comments (4)

agraef avatar agraef commented on May 30, 2024

I should add that this is using the headers from gsl-2.5 on Arch.

from pure-lang.

agraef avatar agraef commented on May 30, 2024

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 (__float128 and __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_pool type 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.

from pure-lang.

agraef avatar agraef commented on May 30, 2024

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.

from pure-lang.

agraef avatar agraef commented on May 30, 2024

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.

from pure-lang.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.