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:



82
83
84
85
86
87
# File 'extend/os/linux/extend/ENV/super.rb', line 82

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

  path
end

#determine_rpath_paths(formula) ⇒ Object

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.



72
73
74
75
76
77
78
79
# File 'extend/os/linux/extend/ENV/super.rb', line 72

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_pathsObject

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.



61
62
63
64
65
66
67
68
69
70
# File 'extend/os/linux/extend/ENV/super.rb', line 61

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
end

#homebrew_extra_pathsObject

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.



50
51
52
53
54
55
56
57
58
59
# File 'extend/os/linux/extend/ENV/super.rb', line 50

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

#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)


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'extend/os/linux/extend/ENV/super.rb', line 34

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) }

  # 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