pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Installing clang alongside GCC on NetBSD 9



On 2020-03-08 10:03, Greg Troxel wrote:
Is that more precisely

   "with C++, you really can't mix gcc and clang"

and

   "with plain C, you can"
With C there are very few potential problems because the ABI is simple and hasn't changed much in the last 30 years.

With C++, it's complicated and I don't claim to understand all the issues in detail.  C++ is still evolving rapidly and different major versions of GCC do not guarantee ABI compatibility or even API compatibility in all cases.

That said, FreeBSD ports mixes clang++ and g++ objects regularly. Ports that use openmp or Fortran still depend on GCC packages (though this may change soon) while the libraries they depend on are almost all built with clang.  In some cases this is reversed, i.e. libraries are build with GCC and the dependent program with clang. There are potential problems with this, but it usually just works with the default GCC port (currently gcc9) and solutions exist in the ports infrastructure for other cases, such as allowing the maintainer to force use of libc++ or libstdc++ or control which C++ standard is used by the compiler.

I'm not sure about Fortran, but I suspect the ABI is much simpler than C++ so it's less problematic mixing in object code built with gfortran.

I've built pkgsrc math/R (which has Fortran dependencies) on OS X recently using clang 10 from Xcode and gcc7 from pkgsrc.  I have not yet encountered any problems.



Home | Main Index | Thread Index | Old Index