I’m not quite sure where this issue belongs to, so posting it here instead of on a random issue tracker.
Recently, a friend of mine wanted to install OCaml on their FreeBSD system. FreeBSD ships since some years clang as the default C compiler, while some applications (e.g.: grub2-bhyve, uefi) still require gcc for installation.
Additionally, if you keep on updating to the latest FreeBSD without every removing binaries, you’ll end up with both gcc(-4.2.1) and clang(-5.0.0) installed at the same time.
So, an installation of the OCaml port (4.02.3) worked fine for my friend, since this explicitly passes “-cc $(CC)” to OCaml’s configure. While a “opam switch” to a newer OCaml compiler worked as well, it failed to install arbitrary opam packages.
The reason for this is that OCaml’s configure tries first to find a gcc binary (if no configure argument is provided), and found the 4.2.1. This was then preserved in Makefile.config, and used by various opam packages (via ocamlbuild I suspect).
Now this initial experience with OCaml was not very intuitive for my friend. How can we get out of this situation? I had assumed POSIX would require that a cc
binary is around, but it doesn’t (there’s optionally a c99 binary). I couldn’t find a way in opam to pass a -cc
argument via opam switch
to the OCaml build system (this would also not be very intuitive, but at least unblock the installation in this specific case).
Should the OCaml configure be changed to first try to find a cc
binary (there is some shell code which deals with cross compilation which I do not understand), and if unsuccessful, move on to gcc
? Should the compiler definitions in opam be modified to pass -cc $CC
to OCaml’s configure?
How do various Linux flavours these days deal with that? The systems I have access to (some ubuntu) has a cc
binary installed which is a link to gcc
, but is having a cc
around widely adapted? Does MacOSX have a gcc
binary around at all? The cross compilation is rather gcc specific (by looking for ${TOOLPREF}/gcc
.
I hope there is a smooth solution, but I don’t know which this is. Are there any systems where cc
is likely an outdated compiler, and gcc
is the thing you want to run? Thanks for feedback! FWIW, since OpenBSD recently switched their default compiler from gcc to clang, there may be some people running into this issue as well.