-
Notifications
You must be signed in to change notification settings - Fork 6.5k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Fortran support #485
Comments
As discussed in #233, at least initially I am for using Intel Fortran. However, I fear that requiring all the Perhaps Microsoft could provide some support for hosting such binaries produced by the community? @ras0219-msft @alexkaratarakis |
More in the long term, it would be interesting to see how the [1] : https://developer.arm.com/-/media/developer/developers/hpc/files/ARM-HPC-UG-SC16-PGI.pdf |
On the use of |
Requiring Intel Fortran for a complete out-of-the-box experience is definitely not desirable considering its licensing. However, it does look like it's a very popular (the most popular?) solution on Windows, so we should support it. This is exactly what triplets should do -- specify the toolchain and build parameters to be used for all built libraries. We can totally handle tools that don't have VS IDE integration; we could easily download Ninja or use MSYS internally as long as we can produce crt-compatible libraries out the other side. As for hosting prebuilt binaries -- assuming it is fine with the intel fortran license (I'm not too familiar on this point), we could very easily host them inside the NuGet gallery, treating the NuGet package as a simple zip archive of the prebuilt binaries. We even already have the capability to download the NuGet.exe tool (for the MSBuild per-project integration). As has been mentioned many times elsewhere, building from source would be preferable for users who can (i.e. that have intel fortran), but it's better to have binaries than nothing at all -- as long as the fortran library doesn't have dependencies. We don't want the fact that library X required a binary drop to obstruct the maintainer of dependency Y from updating. Edit: flang looks really promising! I'll look forward to whenever it gets enough fortran support to build the libraries we need :) |
The only thing I had to change to make it work with the Intel Compiler was to remove the extra arguments that are passed to "cmake --build" in vcpkg_install_cmake and vcpkg_build_cmake. This is because when the Visual Studio project files include Fortran code, "cmake --build" will invoke devenv.exe instead of msbuild.exe which will not understand the extra arguments. The Intel compiler always got detected correctly by cmake automatically. I don't know whether this is the case under all circumstances (e.g. if you have multiple versions installed) but one could always set "CMAKE_Fortran_COMPILER" in the triplet. The problem would here would be to auto-detect and choose the correct paths to ifort.exe. |
Interesting read on this: |
I think that this approach #23 (comment) to packaging a fortran library such as LAPACK is relevant also here. |
The preliminary version of the flang compiler (based on PGI frontend) was open sourced in https://github.com/flang-compiler/flang . I don't think it is ready for use in vcpkg (I doubt there are binary availables) but it is an interesting reference. |
Very interesting! As far as I can see there is no official announcement available yet?! I will go on and compile everything and try how far I can get with it. If it is just the missing binaries we may will be able to host the binaries ourselves somewhere. |
Apparently no: http://www.phoronix.com/scan.php?page=news_item&px=LLVM-NVIDIA-Fortran-Flang . |
Would be curious to hear about your experiences with Flang. We (at conda-forge) have been eyeing progress on it for some time (though it was only recently open sourced). In particular, we were looking at it for building things like OpenBLAS and SciPy, but inevitably including Fortran support for other things. |
Relevant flang issue on Windows support: flang-compiler/flang#143 . |
Good news regarding support for
I don't know if this directly affects the libraries built with |
This sound like great news! The PR at #1098 already includes MinGW+w64 support, but it requires the not yet released version of CMake 3.10 to support GnuToMS for the Ninja generator and of course has the known problems of linking against msvcrt. I am really looking forward to a release version of MinGW that includes the final ucrt suppprt. |
Ironically, using vcpkg to build flang would be the most time-efficient method to get a fortran compiler with MSVC ABI compatibility. But, MSVC does not have OpenMP 4.0, which flang requires. So essentially, the steps would be:
Now whether this will actually happen is a different story. MSFT might not want to add clang support to this project because then people may obviously not use their compiler. But based on their responses, there is little chance of MSVC adding OpenMP 4 support. In other words, this is technically solvable, but when business interests / people come into the picture it might not be (and I have nothing against MSFT; I think it's a good company and I think this is an excellent project that was long overdue). |
@xoviat have you tried to build flang for windows with the described method manually? And then use that flang binary to build any fortran code on windows? As far as I understood, flang does not yet support windows at all (not only being build by MSVC, but in general. Correct me if I am wrong!). |
Flang supports windows but someone just needs to build it, which is not trivial for the same reason that vcpkg exists. |
If that's true, why aren't there any updates in issue ( flang-compiler/flang#143 )? Where has this work been occurring? |
No one has built it yet but it's "just" CMake. |
Actually, after reconsidering the problem, it's possible to override the generator with a So to summarize, we need ports for:
If someone else wants to port one of these, then I may port the other. |
i don't think even ports are necessary. We could just precompile flang and treat it like one of the external tools, and then use it like that. Though I'm not sure if flang is actually buildable on Windows, even with msys2 and friends. |
Let me be clear: flang is buildable on windows, but it has a complex dependency chain, which is the exact problem that vcpkg was designed to solve. The only problem is that one dependency is
Yes, but precompiling is the problem. The libraries aren't there yet. But they could be with vcpkg. |
LLVM's ref: https://github.com/conda-forge/openmp-feedstock |
With MSVC? |
Sorry for the delay, but I've now updated the PR to download the new version from conda-forge. Btw: I could build LAPACK and ScaLAPACK with flang, but when I try to compile MUMPS it fails with a message about a missing header, although on the first look it seems that the correct include path is set. If you want to try it yourself:
|
@albertziegenhagel Thank you for your work on integrating fortran on vcpkg. Just wondering if you were able to make fortran work. @ras0219-msft Regarding the choice of the fotran compiler. Shouldn't we leave that decision to the user. I prefer using intel fortran compiler. So if we choose flang it feels as if vcpkg has locked us in. |
@atkawa7 I am using fortran libraries build via vcpkg locally all the time through #1098. There you have the option to select the fortran compiler in the triplet file with currently |
Hi everyone, how is this PR evolving? |
I obviously cannot speak for vcpkg mantainers, but I guess one of the reasons #1098 cannot be merged is that it three out of the four supported compilers cannot be maintained in a "clean" way (please correct me if I am getting something wrong):
Do not get me wrong, I am a huge fan of the work of @albertziegenhagel , I just suspect these are the reasons why it can't be integrated upstream, and I thought it could be useful to have recap of them at this moment. The only remaining option is |
@traversaro thanks for summarising. It looks as though there is at least some problem with each of the four options of Surely, though, some fortran support is better than no fortran support? I have successfully used @albertziegenhagel's fork in the past, and it would be great to integrate that functionality properly into vcpkg. Why, for instance, does the issue you raise with |
Some interesting recent discussion related to this issue:
|
http://lists.llvm.org/pipermail/llvm-dev/2019-April/131703.html |
@ghost: is the flang win32 version actually 32 bit or you mean x64? conda-forge has dropped support for Windows 32 bit so only 64 bit packages can be found. Have you produced a 32 bit version of flang? If so, it is published through a conda channel or available as a standalone tar? I have tried the channel isuruf/label/flang but no luck. |
@gmanlan, it's x64. flang doesn't support 32 bit version. |
PR #12805 by @Neumann-A merged in vcpkg upstream a minimal support for building fortran packages using |
I am currently working on updating all fortran ports from my old branch to the new fortran support and will open MRs to upstream vcpkg as soon as most of the things are working. I do currently have a working port for Ports for |
Thanks a lot, this is great news!
I am afraid indeed it is, I remember that back in time Note that in theory, if there is no memory allocated by one crt that is then passed across library boundaries to be freed by the user code (or vice versa) in theory the library should work fine even by linking the old CRT, but that is always risky, because assessing all the use of dynamically allocated memory in a complex library is far from trivial. |
I was able to make use of the UCRT via a spec file. If I understand correctly, this should be sufficient for libraries that do use only C and Fortran, and rebuilding mingw with I think using g++ for C++ will be problematic anyways because of its use of |
That is a good point, I never realized that. If that is the case, then everything is indeed easier. |
Just an idea: add a port for gcc and build libgfortran from source via maybe clang-cl? Then you can play with the CMake platform build rules to adjust everything to link/build correctly. |
Hm, seems that I was wrong.
The MinGW libraries still link to MSVCRT:
Maybe this is what we have to do. edit: when I further think about this, I don't think that using gfortran from MinGW will be a sufficient solution for all ports, even with the working UCRT linkage. I don't think we will be able to make libraries that use both, Fortran and C++ ever work. The GNU toolchain and MSVC are using different object formats, so you can not link an object generated by I think if one wants to use |
Unfortunately no, it was an early and unsuccessful test.
I guess this is a problem just for mixed projects, right? I guess those were exactly the one for which the |
Yes, i think so. But if I understand those tools correctly, this would require support from the library to be build e.g. SuperLU_Dist or a big amount of patching from the port author. For a library like PETSc that does not use CMake it will be even more difficult if not even close to impossible. |
I see, yes, for those case gfortran even with ucrt support is not a convenient solution. |
The interesting thing is that I was actually able to build some C++ code with // main.cpp
#include <iostream>
extern "C" {
void fortran_print_();
}
int main()
{
std::cout << "Hello C++" << std::endl;
fortran_print_();
return 0;
} ! fortran.f90
SUBROUTINE FORTRAN_PRINT( )
Print *, "Hello Fortran!"
END Can be compiled and run by:
So I am not sure yet where the limitations exactly are. Next thing I will try is to make the same project build with CMake. |
I note that there are ports using fortran at this time so the original issue filing appears to be resolved, but as you note above there are still some 'holes' in that support. You might want to consider opening issues for the specific CRT problems above to make it easier for folks familiar with this problem space to find. I'll leave this open for now though. |
Since Intel OneAPI is freely available now and includes the intel fortran compiler ifort we should try to switch from gfortran to ifort if it is possible to install Intel OneAPI on the CI machines. This should in theory cleanly resolve the CRT problems. |
For what regards CRT problems, I recently noticed that msys2 now provides ucrt-based builds on top of the already existing |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
There are some port requests on the tracker that require a Fortran compiler to compile the respective libraries (#23, #233). I want to create this issue to start a discussion on how Fortran support could be brought to vcpkg.
Since Visual Studio does not come with a Fortran compiler, on Windows one usually uses one of the following
Intel Fortran is proprietary and thus may not be available for everyone but it has a nice Visual Studio integration which makes it pretty straight forward to consume libraries compiled with ifort from within Visual Studio.
gfortran on the other hand is free but does not have an integration into Visual Studio. In general one uses MinGW/MSYS to compile fortran libraries for windows when using gfortran. This comes with some implications:
So the first question would be which version should implemented in vcpkg:
I do not have a lot of experience in using gfortran on windows but I do have a port for netlib blas+lapack (http://www.netlib.org/lapack/) which works with some minor additional modifications to vcpkg itself when using Intel Fortran.
The text was updated successfully, but these errors were encountered: