diff --git a/.gitmodules b/.gitmodules index 5ff41bf655..28c7f0230a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -28,3 +28,6 @@ [submodule "third_party/abseil-cpp"] path = third_party/abseil-cpp url = https://chromium.googlesource.com/chromium/src/third_party/abseil-cpp.git +[submodule "depot_tools"] + path = depot_tools + url = https://github.com/denoland/depot_tools diff --git a/.gn b/.gn index f7097ddf3e..9a228c3d7c 100644 --- a/.gn +++ b/.gn @@ -73,6 +73,8 @@ default_args = { # Enable V8 object print for debugging. # v8_enable_object_print = true + v8_enable_builtins_optimization = true + # V8 12.3 added google/fuzztest as a third party dependency. # https://chromium.googlesource.com/v8/v8.git/+/d5acece0c9b89b18716c177d1fcc8f734191e1e2%5E%21/#F4 # diff --git a/Cargo.toml b/Cargo.toml index 7dcadaec1d..6aac85d875 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -73,6 +73,7 @@ exclude = [ "!v8/tools/run.py", "!v8/tools/snapshot/asm_to_inline_asm.py", "!v8/tools/testrunner/utils/dump_build_config.py", + "!v8/tools/builtins-pgo", ] [features] diff --git a/build.rs b/build.rs index f890957918..e9503ad7fd 100644 --- a/build.rs +++ b/build.rs @@ -114,6 +114,9 @@ fn build_v8() { if need_gn_ninja_download() { download_ninja_gn_binaries(); } + if need_pgo_data_download() { + download_v8_pgo_data(); + } // On windows, rustc cannot link with a V8 debug build. let mut gn_args = if is_debug() && !cfg!(target_os = "windows") { @@ -310,6 +313,34 @@ fn download_ninja_gn_binaries() { env::set_var("NINJA", ninja); } +fn download_v8_pgo_data() { + // Update $PATH to include depot_tools + // + // required for vpython3 to work. + env::set_var( + "PATH", + format!( + "{}:{}", + env::var("PATH").unwrap(), + std::env::current_dir() + .unwrap() + .join("depot_tools") + .to_str() + .unwrap() + ), + ); + println!("Downloading PGO data"); + #[cfg(not(target_os = "windows"))] + assert!(Command::new(python()) + .arg("./v8/tools/builtins-pgo/download_profiles.py") + .arg("download") + .arg("--depot-tools") + .arg("./depot_tools") + .status() + .unwrap() + .success()); +} + fn static_lib_url() -> String { if let Ok(custom_archive) = env::var("RUSTY_V8_ARCHIVE") { return custom_archive; @@ -533,6 +564,11 @@ fn need_gn_ninja_download() -> bool { !has_ninja || !has_gn } +fn need_pgo_data_download() -> bool { + let pgo_data = Path::new("v8/tools/builtins-pgo/profiles/x64.profile"); + !pgo_data.exists() +} + // Chromiums gn arg clang_base_path is currently compatible with: // * Apples clang and clang from homebrew's llvm@x packages // * the official binaries from releases.llvm.org diff --git a/depot_tools b/depot_tools new file mode 160000 index 0000000000..726042b2c2 --- /dev/null +++ b/depot_tools @@ -0,0 +1 @@ +Subproject commit 726042b2c223ff037daef0678710044d19e4a947