Skip to content

Commit d922efe

Browse files
authored
Merge pull request #399 from JuliaPackaging/im/verselect
Allow specifying a Rust and Go toolchain version for the build
2 parents d7b9ffa + d4b8507 commit d922efe

File tree

3 files changed

+54
-5
lines changed

3 files changed

+54
-5
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "BinaryBuilderBase"
22
uuid = "7f725544-6523-48cd-82d1-3fa08ff4056e"
33
authors = ["Elliot Saba <staticfloat@gmail.com>"]
4-
version = "1.33.0"
4+
version = "1.34.0"
55

66
[deps]
77
Bzip2_jll = "6e34b625-4abd-537c-b88f-471c36dfa7a0"

src/Rootfs.jl

+30-4
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,8 @@ function choose_shards(p::AbstractPlatform;
576576
ps_build::VersionNumber=v"2024.08.10",
577577
GCC_builds::Vector{GCCBuild}=available_gcc_builds,
578578
LLVM_builds::Vector{LLVMBuild}=available_llvm_builds,
579-
Rust_build::VersionNumber=maximum(getversion.(available_rust_builds)),
580-
Go_build::VersionNumber=maximum(getversion.(available_go_builds)),
579+
Rust_builds::Vector{RustBuild}=available_rust_builds,
580+
Go_builds::Vector{GoBuild}=available_go_builds,
581581
archive_type::Symbol = (use_squashfs[] ? :squashfs : :unpacked),
582582
bootstrap_list::Vector{Symbol} = bootstrap_list,
583583
# Because GCC has lots of compatibility issues, we always default to
@@ -586,6 +586,11 @@ function choose_shards(p::AbstractPlatform;
586586
# Because LLVM doesn't have compatibility issues, we always default
587587
# to the newest version possible.
588588
preferred_llvm_version::VersionNumber = getversion(LLVM_builds[end]),
589+
# Rust can have compatibility issues between versions, but by default choose
590+
# the newest one.
591+
preferred_rust_version::VersionNumber = maximum(getversion.(Rust_builds)),
592+
# Always default to the latest Go version
593+
preferred_go_version::VersionNumber = maximum(getversion.(Go_builds)),
589594
)
590595

591596
function find_shard(name, version, archive_type; target = nothing)
@@ -654,9 +659,23 @@ function choose_shards(p::AbstractPlatform;
654659
end
655660

656661
if :rust in compilers
662+
# Make sure the selected Rust toolchain version is available
663+
if preferred_rust_version in getversion.(Rust_builds)
664+
Rust_build = preferred_rust_version
665+
else
666+
error("Requested Rust toolchain $(preferred_rust_version) not available in $(Rust_builds)")
667+
end
668+
669+
base_shard = find_shard("RustBase", Rust_build, archive_type)
670+
toolchain_shard = find_shard("RustToolchain", Rust_build, archive_type; target=p)
671+
672+
if isnothing(toolchain_shard)
673+
error("Requested Rust toolchain $(preferred_rust_version) not available on platform $(triplet(p))")
674+
end
675+
657676
append!(shards, [
658-
find_shard("RustBase", Rust_build, archive_type),
659-
find_shard("RustToolchain", Rust_build, archive_type; target=p),
677+
base_shard,
678+
toolchain_shard,
660679
])
661680

662681
if !platforms_match(p, default_host_platform)
@@ -677,6 +696,13 @@ function choose_shards(p::AbstractPlatform;
677696
end
678697

679698
if :go in compilers
699+
# Make sure the selected Go toolchain version is available
700+
if preferred_go_version in getversion.(Go_builds)
701+
Go_build = preferred_go_version
702+
else
703+
error("Requested Go toolchain $(preferred_go_version) not available in $(Go_builds)")
704+
end
705+
680706
push!(shards, find_shard("Go", Go_build, archive_type))
681707
end
682708
else

test/rootfs.jl

+23
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Test
22
using Base.BinaryPlatforms
33
using BinaryBuilderBase
4+
using BinaryBuilderBase: RustBuild, CompilerShard
45

56
@testset "Expand platforms" begin
67
# expand_gfortran_versions
@@ -117,6 +118,28 @@ end
117118
@testset "Compiler Shards" begin
118119
@test_throws ErrorException CompilerShard("GCCBootstrap", v"4", Platform("x86_64", "linux"), :invalid_archive_type)
119120

121+
@testset "Rust toolchain selection" begin
122+
platform = Platform("x86_64", "linux")
123+
common_opts = (preferred_gcc_version=v"9", compilers=[:c, :rust])
124+
125+
shards = choose_shards(platform; preferred_rust_version = v"1.73", (common_opts)... )
126+
@test filter(s-> s.name == "RustBase", shards)[end].version == v"1.73"
127+
@test filter(s-> s.name == "RustToolchain", shards)[end].version == v"1.73"
128+
129+
@test_throws ErrorException choose_shards(platform; preferred_rust_version = v"1.78", (common_opts)...)
130+
end
131+
132+
@testset "Go toolchain selection" begin
133+
platform = Platform("x86_64", "linux")
134+
common_opts = (preferred_gcc_version=v"9", compilers=[:c, :go])
135+
136+
shards = choose_shards(platform; preferred_go_version = v"1.13", (common_opts)... )
137+
@test filter(s-> s.name == "Go", shards)[end].version == v"1.13"
138+
139+
# 1.14 was never added, so use that as the testcase here
140+
@test_throws ErrorException choose_shards(platform; preferred_go_version = v"1.14", (common_opts)...)
141+
end
142+
120143
@testset "GCC ABI matching" begin
121144
# Preferred libgfortran version and C++ string ABI
122145
platform = Platform("x86_64", "freebsd")

0 commit comments

Comments
 (0)