Module: OS::Linux::Superenv Private

Extended by:
T::Helpers
Included in:
Superenv
Defined in:
extend/os/linux/extend/ENV/super.rb

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.

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#determine_dynamic_linker_pathString?

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:



98
99
100
101
102
103
# File 'extend/os/linux/extend/ENV/super.rb', line 98

def determine_dynamic_linker_path
  path = "#{HOMEBREW_PREFIX}/lib/ld.so"
  return unless File.readable? path

  path
end

#determine_rpath_paths(formula) ⇒ PATH

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:



88
89
90
91
92
93
94
95
# File 'extend/os/linux/extend/ENV/super.rb', line 88

def determine_rpath_paths(formula)
  PATH.new(
    *formula&.lib,
    "#{HOMEBREW_PREFIX}/opt/gcc/lib/gcc/current",
    PATH.new(run_time_deps.map { |dep| dep.opt_lib.to_s }).existing,
    "#{HOMEBREW_PREFIX}/lib",
  )
end

#homebrew_extra_isystem_pathsArray<Pathname>

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:



76
77
78
79
80
81
82
83
84
85
# File 'extend/os/linux/extend/ENV/super.rb', line 76

def homebrew_extra_isystem_paths
  paths = []
  # Add paths for GCC headers when building against versioned glibc because we have to use -nostdinc.
  if deps.any? { |d| d.name.match?(/^glibc@.+$/) }
    gcc_include_dir = Utils.safe_popen_read(cc, "--print-file-name=include").chomp
    gcc_include_fixed_dir = Utils.safe_popen_read(cc, "--print-file-name=include-fixed").chomp
    paths << gcc_include_dir << gcc_include_fixed_dir
  end
  paths.map { |p| Pathname(p) }
end

#homebrew_extra_pathsArray<Pathname>

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:



64
65
66
67
68
69
70
71
72
73
# File 'extend/os/linux/extend/ENV/super.rb', line 64

def homebrew_extra_paths
  paths = super
  paths += %w[binutils make].filter_map do |f|
    bin = Formulary.factory(f).opt_bin
    bin if bin.directory?
  rescue FormulaUnavailableError
    nil
  end
  paths
end

#initializevoid

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.



25
26
27
# File 'extend/os/linux/extend/ENV/super.rb', line 25

def initialize
  @formula = T.let(nil, T.nilable(Formula))
end

#setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_arch: nil, testing_formula: false, debug_symbols: false) ⇒ void

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.

This method returns an undefined value.

Parameters:

  • formula (Formula, nil) (defaults to: nil)
  • cc (String, nil) (defaults to: nil)
  • build_bottle (Boolean, nil) (defaults to: false)
  • bottle_arch (String, nil) (defaults to: nil)
  • testing_formula (Boolean) (defaults to: false)
  • debug_symbols (Boolean, nil) (defaults to: false)


39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'extend/os/linux/extend/ENV/super.rb', line 39

def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_arch: nil,
                            testing_formula: false, debug_symbols: false)
  super

  self["HOMEBREW_OPTIMIZATION_LEVEL"] = "O2"
  self["HOMEBREW_DYNAMIC_LINKER"] = determine_dynamic_linker_path
  self["HOMEBREW_RPATH_PATHS"] = determine_rpath_paths(@formula)
  m4_path_deps = ["libtool", "bison"]
  self["M4"] = "#{HOMEBREW_PREFIX}/opt/m4/bin/m4" if deps.any? { m4_path_deps.include?(_1.name) }
  if ::Hardware::CPU.arch == :arm64
    # Build jemalloc-sys rust crate on ARM64/AArch64 with support for page sizes up to 64K.
    self["JEMALLOC_SYS_WITH_LG_PAGE"] = "16"

    # Workaround patchelf.rb bug causing segfaults and preventing bottling on ARM64/AArch64
    # https://github.com/Homebrew/homebrew-core/issues/163826
    self["CGO_ENABLED"] = "0"
  end

  # Pointer authentication and BTI are hardening techniques most distros
  # use by default on their packages. arm64 Linux we're packaging
  # everything from scratch so the entire dependency tree can have it.
  append_to_cccfg "b" if ::Hardware::CPU.arch == :arm64 && ::DevelopmentTools.gcc_version("gcc") >= 9
end