Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

homebrew

For the development/testing of our CFD code I like to frequently switch between Clang (for its strictness/warnings) and GCC (for performance), but this requires some of its dependencies (like e.g. NetCDF) to be compiled with the same compiler.

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

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

brew switch netcdf 4.3.3-gcc 
brew switch netcdf 4.3.3-clang 
like image 779
Bart Avatar asked Oct 29 '22 15:10

Bart


1 Answers

I think this is possible only if you explicitly have different version numbers like in the example you used "4.3.3-gcc" and "4.3.3-clang".

If the version number is identical then there is no difference in the builds and brew can't differentiate them.

Also I wouldn't do this.

  1. By compiling the same library multiple different ways you now start going into a dependency nightmare.
  2. Dependency conflicts. Because even if you swap out "netcdf", how do you know you swapped out all it's dependencies too? If they are not compiled with the same compiler bad things can happen, for example conflicts can arise due to the differences in how calls are made or due to options enabled in one compiler for both the app and it's dependencies that weren't enabled in another build.

I don't recommend doing this, it's too much of a hassle.

But, if you really need two builds (such as for testing) then I would build them to isolated folder trees outside of your system path and do any testing against them there. Brew is not the best way to address this issue, as this is a non-standard use-case.

like image 111
Joshua Briefman Avatar answered Jan 02 '23 20:01

Joshua Briefman