Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 <staticfloat@gmail.com>"]
version = "1.41.0"
version = "1.42.0"

[deps]
Bzip2_jll = "6e34b625-4abd-537c-b88f-471c36dfa7a0"
Expand Down
34 changes: 20 additions & 14 deletions src/Rootfs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -831,16 +831,18 @@ function supported_platforms(;exclude::Union{Vector{<:Platform},Function}=Return
end

"""
expand_gfortran_versions(p::AbstractPlatform)
expand_gfortran_versions(p::AbstractPlatform; old_abis::Bool=false)

Given a `Platform`, returns an array of `Platforms` with a spread of identical
entries with the exception of the `libgfortran_version` tag within the
`Platform`. This is used to take, for example, a list of supported platforms
and expand them to include multiple GCC versions for the purposes of ABI
matching. If the given `Platform` already specifies a `libgfortran_version`
(as opposed to `nothing`) only that `Platform` is returned.
(as opposed to `nothing`) only that `Platform` is returned. If `old_abis` is
`true`, old ABIs are included in the expanded list, otherwise only the new
ones are included.
"""
function expand_gfortran_versions(platform::AbstractPlatform)
function expand_gfortran_versions(platform::AbstractPlatform; old_abis::Bool=false)
# If this platform is already explicitly libgfortran-versioned, exit out fast here.
if libgfortran_version(platform) !== nothing
return [platform]
Expand All @@ -852,14 +854,13 @@ function expand_gfortran_versions(platform::AbstractPlatform)

# If this is an platform that has limited GCC support (such as aarch64-apple-darwin),
# the libgfortran versions we can expand to are similarly limited.
local libgfortran_versions
if Sys.isbsd(platform) && arch(platform) == "aarch64"
libgfortran_versions = [v"5"]
libgfortran_versions = if Sys.isbsd(platform) && arch(platform) == "aarch64"
[v"5"]
elseif arch(platform) == "riscv64"
# We don't have older GCC versions
libgfortran_versions = [v"5"]
[v"5"]
else
libgfortran_versions = [v"3", v"4", v"5"]
old_abis ? [v"3", v"4", v"5"] : [v"5"]
end

# Create a new platform for each libgfortran version
Expand All @@ -869,12 +870,12 @@ function expand_gfortran_versions(platform::AbstractPlatform)
return p
end
end
function expand_gfortran_versions(ps::Vector{T}) where {T<:AbstractPlatform}
return collect(T,Iterators.flatten(expand_gfortran_versions.(ps)))
function expand_gfortran_versions(ps::Vector{T}; old_abis::Bool=false) where {T<:AbstractPlatform}
return collect(T,Iterators.flatten(expand_gfortran_versions.(ps; old_abis)))
end

"""
expand_cxxstring_abis(p::AbstractPlatform; skip=Sys.isbsd)
expand_cxxstring_abis(p::AbstractPlatform; skip=Sys.isbsd, old_abis::Bool=false)

Given a `Platform`, returns an array of `Platforms` with a spread of identical
entries with the exception of the `cxxstring_abi` tag within the `Platform`
Expand All @@ -886,8 +887,12 @@ If the given `Platform` already specifies a `cxxstring_abi` (as opposed to
`skip(platform)` evaluates to `true`, the given platform is not expanded. By
default FreeBSD and macOS platforms are skipped, due to their lack of a
dependence on `libstdc++` and not needing this compatibility shim.

If `old_abis` is `true`, old ABIs are included in the expanded list, otherwise
only the new ones are included.

"""
function expand_cxxstring_abis(platform::AbstractPlatform; skip=Sys.isbsd)
function expand_cxxstring_abis(platform::AbstractPlatform; skip=Sys.isbsd, old_abis::Bool=false)
# If this platform cannot/should not be expanded, then exit out fast here.
if cxxstring_abi(platform) !== nothing || skip(platform)
return [platform]
Expand All @@ -899,8 +904,9 @@ function expand_cxxstring_abis(platform::AbstractPlatform; skip=Sys.isbsd)
return [p]
end

# Otherwise, generate new versions!
map(["cxx03", "cxx11"]) do abi
# Otherwise, generate new versions! At the moment we only support the C++11 string ABI.
abis = old_abis ? ["cxx03", "cxx11"] : ["cxx11"]
map(abis) do abi
p = deepcopy(platform)
p["cxxstring_abi"] = abi
return p
Expand Down
22 changes: 22 additions & 0 deletions test/rootfs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@ using BinaryBuilderBase: RustBuild, CompilerShard
@testset "Expand platforms" begin
# expand_gfortran_versions
@test expand_gfortran_versions(Platform("i686", "windows")) == [
Platform("i686", "windows"; libgfortran_version=v"5"),
]
@test expand_gfortran_versions(Platform("i686", "windows"); old_abis=true) == [
Platform("i686", "windows"; libgfortran_version=v"3"),
Platform("i686", "windows"; libgfortran_version=v"4"),
Platform("i686", "windows"; libgfortran_version=v"5"),
]
@test expand_gfortran_versions([Platform("i686", "windows"), Platform("x86_64", "windows")]) == [
Platform("i686", "windows"; libgfortran_version=v"5"),
Platform("x86_64", "windows"; libgfortran_version=v"5"),
]
@test expand_gfortran_versions([Platform("i686", "windows"), Platform("x86_64", "windows")]; old_abis=true) == [
Platform("i686", "windows"; libgfortran_version=v"3"),
Platform("i686", "windows"; libgfortran_version=v"4"),
Platform("i686", "windows"; libgfortran_version=v"5"),
Expand All @@ -21,6 +28,10 @@ using BinaryBuilderBase: RustBuild, CompilerShard
@test expand_gfortran_versions([Platform("x86_64", "freebsd"; libgfortran_version=v"3")]) ==
[Platform("x86_64", "freebsd"; libgfortran_version=v"3")]
@test expand_gfortran_versions([Platform("x86_64", "macos"), Platform("aarch64", "macos")]) == [
Platform("x86_64", "macos"; libgfortran_version=v"5"),
Platform("aarch64", "macos"; libgfortran_version=v"5"),
]
@test expand_gfortran_versions([Platform("x86_64", "macos"), Platform("aarch64", "macos")]; old_abis=true) == [
Platform("x86_64", "macos"; libgfortran_version=v"3"),
Platform("x86_64", "macos"; libgfortran_version=v"4"),
Platform("x86_64", "macos"; libgfortran_version=v"5"),
Expand All @@ -34,6 +45,9 @@ using BinaryBuilderBase: RustBuild, CompilerShard

# expand_cxxstring_abis
@test expand_cxxstring_abis(Platform("x86_64", "linux"; libc="musl")) == [
Platform("x86_64", "linux", libc="musl", cxxstring_abi="cxx11"),
]
@test expand_cxxstring_abis(Platform("x86_64", "linux"; libc="musl"); old_abis=true) == [
Platform("x86_64", "linux", libc="musl", cxxstring_abi="cxx03"),
Platform("x86_64", "linux", libc="musl", cxxstring_abi="cxx11"),
]
Expand All @@ -42,12 +56,20 @@ using BinaryBuilderBase: RustBuild, CompilerShard
Platform("x86_64", "macos"),
]
@test expand_cxxstring_abis([Platform("x86_64", "freebsd"), Platform("x86_64", "macos")]; skip=_->false) == [
Platform("x86_64", "freebsd"; cxxstring_abi="cxx11"),
Platform("x86_64", "macos"; cxxstring_abi="cxx11"),
]
@test expand_cxxstring_abis([Platform("x86_64", "freebsd"), Platform("x86_64", "macos")]; skip=_->false, old_abis=true) == [
Platform("x86_64", "freebsd"; cxxstring_abi="cxx03"),
Platform("x86_64", "freebsd"; cxxstring_abi="cxx11"),
Platform("x86_64", "macos"; cxxstring_abi="cxx03"),
Platform("x86_64", "macos"; cxxstring_abi="cxx11"),
]
@test expand_cxxstring_abis([Platform("x86_64", "freebsd"), Platform("x86_64", "linux")]; skip=Sys.islinux) == [
Platform("x86_64", "freebsd"; cxxstring_abi="cxx11"),
Platform("x86_64", "linux"),
]
@test expand_cxxstring_abis([Platform("x86_64", "freebsd"), Platform("x86_64", "linux")]; skip=Sys.islinux, old_abis=true) == [
Platform("x86_64", "freebsd"; cxxstring_abi="cxx03"),
Platform("x86_64", "freebsd"; cxxstring_abi="cxx11"),
Platform("x86_64", "linux"),
Expand Down
Loading