Skip to content

Commit

Permalink
Merge pull request #399 from JuliaPackaging/im/verselect
Browse files Browse the repository at this point in the history
Allow specifying a Rust and Go toolchain version for the build
  • Loading branch information
imciner2 authored Dec 26, 2024
2 parents d7b9ffa + d4b8507 commit d922efe
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "BinaryBuilderBase"
uuid = "7f725544-6523-48cd-82d1-3fa08ff4056e"
authors = ["Elliot Saba <[email protected]>"]
version = "1.33.0"
version = "1.34.0"

[deps]
Bzip2_jll = "6e34b625-4abd-537c-b88f-471c36dfa7a0"
Expand Down
34 changes: 30 additions & 4 deletions src/Rootfs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
23 changes: 23 additions & 0 deletions test/rootfs.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Test
using Base.BinaryPlatforms
using BinaryBuilderBase
using BinaryBuilderBase: RustBuild, CompilerShard

@testset "Expand platforms" begin
# expand_gfortran_versions
Expand Down Expand Up @@ -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")
Expand Down

2 comments on commit d922efe

@imciner2
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/122031

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.34.0 -m "<description of version>" d922efe326812a414fd9ccc61b91b2107c01d747
git push origin v1.34.0

Please sign in to comment.