Skip to content

Commit 76a9f10

Browse files
committed
Allow selecting the go toolchain version
1 parent 4503002 commit 76a9f10

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/Rootfs.jl

+10-1
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ function choose_shards(p::AbstractPlatform;
577577
GCC_builds::Vector{GCCBuild}=available_gcc_builds,
578578
LLVM_builds::Vector{LLVMBuild}=available_llvm_builds,
579579
Rust_builds::Vector{RustBuild}=available_rust_builds,
580-
Go_build::VersionNumber=maximum(getversion.(available_go_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
@@ -589,6 +589,8 @@ function choose_shards(p::AbstractPlatform;
589589
# Rust can have compatibility issues between versions, but by default choose
590590
# the newest one.
591591
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)),
592594
)
593595

594596
function find_shard(name, version, archive_type; target = nothing)
@@ -687,6 +689,13 @@ function choose_shards(p::AbstractPlatform;
687689
end
688690

689691
if :go in compilers
692+
# Make sure the selected Go toolchain version is available
693+
if preferred_go_version in getversion.(Go_builds)
694+
Go_build = preferred_go_version
695+
else
696+
error("Requested Go toolchain $(preferred_go_version) not available in $(Go_builds)")
697+
end
698+
690699
push!(shards, find_shard("Go", Go_build, archive_type))
691700
end
692701
else

test/rootfs.jl

+11
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,17 @@ end
129129
@test_throws ErrorException choose_shards(platform; preferred_rust_version = v"1.78", (common_opts)...)
130130
end
131131

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+
132143
@testset "GCC ABI matching" begin
133144
# Preferred libgfortran version and C++ string ABI
134145
platform = Platform("x86_64", "freebsd")

0 commit comments

Comments
 (0)