-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FCall macro and/or Fortran calling convention #38872
Comments
You mean as discussed in #2167 😂 |
It would also need to handle name mangling, though i'm not sure if that is documented anywhere. |
The name mangling tends to be compiler dependent. I guess you could look at the symbols in a shared library and guess the mangling scheme. |
I was wondering how CMake did it, and it looks like they literally compile a file with different combinations of names and see what resulting symbols are exported: |
@stevengj 's comment in a flexiblas issue is good to link here: mpimd-csc/flexiblas#12 (comment) |
Yes, that's also essentially what the |
@stevengj do you know how they handle the string issue? Or is that up to the caller? |
The string issue is up to the caller AFAIK; it seemed pretty hard to write an autoconf-style compilation check to test for this IIRC, so you were stuck with a table of known compilers. It wasn't a major issue in the past because the most common case of passing strings from C to Fortran was for single-character strings ala LAPACK/BLAS, and not passing the length arguments for single-character strings worked with all common compilers for decades AFAIK until gfortran decided it was important to disallow this (sigh). I don't know how much diversity there is in string-passing conventions between Fortran compilers; you'd have to do some experiments. I'm guessing that for single-character strings it will be a bit more forgiving, since most compilers probably ignore any length arguments that you push onto the stack. |
Should we create a label for |
This literally only comes up in the BLAS dot product: |
In conversation with @vtjnash I mentioned that it might make sense to add a calling convention to
ccall
that implements the GFortran ABI so that we can target different Fortran ABI compilers (see #38836) instead of having it be explicit.Alternatively a
@fcall
macro could make sense that converts the arguments to by-ref and handles, characters correctly.x-ref: JuliaLang/LinearAlgebra.jl#650
The text was updated successfully, but these errors were encountered: