From 45030025e89a5ef703865bf2a13afda4fe7cf4cd Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Thu, 26 Dec 2024 17:57:07 +0000 Subject: [PATCH 1/4] Allow specifying a Rust toolchain version for the build --- src/Rootfs.jl | 12 +++++++++++- test/rootfs.jl | 12 ++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/Rootfs.jl b/src/Rootfs.jl index 8a891856..70757b5d 100644 --- a/src/Rootfs.jl +++ b/src/Rootfs.jl @@ -576,7 +576,7 @@ 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)), + Rust_builds::Vector{RustBuild}=available_rust_builds, Go_build::VersionNumber=maximum(getversion.(available_go_builds)), archive_type::Symbol = (use_squashfs[] ? :squashfs : :unpacked), bootstrap_list::Vector{Symbol} = bootstrap_list, @@ -586,6 +586,9 @@ 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)), ) function find_shard(name, version, archive_type; target = nothing) @@ -654,6 +657,13 @@ 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 + append!(shards, [ find_shard("RustBase", Rust_build, archive_type), find_shard("RustToolchain", Rust_build, archive_type; target=p), diff --git a/test/rootfs.jl b/test/rootfs.jl index 77f5f065..745e4739 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,17 @@ 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 "GCC ABI matching" begin # Preferred libgfortran version and C++ string ABI platform = Platform("x86_64", "freebsd") From 76a9f102d808913cec84d430271464c8c6cd1b91 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Thu, 26 Dec 2024 18:04:25 +0000 Subject: [PATCH 2/4] Allow selecting the go toolchain version --- src/Rootfs.jl | 11 ++++++++++- test/rootfs.jl | 11 +++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/Rootfs.jl b/src/Rootfs.jl index 70757b5d..80bc85ac 100644 --- a/src/Rootfs.jl +++ b/src/Rootfs.jl @@ -577,7 +577,7 @@ function choose_shards(p::AbstractPlatform; GCC_builds::Vector{GCCBuild}=available_gcc_builds, LLVM_builds::Vector{LLVMBuild}=available_llvm_builds, Rust_builds::Vector{RustBuild}=available_rust_builds, - Go_build::VersionNumber=maximum(getversion.(available_go_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 @@ -589,6 +589,8 @@ function choose_shards(p::AbstractPlatform; # 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) @@ -687,6 +689,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 745e4739..ccdb6678 100644 --- a/test/rootfs.jl +++ b/test/rootfs.jl @@ -129,6 +129,17 @@ end @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") From 14898202a54a4cdc67d40ecba621de1e767f7517 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Thu, 26 Dec 2024 20:36:16 +0000 Subject: [PATCH 3/4] Gracefully handle missing Rust toolchain on platforms --- src/Rootfs.jl | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Rootfs.jl b/src/Rootfs.jl index 80bc85ac..ca8a7c13 100644 --- a/src/Rootfs.jl +++ b/src/Rootfs.jl @@ -666,9 +666,16 @@ function choose_shards(p::AbstractPlatform; 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) From d4b8507d5274f03a09f39fb31ffb410755757353 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Thu, 26 Dec 2024 20:52:18 +0000 Subject: [PATCH 4/4] Bump version --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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"