diff --git a/README.md b/README.md index a570398d..dc3fdfe7 100644 --- a/README.md +++ b/README.md @@ -32,4 +32,4 @@ Building binary packages is a pain. `BinaryBuilder` follows a philosophy that i All packages are cross compiled. If a package does not support cross compilation, we patch the package or, in extreme cases, rebundle prebuilt executables. -The cross-compilation environment that we use is a homegrown Linux environment with many different compilers built for it, including various versions of `gcc`, `clang`, `gfortran`, `rustc` and `go`. You can read more about this in [the `RootFS.md` file](https://github.com/JuliaPackaging/Yggdrasil/blob/master/RootFS.md) within the Yggdrasil repository. +The cross-compilation environment that we use is a homegrown Linux environment with many different compilers built for it, including various versions of `gcc`, `clang`, `gfortran`, `rustc`, `go`, and `ocaml`. You can read more about this in [the `RootFS.md` file](https://github.com/JuliaPackaging/Yggdrasil/blob/master/RootFS.md) within the Yggdrasil repository. diff --git a/docs/src/build_tips.md b/docs/src/build_tips.md index b0582e06..2fde9967 100644 --- a/docs/src/build_tips.md +++ b/docs/src/build_tips.md @@ -127,6 +127,12 @@ Example of packages using Rust: The Rust toolchain currently used does not work with the `i686-w64-mingw32` (32-bit Windows) platform. +## OCaml builds + +The OCaml toolchain provided by BinaryBuilder can be requested by adding `:ocaml` to the `compilers` keyword argument to [`build_tarballs`](@ref): `compilers=[:c, :ocaml]`, and a specific version of the toolchain can be selected by adding the `preferred_ocaml_version` keyword argument to [`build_tarballs`](@ref). + +The OCaml toolchain provided by BinaryBuilder automatically selects the appropriate target. + ## C builds If your library has no build system like Make, CMake, Meson, or Autoconf, you may need to use the C compiler directly. The C compiler is stored in the `CC` environment variable, and you can direct output to `libdir` (shared libraries) and `bindir` (executables). @@ -135,7 +141,7 @@ As a high-level example: ```sh # this assumes you are operating out of a Git source named `hello` # adjust your `cd` appropriately -cd $WORKSPACE/srcdir/hello +cd $WORKSPACE/srcdir/hello mkdir -p ${libdir} # make sure the libdir is instantiated ${CC} -shared -o ${libdir}/libhello.${dlext} -fPIC hello.c # compile the library, save to `libdir` ``` diff --git a/docs/src/index.md b/docs/src/index.md index ac711e9d..f16cb546 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -1,6 +1,6 @@ # BinaryBuilder.jl -The purpose of the [`BinaryBuilder.jl`](https://github.com/JuliaPackaging/BinaryBuilder.jl) Julia package is to provide a system for compiling 3rd-party binary dependencies that should work anywhere the [official Julia distribution](https://julialang.org/downloads) does. In particular, using this package you will be able to compile your large pre-existing codebases of C, C++, Fortran, Rust, Go, etc... software into binaries that can be downloaded and loaded/run on a very wide range of machines. As it is difficult (and often expensive) to natively compile software packages across the growing number of platforms that this package will need to support, we focus on providing a set of Linux-hosted cross-compilers. This package will therefore set up an environment to perform cross-compilation for all of the major platforms, and will do its best to make the compilation process as painless as possible. +The purpose of the [`BinaryBuilder.jl`](https://github.com/JuliaPackaging/BinaryBuilder.jl) Julia package is to provide a system for compiling 3rd-party binary dependencies that should work anywhere the [official Julia distribution](https://julialang.org/downloads) does. In particular, using this package you will be able to compile your large pre-existing codebases of C, C++, Fortran, Rust, Go, OCaml, etc... software into binaries that can be downloaded and loaded/run on a very wide range of machines. As it is difficult (and often expensive) to natively compile software packages across the growing number of platforms that this package will need to support, we focus on providing a set of Linux-hosted cross-compilers. This package will therefore set up an environment to perform cross-compilation for all of the major platforms, and will do its best to make the compilation process as painless as possible. Note that at this time, BinaryBuilder itself runs on Linux `x86_64` and macOS `x86_64` systems only, with Windows support under active development. On macOS and Windows, you must have `docker` installed as the backing virtualization engine. Note that Docker Desktop is the recommended version; if you have Docker Machine installed it may not work correctly or may need additional configuration. diff --git a/generate_precompile.jl b/generate_precompile.jl index 02aafca6..8e6b8649 100644 --- a/generate_precompile.jl +++ b/generate_precompile.jl @@ -9,6 +9,7 @@ using SnoopCompile ExecutableProduct("hello_world_fortran", :hello_world_fortran), ExecutableProduct("hello_world_go", :hello_world_go), ExecutableProduct("hello_world_rust", :hello_world_rust), + ExecutableProduct("hello_world_ocaml", :hello_world_ocaml), ] # First, do the build, but only output the meta json, since we definitely want that to be fast @@ -55,7 +56,7 @@ using SnoopCompile Dependency[ Dependency("Zlib_jll"), ]; - compilers=[:c, :rust, :go], + compilers=[:c, :rust, :go, :ocaml], ) rm("build"; recursive=true, force=true) diff --git a/src/AutoBuild.jl b/src/AutoBuild.jl index f3a5eca6..173a3e82 100644 --- a/src/AutoBuild.jl +++ b/src/AutoBuild.jl @@ -488,6 +488,13 @@ function get_compilers_versions(; compilers = [:c]) go version """ end + if :ocaml in compilers + output *= + """ + ocamlc -v + ocamlopt -v + """ + end if :rust in compilers output *= """ @@ -824,7 +831,15 @@ function autobuild(dir::AbstractString, build_path = joinpath(dir, "build", triplet(platform)) mkpath(build_path) - shards = choose_shards(platform; extract_kwargs(kwargs, (:preferred_gcc_version,:preferred_llvm_version,:preferred_rust_version,:preferred_go_version,:bootstrap_list,:compilers))...) + shards = choose_shards(platform; extract_kwargs(kwargs, ( + :preferred_gcc_version, + :preferred_llvm_version, + :preferred_rust_version, + :preferred_go_version, + :preferred_ocaml_version, + :bootstrap_list, + :compilers, + ))...) concrete_platform = get_concrete_platform(platform, shards) prefix = setup_workspace( diff --git a/src/wizard/obtain_source.jl b/src/wizard/obtain_source.jl index c464e747..e1e524cd 100644 --- a/src/wizard/obtain_source.jl +++ b/src/wizard/obtain_source.jl @@ -334,11 +334,11 @@ function get_name_and_version(state::WizardState) end end -@enum Compilers C=1 Go Rust +@enum Compilers C=1 Go Rust OCaml function get_compilers(state::WizardState) while state.compilers === nothing - compiler_descriptions = Dict(C => "C/C++/Fortran", Go => "Go", Rust => "Rust") - compiler_symbols = Dict(Int(C) => :c, Int(Go) => :go, Int(Rust) => :rust) + compiler_descriptions = Dict(C => "C/C++/Fortran", Go => "Go", Rust => "Rust", OCaml => "OCaml") + compiler_symbols = Dict(Int(C) => :c, Int(Go) => :go, Int(Rust) => :rust, Int(OCaml) => :ocaml) terminal = TTYTerminal("xterm", state.ins, state.outs, state.outs) result = nothing while true diff --git a/test/building.jl b/test/building.jl index 33e50537..11e003cb 100644 --- a/test/building.jl +++ b/test/building.jl @@ -156,6 +156,16 @@ shards_to_test = expand_cxxstring_abis(expand_gfortran_versions(shards_to_test)) push!(compilers, :rust) end + # OCaml is not available on 32-bit platforms, and our shards aren't for FreeBSD + if !(platforms_match(shard, Platform("i686", "windows")) || + platforms_match(shard, Platform("i686", "linux")) || + platforms_match(shard, Platform("armv6l", "linux")) || + platforms_match(shard, Platform("armv7l", "linux")) || + platforms_match(shard, Platform("aarch64", "freebsd"))) + push!(products, ExecutableProduct("hello_world_ocaml", :hello_world_ocaml)) + push!(compilers, :ocaml) + end + build_output_meta = autobuild( build_path, "testsuite", diff --git a/test/wizard.jl b/test/wizard.jl index 395b969e..7b05f325 100644 --- a/test/wizard.jl +++ b/test/wizard.jl @@ -180,7 +180,7 @@ end # Check that the state is modified appropriately @test state.source_urls == ["http://127.0.0.1:$(port)/a/source.tar.gz"] @test getfield.(state.source_files, :hash) == [libfoo_tarball_hash] - @test Set(state.compilers) == Set([:c, :rust, :go]) + @test Set(state.compilers) == Set([:c, :rust, :go, :ocaml]) @test state.preferred_gcc_version == getversion(available_gcc_builds[1]) # The default LLVM shard is the latest one, and above we pressed three times # arrow down in the reverse order list.