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

Commit

Permalink
Add :gcc5 and :gcc6 as valid GCC choices for future-proofing (#139)
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
staticfloat authored Nov 12, 2018
1 parent 0f1d2cb commit 241bdc4
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 4 deletions.
20 changes: 17 additions & 3 deletions src/PlatformNames.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ end
# We need to track our compiler ABI compatibility.
struct CompilerABI
# Major GCC version that we're locked into.
# Can be [:gcc4, :gcc7, :gcc8, :gcc_any]
# Can be [:gcc4, :gcc5, :gcc6, :gcc7, :gcc8, :gcc_any]
gcc_version::Symbol

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

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

Expand Down Expand Up @@ -389,6 +389,8 @@ function platform_key_abi(machine::AbstractString)
gcc_version_mapping = Dict(
:gcc_any => "",
:gcc4 => "-gcc4",
:gcc5 => "-gcc5",
:gcc6 => "-gcc6",
:gcc7 => "-gcc7",
:gcc8 => "-gcc8",
)
Expand Down Expand Up @@ -703,9 +705,21 @@ function platforms_match(a::Platform, b::Platform)
function flexible_constraints(a, b)
ac = compiler_abi(a)
bc = compiler_abi(b)

# Map from GCC version to libgfortran SO version
gfmap = Dict(
:gcc4 => 3,
:gcc5 => 3,
:gcc6 => 3,
:gcc7 => 4,
:gcc8 => 5,
)

# We consider two GCC versions to match if their libgfortran
# versions match; e.g. :gcc4 and :gcc5 match.
gcc_match = (ac.gcc_version == :gcc_any
|| bc.gcc_version == :gcc_any
|| ac.gcc_version == bc.gcc_version)
|| gfmap[ac.gcc_version] == gfmap[bc.gcc_version])
cxx_match = (ac.cxx_abi == :cxx_any
|| bc.cxx_abi == :cxx_any
|| ac.cxx_abi == bc.cxx_abi)
Expand Down
32 changes: 31 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,20 @@ end
@test !BinaryProvider.platforms_match(Linux(:x86_64), UnknownPlatform())
@test !BinaryProvider.platforms_match(Linux(:x86_64, compiler_abi=CompilerABI(:gcc7)), Linux(:x86_64, compiler_abi=CompilerABI(:gcc8)))
@test !BinaryProvider.platforms_match(Linux(:x86_64, compiler_abi=CompilerABI(:gcc7, :cxx11)), Linux(:x86_64, compiler_abi=CompilerABI(:gcc7, :cxx03)))

# Test that :gcc4 matches with :gcc5 and :gcc6, as we only care aobut libgfortran version
@test BinaryProvider.platforms_match(
Linux(:x86_64; compiler_abi=CompilerABI(:gcc4)),
Linux(:x86_64; compiler_abi=CompilerABI(:gcc5)),
)
@test BinaryProvider.platforms_match(
Linux(:x86_64; compiler_abi=CompilerABI(:gcc4)),
Linux(:x86_64; compiler_abi=CompilerABI(:gcc6)),
)
@test BinaryProvider.platforms_match(
Linux(:x86_64; compiler_abi=CompilerABI(:gcc5)),
Linux(:x86_64; compiler_abi=CompilerABI(:gcc6)),
)
end

@testset "DL name/version parsing" begin
Expand Down Expand Up @@ -789,21 +803,37 @@ end

@testset "choose_download" begin
platforms = Dict(
# Typical binning test
Linux(:x86_64, compiler_abi=CompilerABI(:gcc4)) => "linux4",
Linux(:x86_64, compiler_abi=CompilerABI(:gcc7)) => "linux7",
Linux(:x86_64, compiler_abi=CompilerABI(:gcc8)) => "linux8",

# Ambiguity test
Linux(:aarch64, compiler_abi=CompilerABI(:gcc4)) => "linux4",
Linux(:aarch64, compiler_abi=CompilerABI(:gcc5)) => "linux5",

MacOS(:x86_64, compiler_abi=CompilerABI(:gcc4)) => "mac4",
Windows(:x86_64, compiler_abi=CompilerABI(:gcc_any, :cxx11)) => "win",
)

@test choose_download(platforms, Linux(:x86_64)) == "linux8"
@test choose_download(platforms, Linux(:x86_64, compiler_abi=CompilerABI(:gcc7))) == "linux7"


# Ambiguity test
@test choose_download(platforms, Linux(:aarch64)) == "linux5"
@test choose_download(platforms, Linux(:aarch64; compiler_abi=CompilerABI(:gcc4))) == "linux5"
@test choose_download(platforms, Linux(:aarch64; compiler_abi=CompilerABI(:gcc5))) == "linux5"
@test choose_download(platforms, Linux(:aarch64; compiler_abi=CompilerABI(:gcc6))) == "linux5"
@test choose_download(platforms, Linux(:aarch64; compiler_abi=CompilerABI(:gcc7))) == nothing

@test choose_download(platforms, MacOS(:x86_64)) == "mac4"
@test choose_download(platforms, MacOS(:x86_64, compiler_abi=CompilerABI(:gcc7))) == nothing

@test choose_download(platforms, Windows(:x86_64, compiler_abi=CompilerABI(:gcc_any, :cxx11))) == "win"
@test choose_download(platforms, Windows(:x86_64, compiler_abi=CompilerABI(:gcc_any, :cxx03))) == nothing

# Poor little guy
@test choose_download(platforms, FreeBSD(:x86_64)) == nothing
end

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

0 comments on commit 241bdc4

Please sign in to comment.