Skip to content

Commit

Permalink
Only mangles llvm-ar case for Darwin.
Browse files Browse the repository at this point in the history
With the previous code, Android failed because `deccontext.o` does not exist to rename.
Darwin failed because `Runtime.o` wasn't found for extraction.
  • Loading branch information
tommie committed Dec 28, 2023
1 parent b0ff453 commit 758bbd2
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions deps/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,24 +197,25 @@ def convert_to_thin_ar(src_fn, dest_fn, dest_obj_dn):
cwd=v8_path)
ar_files = ar_files.splitlines()

# llvm-ar (--clang) for Darwin (but not Android) seems to mangle
# the names to lowercase on extraction, while others do not.
ar_mangles_case = args.os == "darwin"

# Extracting files one-by-one is slow, so let's group them into
# disjoint sets and use "ar N"...
ar_file_names = {}
for ar_file in ar_files:
# llvm-ar (--clang) seems to mangle the names to lowercase on
# extraction, while binutils ar does not.
ar_file_canon = ar_file.lower() if is_clang else ar_file
ar_file_canon = ar_file.lower() if ar_mangles_case else ar_file
ar_file_names.setdefault(ar_file_canon, []).append(ar_file)

ar_file_groups = []
for ar_file_canon, ar_files in ar_file_names.items():
for ar_files in ar_file_names.values():
if len(ar_file_groups) < len(ar_files):
ar_file_groups.extend([[]] * (len(ar_files) - len(ar_file_groups)))
for i, ar_file in enumerate(ar_files):
ar_file_groups[i].append(ar_file)
ar_file_groups[i].append(ar_file.lower() if ar_mangles_case else ar_file)

for i, ar_files in enumerate(ar_file_groups):
# Undocumented: "ar N" is 1-based.
subprocess_check_call(
[
ar_path,
Expand All @@ -225,7 +226,7 @@ def convert_to_thin_ar(src_fn, dest_fn, dest_obj_dn):
] + ar_files,
cwd=v8_path)
for ar_file in ar_files:
ar_file_canon = ar_file.lower() if is_clang else ar_file
ar_file_canon = ar_file.lower() if ar_mangles_case else ar_file
os.rename(os.path.join(dest_obj_dn, ar_file_canon), os.path.join(dest_obj_dn, "{}.{}.o".format(1 + i, ar_file)))

if os.path.exists(dest_fn):
Expand Down

0 comments on commit 758bbd2

Please sign in to comment.