toolchain enhancement: arch/os specialization
Currently the ocaml toolchain is not arch/os sensitive. But since the OCaml linker calls the system linker, this can be a problem.
Case in point: the dreaded link version mismatch warning on macos:
.../libzstd.a[23](zstdmt_compress.o)) was built for newer 'macOS' version (14.5) than being linked (14.0)
This can happen when you build a cc lib using rules_cc and then link it to an OCaml executable. rules_cc will pass -mmacos-version-min to the linker when building the library, but OCaml does not pass that flag to the linker. The workaround is to add the flag using OCaml's -ccopt option, but that's not a general solution.
A better solution is to make the Bazel toolchain for OCaml handle this. I can think of two ways to do this. One is to have a separate toolchain implementation for each arch/os combination. But maybe a better way is to have the OCaml toolchain obtain link flags from the CC toolchain. See Integrating with C++ Rules. In fact this is already partially implmented in the OCaml toolchains.