Skip to content
This repository was archived by the owner on Aug 16, 2023. It is now read-only.

Commit 241bdc4

Browse files
authored
Add :gcc5 and :gcc6 as valid GCC choices for future-proofing (#139)
`platform_matches()` will consider `:gcc4`, `:gcc5` and `:gcc6` as all matching at this point, as we only really care about libgfortran version. The latest compatible release should be the one that gets downloaded in the event of an ambiguity.
1 parent 0f1d2cb commit 241bdc4

File tree

2 files changed

+48
-4
lines changed

2 files changed

+48
-4
lines changed

src/PlatformNames.jl

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ end
1010
# We need to track our compiler ABI compatibility.
1111
struct CompilerABI
1212
# Major GCC version that we're locked into.
13-
# Can be [:gcc4, :gcc7, :gcc8, :gcc_any]
13+
# Can be [:gcc4, :gcc5, :gcc6, :gcc7, :gcc8, :gcc_any]
1414
gcc_version::Symbol
1515

1616
# Whether we're using cxx11abi strings
1717
# Can be [:cxx03, :cxx11, :cxx_any]
1818
cxx_abi::Symbol
1919

2020
function CompilerABI(gcc_version::Symbol = :gcc_any, cxx_abi::Symbol = :cxx_any)
21-
if !in(gcc_version, [:gcc4, :gcc7, :gcc8, :gcc_any])
21+
if !in(gcc_version, [:gcc4, :gcc5, :gcc6, :gcc7, :gcc8, :gcc_any])
2222
throw(ArgumentError("Unsupported GCC major version '$gcc_version'"))
2323
end
2424

@@ -389,6 +389,8 @@ function platform_key_abi(machine::AbstractString)
389389
gcc_version_mapping = Dict(
390390
:gcc_any => "",
391391
:gcc4 => "-gcc4",
392+
:gcc5 => "-gcc5",
393+
:gcc6 => "-gcc6",
392394
:gcc7 => "-gcc7",
393395
:gcc8 => "-gcc8",
394396
)
@@ -703,9 +705,21 @@ function platforms_match(a::Platform, b::Platform)
703705
function flexible_constraints(a, b)
704706
ac = compiler_abi(a)
705707
bc = compiler_abi(b)
708+
709+
# Map from GCC version to libgfortran SO version
710+
gfmap = Dict(
711+
:gcc4 => 3,
712+
:gcc5 => 3,
713+
:gcc6 => 3,
714+
:gcc7 => 4,
715+
:gcc8 => 5,
716+
)
717+
718+
# We consider two GCC versions to match if their libgfortran
719+
# versions match; e.g. :gcc4 and :gcc5 match.
706720
gcc_match = (ac.gcc_version == :gcc_any
707721
|| bc.gcc_version == :gcc_any
708-
|| ac.gcc_version == bc.gcc_version)
722+
|| gfmap[ac.gcc_version] == gfmap[bc.gcc_version])
709723
cxx_match = (ac.cxx_abi == :cxx_any
710724
|| bc.cxx_abi == :cxx_any
711725
|| ac.cxx_abi == bc.cxx_abi)

test/runtests.jl

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,20 @@ end
271271
@test !BinaryProvider.platforms_match(Linux(:x86_64), UnknownPlatform())
272272
@test !BinaryProvider.platforms_match(Linux(:x86_64, compiler_abi=CompilerABI(:gcc7)), Linux(:x86_64, compiler_abi=CompilerABI(:gcc8)))
273273
@test !BinaryProvider.platforms_match(Linux(:x86_64, compiler_abi=CompilerABI(:gcc7, :cxx11)), Linux(:x86_64, compiler_abi=CompilerABI(:gcc7, :cxx03)))
274+
275+
# Test that :gcc4 matches with :gcc5 and :gcc6, as we only care aobut libgfortran version
276+
@test BinaryProvider.platforms_match(
277+
Linux(:x86_64; compiler_abi=CompilerABI(:gcc4)),
278+
Linux(:x86_64; compiler_abi=CompilerABI(:gcc5)),
279+
)
280+
@test BinaryProvider.platforms_match(
281+
Linux(:x86_64; compiler_abi=CompilerABI(:gcc4)),
282+
Linux(:x86_64; compiler_abi=CompilerABI(:gcc6)),
283+
)
284+
@test BinaryProvider.platforms_match(
285+
Linux(:x86_64; compiler_abi=CompilerABI(:gcc5)),
286+
Linux(:x86_64; compiler_abi=CompilerABI(:gcc6)),
287+
)
274288
end
275289

276290
@testset "DL name/version parsing" begin
@@ -789,21 +803,37 @@ end
789803

790804
@testset "choose_download" begin
791805
platforms = Dict(
806+
# Typical binning test
792807
Linux(:x86_64, compiler_abi=CompilerABI(:gcc4)) => "linux4",
793808
Linux(:x86_64, compiler_abi=CompilerABI(:gcc7)) => "linux7",
794809
Linux(:x86_64, compiler_abi=CompilerABI(:gcc8)) => "linux8",
810+
811+
# Ambiguity test
812+
Linux(:aarch64, compiler_abi=CompilerABI(:gcc4)) => "linux4",
813+
Linux(:aarch64, compiler_abi=CompilerABI(:gcc5)) => "linux5",
814+
795815
MacOS(:x86_64, compiler_abi=CompilerABI(:gcc4)) => "mac4",
796816
Windows(:x86_64, compiler_abi=CompilerABI(:gcc_any, :cxx11)) => "win",
797817
)
798818

799819
@test choose_download(platforms, Linux(:x86_64)) == "linux8"
800820
@test choose_download(platforms, Linux(:x86_64, compiler_abi=CompilerABI(:gcc7))) == "linux7"
801-
821+
822+
# Ambiguity test
823+
@test choose_download(platforms, Linux(:aarch64)) == "linux5"
824+
@test choose_download(platforms, Linux(:aarch64; compiler_abi=CompilerABI(:gcc4))) == "linux5"
825+
@test choose_download(platforms, Linux(:aarch64; compiler_abi=CompilerABI(:gcc5))) == "linux5"
826+
@test choose_download(platforms, Linux(:aarch64; compiler_abi=CompilerABI(:gcc6))) == "linux5"
827+
@test choose_download(platforms, Linux(:aarch64; compiler_abi=CompilerABI(:gcc7))) == nothing
828+
802829
@test choose_download(platforms, MacOS(:x86_64)) == "mac4"
803830
@test choose_download(platforms, MacOS(:x86_64, compiler_abi=CompilerABI(:gcc7))) == nothing
804831

805832
@test choose_download(platforms, Windows(:x86_64, compiler_abi=CompilerABI(:gcc_any, :cxx11))) == "win"
806833
@test choose_download(platforms, Windows(:x86_64, compiler_abi=CompilerABI(:gcc_any, :cxx03))) == nothing
834+
835+
# Poor little guy
836+
@test choose_download(platforms, FreeBSD(:x86_64)) == nothing
807837
end
808838

809839
# Use `build_libfoo_tarball.jl` in the BinaryBuilder.jl repository to generate more of these

0 commit comments

Comments
 (0)