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.
source share