Skip to content

Commit

Permalink
Bug 1779845 - Don't rewrite macos executables. r=glandium
Browse files Browse the repository at this point in the history
  • Loading branch information
jschwartzentruber committed Jul 27, 2022
1 parent 4ab4fdb commit 0d6c077
Showing 1 changed file with 1 addition and 30 deletions.
31 changes: 1 addition & 30 deletions build/unix/rewrite_sanitizer_dylib.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@

"""
Scans the given directories for binaries referencing the AddressSanitizer
runtime library, copies it to the main directory and rewrites binaries to not
reference it with absolute paths but with @executable_path instead.
runtime library, copies it to the main directory.
"""

# This is the dylib name pattern
Expand Down Expand Up @@ -83,10 +82,6 @@ def scan_directory(path):
dylibName = match.group(0)
absDylibPath = line.split()[0]

# Don't try to rewrite binaries twice
if absDylibPath.startswith("@executable_path/"):
continue

dylibsRequired.add(dylibName)

if dylibName not in dylibsCopied:
Expand All @@ -100,37 +95,13 @@ def scan_directory(path):
# Copy the runtime once to the main directory, which is passed
# as the argument to this function.
shutil.copy(copyDylibPath, str(path))

# Now rewrite the library itself
subprocess.check_call(
[
substs["INSTALL_NAME_TOOL"],
"-id",
f"@executable_path/{dylibName}",
str(path / dylibName),
]
)
dylibsCopied.add(dylibName)
else:
print(
f"dylib path in {file} was not found at: {copyDylibPath}",
file=sys.stderr,
)

# Now use install_name_tool to rewrite the path in our binary
if file.parent == path:
relpath = ""
else:
relpath = f"{os.path.relpath(str(path), str(file.parent))}/"
subprocess.check_call(
[
substs["INSTALL_NAME_TOOL"],
"-change",
absDylibPath,
f"@executable_path/{relpath}{dylibName}",
str(file),
]
)
break

dylibsMissing = dylibsRequired - dylibsCopied
Expand Down

0 comments on commit 0d6c077

Please sign in to comment.