From 241bdc4bd78e8daf73244278e076d8588394a3af Mon Sep 17 00:00:00 2001 From: Elliot Saba Date: Mon, 12 Nov 2018 16:10:44 +0800 Subject: [PATCH] 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. --- src/PlatformNames.jl | 20 +++++++++++++++++--- test/runtests.jl | 32 +++++++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/src/PlatformNames.jl b/src/PlatformNames.jl index 36f7474..a36ef69 100644 --- a/src/PlatformNames.jl +++ b/src/PlatformNames.jl @@ -10,7 +10,7 @@ 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 @@ -18,7 +18,7 @@ struct CompilerABI 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 @@ -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", ) @@ -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) diff --git a/test/runtests.jl b/test/runtests.jl index ddf358a..9c616eb 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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 @@ -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