Module: Hardware Private

Defined in:
extend/os/mac/hardware.rb,
extend/os/mac/hardware/cpu.rb,
extend/os/linux/hardware/cpu.rb,
hardware.rb

Overview

This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.

Helper module for querying hardware information.

Defined Under Namespace

Classes: CPU

Class Method Summary collapse

Class Method Details

.cores_as_wordsObject

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



189
190
191
192
193
194
195
196
197
198
199
200
# File 'hardware.rb', line 189

def cores_as_words
  case Hardware::CPU.cores
  when 1 then "single"
  when 2 then "dual"
  when 4 then "quad"
  when 6 then "hexa"
  when 8 then "octa"
  when 12 then "dodeca"
  else
    Hardware::CPU.cores
  end
end

.oldest_cpu(_version = nil) ⇒ Symbol Also known as: generic_oldest_cpu

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

Returns:



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'extend/os/mac/hardware.rb', line 6

def self.oldest_cpu(version = nil)
  version = if version
    MacOSVersion.new(version.to_s)
  else
    MacOS.version
  end
  if CPU.arch == :arm64
    :arm_vortex_tempest
  # This cannot use a newer CPU e.g. haswell because Rosetta 2 does not
  # support AVX instructions in bottles:
  #   https://github.com/Homebrew/homebrew-core/issues/67713
  elsif version >= :ventura
    :westmere
  elsif version >= :mojave
    :nehalem
  else
    generic_oldest_cpu
  end
end

.rustflags_target_cpuString?

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns a Rust flag to set the target CPU if necessary. Defaults to nil.

Returns:



230
231
232
233
234
235
236
237
238
239
240
241
242
243
# File 'hardware.rb', line 230

def rustflags_target_cpu
  # Rust already defaults to the oldest supported cpu for each target-triplet
  # so it's safe to ignore generic archs such as :armv6 here.
  # Rust defaults to apple-m1 since Rust 1.71 for aarch64-apple-darwin.
  @target_cpu ||= case (cpu = oldest_cpu)
  when :core
    :prescott
  when :native, :ivybridge, :sandybridge, :westmere, :nehalem, :core2
    cpu
  end
  return if @target_cpu.blank?

  "--codegen target-cpu=#{@target_cpu}"
end