Commit 26713999 authored by Samuel Attard's avatar Samuel Attard Committed by Commit Bot

rename the v8 context snapshot on arm64 macOS builds

This is done so that the arm64 and x64 v8 context snapshots can
live side by side in a universal app build of a Chromium based
application.  All other files can be Mach-O universal binaries
generated using "lipo" but these snapshot files have to be uniquely
named so that both can exist in the Resources folder at the same time
and the correct one is chosen at runtime.

Bug: 1142017
Change-Id: I8449b72ba3a36e7ce69b9d9ec7768bd80ecc3e3a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2490980Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarJochen Eisinger <jochen@chromium.org>
Reviewed-by: default avatarDirk Pranke <dpranke@google.com>
Reviewed-by: default avatarMark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821439}
parent f1fa51af
...@@ -802,7 +802,7 @@ if (android_64bit_target_cpu) { ...@@ -802,7 +802,7 @@ if (android_64bit_target_cpu) {
"32-bit targets shouldn't have secondary abi") "32-bit targets shouldn't have secondary abi")
arch_suffix = "32" arch_suffix = "32"
if (use_v8_context_snapshot) { if (use_v8_context_snapshot) {
renaming_sources = [ "$_secondary_abi_out_dir/v8_context_snapshot.bin" ] renaming_sources = [ "$_secondary_abi_out_dir/$v8_context_snapshot_filename" ]
renaming_destinations = [ "v8_context_snapshot_$arch_suffix.bin" ] renaming_destinations = [ "v8_context_snapshot_$arch_suffix.bin" ]
} else { } else {
renaming_sources = [ "$_secondary_abi_out_dir/snapshot_blob.bin" ] renaming_sources = [ "$_secondary_abi_out_dir/snapshot_blob.bin" ]
......
...@@ -774,7 +774,7 @@ if (is_win) { ...@@ -774,7 +774,7 @@ if (is_win) {
if (v8_use_external_startup_data) { if (v8_use_external_startup_data) {
public_deps += [ "//v8" ] public_deps += [ "//v8" ]
if (use_v8_context_snapshot) { if (use_v8_context_snapshot) {
sources += [ "$root_out_dir/v8_context_snapshot.bin" ] sources += [ "$root_out_dir/$v8_context_snapshot_filename" ]
public_deps += [ "//tools/v8_context_snapshot" ] public_deps += [ "//tools/v8_context_snapshot" ]
} else { } else {
sources += [ "$root_out_dir/snapshot_blob.bin" ] sources += [ "$root_out_dir/snapshot_blob.bin" ]
......
...@@ -228,7 +228,7 @@ template("generate_mini_installer") { ...@@ -228,7 +228,7 @@ template("generate_mini_installer") {
if (v8_use_external_startup_data) { if (v8_use_external_startup_data) {
deps += [ "//v8" ] deps += [ "//v8" ]
if (use_v8_context_snapshot) { if (use_v8_context_snapshot) {
inputs += [ "$root_out_dir/v8_context_snapshot.bin" ] inputs += [ "$root_out_dir/$v8_context_snapshot_filename" ]
deps += [ "//tools/v8_context_snapshot" ] deps += [ "//tools/v8_context_snapshot" ]
} else { } else {
inputs += [ "$root_out_dir/snapshot_blob.bin" ] inputs += [ "$root_out_dir/snapshot_blob.bin" ]
......
...@@ -36,6 +36,7 @@ source_set("browser") { ...@@ -36,6 +36,7 @@ source_set("browser") {
configs += [ configs += [
"//build/config:precompiled_headers", "//build/config:precompiled_headers",
"//content:content_implementation", "//content:content_implementation",
"//tools/v8_context_snapshot:use_v8_context_snapshot",
"//v8:external_startup_data", "//v8:external_startup_data",
] ]
defines = [] defines = []
......
...@@ -13,7 +13,7 @@ std::map<std::string, base::FilePath> GetV8SnapshotFilesToPreload() { ...@@ -13,7 +13,7 @@ std::map<std::string, base::FilePath> GetV8SnapshotFilesToPreload() {
#if defined(OS_LINUX) || defined(OS_CHROMEOS) #if defined(OS_LINUX) || defined(OS_CHROMEOS)
#if defined(USE_V8_CONTEXT_SNAPSHOT) #if defined(USE_V8_CONTEXT_SNAPSHOT)
return {{kV8ContextSnapshotDataDescriptor, return {{kV8ContextSnapshotDataDescriptor,
base::FilePath(FILE_PATH_LITERAL("v8_context_snapshot.bin"))}}; base::FilePath(FILE_PATH_LITERAL(V8_CONTEXT_SNAPSHOT_FILENAME))}};
#else #else
return {{kV8SnapshotDataDescriptor, return {{kV8SnapshotDataDescriptor,
base::FilePath(FILE_PATH_LITERAL("snapshot_blob.bin"))}}; base::FilePath(FILE_PATH_LITERAL("snapshot_blob.bin"))}};
......
...@@ -562,7 +562,7 @@ if (is_mac) { ...@@ -562,7 +562,7 @@ if (is_mac) {
if (v8_use_external_startup_data) { if (v8_use_external_startup_data) {
public_deps += [ "//v8" ] public_deps += [ "//v8" ]
if (use_v8_context_snapshot) { if (use_v8_context_snapshot) {
sources += [ "$root_out_dir/v8_context_snapshot.bin" ] sources += [ "$root_out_dir/$v8_context_snapshot_filename" ]
public_deps += [ "//tools/v8_context_snapshot" ] public_deps += [ "//tools/v8_context_snapshot" ]
} else { } else {
sources += [ "$root_out_dir/snapshot_blob.bin" ] sources += [ "$root_out_dir/snapshot_blob.bin" ]
......
...@@ -85,7 +85,10 @@ component("gin") { ...@@ -85,7 +85,10 @@ component("gin") {
frameworks = [ "CoreFoundation.framework" ] frameworks = [ "CoreFoundation.framework" ]
} }
configs += [ "//v8:external_startup_data" ] configs += [
"//tools/v8_context_snapshot:use_v8_context_snapshot",
"//v8:external_startup_data",
]
} }
executable("gin_shell") { executable("gin_shell") {
......
...@@ -76,7 +76,9 @@ const char kSnapshotFileName32[] = "snapshot_blob_32.bin"; ...@@ -76,7 +76,9 @@ const char kSnapshotFileName32[] = "snapshot_blob_32.bin";
#endif #endif
#else // defined(OS_ANDROID) #else // defined(OS_ANDROID)
const char kV8ContextSnapshotFileName[] = "v8_context_snapshot.bin"; #if defined(USE_V8_CONTEXT_SNAPSHOT)
const char kV8ContextSnapshotFileName[] = V8_CONTEXT_SNAPSHOT_FILENAME;
#endif
const char kSnapshotFileName[] = "snapshot_blob.bin"; const char kSnapshotFileName[] = "snapshot_blob.bin";
#endif // defined(OS_ANDROID) #endif // defined(OS_ANDROID)
...@@ -86,7 +88,12 @@ const char* GetSnapshotFileName( ...@@ -86,7 +88,12 @@ const char* GetSnapshotFileName(
case V8Initializer::V8SnapshotFileType::kDefault: case V8Initializer::V8SnapshotFileType::kDefault:
return kSnapshotFileName; return kSnapshotFileName;
case V8Initializer::V8SnapshotFileType::kWithAdditionalContext: case V8Initializer::V8SnapshotFileType::kWithAdditionalContext:
#if defined(USE_V8_CONTEXT_SNAPSHOT)
return kV8ContextSnapshotFileName; return kV8ContextSnapshotFileName;
#else
NOTREACHED();
return nullptr;
#endif
} }
NOTREACHED(); NOTREACHED();
return nullptr; return nullptr;
......
...@@ -475,7 +475,7 @@ component("headless_non_renderer") { ...@@ -475,7 +475,7 @@ component("headless_non_renderer") {
if (v8_use_external_startup_data) { if (v8_use_external_startup_data) {
public_deps += [ "//v8" ] public_deps += [ "//v8" ]
if (use_v8_context_snapshot) { if (use_v8_context_snapshot) {
data += [ "$root_out_dir/v8_context_snapshot.bin" ] data += [ "$root_out_dir/$v8_context_snapshot_filename" ]
data_deps += [ "//tools/v8_context_snapshot" ] data_deps += [ "//tools/v8_context_snapshot" ]
} else { } else {
data += [ "$root_out_dir/snapshot_blob.bin" ] data += [ "$root_out_dir/snapshot_blob.bin" ]
......
...@@ -21,14 +21,17 @@ group("v8_context_snapshot") { ...@@ -21,14 +21,17 @@ group("v8_context_snapshot") {
if (use_v8_context_snapshot) { if (use_v8_context_snapshot) {
public_deps = [ ":generate_v8_context_snapshot" ] public_deps = [ ":generate_v8_context_snapshot" ]
if (!is_android) { if (!is_android) {
data = [ "$root_out_dir/v8_context_snapshot.bin" ] data = [ "$root_out_dir/$v8_context_snapshot_filename" ]
} }
} }
} }
config("use_v8_context_snapshot") { config("use_v8_context_snapshot") {
if (use_v8_context_snapshot) { if (use_v8_context_snapshot) {
defines = [ "USE_V8_CONTEXT_SNAPSHOT" ] defines = [
"USE_V8_CONTEXT_SNAPSHOT",
"V8_CONTEXT_SNAPSHOT_FILENAME=\"$v8_context_snapshot_filename\"",
]
} }
} }
...@@ -36,7 +39,7 @@ if (use_v8_context_snapshot) { ...@@ -36,7 +39,7 @@ if (use_v8_context_snapshot) {
if (is_android && enable_java_templates) { if (is_android && enable_java_templates) {
android_assets("v8_context_snapshot_assets") { android_assets("v8_context_snapshot_assets") {
deps = [ ":v8_context_snapshot" ] deps = [ ":v8_context_snapshot" ]
renaming_sources = [ "$root_out_dir/v8_context_snapshot.bin" ] renaming_sources = [ "$root_out_dir/$v8_context_snapshot_filename" ]
if (current_cpu == "arm" || current_cpu == "x86" || if (current_cpu == "arm" || current_cpu == "x86" ||
current_cpu == "mipsel") { current_cpu == "mipsel") {
renaming_destinations = [ "v8_context_snapshot_32.bin" ] renaming_destinations = [ "v8_context_snapshot_32.bin" ]
...@@ -49,7 +52,7 @@ if (use_v8_context_snapshot) { ...@@ -49,7 +52,7 @@ if (use_v8_context_snapshot) {
action("generate_v8_context_snapshot") { action("generate_v8_context_snapshot") {
script = "//build/gn_run_binary.py" script = "//build/gn_run_binary.py"
output_file = "$root_out_dir/v8_context_snapshot.bin" output_file = "$root_out_dir/$v8_context_snapshot_filename"
output_path = rebase_path(output_file, root_build_dir) output_path = rebase_path(output_file, root_build_dir)
args = [ args = [
......
...@@ -18,6 +18,18 @@ declare_args() { ...@@ -18,6 +18,18 @@ declare_args() {
!is_chromeos && !is_android && !is_chromecast && !is_fuchsia && !is_chromeos && !is_android && !is_chromecast && !is_fuchsia &&
!(host_os == "mac" && current_cpu == "x86") && !(host_os == "mac" && current_cpu == "x86") &&
(v8_target_cpu == target_cpu || is_msan) && !(is_win && host_os != "win") (v8_target_cpu == target_cpu || is_msan) && !(is_win && host_os != "win")
# We use a different filename for arm64 macOS builds so that the arm64 and
# x64 snapshots can live side-by-side in a universal macOS app.
if (is_mac) {
if (v8_target_cpu == "x64") {
v8_context_snapshot_filename = "v8_context_snapshot.x86_64.bin"
} else if (v8_target_cpu == "arm64") {
v8_context_snapshot_filename = "v8_context_snapshot.arm64.bin"
}
} else {
v8_context_snapshot_filename = "v8_context_snapshot.bin"
}
} }
# We cannot use V8 context snapshot, if V8 doesn't use snapshot files. # We cannot use V8 context snapshot, if V8 doesn't use snapshot files.
......
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