[petsc-dev] Is there any possibility to compile PETCs directly on Windows?
Smith, Barry F.
bsmith at mcs.anl.gov
Mon Jul 15 23:08:59 CDT 2019
> On Jul 15, 2019, at 8:02 PM, Xinghua Hao via petsc-dev <petsc-dev at mcs.anl.gov> wrote:
> We used to install it within WSL(Windows Subsystem for Linux) and I just transferred to a Docker container environment. It works pretty well on both of this two.
Presumably you are using the GNU compiler chain to build your source code and cannot use the results directly with Microsoft cl compiler?
> So I believe using any other kind of intermediate level(like Cygwin) to simulate a Linux-like environment would do nothing better.
Yes if you are working purely with GNU compiler chain then I agree with you, no reason to use Cygwin. The reason we use Cygwin is that it
allows "natural" (though slightly cumbersome, Matt explained why) interaction directly with the Microsoft cl and Intel icl/ifort toolchain.
> The only question(may sound a little stupid) I am still curious about is that why can’t we directly compile PETCs on Windows?
This question could mean a couple of things.
1) could you load the PETSc source up into Microsoft Visual Studio (or whatever their GUI is called) and build the libraries and examples directly there
2) could you use Microsoft Python and Powershell to manage the configuration/compilation process.
We actually have done 1 long ago and it could be done again. The problem was it was a manual process to get all the source code recognized and into Visual Studio and there was no good way to automate this. That is if someone added new code to PETSc source tree it had to be manually integrated into Visual Studio. Also dealing with external packages and some configuration options would not be be possible. Since Visual Studio can now presumably work directly with git repositories it may actually be possible to automate this for "basic" PETSc builds. We have not tried it but would love it if someone did it.
Regarding 2) our entire configuration/build process, bash shell scripts, unix commands, gnumake usage would require a huge port to Microsoft Python/Powershell and again the problem would be, yes it could done once as a snapshot but how to maintain it as PETSc grows and evolves over the years. This is not likely to ever be a viable approach.
3) could you use WSL to play the role that Cygwin does in calling the Microsoft/Intel compilers? Satish investigated this when it first came out and it was missing specific features that Cygwin had that prevented this. Perhaps WSL2 is closer to being able to do this. Again we haven't had the time to fully investigate.
At https://bitbucket.org/petsc/win32fe/src/master/ you can find the source code of Win32fe written by Kris Buschelman. We use this essentially to map a compiler/linker command line in "Unix" to its equivalent in Windows (for the Windows compilers, it is a bit different for each Windows compiler). It maps things like compiler options -I etc to the Window compiler equivalents and handles the difference in the file system representation \ and / etc.
Most of our customers use Linux, Apple, and clusters so we have no funding or mandate to support Windows, we do it as part of our civic duty in our spare time. Likely with some knowledge and time people could develop and implement multiple ways to build and use PETSc more "natively" in Windows. If they did we'd love to add that capability directly to the PETSc repository (so long as it is maintainable).
> Since we write PETCs in languages compilable cross-platform, this should not be where the problems come from.
> So could you offer me some examples which show the PETCs is heavily depended on Linux environment? Some high-level ideas or instructions guiding me to look for them myself are also appreciated.
> What’s more, is it possible for us to modify the source code to compile it directly on Windows? Is it practical?
More information about the petsc-dev