Skip to content

Commit a0c34b8

Browse files
committed
Add new keyword argument for restoring old behaviour
1 parent 0fe40da commit a0c34b8

File tree

2 files changed

+59
-10
lines changed

2 files changed

+59
-10
lines changed

src/Rootfs.jl

Lines changed: 25 additions & 10 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]
@@ -850,8 +852,16 @@ function expand_gfortran_versions(platform::AbstractPlatform)
850852
return [platform] #MSAN doesn't use libgfortran, it uses libflang
851853
end
852854

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

856866
# Create a new platform for each libgfortran version
857867
return map(libgfortran_versions) do v
@@ -860,12 +870,12 @@ function expand_gfortran_versions(platform::AbstractPlatform)
860870
return p
861871
end
862872
end
863-
function expand_gfortran_versions(ps::Vector{T}) where {T<:AbstractPlatform}
864-
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)))
865875
end
866876

867877
"""
868-
expand_cxxstring_abis(p::AbstractPlatform; skip=Sys.isbsd)
878+
expand_cxxstring_abis(p::AbstractPlatform; skip=Sys.isbsd, old_abis::Bool=false)
869879
870880
Given a `Platform`, returns an array of `Platforms` with a spread of identical
871881
entries with the exception of the `cxxstring_abi` tag within the `Platform`
@@ -877,8 +887,12 @@ If the given `Platform` already specifies a `cxxstring_abi` (as opposed to
877887
`skip(platform)` evaluates to `true`, the given platform is not expanded. By
878888
default FreeBSD and macOS platforms are skipped, due to their lack of a
879889
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+
880894
"""
881-
function expand_cxxstring_abis(platform::AbstractPlatform; skip=Sys.isbsd)
895+
function expand_cxxstring_abis(platform::AbstractPlatform; skip=Sys.isbsd, old_abis::Bool=false)
882896
# If this platform cannot/should not be expanded, then exit out fast here.
883897
if cxxstring_abi(platform) !== nothing || skip(platform)
884898
return [platform]
@@ -891,7 +905,8 @@ function expand_cxxstring_abis(platform::AbstractPlatform; skip=Sys.isbsd)
891905
end
892906

893907
# Otherwise, generate new versions! At the moment we only support the C++11 string ABI.
894-
map(["cxx11",]) do abi
908+
abis = old_abis ? ["cxx03", "cxx11"] : ["cxx11"]
909+
map(abis) do abi
895910
p = deepcopy(platform)
896911
p["cxxstring_abi"] = abi
897912
return p

test/rootfs.jl

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,35 @@ using BinaryBuilderBase: RustBuild, CompilerShard
88
@test expand_gfortran_versions(Platform("i686", "windows")) == [
99
Platform("i686", "windows"; libgfortran_version=v"5"),
1010
]
11+
@test expand_gfortran_versions(Platform("i686", "windows"); old_abis=true) == [
12+
Platform("i686", "windows"; libgfortran_version=v"3"),
13+
Platform("i686", "windows"; libgfortran_version=v"4"),
14+
Platform("i686", "windows"; libgfortran_version=v"5"),
15+
]
1116
@test expand_gfortran_versions([Platform("i686", "windows"), Platform("x86_64", "windows")]) == [
1217
Platform("i686", "windows"; libgfortran_version=v"5"),
1318
Platform("x86_64", "windows"; libgfortran_version=v"5"),
1419
]
20+
@test expand_gfortran_versions([Platform("i686", "windows"), Platform("x86_64", "windows")]; old_abis=true) == [
21+
Platform("i686", "windows"; libgfortran_version=v"3"),
22+
Platform("i686", "windows"; libgfortran_version=v"4"),
23+
Platform("i686", "windows"; libgfortran_version=v"5"),
24+
Platform("x86_64", "windows"; libgfortran_version=v"3"),
25+
Platform("x86_64", "windows"; libgfortran_version=v"4"),
26+
Platform("x86_64", "windows"; libgfortran_version=v"5"),
27+
]
1528
@test expand_gfortran_versions([Platform("x86_64", "freebsd"; libgfortran_version=v"3")]) ==
1629
[Platform("x86_64", "freebsd"; libgfortran_version=v"3")]
1730
@test expand_gfortran_versions([Platform("x86_64", "macos"), Platform("aarch64", "macos")]) == [
1831
Platform("x86_64", "macos"; libgfortran_version=v"5"),
1932
Platform("aarch64", "macos"; libgfortran_version=v"5"),
2033
]
34+
@test expand_gfortran_versions([Platform("x86_64", "macos"), Platform("aarch64", "macos")]; old_abis=true) == [
35+
Platform("x86_64", "macos"; libgfortran_version=v"3"),
36+
Platform("x86_64", "macos"; libgfortran_version=v"4"),
37+
Platform("x86_64", "macos"; libgfortran_version=v"5"),
38+
Platform("aarch64", "macos"; libgfortran_version=v"5"),
39+
]
2140
@test expand_gfortran_versions(Platform("aarch64", "freebsd")) ==
2241
[Platform("aarch64", "freebsd"; libgfortran_version=v"5")]
2342
@test expand_gfortran_versions([Platform("x86_64", "linux"; sanitize="memory")]) ==
@@ -28,6 +47,10 @@ using BinaryBuilderBase: RustBuild, CompilerShard
2847
@test expand_cxxstring_abis(Platform("x86_64", "linux"; libc="musl")) == [
2948
Platform("x86_64", "linux", libc="musl", cxxstring_abi="cxx11"),
3049
]
50+
@test expand_cxxstring_abis(Platform("x86_64", "linux"; libc="musl"); old_abis=true) == [
51+
Platform("x86_64", "linux", libc="musl", cxxstring_abi="cxx03"),
52+
Platform("x86_64", "linux", libc="musl", cxxstring_abi="cxx11"),
53+
]
3154
@test expand_cxxstring_abis([Platform("x86_64", "freebsd"), Platform("x86_64", "macos")]) == [
3255
Platform("x86_64", "freebsd"),
3356
Platform("x86_64", "macos"),
@@ -36,10 +59,21 @@ using BinaryBuilderBase: RustBuild, CompilerShard
3659
Platform("x86_64", "freebsd"; cxxstring_abi="cxx11"),
3760
Platform("x86_64", "macos"; cxxstring_abi="cxx11"),
3861
]
62+
@test expand_cxxstring_abis([Platform("x86_64", "freebsd"), Platform("x86_64", "macos")]; skip=_->false, old_abis=true) == [
63+
Platform("x86_64", "freebsd"; cxxstring_abi="cxx03"),
64+
Platform("x86_64", "freebsd"; cxxstring_abi="cxx11"),
65+
Platform("x86_64", "macos"; cxxstring_abi="cxx03"),
66+
Platform("x86_64", "macos"; cxxstring_abi="cxx11"),
67+
]
3968
@test expand_cxxstring_abis([Platform("x86_64", "freebsd"), Platform("x86_64", "linux")]; skip=Sys.islinux) == [
4069
Platform("x86_64", "freebsd"; cxxstring_abi="cxx11"),
4170
Platform("x86_64", "linux"),
4271
]
72+
@test expand_cxxstring_abis([Platform("x86_64", "freebsd"), Platform("x86_64", "linux")]; skip=Sys.islinux, old_abis=true) == [
73+
Platform("x86_64", "freebsd"; cxxstring_abi="cxx03"),
74+
Platform("x86_64", "freebsd"; cxxstring_abi="cxx11"),
75+
Platform("x86_64", "linux"),
76+
]
4377
@test expand_cxxstring_abis([Platform("i686", "linux"; cxxstring_abi="cxx11")]) ==
4478
[Platform("i686", "linux"; cxxstring_abi="cxx11")]
4579
@test expand_cxxstring_abis([Platform("x86_64", "linux"; sanitize="memory")]) ==

0 commit comments

Comments
 (0)