Skip to content

Commit f6d4810

Browse files
authored
[Rootfs] Add keyword argument to exclude old ABIs from output of expand_* functions (#446)
* [Rootfs] Exclude some old ABIs from output of `expand_*` functions This was [announced](https://discourse.julialang.org/t/psa-intent-to-deprecate-cxx03-libgfortran3-libgfortran4-abis/130799) a few months ago and no one reacted, this implements the suggested changes. * Add new keyword argument for restoring old behaviour
1 parent aa54600 commit f6d4810

File tree

3 files changed

+43
-15
lines changed

3 files changed

+43
-15
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
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 <[email protected]>"]
4-
version = "1.41.0"
4+
version = "1.42.0"
55

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

src/Rootfs.jl

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -831,16 +831,18 @@ function supported_platforms(;exclude::Union{Vector{<:Platform},Function}=Return
831831
end
832832

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

853855
# If this is an platform that has limited GCC support (such as aarch64-apple-darwin),
854856
# the libgfortran versions we can expand to are similarly limited.
855-
local libgfortran_versions
856-
if Sys.isbsd(platform) && arch(platform) == "aarch64"
857-
libgfortran_versions = [v"5"]
857+
libgfortran_versions = if Sys.isbsd(platform) && arch(platform) == "aarch64"
858+
[v"5"]
858859
elseif arch(platform) == "riscv64"
859860
# We don't have older GCC versions
860-
libgfortran_versions = [v"5"]
861+
[v"5"]
861862
else
862-
libgfortran_versions = [v"3", v"4", v"5"]
863+
old_abis ? [v"3", v"4", v"5"] : [v"5"]
863864
end
864865

865866
# Create a new platform for each libgfortran version
@@ -869,12 +870,12 @@ function expand_gfortran_versions(platform::AbstractPlatform)
869870
return p
870871
end
871872
end
872-
function expand_gfortran_versions(ps::Vector{T}) where {T<:AbstractPlatform}
873-
return collect(T,Iterators.flatten(expand_gfortran_versions.(ps)))
873+
function expand_gfortran_versions(ps::Vector{T}; old_abis::Bool=false) where {T<:AbstractPlatform}
874+
return collect(T,Iterators.flatten(expand_gfortran_versions.(ps; old_abis)))
874875
end
875876

876877
"""
877-
expand_cxxstring_abis(p::AbstractPlatform; skip=Sys.isbsd)
878+
expand_cxxstring_abis(p::AbstractPlatform; skip=Sys.isbsd, old_abis::Bool=false)
878879
879880
Given a `Platform`, returns an array of `Platforms` with a spread of identical
880881
entries with the exception of the `cxxstring_abi` tag within the `Platform`
@@ -886,8 +887,12 @@ If the given `Platform` already specifies a `cxxstring_abi` (as opposed to
886887
`skip(platform)` evaluates to `true`, the given platform is not expanded. By
887888
default FreeBSD and macOS platforms are skipped, due to their lack of a
888889
dependence on `libstdc++` and not needing this compatibility shim.
890+
891+
If `old_abis` is `true`, old ABIs are included in the expanded list, otherwise
892+
only the new ones are included.
893+
889894
"""
890-
function expand_cxxstring_abis(platform::AbstractPlatform; skip=Sys.isbsd)
895+
function expand_cxxstring_abis(platform::AbstractPlatform; skip=Sys.isbsd, old_abis::Bool=false)
891896
# If this platform cannot/should not be expanded, then exit out fast here.
892897
if cxxstring_abi(platform) !== nothing || skip(platform)
893898
return [platform]
@@ -899,8 +904,9 @@ function expand_cxxstring_abis(platform::AbstractPlatform; skip=Sys.isbsd)
899904
return [p]
900905
end
901906

902-
# Otherwise, generate new versions!
903-
map(["cxx03", "cxx11"]) do abi
907+
# Otherwise, generate new versions! At the moment we only support the C++11 string ABI.
908+
abis = old_abis ? ["cxx03", "cxx11"] : ["cxx11"]
909+
map(abis) do abi
904910
p = deepcopy(platform)
905911
p["cxxstring_abi"] = abi
906912
return p

test/rootfs.jl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,18 @@ using BinaryBuilderBase: RustBuild, CompilerShard
66
@testset "Expand platforms" begin
77
# expand_gfortran_versions
88
@test expand_gfortran_versions(Platform("i686", "windows")) == [
9+
Platform("i686", "windows"; libgfortran_version=v"5"),
10+
]
11+
@test expand_gfortran_versions(Platform("i686", "windows"); old_abis=true) == [
912
Platform("i686", "windows"; libgfortran_version=v"3"),
1013
Platform("i686", "windows"; libgfortran_version=v"4"),
1114
Platform("i686", "windows"; libgfortran_version=v"5"),
1215
]
1316
@test expand_gfortran_versions([Platform("i686", "windows"), Platform("x86_64", "windows")]) == [
17+
Platform("i686", "windows"; libgfortran_version=v"5"),
18+
Platform("x86_64", "windows"; libgfortran_version=v"5"),
19+
]
20+
@test expand_gfortran_versions([Platform("i686", "windows"), Platform("x86_64", "windows")]; old_abis=true) == [
1421
Platform("i686", "windows"; libgfortran_version=v"3"),
1522
Platform("i686", "windows"; libgfortran_version=v"4"),
1623
Platform("i686", "windows"; libgfortran_version=v"5"),
@@ -21,6 +28,10 @@ using BinaryBuilderBase: RustBuild, CompilerShard
2128
@test expand_gfortran_versions([Platform("x86_64", "freebsd"; libgfortran_version=v"3")]) ==
2229
[Platform("x86_64", "freebsd"; libgfortran_version=v"3")]
2330
@test expand_gfortran_versions([Platform("x86_64", "macos"), Platform("aarch64", "macos")]) == [
31+
Platform("x86_64", "macos"; libgfortran_version=v"5"),
32+
Platform("aarch64", "macos"; libgfortran_version=v"5"),
33+
]
34+
@test expand_gfortran_versions([Platform("x86_64", "macos"), Platform("aarch64", "macos")]; old_abis=true) == [
2435
Platform("x86_64", "macos"; libgfortran_version=v"3"),
2536
Platform("x86_64", "macos"; libgfortran_version=v"4"),
2637
Platform("x86_64", "macos"; libgfortran_version=v"5"),
@@ -34,6 +45,9 @@ using BinaryBuilderBase: RustBuild, CompilerShard
3445

3546
# expand_cxxstring_abis
3647
@test expand_cxxstring_abis(Platform("x86_64", "linux"; libc="musl")) == [
48+
Platform("x86_64", "linux", libc="musl", cxxstring_abi="cxx11"),
49+
]
50+
@test expand_cxxstring_abis(Platform("x86_64", "linux"; libc="musl"); old_abis=true) == [
3751
Platform("x86_64", "linux", libc="musl", cxxstring_abi="cxx03"),
3852
Platform("x86_64", "linux", libc="musl", cxxstring_abi="cxx11"),
3953
]
@@ -42,12 +56,20 @@ using BinaryBuilderBase: RustBuild, CompilerShard
4256
Platform("x86_64", "macos"),
4357
]
4458
@test expand_cxxstring_abis([Platform("x86_64", "freebsd"), Platform("x86_64", "macos")]; skip=_->false) == [
59+
Platform("x86_64", "freebsd"; cxxstring_abi="cxx11"),
60+
Platform("x86_64", "macos"; cxxstring_abi="cxx11"),
61+
]
62+
@test expand_cxxstring_abis([Platform("x86_64", "freebsd"), Platform("x86_64", "macos")]; skip=_->false, old_abis=true) == [
4563
Platform("x86_64", "freebsd"; cxxstring_abi="cxx03"),
4664
Platform("x86_64", "freebsd"; cxxstring_abi="cxx11"),
4765
Platform("x86_64", "macos"; cxxstring_abi="cxx03"),
4866
Platform("x86_64", "macos"; cxxstring_abi="cxx11"),
4967
]
5068
@test expand_cxxstring_abis([Platform("x86_64", "freebsd"), Platform("x86_64", "linux")]; skip=Sys.islinux) == [
69+
Platform("x86_64", "freebsd"; cxxstring_abi="cxx11"),
70+
Platform("x86_64", "linux"),
71+
]
72+
@test expand_cxxstring_abis([Platform("x86_64", "freebsd"), Platform("x86_64", "linux")]; skip=Sys.islinux, old_abis=true) == [
5173
Platform("x86_64", "freebsd"; cxxstring_abi="cxx03"),
5274
Platform("x86_64", "freebsd"; cxxstring_abi="cxx11"),
5375
Platform("x86_64", "linux"),

0 commit comments

Comments
 (0)