Merge pull request #10512 from iMichka/gcc5
compilers: prefer gcc 5 on linux
This commit is contained in:
commit
066ef6b43e
@ -78,6 +78,7 @@ end
|
||||
#
|
||||
# @api private
|
||||
class CompilerSelector
|
||||
extend T::Sig
|
||||
include CompilerConstants
|
||||
|
||||
Compiler = Struct.new(:name, :version)
|
||||
@ -111,9 +112,14 @@ class CompilerSelector
|
||||
|
||||
private
|
||||
|
||||
sig { returns(String) }
|
||||
def preferred_gcc
|
||||
"gcc"
|
||||
end
|
||||
|
||||
def gnu_gcc_versions
|
||||
# prioritize gcc version provided by gcc formula.
|
||||
v = Formulary.factory("gcc").version.to_s.slice(/\d+/)
|
||||
v = Formulary.factory(preferred_gcc).version.to_s.slice(/\d+/)
|
||||
GNU_GCC_VERSIONS - [v] + [v] # move the version to the end of the list
|
||||
rescue FormulaUnavailableError
|
||||
GNU_GCC_VERSIONS
|
||||
@ -150,3 +156,5 @@ class CompilerSelector
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
require "extend/os/compilers"
|
||||
|
||||
4
Library/Homebrew/extend/os/compilers.rb
Normal file
4
Library/Homebrew/extend/os/compilers.rb
Normal file
@ -0,0 +1,4 @@
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "extend/os/linux/compilers" if OS.linux?
|
||||
11
Library/Homebrew/extend/os/linux/compilers.rb
Normal file
11
Library/Homebrew/extend/os/linux/compilers.rb
Normal file
@ -0,0 +1,11 @@
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
class CompilerSelector
|
||||
sig { returns(String) }
|
||||
def preferred_gcc
|
||||
# gcc-5 is the lowest gcc version we support on Linux.
|
||||
# gcc-5 is the default gcc in Ubuntu 16.04 (used for our CI)
|
||||
"gcc@5"
|
||||
end
|
||||
end
|
||||
@ -22,6 +22,7 @@ describe CompilerSelector do
|
||||
case name
|
||||
when "gcc-7" then Version.create("7.1")
|
||||
when "gcc-6" then Version.create("6.1")
|
||||
when "gcc-5" then Version.create("5.1")
|
||||
else Version::NULL
|
||||
end
|
||||
end
|
||||
@ -42,16 +43,31 @@ describe CompilerSelector do
|
||||
expect(selector.compiler).to eq("gcc-7")
|
||||
end
|
||||
|
||||
it "returns gcc-6 if gcc formula offers gcc-6" do
|
||||
it "returns gcc-6 if gcc formula offers gcc-6 on mac", :needs_macos do
|
||||
software_spec.fails_with(:clang)
|
||||
allow(Formulary).to receive(:factory).with("gcc").and_return(double(version: "6.0"))
|
||||
expect(selector.compiler).to eq("gcc-6")
|
||||
end
|
||||
|
||||
it "returns gcc-5 if gcc formula offers gcc-5 on linux", :needs_linux do
|
||||
software_spec.fails_with(:clang)
|
||||
allow(Formulary).to receive(:factory).with("gcc@5").and_return(double(version: "5.0"))
|
||||
expect(selector.compiler).to eq("gcc-5")
|
||||
end
|
||||
|
||||
it "returns gcc-6 if gcc formula offers gcc-6 and fails with gcc-5 and gcc-7 on linux", :needs_linux do
|
||||
software_spec.fails_with(:clang)
|
||||
software_spec.fails_with(gcc: "5")
|
||||
software_spec.fails_with(gcc: "7")
|
||||
allow(Formulary).to receive(:factory).with("gcc@5").and_return(double(version: "5.0"))
|
||||
expect(selector.compiler).to eq("gcc-6")
|
||||
end
|
||||
|
||||
it "raises an error when gcc or llvm is missing" do
|
||||
software_spec.fails_with(:clang)
|
||||
software_spec.fails_with(gcc: "7")
|
||||
software_spec.fails_with(gcc: "6")
|
||||
software_spec.fails_with(gcc: "5")
|
||||
|
||||
expect { selector.compiler }.to raise_error(CompilerSelectionError)
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user