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,
|
cc: args.cc,
|
||||||
build_bottle: args.build_bottle?,
|
build_bottle: args.build_bottle?,
|
||||||
bottle_arch: args.bottle_arch,
|
bottle_arch: args.bottle_arch,
|
||||||
|
debug_symbols: args.debug_symbols?,
|
||||||
)
|
)
|
||||||
reqs.each do |req|
|
reqs.each do |req|
|
||||||
req.modify_build_environment(
|
req.modify_build_environment(
|
||||||
@ -96,6 +97,7 @@ class Build
|
|||||||
cc: args.cc,
|
cc: args.cc,
|
||||||
build_bottle: args.build_bottle?,
|
build_bottle: args.build_bottle?,
|
||||||
bottle_arch: args.bottle_arch,
|
bottle_arch: args.bottle_arch,
|
||||||
|
debug_symbols: args.debug_symbols?,
|
||||||
)
|
)
|
||||||
reqs.each do |req|
|
reqs.each do |req|
|
||||||
req.modify_build_environment(
|
req.modify_build_environment(
|
||||||
|
@ -40,12 +40,22 @@ module EnvActivation
|
|||||||
_block: T.proc.returns(T.untyped),
|
_block: T.proc.returns(T.untyped),
|
||||||
).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
|
old_env = to_hash.dup
|
||||||
tmp_env = to_hash.dup.extend(EnvActivation)
|
tmp_env = to_hash.dup.extend(EnvActivation)
|
||||||
T.cast(tmp_env, EnvActivation).activate_extensions!(env: env)
|
T.cast(tmp_env, EnvActivation).activate_extensions!(env: env)
|
||||||
T.cast(tmp_env, T.any(Superenv, Stdenv))
|
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)
|
replace(tmp_env)
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
@ -40,13 +40,22 @@ module SharedEnvExtension
|
|||||||
build_bottle: T.nilable(T::Boolean),
|
build_bottle: T.nilable(T::Boolean),
|
||||||
bottle_arch: T.nilable(String),
|
bottle_arch: T.nilable(String),
|
||||||
testing_formula: T::Boolean,
|
testing_formula: T::Boolean,
|
||||||
|
debug_symbols: T.nilable(T::Boolean),
|
||||||
).void
|
).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
|
@formula = formula
|
||||||
@cc = cc
|
@cc = cc
|
||||||
@build_bottle = build_bottle
|
@build_bottle = build_bottle
|
||||||
@bottle_arch = bottle_arch
|
@bottle_arch = bottle_arch
|
||||||
|
@debug_symbols = debug_symbols
|
||||||
reset
|
reset
|
||||||
end
|
end
|
||||||
private :setup_build_environment
|
private :setup_build_environment
|
||||||
@ -315,9 +324,6 @@ module SharedEnvExtension
|
|||||||
sig { void }
|
sig { void }
|
||||||
def permit_arch_flags; end
|
def permit_arch_flags; end
|
||||||
|
|
||||||
sig { void }
|
|
||||||
def debug_symbols; end
|
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
sig { params(cc: T.any(Symbol, String)).returns(T::Boolean) }
|
sig { params(cc: T.any(Symbol, String)).returns(T::Boolean) }
|
||||||
def compiler_any_clang?(cc = compiler)
|
def compiler_any_clang?(cc = compiler)
|
||||||
|
@ -23,7 +23,14 @@ module Stdenv
|
|||||||
testing_formula: T::Boolean,
|
testing_formula: T::Boolean,
|
||||||
).void
|
).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
|
super
|
||||||
|
|
||||||
self["HOMEBREW_ENV"] = "std"
|
self["HOMEBREW_ENV"] = "std"
|
||||||
|
@ -57,7 +57,14 @@ module Superenv
|
|||||||
testing_formula: T::Boolean,
|
testing_formula: T::Boolean,
|
||||||
).void
|
).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
|
super
|
||||||
send(compiler)
|
send(compiler)
|
||||||
|
|
||||||
@ -87,6 +94,8 @@ module Superenv
|
|||||||
self["HOMEBREW_DEPENDENCIES"] = determine_dependencies
|
self["HOMEBREW_DEPENDENCIES"] = determine_dependencies
|
||||||
self["HOMEBREW_FORMULA_PREFIX"] = @formula.prefix unless @formula.nil?
|
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
|
# 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
|
# compiler flag stripping. It consists of a string of characters which act
|
||||||
# as flags. Some of these flags are mutually exclusive.
|
# as flags. Some of these flags are mutually exclusive.
|
||||||
@ -283,9 +292,7 @@ module Superenv
|
|||||||
|
|
||||||
sig { returns(String) }
|
sig { returns(String) }
|
||||||
def determine_cccfg
|
def determine_cccfg
|
||||||
# TODO: temporarily hard code symbol generation
|
""
|
||||||
# ""
|
|
||||||
"D"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
public
|
public
|
||||||
@ -335,8 +342,7 @@ module Superenv
|
|||||||
end
|
end
|
||||||
|
|
||||||
sig { void }
|
sig { void }
|
||||||
def debug_symbols
|
def set_debug_symbols
|
||||||
# TODO: how do I get this method called?
|
|
||||||
append_to_cccfg "D" if OS.mac?
|
append_to_cccfg "D" if OS.mac?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2,10 +2,18 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Stdenv
|
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(
|
generic_setup_build_environment(
|
||||||
formula: formula, cc: cc, build_bottle: build_bottle,
|
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"
|
prepend_path "CPATH", HOMEBREW_PREFIX/"include"
|
||||||
|
@ -15,10 +15,18 @@ module Superenv
|
|||||||
end
|
end
|
||||||
|
|
||||||
# @private
|
# @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(
|
generic_setup_build_environment(
|
||||||
formula: formula, cc: cc, build_bottle: build_bottle,
|
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_OPTIMIZATION_LEVEL"] = "O2"
|
||||||
self["HOMEBREW_DYNAMIC_LINKER"] = determine_dynamic_linker_path
|
self["HOMEBREW_DYNAMIC_LINKER"] = determine_dynamic_linker_path
|
||||||
|
@ -4,10 +4,18 @@
|
|||||||
module SharedEnvExtension
|
module SharedEnvExtension
|
||||||
extend T::Sig
|
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(
|
generic_shared_setup_build_environment(
|
||||||
formula: formula, cc: cc, build_bottle: build_bottle,
|
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
|
# 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}"]
|
["#{HOMEBREW_LIBRARY}/Homebrew/os/mac/pkgconfig/#{MacOS.version}"]
|
||||||
end
|
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(
|
generic_setup_build_environment(
|
||||||
formula: formula, cc: cc, build_bottle: build_bottle,
|
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"
|
append "LDFLAGS", "-Wl,-headerpad_max_install_names"
|
||||||
|
@ -85,7 +85,14 @@ module Superenv
|
|||||||
end
|
end
|
||||||
|
|
||||||
# @private
|
# @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
|
sdk = formula ? MacOS.sdk_for_formula(formula) : MacOS.sdk
|
||||||
is_xcode_sdk = sdk&.source == :xcode
|
is_xcode_sdk = sdk&.source == :xcode
|
||||||
|
|
||||||
@ -102,7 +109,8 @@ module Superenv
|
|||||||
|
|
||||||
generic_setup_build_environment(
|
generic_setup_build_environment(
|
||||||
formula: formula, cc: cc, build_bottle: build_bottle,
|
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
|
# Filter out symbols known not to be defined since GNU Autotools can't
|
||||||
|
Loading…
x
Reference in New Issue
Block a user