mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Merge pull request #7465 from runlevel5/ppc64le-arch-detect
Add OpenPOWER platform detection
This commit is contained in:
commit
1fc8b8ff5b
@ -3,17 +3,12 @@
|
||||
module Hardware
|
||||
class CPU
|
||||
class << self
|
||||
OPTIMIZATION_FLAGS_LINUX = {
|
||||
native: "-march=#{Homebrew::EnvConfig.arch}",
|
||||
nehalem: "-march=nehalem",
|
||||
core2: "-march=core2",
|
||||
core: "-march=prescott",
|
||||
armv6: "-march=armv6",
|
||||
armv8: "-march=armv8-a",
|
||||
}.freeze
|
||||
|
||||
def optimization_flags
|
||||
OPTIMIZATION_FLAGS_LINUX
|
||||
@optimization_flags ||= begin
|
||||
flags = generic_optimization_flags.dup
|
||||
flags[:native] = arch_flag(Homebrew::EnvConfig.arch)
|
||||
flags
|
||||
end
|
||||
end
|
||||
|
||||
def cpuinfo
|
||||
|
@ -14,6 +14,19 @@ module Homebrew
|
||||
"/system/bin/linker",
|
||||
].freeze
|
||||
|
||||
def check_cpu
|
||||
return if (Hardware::CPU.intel? && Hardware::CPU.is_64_bit?) || Hardware::CPU.arm?
|
||||
|
||||
message = "Sorry, Homebrew does not support your computer's CPU architecture!"
|
||||
if Hardware::CPU.ppc64le?
|
||||
message += <<~EOS
|
||||
For OpenPOWER Linux (PPC64LE) support, see:
|
||||
#{Formatter.url("https://github.com/homebrew-ppc64le/brew")}
|
||||
EOS
|
||||
end
|
||||
abort message
|
||||
end
|
||||
|
||||
def symlink_ld_so
|
||||
brew_ld_so = HOMEBREW_PREFIX/"lib/ld.so"
|
||||
return if brew_ld_so.readable?
|
||||
|
@ -7,28 +7,29 @@ module Hardware
|
||||
INTEL_32BIT_ARCHS = [:i386].freeze
|
||||
INTEL_64BIT_ARCHS = [:x86_64].freeze
|
||||
PPC_32BIT_ARCHS = [:ppc, :ppc32, :ppc7400, :ppc7450, :ppc970].freeze
|
||||
PPC_64BIT_ARCHS = [:ppc64].freeze
|
||||
PPC_64BIT_ARCHS = [:ppc64, :ppc64le, :ppc970].freeze
|
||||
|
||||
class << self
|
||||
OPTIMIZATION_FLAGS = {
|
||||
native: "-march=native",
|
||||
nehalem: "-march=nehalem",
|
||||
core2: "-march=core2",
|
||||
core: "-march=prescott",
|
||||
armv6: "-march=armv6",
|
||||
armv8: "-march=armv8-a",
|
||||
}.freeze
|
||||
|
||||
def optimization_flags
|
||||
OPTIMIZATION_FLAGS
|
||||
@optimization_flags ||= {
|
||||
native: arch_flag("native"),
|
||||
nehalem: "-march=nehalem",
|
||||
core2: "-march=core2",
|
||||
core: "-march=prescott",
|
||||
armv6: "-march=armv6",
|
||||
armv8: "-march=armv8-a",
|
||||
ppc64: "-mcpu=powerpc64",
|
||||
ppc64le: "-mcpu=powerpc64le",
|
||||
}.freeze
|
||||
end
|
||||
alias generic_optimization_flags optimization_flags
|
||||
|
||||
def arch_32_bit
|
||||
if arm?
|
||||
:arm
|
||||
elsif intel?
|
||||
:i386
|
||||
elsif ppc?
|
||||
elsif ppc32?
|
||||
:ppc32
|
||||
else
|
||||
:dunno
|
||||
@ -40,7 +41,9 @@ module Hardware
|
||||
:arm64
|
||||
elsif intel?
|
||||
:x86_64
|
||||
elsif ppc?
|
||||
elsif ppc64le?
|
||||
:ppc64le
|
||||
elsif ppc64?
|
||||
:ppc64
|
||||
else
|
||||
:dunno
|
||||
@ -66,7 +69,7 @@ module Hardware
|
||||
case RUBY_PLATFORM
|
||||
when /x86_64/, /i\d86/ then :intel
|
||||
when /arm/, /aarch64/ then :arm
|
||||
when /ppc\d+/ then :ppc
|
||||
when /ppc|powerpc/ then :ppc
|
||||
else :dunno
|
||||
end
|
||||
end
|
||||
@ -85,7 +88,7 @@ module Hardware
|
||||
|
||||
def bits
|
||||
@bits ||= case RUBY_PLATFORM
|
||||
when /x86_64/, /ppc64/, /aarch64|arm64/ then 64
|
||||
when /x86_64/, /ppc64|powerpc64/, /aarch64|arm64/ then 64
|
||||
when /i\d86/, /ppc/, /arm/ then 32
|
||||
end
|
||||
end
|
||||
@ -110,10 +113,30 @@ module Hardware
|
||||
type == :ppc
|
||||
end
|
||||
|
||||
def ppc32?
|
||||
ppc? && is_32_bit?
|
||||
end
|
||||
|
||||
def ppc64le?
|
||||
ppc? && is_64_bit? && little_endian?
|
||||
end
|
||||
|
||||
def ppc64?
|
||||
ppc? && is_64_bit? && big_endian?
|
||||
end
|
||||
|
||||
def arm?
|
||||
type == :arm
|
||||
end
|
||||
|
||||
def little_endian?
|
||||
!big_endian?
|
||||
end
|
||||
|
||||
def big_endian?
|
||||
[1].pack("I") == [1].pack("N")
|
||||
end
|
||||
|
||||
def features
|
||||
[]
|
||||
end
|
||||
@ -121,6 +144,12 @@ module Hardware
|
||||
def feature?(name)
|
||||
features.include?(name)
|
||||
end
|
||||
|
||||
def arch_flag(arch)
|
||||
return "-mcpu=#{arch}" if ppc?
|
||||
|
||||
"-march=#{arch}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -10,14 +10,16 @@ module Homebrew
|
||||
module_function
|
||||
|
||||
def check_cpu
|
||||
case Hardware::CPU.type
|
||||
when :ppc
|
||||
abort <<~EOS
|
||||
Sorry, Homebrew does not support your computer's CPU architecture.
|
||||
For PPC support, see:
|
||||
return if Hardware::CPU.intel? && Hardware::CPU.is_64_bit?
|
||||
|
||||
message = "Sorry, Homebrew does not support your computer's CPU architecture!"
|
||||
if Hardware::CPU.ppc?
|
||||
message += <<~EOS
|
||||
For PowerPC Mac (PPC32/PPC64BE) support, see:
|
||||
#{Formatter.url("https://github.com/mistydemeo/tigerbrew")}
|
||||
EOS
|
||||
end
|
||||
abort message
|
||||
end
|
||||
|
||||
def attempt_directory_creation
|
||||
|
Loading…
x
Reference in New Issue
Block a user