mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Compiler -g
flag set based on --debug-symbols
This commit is contained in:
parent
91065b9ddd
commit
c2a95f077f
@ -83,6 +83,7 @@ class Build
|
||||
cc: args.cc,
|
||||
build_bottle: args.build_bottle?,
|
||||
bottle_arch: args.bottle_arch,
|
||||
debug_symbols: args.debug_symbols?,
|
||||
)
|
||||
reqs.each do |req|
|
||||
req.modify_build_environment(
|
||||
@ -96,6 +97,7 @@ class Build
|
||||
cc: args.cc,
|
||||
build_bottle: args.build_bottle?,
|
||||
bottle_arch: args.bottle_arch,
|
||||
debug_symbols: args.debug_symbols?,
|
||||
)
|
||||
reqs.each do |req|
|
||||
req.modify_build_environment(
|
||||
|
@ -40,12 +40,22 @@ module EnvActivation
|
||||
_block: T.proc.returns(T.untyped),
|
||||
).returns(T.untyped)
|
||||
}
|
||||
def with_build_environment(env: nil, cc: nil, build_bottle: false, bottle_arch: nil, &_block)
|
||||
def with_build_environment(
|
||||
env: nil,
|
||||
cc: nil,
|
||||
build_bottle: false,
|
||||
bottle_arch: nil,
|
||||
debug_symbols: false,
|
||||
&_block
|
||||
)
|
||||
old_env = to_hash.dup
|
||||
tmp_env = to_hash.dup.extend(EnvActivation)
|
||||
T.cast(tmp_env, EnvActivation).activate_extensions!(env: env)
|
||||
T.cast(tmp_env, T.any(Superenv, Stdenv))
|
||||
.setup_build_environment(cc: cc, build_bottle: build_bottle, bottle_arch: bottle_arch)
|
||||
.setup_build_environment(
|
||||
cc: cc, build_bottle: build_bottle, bottle_arch: bottle_arch,
|
||||
debug_symbols: debug_symbols,
|
||||
)
|
||||
replace(tmp_env)
|
||||
|
||||
begin
|
||||
|
@ -40,13 +40,22 @@ module SharedEnvExtension
|
||||
build_bottle: T.nilable(T::Boolean),
|
||||
bottle_arch: T.nilable(String),
|
||||
testing_formula: T::Boolean,
|
||||
debug_symbols: T.nilable(T::Boolean),
|
||||
).void
|
||||
}
|
||||
def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_arch: nil, testing_formula: false)
|
||||
def setup_build_environment(
|
||||
formula: nil,
|
||||
cc: nil,
|
||||
build_bottle: false,
|
||||
bottle_arch: nil,
|
||||
testing_formula: false,
|
||||
debug_symbols: false
|
||||
)
|
||||
@formula = formula
|
||||
@cc = cc
|
||||
@build_bottle = build_bottle
|
||||
@bottle_arch = bottle_arch
|
||||
@debug_symbols = debug_symbols
|
||||
reset
|
||||
end
|
||||
private :setup_build_environment
|
||||
@ -315,9 +324,6 @@ module SharedEnvExtension
|
||||
sig { void }
|
||||
def permit_arch_flags; end
|
||||
|
||||
sig { void }
|
||||
def debug_symbols; end
|
||||
|
||||
# @private
|
||||
sig { params(cc: T.any(Symbol, String)).returns(T::Boolean) }
|
||||
def compiler_any_clang?(cc = compiler)
|
||||
|
@ -23,7 +23,14 @@ module Stdenv
|
||||
testing_formula: T::Boolean,
|
||||
).void
|
||||
}
|
||||
def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_arch: nil, testing_formula: false)
|
||||
def setup_build_environment(
|
||||
formula: nil,
|
||||
cc: nil,
|
||||
build_bottle: false,
|
||||
bottle_arch: nil,
|
||||
testing_formula: false,
|
||||
debug_symbols: false
|
||||
)
|
||||
super
|
||||
|
||||
self["HOMEBREW_ENV"] = "std"
|
||||
|
@ -57,7 +57,14 @@ module Superenv
|
||||
testing_formula: T::Boolean,
|
||||
).void
|
||||
}
|
||||
def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_arch: nil, testing_formula: false)
|
||||
def setup_build_environment(
|
||||
formula: nil,
|
||||
cc: nil,
|
||||
build_bottle: false,
|
||||
bottle_arch: nil,
|
||||
testing_formula: false,
|
||||
debug_symbols: false
|
||||
)
|
||||
super
|
||||
send(compiler)
|
||||
|
||||
@ -87,6 +94,8 @@ module Superenv
|
||||
self["HOMEBREW_DEPENDENCIES"] = determine_dependencies
|
||||
self["HOMEBREW_FORMULA_PREFIX"] = @formula.prefix unless @formula.nil?
|
||||
|
||||
set_debug_symbols if debug_symbols
|
||||
|
||||
# The HOMEBREW_CCCFG ENV variable is used by the ENV/cc tool to control
|
||||
# compiler flag stripping. It consists of a string of characters which act
|
||||
# as flags. Some of these flags are mutually exclusive.
|
||||
@ -283,9 +292,7 @@ module Superenv
|
||||
|
||||
sig { returns(String) }
|
||||
def determine_cccfg
|
||||
# TODO: temporarily hard code symbol generation
|
||||
# ""
|
||||
"D"
|
||||
""
|
||||
end
|
||||
|
||||
public
|
||||
@ -335,8 +342,7 @@ module Superenv
|
||||
end
|
||||
|
||||
sig { void }
|
||||
def debug_symbols
|
||||
# TODO: how do I get this method called?
|
||||
def set_debug_symbols
|
||||
append_to_cccfg "D" if OS.mac?
|
||||
end
|
||||
|
||||
|
@ -2,10 +2,18 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Stdenv
|
||||
def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_arch: nil, testing_formula: false)
|
||||
def setup_build_environment(
|
||||
formula: nil,
|
||||
cc: nil,
|
||||
build_bottle: false,
|
||||
bottle_arch: nil,
|
||||
testing_formula: false,
|
||||
debug_symbols: false
|
||||
)
|
||||
generic_setup_build_environment(
|
||||
formula: formula, cc: cc, build_bottle: build_bottle,
|
||||
bottle_arch: bottle_arch, testing_formula: testing_formula
|
||||
bottle_arch: bottle_arch, testing_formula: testing_formula,
|
||||
debug_symbols: debug_symbols,
|
||||
)
|
||||
|
||||
prepend_path "CPATH", HOMEBREW_PREFIX/"include"
|
||||
|
@ -15,10 +15,18 @@ module Superenv
|
||||
end
|
||||
|
||||
# @private
|
||||
def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_arch: nil, testing_formula: false)
|
||||
def setup_build_environment(
|
||||
formula: nil,
|
||||
cc: nil,
|
||||
build_bottle: false,
|
||||
bottle_arch: nil,
|
||||
testing_formula: false,
|
||||
debug_symbols: false
|
||||
)
|
||||
generic_setup_build_environment(
|
||||
formula: formula, cc: cc, build_bottle: build_bottle,
|
||||
bottle_arch: bottle_arch, testing_formula: testing_formula
|
||||
bottle_arch: bottle_arch, testing_formula: testing_formula,
|
||||
debug_symbols: debug_symbols,
|
||||
)
|
||||
self["HOMEBREW_OPTIMIZATION_LEVEL"] = "O2"
|
||||
self["HOMEBREW_DYNAMIC_LINKER"] = determine_dynamic_linker_path
|
||||
|
@ -4,10 +4,18 @@
|
||||
module SharedEnvExtension
|
||||
extend T::Sig
|
||||
|
||||
def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_arch: nil, testing_formula: false)
|
||||
def setup_build_environment(
|
||||
formula: nil,
|
||||
cc: nil,
|
||||
build_bottle: false,
|
||||
bottle_arch: nil,
|
||||
testing_formula: false,
|
||||
debug_symbols: false
|
||||
)
|
||||
generic_shared_setup_build_environment(
|
||||
formula: formula, cc: cc, build_bottle: build_bottle,
|
||||
bottle_arch: bottle_arch, testing_formula: testing_formula
|
||||
bottle_arch: bottle_arch, testing_formula: testing_formula,
|
||||
debug_symbols: debug_symbols,
|
||||
)
|
||||
|
||||
# Normalise the system Perl version used, where multiple may be available
|
||||
|
@ -10,10 +10,18 @@ module Stdenv
|
||||
["#{HOMEBREW_LIBRARY}/Homebrew/os/mac/pkgconfig/#{MacOS.version}"]
|
||||
end
|
||||
|
||||
def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_arch: nil, testing_formula: false)
|
||||
def setup_build_environment(
|
||||
formula: nil,
|
||||
cc: nil,
|
||||
build_bottle: false,
|
||||
bottle_arch: nil,
|
||||
testing_formula: false,
|
||||
debug_symbols: false
|
||||
)
|
||||
generic_setup_build_environment(
|
||||
formula: formula, cc: cc, build_bottle: build_bottle,
|
||||
bottle_arch: bottle_arch, testing_formula: testing_formula
|
||||
bottle_arch: bottle_arch, testing_formula: testing_formula,
|
||||
debug_symbols: debug_symbols,
|
||||
)
|
||||
|
||||
append "LDFLAGS", "-Wl,-headerpad_max_install_names"
|
||||
|
@ -85,7 +85,14 @@ module Superenv
|
||||
end
|
||||
|
||||
# @private
|
||||
def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_arch: nil, testing_formula: false)
|
||||
def setup_build_environment(
|
||||
formula: nil,
|
||||
cc: nil,
|
||||
build_bottle: false,
|
||||
bottle_arch: nil,
|
||||
testing_formula: false,
|
||||
debug_symbols: false
|
||||
)
|
||||
sdk = formula ? MacOS.sdk_for_formula(formula) : MacOS.sdk
|
||||
is_xcode_sdk = sdk&.source == :xcode
|
||||
|
||||
@ -102,7 +109,8 @@ module Superenv
|
||||
|
||||
generic_setup_build_environment(
|
||||
formula: formula, cc: cc, build_bottle: build_bottle,
|
||||
bottle_arch: bottle_arch, testing_formula: testing_formula
|
||||
bottle_arch: bottle_arch, testing_formula: testing_formula,
|
||||
debug_symbols: debug_symbols,
|
||||
)
|
||||
|
||||
# Filter out symbols known not to be defined since GNU Autotools can't
|
||||
|
Loading…
x
Reference in New Issue
Block a user