Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use prebuilt v8 binaries #1217

Merged
merged 3 commits into from
Nov 27, 2018
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# build
*.swp
/out/
/target/
*.pyc
Expand Down
3 changes: 1 addition & 2 deletions .gn
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ default_args = {
# for now. See http://clang.llvm.org/docs/ControlFlowIntegrity.html
is_cfi = false

is_component_build = false
symbol_level = 1
treat_warnings_as_errors = true
rust_treat_warnings_as_errors = true
Expand All @@ -44,7 +43,7 @@ default_args = {
v8_experimental_extra_library_files = []
v8_extra_library_files = []
v8_imminent_deprecation_warnings = false
v8_monolithic = true
v8_monolithic = false
v8_untrusted_code_mitigations = false
v8_use_external_startup_data = false
v8_use_snapshot = true
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ env:
- RUSTUP_HOME=$HOME/.rustup/
- RUST_BACKTRACE=1
- HOMEBREW_PATH=$HOME/homebrew/
- DENO_BUILD_ARGS="use_custom_libcxx=false use_sysroot=false"
- DENO_BUILD_ARGS="use_sysroot=false"
- DENO_BUILD_PATH=$HOME/out/Default
- CARGO_TARGET_DIR=$HOME/target
- DENO_BUILD_MODE=release
Expand Down
44 changes: 35 additions & 9 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,23 @@ v8_executable("test_cc") {
configs = [ ":deno_config" ]
}

v8_static_library("v8") {
public_deps = [
"third_party/v8:v8",
"third_party/v8:v8_libbase",
"third_party/v8:v8_libplatform",
"third_party/v8:v8_libsampler",
"//build/win:default_exe_manifest",
]
configs = [ ":deno_config" ]
}

# Only functionality needed for libdeno_test and snapshot_creator
# In particular no flatbuffers, no assets, no rust, no msg handlers.
# Because snapshots are slow, it's important that snapshot_creator's
# dependencies are minimal.
static_library("libdeno") {
v8_static_library("libdeno") {
configs = [ ":deno_config" ]
sources = [
"libdeno/api.cc",
"libdeno/binding.cc",
Expand All @@ -231,30 +243,44 @@ static_library("libdeno") {
"libdeno/file_util.h",
"libdeno/internal.h",
]
public_deps = [
"third_party/v8:v8_monolith",
]
configs += [ ":deno_config" ]
if (!use_prebuilt_v8) {
public_deps = [
":v8",
]
} else {
# TODO(ry) It would be nice to have a standalone target for the prebuilt
# library that could simply be added to the deps here, but it wasn't
# obvious how to accomplish that in gn.
if (is_mac) {
libs = [ "//prebuilt/mac/libv8.a" ]
} else if (is_linux) {
libs = [ "//prebuilt/linux64/libv8.a" ]
} else if (is_win) {
libs = [ "//prebuilt/win/v8.lib" ]
} else {
assert(false, "We don't have prebuilt binaries for this platform yet.")
}
}
}

static_library("deno_deps") {
v8_static_library("deno_deps") {
complete_static_lib = true
public_deps = [
":libdeno",
":msg_rs",
":snapshot",
]
configs += [ ":deno_config" ]
configs = [ ":deno_config" ]
}

executable("snapshot_creator") {
v8_executable("snapshot_creator") {
sources = [
"libdeno/snapshot_creator.cc",
]
deps = [
":libdeno",
]
configs += [ ":deno_config" ]
configs = [ ":deno_config" ]
}

# Generates the core TypeScript type library for deno that will be
Expand Down
11 changes: 11 additions & 0 deletions Docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,17 @@ We use Flatbuffers to define common structs and enums between TypeScript and
Rust. These common data structures are defined in
https://github.com/denoland/deno/blob/master/src/msg.fbs

### Internal: Updating prebuilt binaries

V8 takes a long time to build - on the order of an hour. We use pre-built V8
libraries stored in a Google Storage bucket instead of rebuilding it from
scratch each time. Our build system is however setup such that we can build V8
as part of the Deno build if necessary (useful for debugging or changing various
configurations in V8, or building the pre-built binaries themselves). To control
whether to use a pre-built V8 or not use the `use_v8_prebuilt` GN argument.

Use `tools/gcloud_upload.py` to upload new prebuilt files.

## Contributing

See
Expand Down
5 changes: 5 additions & 0 deletions build_extra/deno.gni
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Copyright 2018 the Deno authors. All rights reserved. MIT license.
import("//build/compiled_action.gni")

declare_args() {
# Use prebuilt V8 libraries from //prebuilt/
use_prebuilt_v8 = true
}

template("run_node") {
action(target_name) {
forward_variables_from(invoker, "*")
Expand Down
2 changes: 2 additions & 0 deletions prebuilt/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.a
*.lib
1 change: 1 addition & 0 deletions prebuilt/linux64/libv8.a.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3728bfff7eb91e4e2c96999d974573e4d697e663
1 change: 1 addition & 0 deletions prebuilt/mac/libv8.a.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
597ca3bbcdc6edbaf23905988f9ca9911bb23250
1 change: 1 addition & 0 deletions prebuilt/win/v8.lib.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
052b261b8f8a7fc3f1babeb510d5bd73af0bcece
54 changes: 54 additions & 0 deletions tools/gcloud_upload.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env python
# Prereq:
# - gcloud auth login
# - gcloud config set project deno-223616
# This program uploads the specified file to GCloud Storage in the denoland
# bucket. It places a checksum file into the current directory using the base
# filename of the specified file.

import os
import sys
import hashlib
from util import root_path, run
from third_party import tp


def print_usage():
print "Usage: ./tools/gcloud_upload.py target/release/obj/third_party/v8/libv8.a"
sys.exit(1)


def compute_sha1(filename):
m = hashlib.sha1()
with open(filename) as f:
m.update(f.read())
return m.hexdigest()


def main(argv):
if len(argv) != 2:
print_usage()
os.chdir(root_path)

filename = sys.argv[1]
basename = os.path.basename(filename)

sha1 = compute_sha1(filename)
print sha1

gs_url = "gs://denoland/" + sha1

#gsutil = tp("depot_tools/gsutil.py")
gsutil = "gsutil" # standalone installation

run([gsutil, "cp", filename, gs_url])
run([gsutil, "acl", "ch", "-u", "AllUsers:R", gs_url])

target_filename = basename + ".sha1"
with open(target_filename, 'w') as f:
f.write(sha1)
print "Wrote", target_filename


if __name__ == '__main__':
sys.exit(main(sys.argv))
31 changes: 31 additions & 0 deletions tools/prebuilt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import sys
from util import run
from third_party import tp, google_env


def download_v8_prebuilt():
if sys.platform == 'win32':
sha1_file = "prebuilt/win/v8.lib.sha1"
elif sys.platform.startswith('linux'):
sha1_file = "prebuilt/linux64/libv8.a.sha1"
elif sys.platform == 'darwin':
sha1_file = "prebuilt/mac/libv8.a.sha1"

run([
"python",
tp('depot_tools/download_from_google_storage.py'),
'--platform=' + sys.platform,
'--no_auth',
'--bucket=denoland',
'--sha1_file',
sha1_file,
],
env=google_env())


def load():
ry marked this conversation as resolved.
Show resolved Hide resolved
download_v8_prebuilt()


if __name__ == '__main__':
sys.exit(load())
2 changes: 2 additions & 0 deletions tools/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import re
import sys
from distutils.spawn import find_executable
import prebuilt


def main():
Expand All @@ -18,6 +19,7 @@ def main():
third_party.download_gn()
third_party.download_clang_format()
third_party.download_clang()
prebuilt.load()
third_party.maybe_download_sysroot()

write_lastchange()
Expand Down