File: v8.gni

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (477 lines) | stat: -rw-r--r-- 15,951 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
# 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.

import("//build/config/chrome_build.gni")
import("//build/config/compiler/pgo/pgo.gni")
import("//build/config/gclient_args.gni")
import("//build/config/ios/config.gni")
import("//build/config/ios/ios_sdk_overrides.gni")
import("//build/config/sanitizers/sanitizers.gni")
import("//build/config/v8_target_cpu.gni")
import("//build_overrides/build.gni")
import("release_branch_toggle.gni")
import("split_static_library.gni")

if (is_ios) {
  import("//build/config/apple/mobile_config.gni")  # For `target_platform`.
}

declare_args() {
  # Includes files needed for correctness fuzzing.
  v8_correctness_fuzzer = false

  # Adds additional compile target for building multiple architectures at once.
  v8_multi_arch_build = false

  # Indicate if valgrind was fetched as a custom deps to make it available on
  # swarming.
  v8_has_valgrind = false

  # Indicate if gcmole was fetched as a hook to make it available on swarming.
  v8_gcmole = false

  # Turns on compiler optimizations in V8 in Debug build.
  v8_optimized_debug = true

  # Support for backtrace_symbols on linux.
  v8_enable_backtrace = ""

  # Use external files for startup data blobs:
  # the JS builtins sources and the start snapshot.
  v8_use_external_startup_data = ""

  # Includes profiles to optimize builtins.
  v8_enable_builtins_optimization = ""

  # Turns on all V8 debug features. Enables running V8 in a pseudo debug mode
  # within a release Chrome.
  v8_enable_debugging_features = is_debug

  # Enable ECMAScript Internationalization API. Enabling this feature will
  # add a dependency on the ICU library.
  v8_enable_i18n_support = true

  # Enable Temporal API. Enabling this feature will
  # add a dependency on the temporal_rs library.
  #
  # We currently only want it enabled on d8 and chromium builds (Functionality
  # is still not accessible unless --harmony-temporal is enabled at runtime)
  #
  # Furthermore, some architectures don't have Rust toolchains in Chromium
  v8_enable_temporal_support = !(defined(build_with_node) && build_with_node) &&
                               target_cpu != "ppc64" && target_cpu != "s390x"

  # Use static libraries instead of source_sets.
  v8_static_library = false

  # Enable monolithic static library for embedders.
  v8_monolithic = false

  # Expose public symbols for native modules of Node.js and Electron. Default
  # is false.
  v8_expose_public_symbols = ""

  # Deprecated for v8_expose_public_symbols.
  v8_expose_symbols = false

  # Implement tracing using Perfetto (https://perfetto.dev).
  v8_use_perfetto = false

  # Override global symbol level setting for v8.
  v8_symbol_level = symbol_level

  # Enable WebAssembly debugging via GDB-remote protocol.
  v8_enable_wasm_gdb_remote_debugging = false

  # Lite mode disables a number of performance optimizations to reduce memory
  # at the cost of performance.
  # Sets -DV8_LITE_MODE.
  v8_enable_lite_mode = false

  # We use target_os == "ios" here because it isn't equivalent to is_ios
  # (is_ios is based on host_os).
  if (target_os == "ios") {
    if (target_platform == "iphoneos") {
      # iOS executable code pages is in 18.4 SDK.
      # TODO(dtapuska): Change this to an assert.
      v8_enable_lite_mode = ios_deployment_target != "18.4"
    } else if (target_platform == "tvos") {
      # tvOS runs in single process mode and is not allowed to use JIT.
      # TODO(crbug.com/394710095): Enable the v8 lite mode to run v8 with the
      # jitless mode on tvOS.
      v8_enable_lite_mode = true
    }
  }

  # Enable the Turbofan compiler.
  # Sets -dV8_ENABLE_TURBOFAN.
  v8_enable_turbofan = ""

  # Enable the Maglev compiler.
  # Sets -dV8_ENABLE_MAGLEV
  v8_enable_maglev = ""

  # Include support for WebAssembly. If disabled, the 'WebAssembly' global
  # will not be available, and embedder APIs to generate WebAssembly modules
  # will fail. Also, asm.js will not be translated to WebAssembly and will be
  # executed as standard JavaScript instead.
  # Sets -dV8_ENABLE_WEBASSEMBLY.
  v8_enable_webassembly = ""

  # Enable 256-bit long vector re-vectorization pass in WASM compilation pipeline.
  v8_enable_wasm_simd256_revec = false

  # Enable runtime call stats.
  v8_enable_runtime_call_stats = !v8_is_on_release_branch

  # Add fuzzilli fuzzer support.
  v8_fuzzilli = false

  # Enable FuzzTest
  v8_enable_fuzztest = !build_with_v8_embedder &&
                       !(defined(build_with_node) && build_with_node) &&
                       !(is_win && is_component_build) && is_clang

  # Use direct pointers in handles (v8::internal::Handle and v8::Local).
  v8_enable_direct_handle = false

  # Check for off-stack allocated local handles.
  v8_enable_local_off_stack_check = false

  v8_enable_google_benchmark = false

  cppgc_is_standalone = false

  # Enables certain checks on API level functionality.
  cppgc_enable_api_checks = is_debug || dcheck_always_on

  # Enable slow checks on API level functionality.
  cppgc_enable_slow_api_checks = false

  # Enable object names in cppgc for profiling purposes.
  cppgc_enable_object_names = is_chrome_for_testing

  # Enable young generation in cppgc.
  cppgc_enable_young_generation = false

  # Enables a slim write barrier that only performs a single check in the fast
  # path and delegates all further checks to a slow path call. This is fast
  # in a setting with few slow-path checks, i.e., with disabled young generation
  # GC.
  cppgc_enable_slim_write_barrier = true

  # Enable pointer compression in cppgc.
  cppgc_enable_pointer_compression = false

  # Enable support for larger cages, up to 16GB.
  # iOS cannot mmap above 8GB, so use the smaller cage.
  cppgc_enable_larger_cage = !is_ios

  # Enable advanced BigInt algorithms, costing about 10-30 KB binary size
  # depending on platform. Disabled on Android to save binary size.
  v8_advanced_bigint_algorithms = !is_android

  # TODO: macros for determining endian type are clang specific.
  v8_use_libm_trig_functions = is_clang

  # Location of icu.
  v8_icu_path = "//third_party/icu"

  # Location of zlib.
  v8_zlib_path = "//third_party/zlib"

  # Enable pointer compression (sets -dV8_COMPRESS_POINTERS).
  v8_enable_pointer_compression = ""
  v8_enable_pointer_compression_shared_cage = ""
  v8_enable_31bit_smis_on_64bit_arch = false

  # Change code emission and runtime features to be CET shadow-stack compliant
  # (incomplete and experimental).
  v8_enable_cet_shadow_stack = false

  # Emit CET IBT landing pad instructions in JIT generated code (experimental).
  v8_enable_cet_ibt = false

  # Use memory sealing to protect various global memory mappings for CFI
  # (experimental).
  # TODO(sroettger): enable by default once we have bot support for testing.
  v8_enable_memory_sealing = false

  # Sets -DV8_ENABLE_ETW_STACK_WALKING. Enables ETW Stack Walking
  v8_enable_etw_stack_walking = is_win

  # Specifies if the target build is a simulator build. By default it is set to
  # true if the host and target do not match and we are not cross-compiling.
  v8_target_is_simulator = ""
}

if (v8_use_external_startup_data == "") {
  # If not specified as a gn arg, use external startup data by default if
  # we're not on ios.
  v8_use_external_startup_data = !is_ios
}

if (v8_enable_backtrace == "") {
  v8_enable_backtrace = is_debug && !v8_optimized_debug
}

# Chromium is configured to use the perfetto client library, v8 should also
# use perfetto for tracing.
if (build_with_chromium) {
  v8_use_perfetto = true
}

# Includes profiles to optimize builtins if
#   * it is a Chromium build, and
#   * Chromium builds with optimization.
# If no profiles are downloaded during gclient runhooks, optimization fails
# silently.
if (v8_enable_builtins_optimization == "") {
  v8_enable_builtins_optimization = build_with_chromium && chrome_pgo_phase == 2
}

# TODO(jgruber): Move v8_jitless from BUILD.gn here as these
# all depend on each other and really should be derived from
# v8_jitless.
# WebAssembly is enabled by default, except in lite mode.
if (v8_enable_webassembly == "") {
  v8_enable_webassembly = !v8_enable_lite_mode
}
assert(!(v8_enable_webassembly && v8_enable_lite_mode),
       "Webassembly is not available in lite mode.")

if (v8_enable_pointer_compression == "") {
  v8_enable_pointer_compression =
      v8_current_cpu == "arm64" || v8_current_cpu == "x64" ||
      v8_current_cpu == "loong64" || v8_current_cpu == "ppc64"
}

# The Wasm interpreter is currently supported only on arm64 and x64, on
# Windows, Linux and MacOS.
is_drumbrake_supported =
    v8_enable_webassembly && v8_enable_pointer_compression &&
    (v8_current_cpu == "x64" || v8_current_cpu == "arm64") &&
    (target_os == "win" || target_os == "linux" || target_os == "mac")

# Turbofan is enabled by default, except in lite mode.
if (v8_enable_turbofan == "") {
  v8_enable_turbofan = !v8_enable_lite_mode
}
assert(v8_enable_turbofan || !v8_enable_webassembly,
       "Webassembly is not available when Turbofan is disabled.")

if (v8_target_is_simulator == "") {
  # We compare target cpu with v8 target cpu to not affect simulator builds for
  # making cross-compile snapshots.
  v8_target_is_simulator =
      (target_cpu != v8_target_cpu && !v8_multi_arch_build) ||
      (current_cpu != v8_current_cpu && v8_multi_arch_build)
}

# 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.
v8_path_prefix = get_path_info("../", "abspath")

v8_inspector_js_protocol = v8_path_prefix + "/include/js_protocol.pdl"

###############################################################################
# Templates
#

# Common configs to remove or add in all v8 targets.
v8_remove_configs = []
v8_add_configs = [
  v8_path_prefix + ":features",
  v8_path_prefix + ":toolchain",
  v8_path_prefix + ":strict_warnings",
]

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_win) && !using_sanitizer) {
    v8_add_configs += [ "//build/config/compiler:optimize_speed" ]
  } else {
    v8_add_configs += [ "//build/config/compiler:optimize_max" ]
  }
}

if (!is_debug &&
    # TODO(crbug.com/417956700): Remove this after clang roll.
    !use_libcxx_modules) {
  v8_remove_configs += [
    # Too much performance impact, unclear security benefit.
    "//build/config/compiler:default_init_stack_vars",
  ]
}

if (v8_symbol_level != symbol_level) {
  v8_remove_configs += [ "//build/config/compiler:default_symbols" ]
  if (v8_symbol_level == 0) {
    v8_add_configs += [ "//build/config/compiler:no_symbols" ]
  } else if (v8_symbol_level == 1) {
    v8_add_configs += [ "//build/config/compiler:minimal_symbols" ]
  } else if (v8_symbol_level == 2) {
    v8_add_configs += [ "//build/config/compiler:symbols" ]
  } else {
    assert(false)
  }
}

if ((is_posix || is_fuchsia) && (v8_enable_backtrace || v8_monolithic)) {
  v8_remove_configs += [ "//build/config/gcc:symbol_visibility_hidden" ]
  v8_add_configs += [ "//build/config/gcc:symbol_visibility_default" ]
}

# On MIPS gcc_target_rpath and ldso_path might be needed for all builds.
if (target_cpu == "mips64el" || target_cpu == "mips64") {
  v8_add_configs += [ "//build/config/gcc:rpath_for_built_shared_libraries" ]
}

if (!build_with_chromium && is_clang) {
  v8_remove_configs += [ "//build/config/clang:find_bad_constructs" ]
}

# All templates should be kept in sync.
template("v8_source_set") {
  if (defined(invoker.split_count) && invoker.split_count > 1 &&
      defined(v8_static_library) && v8_static_library && is_win) {
    link_target_type = "split_static_library"
  } else if (defined(v8_static_library) && v8_static_library) {
    link_target_type = "static_library"
  } else {
    link_target_type = "source_set"
  }
  target(link_target_type, target_name) {
    forward_variables_from(invoker,
                           "*",
                           [
                             "configs",
                             "remove_configs",
                           ])
    configs -= v8_remove_configs
    configs += v8_add_configs
    if (defined(invoker.remove_configs)) {
      configs -= invoker.remove_configs
    }
    configs += invoker.configs
  }
}

template("v8_header_set") {
  source_set(target_name) {
    forward_variables_from(invoker, "*", [ "configs" ])
    configs -= v8_remove_configs
    configs += v8_add_configs
    configs += invoker.configs
  }
}

template("v8_executable") {
  if (is_ios) {
    import("//build/config/ios/rules.gni")

    ios_app_bundle(target_name) {
      forward_variables_from(invoker,
                             "*",
                             [
                               "configs",
                               "remove_configs",
                             ])
      configs -= v8_remove_configs
      configs += v8_add_configs
      if (defined(invoker.remove_configs)) {
        configs -= invoker.remove_configs
      }
      configs += invoker.configs
      deps += [ v8_path_prefix + ":v8_dump_build_config" ]

      # Provide sensible defaults in case invoker did not define any of those
      # required variables.
      if (!defined(info_plist) && !defined(info_plist_target)) {
        info_plist = v8_path_prefix + "/gni/Info.plist"
      }

      bundle_identifier = "$ios_app_bundle_id_prefix.chrome.unittests.dev"
    }
  } else {
    executable(target_name) {
      forward_variables_from(invoker,
                             "*",
                             [
                               "configs",
                               "remove_configs",
                             ])
      configs -= v8_remove_configs
      configs += v8_add_configs
      if (defined(invoker.remove_configs)) {
        configs -= invoker.remove_configs
      }
      configs += invoker.configs
      if (is_linux || is_chromeos) {
        # For enabling ASLR.
        ldflags = [ "-pie" ]
      }
      deps += [ v8_path_prefix + ":v8_dump_build_config" ]

      if (is_win && !v8_enable_cet_shadow_stack) {
        configs -= [ "//build/config/compiler:cet_shadow_stack" ]
      }
    }
  }
}

template("v8_component") {
  component(target_name) {
    output_name = target_name
    forward_variables_from(invoker,
                           "*",
                           [
                             "configs",
                             "remove_configs",
                           ])
    configs -= v8_remove_configs
    configs += v8_add_configs
    if (defined(invoker.remove_configs)) {
      configs -= invoker.remove_configs
    }
    configs += invoker.configs
  }
}

template("v8_shared_library") {
  shared_library(target_name) {
    forward_variables_from(invoker,
                           "*",
                           [
                             "configs",
                             "remove_configs",
                           ])
    configs -= v8_remove_configs
    configs += v8_add_configs
    if (defined(invoker.remove_configs)) {
      configs -= invoker.remove_configs
    }
    if (defined(invoker.configs)) {
      configs += invoker.configs
    }
  }
}

template("v8_static_library") {
  static_library(target_name) {
    complete_static_lib = true
    forward_variables_from(invoker, "*", [ "configs" ])
    configs -= v8_remove_configs
    configs -= [ "//build/config/compiler:thin_archive" ]
    configs += v8_add_configs
    configs += invoker.configs
  }
}