Install the same software / version with different compilers side by side

To develop / test our CFD code, I often have to switch between Clang (for its strictness / warning) and GCC (for performance), but this requires that some of its dependencies (for example, NetCDF) be compiled using the same compiler .

I know that Homebrew has the ability to install several versions of side-by-side software and a switch between them, but is it possible to do something similar using the same version of software, but compiled with different compilers (by setting HOMEBREW_CC and HOMEBREW_CXX ) ?

Something like (wishful thinking after somehow installing NetCDF with Clang and GCC):

 brew switch netcdf 4.3.3-gcc brew switch netcdf 4.3.3-clang 
+5
source share
1 answer

I think this is possible only if you explicitly use different version numbers, for example, in the example that you used "4.3.3-gcc" and "4.3.3-clang".

If the version number is identical, there is no difference in assemblies, and brew cannot distinguish them.

Also I would not do that.

  • Having compiled the same library in several different ways, you are now starting to get into the nightmare of addiction.
  • Conflicts of dependency. Because, even if you replace "netcdf", how do you know that you have changed all its dependencies? If they are not compiled with the same compiler, bad things can happen, for example, conflicts can arise due to differences in how calls are made or due to parameters included in the same compiler for both applications and dependencies, which were not included in another build.

I do not recommend doing this, it is too much trouble.

But, if you really need two assemblies (for example, for testing), I would build them on separate folder trees outside your system path and check any testing there. brew is not the best way to solve this problem, as this is a non-standard use case.

+2
source

Source: https://habr.com/ru/post/1261123/


All Articles