Commit 39a3a9de authored by Nico Weber's avatar Nico Weber Committed by Commit Bot

mac: Remove rpath stack handling from generate_breakpad_symbols.py again.

Doing rpath stack handling is the correct thing to do, but since the framework
needs to be able to be symbolized on its own for the telemetry crash tests,
it needs to have all the rpaths it needs directly -- and then this code isn't
needed.  Removing it makes telemetry_perf_unittests's core.stacktrace_unittests
and content_shell_crash_test both fail if a framework has incomplete rpaths.

Reverts the parts of https://chromium-review.googlesource.com/c/chromium/src/+/1095834
that weren't a revert.

Bug: 850055
Change-Id: I9d0c4bd0d64ffbcfc03184dc761a4a2694b6754d
Reviewed-on: https://chromium-review.googlesource.com/1102056Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567684}
parent 6a9b06a5
...@@ -105,7 +105,7 @@ def GetDeveloperDirMac(): ...@@ -105,7 +105,7 @@ def GetDeveloperDirMac():
print 'WARNING: no value found for DEVELOPER_DIR. Some commands may fail.' print 'WARNING: no value found for DEVELOPER_DIR. Some commands may fail.'
def GetSharedLibraryDependenciesMac(binary, exe_path, loader_rpaths): def GetSharedLibraryDependenciesMac(binary, exe_path):
"""Return absolute paths to all shared library dependecies of the binary. """Return absolute paths to all shared library dependecies of the binary.
This implementation assumes that we're running on a Mac system.""" This implementation assumes that we're running on a Mac system."""
...@@ -127,6 +127,11 @@ def GetSharedLibraryDependenciesMac(binary, exe_path, loader_rpaths): ...@@ -127,6 +127,11 @@ def GetSharedLibraryDependenciesMac(binary, exe_path, loader_rpaths):
elif line.find('cmd LC_ID_DYLIB') != -1: elif line.find('cmd LC_ID_DYLIB') != -1:
m = re.match(' *name (.*) \(offset .*\)$', otool[idx+2]) m = re.match(' *name (.*) \(offset .*\)$', otool[idx+2])
dylib_id = m.group(1) dylib_id = m.group(1)
# `man dyld` says that @rpath is resolved against a stack of LC_RPATHs from
# all executable images leading to the load of the current module. This is
# intentionally not implemented here, since we require that every .dylib
# contains all the rpaths it needs on its own, without relying on rpaths of
# the loading executables.
otool = subprocess.check_output(['otool', '-L', binary], env=env).splitlines() otool = subprocess.check_output(['otool', '-L', binary], env=env).splitlines()
lib_re = re.compile('\t(.*) \(compatibility .*\)$') lib_re = re.compile('\t(.*) \(compatibility .*\)$')
...@@ -138,26 +143,25 @@ def GetSharedLibraryDependenciesMac(binary, exe_path, loader_rpaths): ...@@ -138,26 +143,25 @@ def GetSharedLibraryDependenciesMac(binary, exe_path, loader_rpaths):
# as the first line. Filter that out. # as the first line. Filter that out.
if m.group(1) == dylib_id: if m.group(1) == dylib_id:
continue continue
dep = Resolve(m.group(1), exe_path, loader_path, loader_rpaths + rpaths) dep = Resolve(m.group(1), exe_path, loader_path, rpaths)
if dep: if dep:
deps.append(os.path.normpath(dep)) deps.append(os.path.normpath(dep))
else: else:
print >>sys.stderr, ( print >>sys.stderr, (
'ERROR: failed to resolve %s, exe_path %s, loader_path %s, ' 'ERROR: failed to resolve %s, exe_path %s, loader_path %s, '
'rpaths %s' % (m.group(1), exe_path, loader_path, 'rpaths %s' % (m.group(1), exe_path, loader_path,
', '.join(loader_rpaths + rpaths))) ', '.join(rpaths)))
sys.exit(1) sys.exit(1)
return deps, rpaths return deps
def GetSharedLibraryDependencies(options, binary, exe_path, loader_rpaths): def GetSharedLibraryDependencies(options, binary, exe_path):
"""Return absolute paths to all shared library dependecies of the binary.""" """Return absolute paths to all shared library dependecies of the binary."""
deps = [] deps = []
if sys.platform.startswith('linux'): if sys.platform.startswith('linux'):
deps, rpaths = GetSharedLibraryDependenciesLinux(binary), [] deps = GetSharedLibraryDependenciesLinux(binary)
elif sys.platform == 'darwin': elif sys.platform == 'darwin':
deps, rpaths = GetSharedLibraryDependenciesMac( deps = GetSharedLibraryDependenciesMac(binary, exe_path)
binary, exe_path, loader_rpaths)
else: else:
print "Platform not supported." print "Platform not supported."
sys.exit(1) sys.exit(1)
...@@ -168,7 +172,7 @@ def GetSharedLibraryDependencies(options, binary, exe_path, loader_rpaths): ...@@ -168,7 +172,7 @@ def GetSharedLibraryDependencies(options, binary, exe_path, loader_rpaths):
if (os.access(dep, os.X_OK) and if (os.access(dep, os.X_OK) and
os.path.abspath(os.path.dirname(dep)).startswith(build_dir)): os.path.abspath(os.path.dirname(dep)).startswith(build_dir)):
result.append(dep) result.append(dep)
return result, rpaths return result
def mkdir_p(path): def mkdir_p(path):
...@@ -317,15 +321,13 @@ def main(): ...@@ -317,15 +321,13 @@ def main():
# Build the transitive closure of all dependencies. # Build the transitive closure of all dependencies.
binaries = set([options.binary]) binaries = set([options.binary])
queue = [(options.binary, [])] queue = [options.binary]
exe_path = os.path.dirname(options.binary) exe_path = os.path.dirname(options.binary)
while queue: while queue:
current_binary, current_rpaths = queue.pop(0) deps = GetSharedLibraryDependencies(options, queue.pop(0), exe_path)
deps, new_rpaths = GetSharedLibraryDependencies(
options, current_binary, exe_path, current_rpaths)
new_deps = set(deps) - binaries new_deps = set(deps) - binaries
binaries |= new_deps binaries |= new_deps
queue.extend([(dep, current_rpaths + new_rpaths) for dep in new_deps]) queue.extend(list(new_deps))
GenerateSymbols(options, binaries) GenerateSymbols(options, binaries)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment