build: rename the v8 context snapshot on arm64 macOS builds (#26086)
* chore: rename the v8 context snapshot on arm64 macOS builds * build: update zip manifests * build: update to upstream patch
This commit is contained in:
parent
98b0ccbdb1
commit
760c4aeb3e
9 changed files with 707 additions and 7 deletions
|
@ -100,3 +100,4 @@ worker_feat_add_hook_to_notify_script_ready.patch
|
|||
fix_properly_honor_printing_page_ranges.patch
|
||||
fix_use_electron_generated_resources.patch
|
||||
chore_expose_v8_initialization_isolate_callbacks.patch
|
||||
rename_the_v8_context_snapshot_on_arm64_macos_builds.patch
|
||||
|
|
|
@ -0,0 +1,214 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Samuel Attard <samuel.r.attard@gmail.com>
|
||||
Date: Wed, 21 Oct 2020 13:13:00 -0700
|
||||
Subject: 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
|
||||
|
||||
diff --git a/android_webview/BUILD.gn b/android_webview/BUILD.gn
|
||||
index 49ba7977cc0d5710918b3452ab57078ba31c9949..a362123cad17d061690e7cb5a26413fdb51ac96b 100644
|
||||
--- a/android_webview/BUILD.gn
|
||||
+++ b/android_webview/BUILD.gn
|
||||
@@ -803,7 +803,7 @@ if (android_64bit_target_cpu) {
|
||||
"32-bit targets shouldn't have secondary abi")
|
||||
arch_suffix = "32"
|
||||
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" ]
|
||||
} else {
|
||||
renaming_sources = [ "$_secondary_abi_out_dir/snapshot_blob.bin" ]
|
||||
diff --git a/chrome/BUILD.gn b/chrome/BUILD.gn
|
||||
index f7a1a0a98e1fd719a978dca14a743f4c12a360fc..d95d8602356c4488f2e8dfd9acbacf56fe6da4c7 100644
|
||||
--- a/chrome/BUILD.gn
|
||||
+++ b/chrome/BUILD.gn
|
||||
@@ -768,7 +768,7 @@ if (is_win) {
|
||||
if (v8_use_external_startup_data) {
|
||||
public_deps += [ "//v8" ]
|
||||
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" ]
|
||||
} else {
|
||||
sources += [ "$root_out_dir/snapshot_blob.bin" ]
|
||||
diff --git a/chrome/installer/mini_installer/BUILD.gn b/chrome/installer/mini_installer/BUILD.gn
|
||||
index 7c7af8c0d9487abcd82ecd9d2d5b1ab4b737148b..df39ea145cc6b05775db7fbfb680fce892b8941a 100644
|
||||
--- a/chrome/installer/mini_installer/BUILD.gn
|
||||
+++ b/chrome/installer/mini_installer/BUILD.gn
|
||||
@@ -228,7 +228,7 @@ template("generate_mini_installer") {
|
||||
if (v8_use_external_startup_data) {
|
||||
deps += [ "//v8" ]
|
||||
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" ]
|
||||
} else {
|
||||
inputs += [ "$root_out_dir/snapshot_blob.bin" ]
|
||||
diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn
|
||||
index ea3dbb364ece871c9ac9e21c0cd17aecb1b0480f..e38fe0bab6d66fbbed23c0ed3ccfa84eff9257f9 100644
|
||||
--- a/content/browser/BUILD.gn
|
||||
+++ b/content/browser/BUILD.gn
|
||||
@@ -36,6 +36,7 @@ source_set("browser") {
|
||||
configs += [
|
||||
"//build/config:precompiled_headers",
|
||||
"//content:content_implementation",
|
||||
+ "//tools/v8_context_snapshot:use_v8_context_snapshot",
|
||||
"//v8:external_startup_data",
|
||||
]
|
||||
defines = []
|
||||
diff --git a/content/browser/v8_snapshot_files.cc b/content/browser/v8_snapshot_files.cc
|
||||
index d557c41a38e17c61e1b91d3daa47ea17e13a6a9e..43c93e3f50290d2aef230083a4bcebf307ef0c6e 100644
|
||||
--- a/content/browser/v8_snapshot_files.cc
|
||||
+++ b/content/browser/v8_snapshot_files.cc
|
||||
@@ -13,7 +13,7 @@ std::map<std::string, base::FilePath> GetV8SnapshotFilesToPreload() {
|
||||
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#if defined(USE_V8_CONTEXT_SNAPSHOT)
|
||||
return {{kV8ContextSnapshotDataDescriptor,
|
||||
- base::FilePath(FILE_PATH_LITERAL("v8_context_snapshot.bin"))}};
|
||||
+ base::FilePath(FILE_PATH_LITERAL(V8_CONTEXT_SNAPSHOT_FILENAME))}};
|
||||
#else
|
||||
return {{kV8SnapshotDataDescriptor,
|
||||
base::FilePath(FILE_PATH_LITERAL("snapshot_blob.bin"))}};
|
||||
diff --git a/content/shell/BUILD.gn b/content/shell/BUILD.gn
|
||||
index 4e5161f3b5d71ef511fba0183dbdad0b2c6b58c9..09d4a1e0a80d193ab05bf6c61278e7cc7f6d7beb 100644
|
||||
--- a/content/shell/BUILD.gn
|
||||
+++ b/content/shell/BUILD.gn
|
||||
@@ -560,7 +560,7 @@ if (is_mac) {
|
||||
if (v8_use_external_startup_data) {
|
||||
public_deps += [ "//v8" ]
|
||||
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" ]
|
||||
} else {
|
||||
sources += [ "$root_out_dir/snapshot_blob.bin" ]
|
||||
diff --git a/gin/BUILD.gn b/gin/BUILD.gn
|
||||
index 9ec6eb1b898bc87d066bdc75867ff624f7ef1f50..dfc59c17382f8463e82185032d977a1868c71985 100644
|
||||
--- a/gin/BUILD.gn
|
||||
+++ b/gin/BUILD.gn
|
||||
@@ -85,7 +85,10 @@ component("gin") {
|
||||
frameworks = [ "CoreFoundation.framework" ]
|
||||
}
|
||||
|
||||
- configs += [ "//v8:external_startup_data" ]
|
||||
+ configs += [
|
||||
+ "//tools/v8_context_snapshot:use_v8_context_snapshot",
|
||||
+ "//v8:external_startup_data",
|
||||
+ ]
|
||||
}
|
||||
|
||||
executable("gin_shell") {
|
||||
diff --git a/gin/v8_initializer.cc b/gin/v8_initializer.cc
|
||||
index 51fe2fa000e47ced3661ba581c52dceba93447fe..07d970b84b770b06019dc1de441cf108d67b1782 100644
|
||||
--- a/gin/v8_initializer.cc
|
||||
+++ b/gin/v8_initializer.cc
|
||||
@@ -76,7 +76,9 @@ const char kSnapshotFileName32[] = "snapshot_blob_32.bin";
|
||||
#endif
|
||||
|
||||
#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";
|
||||
#endif // defined(OS_ANDROID)
|
||||
|
||||
@@ -86,7 +88,12 @@ const char* GetSnapshotFileName(
|
||||
case V8Initializer::V8SnapshotFileType::kDefault:
|
||||
return kSnapshotFileName;
|
||||
case V8Initializer::V8SnapshotFileType::kWithAdditionalContext:
|
||||
+#if defined(USE_V8_CONTEXT_SNAPSHOT)
|
||||
return kV8ContextSnapshotFileName;
|
||||
+#else
|
||||
+ NOTREACHED();
|
||||
+ return nullptr;
|
||||
+#endif
|
||||
}
|
||||
NOTREACHED();
|
||||
return nullptr;
|
||||
diff --git a/headless/BUILD.gn b/headless/BUILD.gn
|
||||
index 1bd826a5562fc388f3b936e24a316902a8459ad5..1d099ce725d369fb0fea5f690ed2dee7934ef0b0 100644
|
||||
--- a/headless/BUILD.gn
|
||||
+++ b/headless/BUILD.gn
|
||||
@@ -475,7 +475,7 @@ component("headless_non_renderer") {
|
||||
if (v8_use_external_startup_data) {
|
||||
public_deps += [ "//v8" ]
|
||||
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" ]
|
||||
} else {
|
||||
data += [ "$root_out_dir/snapshot_blob.bin" ]
|
||||
diff --git a/tools/v8_context_snapshot/BUILD.gn b/tools/v8_context_snapshot/BUILD.gn
|
||||
index 2f20f684d89021dcd0e64421a0553a3e4a66334d..7662cc8ee83e39709eee6e0919c85370fedbb983 100644
|
||||
--- a/tools/v8_context_snapshot/BUILD.gn
|
||||
+++ b/tools/v8_context_snapshot/BUILD.gn
|
||||
@@ -21,14 +21,17 @@ group("v8_context_snapshot") {
|
||||
if (use_v8_context_snapshot) {
|
||||
public_deps = [ ":generate_v8_context_snapshot" ]
|
||||
if (!is_android) {
|
||||
- data = [ "$root_out_dir/v8_context_snapshot.bin" ]
|
||||
+ data = [ "$root_out_dir/$v8_context_snapshot_filename" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
config("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) {
|
||||
if (is_android && enable_java_templates) {
|
||||
android_assets("v8_context_snapshot_assets") {
|
||||
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" ||
|
||||
current_cpu == "mipsel") {
|
||||
renaming_destinations = [ "v8_context_snapshot_32.bin" ]
|
||||
@@ -49,7 +52,7 @@ if (use_v8_context_snapshot) {
|
||||
|
||||
action("generate_v8_context_snapshot") {
|
||||
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)
|
||||
|
||||
args = [
|
||||
diff --git a/tools/v8_context_snapshot/v8_context_snapshot.gni b/tools/v8_context_snapshot/v8_context_snapshot.gni
|
||||
index 6a6f477ad3f543680cd6485bdf6b0e82d567012c..7f485e135cef8e3f0c01ede28b4cfe76067bc624 100644
|
||||
--- a/tools/v8_context_snapshot/v8_context_snapshot.gni
|
||||
+++ b/tools/v8_context_snapshot/v8_context_snapshot.gni
|
||||
@@ -18,6 +18,18 @@ declare_args() {
|
||||
!is_chromeos && !is_android && !is_chromecast && !is_fuchsia &&
|
||||
!(host_os == "mac" && current_cpu == "x86") &&
|
||||
(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.
|
Loading…
Add table
Add a link
Reference in a new issue