Add ocaml-option-llvm for cross-platform LLVM toolchain support#29582
Add ocaml-option-llvm for cross-platform LLVM toolchain support#29582
Conversation
de3b2ef to
9346fc9
Compare
|
It would be good to have this but I think switching the C compiler is just a part of the solution. IMO the whole MSVC toolchain should be replaced by LLVM tools in this context. There's not just the C compiler, but also the archive program Of all of these as of LLVM 22 only As of the 5.6 trunk of 2026-03-23, OCaml doesn't support the user specifying another default linker, doesn't support Maybe we could have a |
|
That's a fair point — renaming to One thought on scope: rather than restricting this to Windows, would it make sense to have As the LLVM toolchain support in OCaml matures, we could then incrementally add the linker, archiver, assembler, etc. on all platforms — not just Windows. Does that align with what you had in mind, or would you prefer to keep the initial scope Windows-only? |
|
That is exactly what I had in mind ;) |
Add an ocaml-option-llvm package following the established ocaml-option-* pure marker pattern. On Windows it sets CC=clang-cl (with a system-msvc dependency), whilst on other platforms it sets CC=clang. This allows the LLVM toolchain to be properly scoped to the OCaml compiler build. As upstream OCaml gains support for specifying alternative linkers and assemblers, this package can be extended incrementally to configure lld-link, llvm-ar, llvm-mt, llvm-rc, etc. Changes: - New package: ocaml-option-llvm.1 (conflicts with 32bit, musl, address-sanitizer, leak-sanitizer) - ocaml-options-vanilla: add unconditional conflict - ocaml-variants.5.2.0+msvc: add as depopt with CC=clang-cl - ocaml-compiler.5.3.0 through 5.6: add as depopt with CC=clang-cl on Windows and CC=clang elsewhere; add !ocaml-option-llvm guard to the existing CC=cc line
9346fc9 to
fa5fb3a
Compare
|
Done! |
Summary
ocaml-option-llvmpackage as a pure marker following the establishedocaml-option-*patternCC=clang-cl(with asystem-msvcdependency), whilst on other platforms it setsCC=clang(switching from GCC to Clang)lld-link,llvm-ar,llvm-mt,llvm-rc, etc. on all platformsChanges
ocaml-option-llvm.1— pure marker withflags: compiler, depends onsystem-msvcon Windows only, conflicts withocaml-option-32bit,ocaml-option-musl,ocaml-option-address-sanitizer,ocaml-option-leak-sanitizerocaml-options-vanilla: add unconditional conflict withocaml-option-llvmocaml-variants.5.2.0+msvc: addocaml-option-llvmas depopt withCC=clang-clbuild argocaml-compiler.5.3.0through5.6(12 packages): addocaml-option-llvmas depopt withCC=clang-clon Windows /CC=clangelsewhere; add!ocaml-option-llvm:installedguard to the existingCC=ccline on macOS/OpenBSDDesign
Follows the same pattern as
ocaml-option-musl(CC=musl-gcc): a pure marker package that compiler packages reference viadepoptsand{ocaml-option-llvm:installed}guards in their build sections. Nosetenvis used — the CC override is scoped to the compiler's./configureinvocation only.Conflict analysis
All existing
CC=overrides in the build sections were checked for potential conflicts:CC=ccon macOS/OpenBSD — guarded with!ocaml-option-llvm:installedto prevent doubleCC=CC=clangfor tsan on macOS — compatible (same value), no conflict neededCC=musl-gcc,CC=gcc -m32, sanitiserCC=lines — all incompatible, declared as conflicts on the option packageocaml-option-tsanis intentionally not conflicted — tsan already usesCC=clangon macOS (same as llvm), and on Linux it does not setCCat all, so the combination works correctly.Ref: ocaml/setup-ocaml#1073