@@ -383,6 +383,10 @@ struct RustBuild <: CompilerBuild
383383 version:: VersionNumber
384384end
385385
386+ struct OCamlBuild <: CompilerBuild
387+ version:: VersionNumber
388+ end
389+
386390getversion (c:: CompilerBuild ) = c. version
387391getabi (c:: CompilerBuild ) = c. abi
388392
@@ -413,6 +417,8 @@ const available_go_builds = GoBuild.(get_available_builds("Go."))
413417
414418const available_rust_builds = RustBuild .(get_available_builds (" RustBase." ))
415419
420+ const available_ocaml_builds = OCamlBuild .(get_available_builds (" OCaml." ))
421+
416422"""
417423 gcc_version(p::AbstractPlatform, GCC_builds::Vector{GCCBuild},
418424 compilers::Vector{Symbol}=[:c];
@@ -581,6 +587,7 @@ function choose_shards(p::AbstractPlatform;
581587 LLVM_builds:: Vector{LLVMBuild} = available_llvm_builds,
582588 Rust_builds:: Vector{RustBuild} = available_rust_builds,
583589 Go_builds:: Vector{GoBuild} = available_go_builds,
590+ OCaml_builds:: Vector{OCamlBuild} = available_ocaml_builds,
584591 archive_type:: Symbol = (use_squashfs[] ? :squashfs : :unpacked ),
585592 bootstrap_list:: Vector{Symbol} = bootstrap_list,
586593 # Because GCC has lots of compatibility issues, we always default to
@@ -594,6 +601,8 @@ function choose_shards(p::AbstractPlatform;
594601 preferred_rust_version:: VersionNumber = maximum (getversion .(Rust_builds)),
595602 # Always default to the latest Go version
596603 preferred_go_version:: VersionNumber = maximum (getversion .(Go_builds)),
604+ # Always default to the latest OCaml version
605+ preferred_ocaml_version:: VersionNumber = maximum (getversion .(OCaml_builds)),
597606 )
598607
599608 function find_shard (name, version, archive_type; target = nothing )
@@ -708,6 +717,17 @@ function choose_shards(p::AbstractPlatform;
708717
709718 push! (shards, find_shard (" Go" , Go_build, archive_type))
710719 end
720+
721+ if :ocaml in compilers
722+ # Make sure the selected Go toolchain version is available
723+ if preferred_ocaml_version in getversion .(OCaml_builds)
724+ OCaml_build = preferred_ocaml_version
725+ else
726+ error (" Requested OCaml toolchain $(preferred_ocaml_version) not available in $(OCaml_builds) " )
727+ end
728+
729+ push! (shards, find_shard (" OCaml" , OCaml_build, archive_type))
730+ end
711731 else
712732 function find_latest_version (name)
713733 versions = [cs. version for cs in all_compiler_shards ()
0 commit comments