Prefer brewed Clang over gcc-6 for needs :openmp
Clang has fully implemented OpenMP support as of LLVM 3.7, so if OpenMP is required by a formula gcc is no longer the only choice of compiler. Clang should be preferred over gcc because using gcc meant linking against libstdc++, which is ABI incompatible with libc++. This may be unnoticeable for some users, but it causes other builds to fail, e.g. pstoedit when imagemagick was built with OpenMP. pstoedit is required for the octave formula, so for some users this could be a significant problem.
This commit is contained in:
parent
5e073f1f40
commit
3e4544025d
@ -3,9 +3,10 @@ module CompilerConstants
|
|||||||
GNU_GCC_VERSIONS = %w[4.3 4.4 4.5 4.6 4.7 4.8 4.9 5 6 7].freeze
|
GNU_GCC_VERSIONS = %w[4.3 4.4 4.5 4.6 4.7 4.8 4.9 5 6 7].freeze
|
||||||
GNU_GCC_REGEXP = /^gcc-(4\.[3-9]|[5-7])$/
|
GNU_GCC_REGEXP = /^gcc-(4\.[3-9]|[5-7])$/
|
||||||
COMPILER_SYMBOL_MAP = {
|
COMPILER_SYMBOL_MAP = {
|
||||||
"gcc-4.0" => :gcc_4_0,
|
"gcc-4.0" => :gcc_4_0,
|
||||||
"gcc-4.2" => :gcc,
|
"gcc-4.2" => :gcc,
|
||||||
"clang" => :clang,
|
"clang" => :clang,
|
||||||
|
"llvm_clang" => :llvm_clang,
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
COMPILERS = COMPILER_SYMBOL_MAP.values +
|
COMPILERS = COMPILER_SYMBOL_MAP.values +
|
||||||
@ -86,7 +87,7 @@ class CompilerSelector
|
|||||||
Compiler = Struct.new(:name, :version)
|
Compiler = Struct.new(:name, :version)
|
||||||
|
|
||||||
COMPILER_PRIORITY = {
|
COMPILER_PRIORITY = {
|
||||||
clang: [:clang, :gcc, :gnu, :gcc_4_0],
|
clang: [:clang, :gcc, :gnu, :gcc_4_0, :llvm_clang],
|
||||||
gcc: [:gcc, :gnu, :clang, :gcc_4_0],
|
gcc: [:gcc, :gnu, :clang, :gcc_4_0],
|
||||||
gcc_4_0: [:gcc_4_0, :gcc, :gnu, :clang],
|
gcc_4_0: [:gcc_4_0, :gcc, :gnu, :clang],
|
||||||
}.freeze
|
}.freeze
|
||||||
|
@ -86,6 +86,13 @@ class DevelopmentTools
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def llvm_clang_build_version
|
||||||
|
@llvm_clang_build_version ||= if Tab.for_name "llvm"
|
||||||
|
path = Formulary.factory("llvm").opt_prefix/"bin/clang"
|
||||||
|
`#{path} --version`[/clang version (\d\.\d\.\d)/, 1]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def non_apple_gcc_version(cc)
|
def non_apple_gcc_version(cc)
|
||||||
(@non_apple_gcc_version ||= {}).fetch(cc) do
|
(@non_apple_gcc_version ||= {}).fetch(cc) do
|
||||||
path = HOMEBREW_PREFIX.join("opt", "gcc", "bin", cc)
|
path = HOMEBREW_PREFIX.join("opt", "gcc", "bin", cc)
|
||||||
|
@ -58,6 +58,8 @@ class Cmd
|
|||||||
@tool ||= case @arg0
|
@tool ||= case @arg0
|
||||||
when "ld" then "ld"
|
when "ld" then "ld"
|
||||||
when "cpp" then "cpp"
|
when "cpp" then "cpp"
|
||||||
|
when /llvm_(clang(\+\+)?)/
|
||||||
|
"#{ENV["HOMEBREW_PREFIX"]}/opt/llvm/bin/#{$1}"
|
||||||
when /\w\+\+(-\d(\.\d)?)?$/
|
when /\w\+\+(-\d(\.\d)?)?$/
|
||||||
case ENV["HOMEBREW_CC"]
|
case ENV["HOMEBREW_CC"]
|
||||||
when /clang/
|
when /clang/
|
||||||
@ -154,7 +156,7 @@ class Cmd
|
|||||||
/^-O[0-9zs]?$/, "-fast", "-no-cpp-precomp",
|
/^-O[0-9zs]?$/, "-fast", "-no-cpp-precomp",
|
||||||
"-pedantic", "-pedantic-errors", "-Wno-long-double",
|
"-pedantic", "-pedantic-errors", "-Wno-long-double",
|
||||||
"-Wno-unused-but-set-variable"
|
"-Wno-unused-but-set-variable"
|
||||||
when "-fopenmp", "-lgomp", "-mno-fused-madd", "-fforce-addr", "-fno-defer-pop",
|
when "-mno-fused-madd", "-fforce-addr", "-fno-defer-pop",
|
||||||
"-mno-dynamic-no-pic", "-fearly-inlining", /^-f(?:no-)?inline-functions-called-once/,
|
"-mno-dynamic-no-pic", "-fearly-inlining", /^-f(?:no-)?inline-functions-called-once/,
|
||||||
/^-finline-limit/, /^-f(?:no-)?check-new/, "-fno-delete-null-pointer-checks",
|
/^-finline-limit/, /^-f(?:no-)?check-new/, "-fno-delete-null-pointer-checks",
|
||||||
"-fcaller-saves", "-fthread-jumps", "-fno-reorder-blocks", "-fcse-skip-blocks",
|
"-fcaller-saves", "-fthread-jumps", "-fno-reorder-blocks", "-fcse-skip-blocks",
|
||||||
@ -163,6 +165,8 @@ class Cmd
|
|||||||
"-fuse-linker-plugin", "-frounding-math"
|
"-fuse-linker-plugin", "-frounding-math"
|
||||||
# clang doesn't support these flags
|
# clang doesn't support these flags
|
||||||
args << arg unless tool =~ /^clang/
|
args << arg unless tool =~ /^clang/
|
||||||
|
when "-fopenmp", "-lgomp"
|
||||||
|
args << arg if tool =~ /^llvm_clang/
|
||||||
when "--fast-math"
|
when "--fast-math"
|
||||||
arg = "-ffast-math" if tool =~ /^clang/
|
arg = "-ffast-math" if tool =~ /^clang/
|
||||||
args << arg
|
args << arg
|
||||||
|
1
Library/Homebrew/shims/super/llvm_clang
Symbolic link
1
Library/Homebrew/shims/super/llvm_clang
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
cc
|
1
Library/Homebrew/shims/super/llvm_clang++
Symbolic link
1
Library/Homebrew/shims/super/llvm_clang++
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
cc
|
Loading…
x
Reference in New Issue
Block a user