2016-05-24 08:54:42 +00:00
|
|
|
# Copyright 2016 the V8 project authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
2017-08-09 08:11:21 +00:00
|
|
|
import("//build/config/jumbo.gni")
|
2016-06-21 23:35:19 +00:00
|
|
|
import("//build/config/sanitizers/sanitizers.gni")
|
2016-07-15 22:32:55 +00:00
|
|
|
import("//build/config/v8_target_cpu.gni")
|
2017-06-13 14:21:07 +00:00
|
|
|
import("//build/split_static_library.gni")
|
2016-05-24 10:39:57 +00:00
|
|
|
|
2016-05-24 08:54:42 +00:00
|
|
|
declare_args() {
|
2017-06-27 11:49:13 +00:00
|
|
|
# Set flags for tracking code coverage. Uses gcov with gcc and sanitizer
|
|
|
|
# coverage with clang.
|
|
|
|
v8_code_coverage = false
|
|
|
|
|
2017-01-10 10:19:21 +00:00
|
|
|
# Includes files needed for correctness fuzzing.
|
|
|
|
v8_correctness_fuzzer = false
|
|
|
|
|
2017-02-02 11:32:52 +00:00
|
|
|
# Adds additional compile target for building multiple architectures at once.
|
|
|
|
v8_multi_arch_build = false
|
|
|
|
|
2016-06-30 08:58:09 +00:00
|
|
|
# Indicate if valgrind was fetched as a custom deps to make it available on
|
|
|
|
# swarming.
|
|
|
|
v8_has_valgrind = false
|
|
|
|
|
2016-07-04 07:52:08 +00:00
|
|
|
# Indicate if gcmole was fetched as a hook to make it available on swarming.
|
|
|
|
v8_gcmole = false
|
|
|
|
|
2016-06-14 10:07:22 +00:00
|
|
|
# Turns on compiler optimizations in V8 in Debug build.
|
|
|
|
v8_optimized_debug = true
|
|
|
|
|
2016-07-20 12:52:27 +00:00
|
|
|
# Support for backtrace_symbols on linux.
|
|
|
|
v8_enable_backtrace = ""
|
|
|
|
|
2019-03-20 08:46:47 +00:00
|
|
|
# Enables raw heap snapshots containing internals. Used for debugging memory
|
2019-03-06 09:01:22 +00:00
|
|
|
# on platform and embedder level.
|
2019-03-20 08:46:47 +00:00
|
|
|
v8_enable_raw_heap_snapshots = false
|
|
|
|
|
2016-06-03 08:16:50 +00:00
|
|
|
# Enable the snapshot feature, for fast context creation.
|
2018-12-28 21:02:51 +00:00
|
|
|
# https://v8.dev/blog/custom-startup-snapshots
|
2019-03-19 17:43:32 +00:00
|
|
|
# TODO(thakis): Make snapshots work in 64-bit win/cross builds,
|
|
|
|
# https://803591
|
2019-03-22 19:30:30 +00:00
|
|
|
# On Mac hosts, 32-bit builds targeting Windows can't use snapshots, see
|
|
|
|
# https://crbug.com/794838
|
|
|
|
v8_use_snapshot = !(is_win && host_os != "win" && target_cpu == "x64") &&
|
|
|
|
!(is_win && host_os == "mac" && target_cpu == "x86")
|
2016-06-03 08:16:50 +00:00
|
|
|
|
2018-03-20 10:16:14 +00:00
|
|
|
# Enable several snapshots side-by-side (e.g. default and for trusted code).
|
2018-06-28 09:31:07 +00:00
|
|
|
v8_use_multi_snapshots = false
|
2018-03-20 10:16:14 +00:00
|
|
|
|
2016-06-03 08:16:50 +00:00
|
|
|
# Use external files for startup data blobs:
|
|
|
|
# the JS builtins sources and the start snapshot.
|
2016-07-06 15:14:07 +00:00
|
|
|
v8_use_external_startup_data = ""
|
2016-11-14 10:00:58 +00:00
|
|
|
|
|
|
|
# Enable ECMAScript Internationalization API. Enabling this feature will
|
|
|
|
# add a dependency on the ICU library.
|
|
|
|
v8_enable_i18n_support = true
|
2016-11-21 19:29:02 +00:00
|
|
|
|
2017-01-25 00:20:56 +00:00
|
|
|
# Use static libraries instead of source_sets.
|
|
|
|
v8_static_library = false
|
2018-01-05 15:39:29 +00:00
|
|
|
|
|
|
|
# Enable monolithic static library for embedders.
|
|
|
|
v8_monolithic = false
|
2019-02-13 12:51:56 +00:00
|
|
|
|
|
|
|
# Expose symbols for dynamic linking.
|
|
|
|
v8_expose_symbols = false
|
2019-05-27 12:46:35 +00:00
|
|
|
|
|
|
|
# Use Perfetto (https://perfetto.dev) as the default TracingController. Not
|
|
|
|
# currently implemented.
|
|
|
|
v8_use_perfetto = false
|
2016-07-06 15:14:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (v8_use_external_startup_data == "") {
|
|
|
|
# If not specified as a gn arg, use external startup data by default if
|
|
|
|
# a snapshot is used and if we're not on ios.
|
|
|
|
v8_use_external_startup_data = v8_use_snapshot && !is_ios
|
2016-05-24 10:39:57 +00:00
|
|
|
}
|
2016-06-14 10:07:22 +00:00
|
|
|
|
2018-06-28 09:31:07 +00:00
|
|
|
if (v8_use_multi_snapshots) {
|
|
|
|
# Silently disable multi snapshots if they're incompatible with the current
|
|
|
|
# build configuration. This allows us to set v8_use_multi_snapshots=true on
|
|
|
|
# all bots, and e.g. no-snapshot bots will automatically do the right thing.
|
2018-03-22 10:10:39 +00:00
|
|
|
v8_use_multi_snapshots =
|
|
|
|
v8_use_external_startup_data && !build_with_chromium && !use_jumbo_build
|
2018-03-20 10:16:14 +00:00
|
|
|
}
|
|
|
|
|
2016-07-20 12:52:27 +00:00
|
|
|
if (v8_enable_backtrace == "") {
|
2016-07-22 18:13:08 +00:00
|
|
|
v8_enable_backtrace = is_debug && !v8_optimized_debug
|
2016-07-20 12:52:27 +00:00
|
|
|
}
|
|
|
|
|
2016-06-14 10:07:22 +00:00
|
|
|
# Points to // in v8 stand-alone or to //v8/ in chromium. We need absolute
|
|
|
|
# paths for all configs in templates as they are shared in different
|
|
|
|
# subdirectories.
|
2016-07-20 09:16:27 +00:00
|
|
|
v8_path_prefix = get_path_info("../", "abspath")
|
2016-06-14 10:07:22 +00:00
|
|
|
|
2019-06-11 13:11:16 +00:00
|
|
|
v8_inspector_js_protocol = v8_path_prefix + "/include/js_protocol.pdl"
|
2016-10-12 14:10:57 +00:00
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# Templates
|
|
|
|
#
|
|
|
|
|
2016-06-14 10:07:22 +00:00
|
|
|
# Common configs to remove or add in all v8 targets.
|
2017-03-17 15:18:18 +00:00
|
|
|
v8_remove_configs = []
|
2016-07-20 09:16:27 +00:00
|
|
|
v8_add_configs = [
|
|
|
|
v8_path_prefix + ":features",
|
|
|
|
v8_path_prefix + ":toolchain",
|
2016-06-14 10:07:22 +00:00
|
|
|
]
|
|
|
|
|
2019-04-02 14:35:58 +00:00
|
|
|
if (is_debug && !v8_optimized_debug) {
|
|
|
|
v8_remove_configs += [ "//build/config/compiler:default_optimization" ]
|
|
|
|
v8_add_configs += [ "//build/config/compiler:no_optimize" ]
|
|
|
|
} else {
|
|
|
|
v8_remove_configs += [ "//build/config/compiler:default_optimization" ]
|
|
|
|
|
|
|
|
# TODO(crbug.com/621335) Rework this so that we don't have the confusion
|
|
|
|
# between "optimize_speed" and "optimize_max".
|
|
|
|
if (((is_posix && !is_android) || is_fuchsia) && !using_sanitizer) {
|
|
|
|
v8_add_configs += [ "//build/config/compiler:optimize_speed" ]
|
|
|
|
} else {
|
|
|
|
v8_add_configs += [ "//build/config/compiler:optimize_max" ]
|
|
|
|
}
|
|
|
|
}
|
2016-06-14 10:07:22 +00:00
|
|
|
|
2017-06-27 11:49:13 +00:00
|
|
|
if (v8_code_coverage && !is_clang) {
|
|
|
|
v8_add_configs += [
|
|
|
|
v8_path_prefix + ":v8_gcov_coverage_cflags",
|
|
|
|
v8_path_prefix + ":v8_gcov_coverage_ldflags",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2019-02-13 12:51:56 +00:00
|
|
|
if ((is_posix || is_fuchsia) &&
|
|
|
|
(v8_enable_backtrace || v8_monolithic || v8_expose_symbols)) {
|
2016-07-20 12:52:27 +00:00
|
|
|
v8_remove_configs += [ "//build/config/gcc:symbol_visibility_hidden" ]
|
|
|
|
v8_add_configs += [ "//build/config/gcc:symbol_visibility_default" ]
|
|
|
|
}
|
|
|
|
|
2018-01-29 09:56:47 +00:00
|
|
|
# On MIPS gcc_target_rpath and ldso_path might be needed for all builds.
|
|
|
|
if (target_cpu == "mipsel" || target_cpu == "mips64el" ||
|
|
|
|
target_cpu == "mips" || target_cpu == "mips64") {
|
|
|
|
v8_add_configs += [ "//build/config/gcc:rpath_for_built_shared_libraries" ]
|
|
|
|
}
|
|
|
|
|
2018-04-06 12:30:02 +00:00
|
|
|
if (!build_with_chromium && is_clang) {
|
|
|
|
v8_remove_configs += [ "//build/config/clang:find_bad_constructs" ]
|
|
|
|
}
|
|
|
|
|
2016-06-14 10:07:22 +00:00
|
|
|
# All templates should be kept in sync.
|
|
|
|
template("v8_source_set") {
|
2017-06-13 14:21:07 +00:00
|
|
|
if (defined(invoker.split_count) && invoker.split_count > 1 &&
|
|
|
|
defined(v8_static_library) && v8_static_library && is_win) {
|
2019-01-23 17:06:04 +00:00
|
|
|
link_target_type = "jumbo_split_static_library"
|
2017-06-13 14:21:07 +00:00
|
|
|
} else if (defined(v8_static_library) && v8_static_library) {
|
2019-01-23 17:06:04 +00:00
|
|
|
link_target_type = "jumbo_static_library"
|
2016-11-28 10:41:47 +00:00
|
|
|
} else {
|
2019-01-23 17:06:04 +00:00
|
|
|
link_target_type = "jumbo_source_set"
|
2017-06-13 14:21:07 +00:00
|
|
|
}
|
|
|
|
target(link_target_type, target_name) {
|
2018-10-10 09:58:16 +00:00
|
|
|
forward_variables_from(invoker,
|
|
|
|
"*",
|
|
|
|
[
|
|
|
|
"configs",
|
|
|
|
"remove_configs",
|
|
|
|
])
|
2019-04-09 12:34:36 +00:00
|
|
|
configs -= v8_remove_configs
|
|
|
|
configs += v8_add_configs
|
2018-10-10 09:58:16 +00:00
|
|
|
if (defined(invoker.remove_configs)) {
|
|
|
|
configs -= invoker.remove_configs
|
|
|
|
}
|
2017-06-13 14:21:07 +00:00
|
|
|
configs += invoker.configs
|
2016-06-14 10:07:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-09 13:28:10 +00:00
|
|
|
template("v8_header_set") {
|
2017-08-09 08:11:21 +00:00
|
|
|
jumbo_source_set(target_name) {
|
2017-02-09 13:28:10 +00:00
|
|
|
forward_variables_from(invoker, "*", [ "configs" ])
|
|
|
|
configs -= v8_remove_configs
|
|
|
|
configs += v8_add_configs
|
2019-04-09 12:34:36 +00:00
|
|
|
configs += invoker.configs
|
2017-02-09 13:28:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-14 10:07:22 +00:00
|
|
|
template("v8_executable") {
|
|
|
|
executable(target_name) {
|
2016-10-12 09:59:31 +00:00
|
|
|
forward_variables_from(invoker,
|
|
|
|
"*",
|
|
|
|
[
|
|
|
|
"configs",
|
|
|
|
"remove_configs",
|
|
|
|
])
|
2019-04-09 12:34:36 +00:00
|
|
|
configs -= v8_remove_configs
|
|
|
|
configs += v8_add_configs
|
2016-10-12 09:59:31 +00:00
|
|
|
if (defined(invoker.remove_configs)) {
|
|
|
|
configs -= invoker.remove_configs
|
|
|
|
}
|
2016-06-14 10:07:22 +00:00
|
|
|
configs += invoker.configs
|
2016-07-27 11:43:42 +00:00
|
|
|
if (is_linux) {
|
|
|
|
# For enabling ASLR.
|
|
|
|
ldflags = [ "-pie" ]
|
2016-07-15 14:53:57 +00:00
|
|
|
}
|
2017-06-27 11:49:13 +00:00
|
|
|
if (defined(testonly) && testonly && v8_code_coverage) {
|
2017-06-26 11:06:03 +00:00
|
|
|
# Only add code coverage cflags for non-test files for performance
|
|
|
|
# reasons.
|
2017-06-27 11:49:13 +00:00
|
|
|
if (is_clang) {
|
|
|
|
configs -= [ "//build/config/sanitizers:default_sanitizer_flags" ]
|
2017-08-09 08:11:21 +00:00
|
|
|
configs +=
|
|
|
|
[ "//build/config/sanitizers:default_sanitizer_flags_but_coverage" ]
|
2017-06-27 11:49:13 +00:00
|
|
|
} else {
|
|
|
|
configs -= [ v8_path_prefix + ":v8_gcov_coverage_cflags" ]
|
|
|
|
}
|
2017-06-26 11:06:03 +00:00
|
|
|
}
|
2017-08-09 08:11:21 +00:00
|
|
|
deps += [ v8_path_prefix + ":v8_dump_build_config" ]
|
2016-06-14 10:07:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template("v8_component") {
|
|
|
|
component(target_name) {
|
|
|
|
forward_variables_from(invoker, "*", [ "configs" ])
|
2016-07-20 09:16:27 +00:00
|
|
|
configs -= v8_remove_configs
|
|
|
|
configs += v8_add_configs
|
2019-04-09 12:34:36 +00:00
|
|
|
configs += invoker.configs
|
2016-06-14 10:07:22 +00:00
|
|
|
}
|
|
|
|
}
|
2017-11-27 09:36:01 +00:00
|
|
|
|
|
|
|
template("v8_static_library") {
|
|
|
|
static_library(target_name) {
|
|
|
|
complete_static_lib = true
|
|
|
|
forward_variables_from(invoker, "*", [ "configs" ])
|
|
|
|
configs -= v8_remove_configs
|
2018-03-21 00:18:34 +00:00
|
|
|
configs -= [ "//build/config/compiler:thin_archive" ]
|
2017-11-27 09:36:01 +00:00
|
|
|
configs += v8_add_configs
|
2019-04-09 12:34:36 +00:00
|
|
|
configs += invoker.configs
|
2017-11-27 09:36:01 +00:00
|
|
|
}
|
|
|
|
}
|