Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Generate gen_snapshot_armv7 and gen_snapshot_arm64 #22818

Merged
merged 2 commits into from
Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions lib/snapshot/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,29 @@ bin_to_linkable("platform_strong_dill_linkable") {
executable = false
}

action("create_arm_gen_snapshot") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmagman @cbracken This rule must declare a dependency on some rule that causes gen_snapshot to end up at the expected location. Otherwise GN/Ninja might try to run this rule before gen_snapshot is there.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to reopen flutter/flutter#38933 since it didn't work the next time I ran it. That would explain it...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am poking around something related, and will make a concrete suggestion shortly.

output_dir = "$root_out_dir/clang_x64"
script = "//flutter/sky/tools/create_macos_gen_snapshots.py"
visibility = [ ":*" ]
args = [
"--dst",
rebase_path(output_dir),
]
if (target_cpu == "arm") {
args += [
"--armv7-out-dir",
rebase_path("$root_out_dir"),
]
outputs = [ "$output_dir/gen_snapshot_armv7" ]
} else {
args += [
"--arm64-out-dir",
rebase_path("$root_out_dir"),
]
outputs = [ "$output_dir/gen_snapshot_arm64" ]
}
}

source_set("snapshot") {
deps = [
":isolate_snapshot_data_linkable",
Expand All @@ -205,6 +228,10 @@ source_set("snapshot") {
":vm_snapshot_data_linkable",
":vm_snapshot_instructions_linkable",
]
if (host_os == "macos" && (target_cpu == "arm" || target_cpu == "arm64")) {
deps += [ ":create_arm_gen_snapshot" ]
}

sources = get_target_outputs(":isolate_snapshot_data_linkable") +
get_target_outputs(":isolate_snapshot_instructions_linkable") +
get_target_outputs(":vm_snapshot_data_linkable") +
Expand Down
29 changes: 15 additions & 14 deletions sky/tools/create_macos_gen_snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,27 @@ def main():
parser = argparse.ArgumentParser(description='Copies architecture-dependent gen_snapshot binaries to output dir')

parser.add_argument('--dst', type=str, required=True)
parser.add_argument('--arm64-out-dir', type=str, required=True)
parser.add_argument('--armv7-out-dir', type=str, required=True)
parser.add_argument('--arm64-out-dir', type=str)
parser.add_argument('--armv7-out-dir', type=str)

args = parser.parse_args()

arm64_gen_snapshot = os.path.join(args.arm64_out_dir, 'clang_x64', 'gen_snapshot')
armv7_gen_snapshot = os.path.join(args.armv7_out_dir, 'clang_x64', 'gen_snapshot')
if args.arm64_out_dir:
generate_gen_snapshot(args.arm64_out_dir, os.path.join(args.dst, 'gen_snapshot_arm64'))

if not os.path.isfile(arm64_gen_snapshot):
print 'Cannot find x86_64 (arm64) gen_snapshot at', arm64_gen_snapshot
return 1
if args.armv7_out_dir:
generate_gen_snapshot(args.armv7_out_dir, os.path.join(args.dst, 'gen_snapshot_armv7'))

if not os.path.isfile(armv7_gen_snapshot):
print 'Cannot find i386 (armv7) gen_snapshot at', armv7_gen_snapshot
return 1

subprocess.check_call(['xcrun', 'bitcode_strip', '-r', armv7_gen_snapshot,
'-o', os.path.join(args.dst, 'gen_snapshot_armv7')])
subprocess.check_call(['xcrun', 'bitcode_strip', '-r', arm64_gen_snapshot,
'-o', os.path.join(args.dst, 'gen_snapshot_arm64')])
def generate_gen_snapshot(directory, destination):
gen_snapshot_dir = os.path.join(directory, 'clang_x64', 'gen_snapshot')
if not os.path.isfile(gen_snapshot_dir):
print 'Cannot find gen_snapshot at', gen_snapshot_dir
sys.exit(1)

subprocess.check_call(['xcrun', 'bitcode_strip', '-r', gen_snapshot_dir,
'-o', destination])


if __name__ == '__main__':
sys.exit(main())
Expand Down