alidist icon indicating copy to clipboard operation
alidist copied to clipboard

Define compilers in defaults file

Open fuhlig1 opened this issue 8 years ago • 8 comments

Would it be possible to define also the compilers in the defaults files by adding the following three variables to the env section?

CXX: "c++ compiler" CC: "c compiler" FC: "fortran compiler"

This would allow to use also non standard compilers which are installed outside of the system directories.

The Makefiles generated by the autotools evaluate this environment variables and use the correct compiler. For CMake based recipes one has to change the cmake call and add the following flags to make sure that CMake uses the correct compilers

-DCMAKE_CXX_COMPILER=$CXX
-DCMAKE_C_COMPILER=$CC
-DCMAKE_Fortran_COMPILER=$FC \

fuhlig1 avatar Aug 23 '17 08:08 fuhlig1

Hi @fuhlig1, the current philosophy is to use whatever's available in the $PATH. What you suggest leads to the following scenario:

  • autotools-based projects: they will (mostly) use the variables
  • CMake-based projects: we will need to change all the CMake calls
  • All other projects: the behavior needs to be seen case by case

In other words, what you request is feasible but it requires lots of work in order to be generic enough, and compatible with what we have.

What is the specific problem you are trying to solve? (What compiler, what recipes.)

Note that in most cases, a symlink in the $PATH with cc pointing to, say, icc would be enough to do the trick (I guess this is the compiler you have in mind.)

dberzano avatar Aug 23 '17 08:08 dberzano

@dberzano , @fuhlig1 : I like this idea as it would allow us (more) easily to switch to a different compiler (clang, icc) for the complete software stack altogether.

sawenzel avatar Aug 23 '17 08:08 sawenzel

Hi @dberzano, the problem I had some time ago is, that CMake on Mac OSX wasn't evaluating the environment variables CC, CXX and FC, so the only way to get it working with a non standard compiler was to pass the compiler explicitly when calling CMake. I can't reproduce this behavior with the latest version of CMake now I found some discussions on StackOverflow about the issue. I am not sure if the problem was due to the Mac OSX version or the CMake version. Anyway the problem is gone.

I think I don't understand exactly what you mean. What would I have to do to compile something with clang on Linux using aliBuild?

If I get you correct the way would be to create a directory and add inside some symbolic links cc->/mypath/clang, c++->/mypath/clang++ and add this directory as first entry to $PATH. How to define the fortran compiler?

Another solution would be to define the environment variables CC, CXX, FC before calling aliBuild.

Both solutions have in my opinion the disadvantage that alibuild doesn't know anything about it. I can easily compile some parts with one compiler and other parts with another compiler which may result in problems which are hard to find. If the compilers would be defined in the defaults files a change of the compiler would result in a recompilation of the complete list of recipes.

fuhlig1 avatar Aug 23 '17 09:08 fuhlig1

Hi @fuhlig1, by saying:

What would I have to do to compile something with clang on Linux using aliBuild?

you have actually answered my question :-)

To answer both you and @sawenzel, and better specify what I mean:

  • aliBuild per se does not and will never know anything about the environment, this is up to the recipes
  • This is a nice-to-have, I am definitely in favor of that
  • Not only defaults, but recipes too need to be adapted
  • Given that we have quite a huge number of recipes, I would first focus on 1) a specific compiler, 2) a specific set of recipes, e.g. "I would like to build the full O2 stack using clang on Linux", which is exactly what you have asked for.

dberzano avatar Aug 23 '17 14:08 dberzano

Hi @dberzano,

please find at https://github.com/fuhlig1/alidist/tree/issue_824 a branch which implements the requested feature for the complete O2 stack. I changed all recipes for the full O2 stack and I add the file defaults-o2.issue824.sh which I have used on my system. The newly defined variables CXX_COMPILER, C_COMPILER and Fortran_COMPILER are used in the recipes if defined in the default file. If the variables are not defined or defined but empty they are not used in the recipes. This allows to use the same recipes for all default files such that the new recipes shouldn't break the current setup. I have tested the recipes with Clang and the Intel compiler on Linux. Beside problems with the compilation of some of the packages with the Intel compiler I haven't seen any problems.

Please test the implementation and let me know if you encounter any problems. The corresponding PR is #849.

fuhlig1 avatar Sep 11 '17 14:09 fuhlig1

@dberzano : Did you have a chance to study the proposal by @fuhlig? I think this a great new feature and shows that it can be achieved rather easily.

sawenzel avatar Oct 27 '17 09:10 sawenzel

Yes the general idea is fine but there are many things I would like to change before merging. Appropriate comments will come when time allows.

dberzano avatar Oct 27 '17 10:10 dberzano

What's the status of this?

ktf avatar Dec 11 '17 08:12 ktf