Skip to content

Instantly share code, notes, and snippets.

@zckevin
Last active August 15, 2019 04:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zckevin/853242ea6d751c984fe1543bf5c01582 to your computer and use it in GitHub Desktop.
Save zckevin/853242ea6d751c984fe1543bf5c01582 to your computer and use it in GitHub Desktop.
Compile chromium from scratch
solutions = [
{ "name" : "src",
"url" : "https://chromium.googlesource.com/chromium/src.git",
"deps_file" : "DEPS",
"managed" : True,
"custom_deps" : {
},
"custom_vars": {},
},
];
target_os = ["linux"];
target_os_only = True;
# debug functions e.g. print_decl depend on this
# is_official_build requires is_debug = false
is_debug = false
target_cpu = "x64"
target_os = "linux"
enable_nacl = false
blink_symbol_level = 0
# slow down a lot without it
use_jumbo_build = true
symbol_level = 0
is_component_build = false
# debug, release, official
is_official_build = true
From da889115beda397550e00fe08af38445d01e03df Mon Sep 17 00:00:00 2001
From: Cong Zuo <zckevinzc@gmail.com>
Date: Wed, 31 Jul 2019 10:52:26 +0800
Subject: [PATCH 1/3] Create `SnaptshotCreator` during v8::Isolate's creation.
---
gin/isolate_holder.cc | 49 +++++++++++++++++++++++++++++++++++++++++--
1 file changed, 47 insertions(+), 2 deletions(-)
diff --git a/gin/isolate_holder.cc b/gin/isolate_holder.cc
index 5f8aea7105..3c9263f5cc 100644
--- a/gin/isolate_holder.cc
+++ b/gin/isolate_holder.cc
@@ -23,6 +23,9 @@
#include "gin/v8_initializer.h"
#include "gin/v8_isolate_memory_dump_provider.h"
+#include <iostream>
+#include "gin/v8_foreground_task_runner.h"
+
namespace gin {
namespace {
@@ -60,17 +63,31 @@ IsolateHolder::IsolateHolder(
v8::ArrayBuffer::Allocator* allocator = g_array_buffer_allocator;
CHECK(allocator) << "You need to invoke gin::IsolateHolder::Initialize first";
+ if (isolate_creation_mode == IsolateCreationMode::kCreateSnapshot) {
isolate_ = v8::Isolate::Allocate();
isolate_data_.reset(
new PerIsolateData(isolate_, allocator, access_mode_, task_runner));
- if (isolate_creation_mode == IsolateCreationMode::kCreateSnapshot) {
// This branch is called when creating a V8 snapshot for Blink.
// Note SnapshotCreator calls isolate->Enter() in its construction.
snapshot_creator_.reset(
new v8::SnapshotCreator(isolate_, g_reference_table));
DCHECK_EQ(isolate_, snapshot_creator_->GetIsolate());
+
+ v8::Isolate::CreateParams params;
+ params.code_event_handler = DebugImpl::GetJitCodeEventHandler();
+ params.constraints.ConfigureDefaults(
+ base::SysInfo::AmountOfPhysicalMemory(),
+ base::SysInfo::AmountOfVirtualMemory());
+ params.array_buffer_allocator = allocator;
+ params.allow_atomics_wait =
+ atomics_wait_mode == AllowAtomicsWaitMode::kAllowAtomicsWait;
+ params.external_references = g_reference_table;
+ params.only_terminate_in_safe_scope = true;
+ // v8::Isolate::Initialize(isolate_, params);
+
} else {
v8::Isolate::CreateParams params;
+
params.code_event_handler = DebugImpl::GetJitCodeEventHandler();
params.constraints.ConfigureDefaults(
base::SysInfo::AmountOfPhysicalMemory(),
@@ -81,7 +98,35 @@ IsolateHolder::IsolateHolder(
params.external_references = g_reference_table;
params.only_terminate_in_safe_scope = true;
- v8::Isolate::Initialize(isolate_, params);
+ isolate_ = v8::Isolate::Allocate();
+ /*
+ {
+ std::shared_ptr<v8::TaskRunner> runner = std::make_shared<V8ForegroundTaskRunner>(task_runner);
+ isolate_->SetData(0, reinterpret_cast<void*>(&runner));
+ }
+ */
+ isolate_data_.reset(
+ new PerIsolateData(isolate_, allocator, access_mode_, task_runner));
+ {
+ // v8::Isolate* isolate = v8::Isolate::Allocate();
+ // std::unique_ptr<PerIsolateData> isolate_data;
+ // isolate_data.reset(
+ // new PerIsolateData(isolate, allocator, access_mode_, task_runner));
+
+ // std::cout << isolate_ << std::endl;
+ v8::SnapshotCreator *creator = new v8::SnapshotCreator(isolate_, g_reference_table);
+ if (false) {
+ creator = nullptr;
+ }
+ std::cout << "== creator! " << creator << std::endl;
+ isolate_->SetData(15, reinterpret_cast<void*>(creator));
+
+ // isolate_ = creator->GetIsolate();
+ }
+ // v8::Isolate::Initialize(isolate_, params);
+ // isolate_ = v8::Isolate::New(params);
+ // v8::Isolate::Initialize(isolate_, params);
+
}
isolate_memory_dump_provider_.reset(
--
2.17.0
From d8d399fc271e256513325e022c4c3afa531efc27 Mon Sep 17 00:00:00 2001
From: sb <sb@localhost.localdomain>
Date: Tue, 16 Jul 2019 15:54:55 +0800
Subject: [PATCH 2/3] Set document.cookie return httponly cookies by default.
---
net/cookies/cookie_options.cc | 2 +-
services/network/public/mojom/cookie_manager.mojom | 2 +-
services/network/restricted_cookie_manager.cc | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/cookies/cookie_options.cc b/net/cookies/cookie_options.cc
index 135bf6daa0..365d7566aa 100644
--- a/net/cookies/cookie_options.cc
+++ b/net/cookies/cookie_options.cc
@@ -10,7 +10,7 @@ namespace net {
// Keep default values in sync with content/public/common/cookie_manager.mojom.
CookieOptions::CookieOptions()
- : exclude_httponly_(true),
+ : exclude_httponly_(false),
same_site_cookie_context_(SameSiteCookieContext::CROSS_SITE),
update_access_time_(true),
server_time_(),
diff --git a/services/network/public/mojom/cookie_manager.mojom b/services/network/public/mojom/cookie_manager.mojom
index ebe47edf8c..f8bcb882d5 100644
--- a/services/network/public/mojom/cookie_manager.mojom
+++ b/services/network/public/mojom/cookie_manager.mojom
@@ -56,7 +56,7 @@ enum CookieSameSiteContext {
// Keep defaults here in sync with net/cookies/cookie_options.cc.
struct CookieOptions {
- bool exclude_httponly = true;
+ bool exclude_httponly = false;
CookieSameSiteContext same_site_cookie_context = CROSS_SITE;
bool update_access_time = true;
// TODO(rdsmith): Remove this element from the mojo structure? It's only
diff --git a/services/network/restricted_cookie_manager.cc b/services/network/restricted_cookie_manager.cc
index bb891b1eb9..c8dc023b44 100644
--- a/services/network/restricted_cookie_manager.cc
+++ b/services/network/restricted_cookie_manager.cc
@@ -209,7 +209,7 @@ void RestrictedCookieManager::SetCanonicalCookie(
base::Time now = base::Time::NowFromSystemTime();
auto sanitized_cookie = std::make_unique<net::CanonicalCookie>(
cookie.Name(), cookie.Value(), cookie.Domain(), cookie.Path(), now,
- cookie.ExpiryDate(), now, cookie.IsSecure(), cookie.IsHttpOnly(),
+ cookie.ExpiryDate(), now, cookie.IsSecure(), false,
cookie.SameSite(), cookie.Priority());
// TODO(pwnall): source_scheme might depend on the renderer.
--
2.17.0
From 3d7c81f5ab5f6aadfca306d533bff9626bb2d988 Mon Sep 17 00:00:00 2001
From: Cong Zuo <zckevinzc@gmail.com>
Date: Wed, 14 Aug 2019 10:09:30 +0800
Subject: [PATCH 3/3] Fix localhost:9222 tab list broken.
---
headless/lib/resources/devtools_discovery_page.html | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/headless/lib/resources/devtools_discovery_page.html b/headless/lib/resources/devtools_discovery_page.html
index 86809b9d1c..43f85cbdfe 100644
--- a/headless/lib/resources/devtools_discovery_page.html
+++ b/headless/lib/resources/devtools_discovery_page.html
@@ -15,7 +15,8 @@ function loadData() {
function parseResults([listData, versionData]){
const version = versionData['WebKit-Version'];
- const hash = version.match(/\s\(@(\b[0-9a-f]{5,40}\b)/)[1];
+ // const hash = version.match(/\s\(@(\b[0-9a-f]{5,40}\b)/)[1];
+ const hash = "909ee014fcea6828f9a610e6716145bc0b3ebf4a";
listData.forEach(item => appendItem(item, hash));
}
--
2.17.0
systemctl stop firewalld
# compiling dependencies
dnf install mosh tmux git python bzip2 tar pkgconfig atk-devel alsa-lib-devel \
bison binutils brlapi-devel bluez-libs-devel bzip2-devel cairo-devel \
cups-devel dbus-devel dbus-glib-devel expat-devel fontconfig-devel \
freetype-devel gcc-c++ glib2-devel glibc gperf glib2-devel \
gtk3-devel java-1.8.0-openjdk-devel libatomic libcap-devel libffi-devel \
libgcc libgnome-keyring-devel libjpeg-devel libstdc++ libX11-devel \
libXScrnSaver-devel libXtst-devel libxkbcommon-x11-devel ncurses-compat-libs \
nspr-devel nss-devel pam-devel pango-devel pciutils-devel \
pulseaudio-libs-devel zlib httpd mod_ssl php php-cli python-psutil wdiff \
xorg-x11-server-Xvfb bwm-ng htop rsync nodejs -y
# get chromium source_management/dev tools, e.g. ninja/gn/gclient...
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH=$PATH:/root/depot_tools
mkdir chrome && cd chrome
git config --global user.email "zckevinzc@gmail.com"
git config --global user.name "zc"
git init
# fetch chromium source, 4~5 GiB
git fetch https://chromium.googlesource.com/chromium/src.git +refs/tags/76.0.3809.82:chromium_76.0.3809.82 --depth 1
git checkout tags/76.0.3809.82
# create .gclient file
# gclient config https://chromium.googlesource.com/chromium/src.git
wget https://gist.githubusercontent.com/zckevin/853242ea6d751c984fe1543bf5c01582/raw/.gclient
# fetch chrome third_party dependencies(e.g. v8) from DEPS file and then run dependency hooks, ~16 GiB
# tags/76.0.3809.82
gclient sync --force --with_branch_heads -r feb121dc90d305720c9edacb3b31c187309f7814
# in ROOT/src/v8
cd ./src/v8
git remote add github https://github.com/zckevin/v8.git
git fetch github
git checkout github/release_build
# in ROOT/src
cd ../
gn gen out/Default
# in ROOT/src/out/Default
cd ./out/Default
wget https://gist.githubusercontent.com/zckevin/853242ea6d751c984fe1543bf5c01582/raw/args.gn
time ninja -d stats chrome
time ninja -d stats d8
mkdir ~/chrome.out
rsync --progress -arv --exclude=gen --exclude=thinlto-cache --exclude=obj `pwd` ~/chrome.out
cd ~
zip -r chrome.out.zip ~/chrome.out
npm install -g serve
# serve .
# aria2c -x 16 http://server_ip:5000/chrome.out.zip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment