diff --git a/Project.toml b/Project.toml index 4661b4c1..6bd8d028 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "BinaryBuilderBase" uuid = "7f725544-6523-48cd-82d1-3fa08ff4056e" authors = ["Elliot Saba "] -version = "1.33.0" +version = "1.34.0" [deps] Bzip2_jll = "6e34b625-4abd-537c-b88f-471c36dfa7a0" diff --git a/src/Rootfs.jl b/src/Rootfs.jl index 8a891856..ca8a7c13 100644 --- a/src/Rootfs.jl +++ b/src/Rootfs.jl @@ -576,8 +576,8 @@ function choose_shards(p::AbstractPlatform; ps_build::VersionNumber=v"2024.08.10", GCC_builds::Vector{GCCBuild}=available_gcc_builds, LLVM_builds::Vector{LLVMBuild}=available_llvm_builds, - Rust_build::VersionNumber=maximum(getversion.(available_rust_builds)), - Go_build::VersionNumber=maximum(getversion.(available_go_builds)), + Rust_builds::Vector{RustBuild}=available_rust_builds, + Go_builds::Vector{GoBuild}=available_go_builds, archive_type::Symbol = (use_squashfs[] ? :squashfs : :unpacked), bootstrap_list::Vector{Symbol} = bootstrap_list, # Because GCC has lots of compatibility issues, we always default to @@ -586,6 +586,11 @@ function choose_shards(p::AbstractPlatform; # Because LLVM doesn't have compatibility issues, we always default # to the newest version possible. preferred_llvm_version::VersionNumber = getversion(LLVM_builds[end]), + # Rust can have compatibility issues between versions, but by default choose + # the newest one. + preferred_rust_version::VersionNumber = maximum(getversion.(Rust_builds)), + # Always default to the latest Go version + preferred_go_version::VersionNumber = maximum(getversion.(Go_builds)), ) function find_shard(name, version, archive_type; target = nothing) @@ -654,9 +659,23 @@ function choose_shards(p::AbstractPlatform; end if :rust in compilers + # Make sure the selected Rust toolchain version is available + if preferred_rust_version in getversion.(Rust_builds) + Rust_build = preferred_rust_version + else + error("Requested Rust toolchain $(preferred_rust_version) not available in $(Rust_builds)") + end + + base_shard = find_shard("RustBase", Rust_build, archive_type) + toolchain_shard = find_shard("RustToolchain", Rust_build, archive_type; target=p) + + if isnothing(toolchain_shard) + error("Requested Rust toolchain $(preferred_rust_version) not available on platform $(triplet(p))") + end + append!(shards, [ - find_shard("RustBase", Rust_build, archive_type), - find_shard("RustToolchain", Rust_build, archive_type; target=p), + base_shard, + toolchain_shard, ]) if !platforms_match(p, default_host_platform) @@ -677,6 +696,13 @@ function choose_shards(p::AbstractPlatform; end if :go in compilers + # Make sure the selected Go toolchain version is available + if preferred_go_version in getversion.(Go_builds) + Go_build = preferred_go_version + else + error("Requested Go toolchain $(preferred_go_version) not available in $(Go_builds)") + end + push!(shards, find_shard("Go", Go_build, archive_type)) end else diff --git a/test/rootfs.jl b/test/rootfs.jl index 77f5f065..ccdb6678 100644 --- a/test/rootfs.jl +++ b/test/rootfs.jl @@ -1,6 +1,7 @@ using Test using Base.BinaryPlatforms using BinaryBuilderBase +using BinaryBuilderBase: RustBuild, CompilerShard @testset "Expand platforms" begin # expand_gfortran_versions @@ -117,6 +118,28 @@ end @testset "Compiler Shards" begin @test_throws ErrorException CompilerShard("GCCBootstrap", v"4", Platform("x86_64", "linux"), :invalid_archive_type) + @testset "Rust toolchain selection" begin + platform = Platform("x86_64", "linux") + common_opts = (preferred_gcc_version=v"9", compilers=[:c, :rust]) + + shards = choose_shards(platform; preferred_rust_version = v"1.73", (common_opts)... ) + @test filter(s-> s.name == "RustBase", shards)[end].version == v"1.73" + @test filter(s-> s.name == "RustToolchain", shards)[end].version == v"1.73" + + @test_throws ErrorException choose_shards(platform; preferred_rust_version = v"1.78", (common_opts)...) + end + + @testset "Go toolchain selection" begin + platform = Platform("x86_64", "linux") + common_opts = (preferred_gcc_version=v"9", compilers=[:c, :go]) + + shards = choose_shards(platform; preferred_go_version = v"1.13", (common_opts)... ) + @test filter(s-> s.name == "Go", shards)[end].version == v"1.13" + + # 1.14 was never added, so use that as the testcase here + @test_throws ErrorException choose_shards(platform; preferred_go_version = v"1.14", (common_opts)...) + end + @testset "GCC ABI matching" begin # Preferred libgfortran version and C++ string ABI platform = Platform("x86_64", "freebsd")