Conceptual draft of dsym support for macos

This commit is contained in:
Lukas Oberhuber 2022-07-26 00:00:45 +01:00
parent 0c785673d9
commit e1ea9da507
4 changed files with 42 additions and 0 deletions

View File

@ -62,4 +62,21 @@ class Keg
#{result.stderr}
EOS
end
def dsymutil
binary_executable_or_library_files.each { |file| dsymutil_binary(file) }
end
def dsymutil_binary(file)
odebug "Extracting symbols #{file}"
result = system_command("dsymutil", args: [file])
return if result.success?
# If it fails again, error out
onoe <<~EOS
Failed to extract symbols from #{file}:
#{result.stderr}
EOS
end
end

View File

@ -39,6 +39,7 @@ class FormulaInstaller
attr_predicate :installed_as_dependency?, :installed_on_request?
attr_predicate :show_summary_heading?, :show_header?
attr_predicate :force_bottle?, :ignore_deps?, :only_deps?, :interactive?, :git?, :force?, :overwrite?, :keep_tmp?
attr_predicate :debug_symbols?
attr_predicate :verbose?, :debug?, :quiet?
def initialize(
@ -71,6 +72,8 @@ class FormulaInstaller
@force = force
@overwrite = overwrite
@keep_tmp = keep_tmp
# Just for this proof of concept
@debug_symbols = keep_tmp
@link_keg = !formula.keg_only? || link_keg
@show_header = show_header
@ignore_deps = ignore_deps
@ -802,6 +805,8 @@ class FormulaInstaller
post_install
end
dsymutil(keg) if debug_symbols?
# Updates the cache for a particular formula after doing an install
CacheStoreDatabase.use(:linkage) do |db|
break unless db.created?
@ -1326,4 +1331,14 @@ class FormulaInstaller
#{SPDX.license_expression_to_string formula.license}.
EOS
end
sig { params(keg: Keg).void }
def dsymutil(keg)
keg.dsymutil
# TODO
# rescue Keg::DsymError => e
rescue RuntimeError => e
ofail "Failed to extract debugging symbols for #{formula.full_name}"
puts e
end
end

View File

@ -483,6 +483,8 @@ class Keg
ObserverPathnameExtension.n
end
def dsymutil; end
def remove_oldname_opt_record
return unless oldname_opt_record
return if oldname_opt_record.resolved_path != path
@ -531,6 +533,8 @@ class Keg
def codesign_patched_binary(file); end
def dsymutil_binary(file); end
private
def resolve_any_conflicts(dst, dry_run: false, verbose: false, overwrite: false)

View File

@ -292,6 +292,7 @@ class Cmd
args.concat(optflags) unless runtime_cpu_detection?
args.concat(archflags)
args << "-std=#{@arg0}" if /c[89]9/.match?(@arg0)
args << "-g" if debug_symbols?
args
end
@ -399,6 +400,11 @@ class Cmd
config.include?("w")
end
def debug_symbols?
mac?
# && config.include?("D")
end
def canonical_path(path)
path = Pathname.new(path)
path = path.realpath if path.exist?