1{ 2 'variables': { 3 'configuring_node%': 0, 4 'asan%': 0, 5 'werror': '', # Turn off -Werror in V8 build. 6 'visibility%': 'hidden', # V8's visibility setting 7 'target_arch%': 'ia32', # set v8's target architecture 8 'host_arch%': 'ia32', # set v8's host architecture 9 'want_separate_host_toolset%': 0, # V8 should not build target and host 10 'library%': 'static_library', # allow override to 'shared_library' for DLL/.so builds 11 'component%': 'static_library', # NB. these names match with what V8 expects 12 'msvs_multi_core_compile': '0', # we do enable multicore compiles, but not using the V8 way 13 'enable_pgo_generate%': '0', 14 'enable_pgo_use%': '0', 15 'python%': 'python', 16 17 'node_shared%': 'false', 18 'force_dynamic_crt%': 0, 19 'node_use_v8_platform%': 'true', 20 'node_use_bundled_v8%': 'true', 21 'node_module_version%': '', 22 'node_with_ltcg%': '', 23 'node_shared_openssl%': 'false', 24 25 'node_tag%': '', 26 'uv_library%': 'static_library', 27 28 'clang%': 0, 29 'error_on_warn%': 'false', 30 31 'openssl_fips%': '', 32 'openssl_no_asm%': 0, 33 34 # Don't use ICU data file (icudtl.dat) from V8, we use our own. 35 'icu_use_data_file_flag%': 0, 36 37 # Reset this number to 0 on major V8 upgrades. 38 # Increment by one for each non-official patch applied to deps/v8. 39 'v8_embedder_string': '-node.88', 40 41 ##### V8 defaults for Node.js ##### 42 43 # Turn on SipHash for hash seed generation, addresses HashWick 44 'v8_use_siphash': 'true', 45 46 # These are more relevant for V8 internal development. 47 # Refs: https://github.com/nodejs/node/issues/23122 48 # Refs: https://github.com/nodejs/node/issues/23167 49 # Enable compiler warnings when using V8_DEPRECATED apis from V8 code. 50 'v8_deprecation_warnings': 0, 51 # Enable compiler warnings when using V8_DEPRECATE_SOON apis from V8 code. 52 'v8_imminent_deprecation_warnings': 0, 53 54 # Enable disassembler for `--print-code` v8 options 55 'v8_enable_disassembler': 1, 56 57 # Sets -dOBJECT_PRINT. 58 'v8_enable_object_print%': 1, 59 60 # https://github.com/nodejs/node/pull/22920/files#r222779926 61 'v8_enable_handle_zapping': 0, 62 63 # Disable pointer compression. Can be enabled at build time via configure 64 # options but default values are required here as this file is also used by 65 # node-gyp to build addons. 66 'v8_enable_pointer_compression%': 0, 67 'v8_enable_31bit_smis_on_64bit_arch%': 0, 68 69 # Disable V8 untrusted code mitigations. 70 # See https://github.com/v8/v8/wiki/Untrusted-code-mitigations 71 'v8_untrusted_code_mitigations': 0, 72 73 # This is more of a V8 dev setting 74 # https://github.com/nodejs/node/pull/22920/files#r222779926 75 'v8_enable_fast_mksnapshot': 0, 76 77 'v8_win64_unwinding_info': 1, 78 79 # TODO(refack): make v8-perfetto happen 80 'v8_use_perfetto': 0, 81 82 ##### end V8 defaults ##### 83 84 'conditions': [ 85 ['OS == "win"', { 86 'os_posix': 0, 87 'v8_postmortem_support%': 0, 88 'obj_dir': '<(PRODUCT_DIR)/obj', 89 'v8_base': '<(PRODUCT_DIR)/lib/libv8_snapshot.a', 90 }, { 91 'os_posix': 1, 92 'v8_postmortem_support%': 1, 93 }], 94 ['GENERATOR == "ninja"', { 95 'obj_dir': '<(PRODUCT_DIR)/obj', 96 'v8_base': '<(PRODUCT_DIR)/obj/tools/v8_gypfiles/libv8_snapshot.a', 97 }, { 98 'obj_dir%': '<(PRODUCT_DIR)/obj.target', 99 'v8_base': '<(PRODUCT_DIR)/obj.target/tools/v8_gypfiles/libv8_snapshot.a', 100 }], 101 ['openssl_fips != ""', { 102 'openssl_product': '<(STATIC_LIB_PREFIX)crypto<(STATIC_LIB_SUFFIX)', 103 }, { 104 'openssl_product': '<(STATIC_LIB_PREFIX)openssl<(STATIC_LIB_SUFFIX)', 105 }], 106 ['OS=="mac"', { 107 'clang%': 1, 108 'obj_dir%': '<(PRODUCT_DIR)/obj.target', 109 'v8_base': '<(PRODUCT_DIR)/libv8_snapshot.a', 110 }], 111 ['target_arch in "ppc64 s390x"', { 112 'v8_enable_backtrace': 1, 113 }], 114 ['OS=="linux"', { 115 'node_section_ordering_info%': '' 116 }] 117 ], 118 }, 119 120 'target_defaults': { 121 'default_configuration': 'Release', 122 'configurations': { 123 'Debug': { 124 'variables': { 125 'v8_enable_handle_zapping': 1, 126 'conditions': [ 127 ['node_shared != "true"', { 128 'MSVC_runtimeType': 1, # MultiThreadedDebug (/MTd) 129 }, { 130 'MSVC_runtimeType': 3, # MultiThreadedDebugDLL (/MDd) 131 }], 132 ], 133 }, 134 'defines': [ 'DEBUG', '_DEBUG', 'V8_ENABLE_CHECKS' ], 135 'cflags': [ '-g', '-O0' ], 136 'conditions': [ 137 ['OS=="aix"', { 138 'cflags': [ '-gxcoff' ], 139 'ldflags': [ '-Wl,-bbigtoc' ], 140 }], 141 ['OS == "android"', { 142 'cflags': [ '-fPIC' ], 143 'ldflags': [ '-fPIC' ] 144 }], 145 ], 146 'msvs_settings': { 147 'VCCLCompilerTool': { 148 'BasicRuntimeChecks': 3, # /RTC1 149 'MinimalRebuild': 'false', 150 'OmitFramePointers': 'false', 151 'Optimization': 0, # /Od, no optimization 152 'RuntimeLibrary': '<(MSVC_runtimeType)', 153 }, 154 'VCLinkerTool': { 155 'LinkIncremental': 2, # enable incremental linking 156 }, 157 }, 158 'xcode_settings': { 159 'GCC_OPTIMIZATION_LEVEL': '0', # stop gyp from defaulting to -Os 160 }, 161 }, 162 'Release': { 163 'variables': { 164 'v8_enable_handle_zapping': 0, 165 'pgo_generate': ' -fprofile-generate ', 166 'pgo_use': ' -fprofile-use -fprofile-correction ', 167 'conditions': [ 168 ['node_shared != "true"', { 169 'MSVC_runtimeType': 0 # MultiThreaded (/MT) 170 }, { 171 'MSVC_runtimeType': 2 # MultiThreadedDLL (/MD) 172 }], 173 ['llvm_version=="0.0"', { 174 'lto': ' -flto=4 -fuse-linker-plugin -ffat-lto-objects ', # GCC 175 }, { 176 'lto': ' -flto ', # Clang 177 }], 178 ], 179 }, 180 'cflags': [ '-O3' ], 181 'conditions': [ 182 ['enable_lto=="true"', { 183 'cflags': ['<(lto)'], 184 'ldflags': ['<(lto)'], 185 'xcode_settings': { 186 'LLVM_LTO': 'YES', 187 }, 188 }], 189 ['OS=="linux"', { 190 'conditions': [ 191 ['node_section_ordering_info!=""', { 192 'cflags': [ 193 '-fuse-ld=gold', 194 '-ffunction-sections', 195 ], 196 'ldflags': [ 197 '-fuse-ld=gold', 198 '-Wl,--section-ordering-file=<(node_section_ordering_info)', 199 ], 200 }], 201 ], 202 }], 203 ['OS=="solaris"', { 204 # pull in V8's postmortem metadata 205 'ldflags': [ '-Wl,-z,allextract' ] 206 }], 207 ['OS!="mac" and OS!="win"', { 208 'cflags': [ '-fno-omit-frame-pointer' ], 209 }], 210 ['OS=="linux"', { 211 'conditions': [ 212 ['enable_pgo_generate=="true"', { 213 'cflags': ['<(pgo_generate)'], 214 'ldflags': ['<(pgo_generate)'], 215 },], 216 ['enable_pgo_use=="true"', { 217 'cflags': ['<(pgo_use)'], 218 'ldflags': ['<(pgo_use)'], 219 },], 220 ], 221 },], 222 ['OS == "android"', { 223 'cflags': [ '-fPIC' ], 224 'ldflags': [ '-fPIC' ] 225 }], 226 ], 227 'msvs_settings': { 228 'VCCLCompilerTool': { 229 'conditions': [ 230 ['target_arch=="arm64"', { 231 'FloatingPointModel': 1 # /fp:strict 232 }] 233 ], 234 'EnableFunctionLevelLinking': 'true', 235 'EnableIntrinsicFunctions': 'true', 236 'FavorSizeOrSpeed': 1, # /Ot, favor speed over size 237 'InlineFunctionExpansion': 2, # /Ob2, inline anything eligible 238 'OmitFramePointers': 'true', 239 'Optimization': 3, # /Ox, full optimization 240 'RuntimeLibrary': '<(MSVC_runtimeType)', 241 'RuntimeTypeInfo': 'false', 242 } 243 }, 244 'xcode_settings': { 245 'GCC_OPTIMIZATION_LEVEL': '3', # stop gyp from defaulting to -Os 246 }, 247 } 248 }, 249 250 # Defines these mostly for node-gyp to pickup, and warn addon authors of 251 # imminent V8 deprecations, also to sync how dependencies are configured. 252 'defines': [ 253 'V8_DEPRECATION_WARNINGS', 254 'V8_IMMINENT_DEPRECATION_WARNINGS', 255 ], 256 257 # Forcibly disable -Werror. We support a wide range of compilers, it's 258 # simply not feasible to squelch all warnings, never mind that the 259 # libraries in deps/ are not under our control. 260 'conditions': [ 261 [ 'error_on_warn=="false"', { 262 'cflags!': ['-Werror'], 263 }, '(_target_name!="<(node_lib_target_name)" or ' 264 '_target_name!="<(node_core_target_name)")', { 265 'cflags!': ['-Werror'], 266 }], 267 ], 268 'msvs_settings': { 269 'VCCLCompilerTool': { 270 'BufferSecurityCheck': 'true', 271 'DebugInformationFormat': 1, # /Z7 embed info in .obj files 272 'ExceptionHandling': 0, # /EHsc 273 'MultiProcessorCompilation': 'true', 274 'StringPooling': 'true', # pool string literals 275 'SuppressStartupBanner': 'true', 276 'WarnAsError': 'false', 277 'WarningLevel': 3, # /W3 278 }, 279 'VCLinkerTool': { 280 'target_conditions': [ 281 ['_type=="executable"', { 282 'SubSystem': 1, # /SUBSYSTEM:CONSOLE 283 }], 284 ], 285 'conditions': [ 286 ['target_arch=="ia32"', { 287 'TargetMachine' : 1, # /MACHINE:X86 288 }], 289 ['target_arch=="x64"', { 290 'TargetMachine' : 17, # /MACHINE:X64 291 }], 292 ['target_arch=="arm64"', { 293 'TargetMachine' : 0, # NotSet. MACHINE:ARM64 is inferred from the input files. 294 }], 295 ], 296 'GenerateDebugInformation': 'true', 297 'SuppressStartupBanner': 'true', 298 }, 299 }, 300 # Disable warnings: 301 # - "C4251: class needs to have dll-interface" 302 # - "C4275: non-DLL-interface used as base for DLL-interface" 303 # Over 10k of these warnings are generated when compiling node, 304 # originating from v8.h. Most of them are false positives. 305 # See also: https://github.com/nodejs/node/pull/15570 306 # TODO: re-enable when Visual Studio fixes these upstream. 307 # 308 # - "C4267: conversion from 'size_t' to 'int'" 309 # Many any originate from our dependencies, and their sheer number 310 # drowns out other, more legitimate warnings. 311 # - "C4244: conversion from 'type1' to 'type2', possible loss of data" 312 # Ususaly safe. Disable for `dep`, enable for `src` 313 'msvs_disabled_warnings': [4351, 4355, 4800, 4251, 4275, 4244, 4267], 314 'msvs_cygwin_shell': 0, # prevent actions from trying to use cygwin 315 316 'conditions': [ 317 [ 'configuring_node', { 318 'msvs_configuration_attributes': { 319 'OutputDirectory': '<(DEPTH)/out/$(Configuration)/', 320 'IntermediateDirectory': '$(OutDir)obj/$(ProjectName)/' 321 }, 322 }], 323 [ 'target_arch=="x64"', { 324 'msvs_configuration_platform': 'x64', 325 }], 326 [ 'target_arch=="arm64"', { 327 'msvs_configuration_platform': 'arm64', 328 }], 329 ['asan == 1 and OS != "mac"', { 330 'cflags+': [ 331 '-fno-omit-frame-pointer', 332 '-fsanitize=address', 333 '-fsanitize-address-use-after-scope', 334 ], 335 'defines': [ 'LEAK_SANITIZER', 'V8_USE_ADDRESS_SANITIZER' ], 336 'cflags!': [ '-fomit-frame-pointer' ], 337 'ldflags': [ '-fsanitize=address' ], 338 }], 339 ['asan == 1 and OS == "mac"', { 340 'xcode_settings': { 341 'OTHER_CFLAGS+': [ 342 '-fno-omit-frame-pointer', 343 '-gline-tables-only', 344 '-fsanitize=address', 345 '-DLEAK_SANITIZER' 346 ], 347 'OTHER_CFLAGS!': [ 348 '-fomit-frame-pointer', 349 ], 350 }, 351 'target_conditions': [ 352 ['_type!="static_library"', { 353 'xcode_settings': {'OTHER_LDFLAGS': ['-fsanitize=address']}, 354 }], 355 ], 356 }], 357 ['v8_enable_pointer_compression == 1', { 358 'defines': ['V8_COMPRESS_POINTERS'], 359 }], 360 ['v8_enable_pointer_compression == 1 or v8_enable_31bit_smis_on_64bit_arch == 1', { 361 'defines': ['V8_31BIT_SMIS_ON_64BIT_ARCH'], 362 }], 363 ['OS == "win"', { 364 'defines': [ 365 'WIN32', 366 # we don't really want VC++ warning us about 367 # how dangerous C functions are... 368 '_CRT_SECURE_NO_DEPRECATE', 369 # ... or that C implementations shouldn't use 370 # POSIX names 371 '_CRT_NONSTDC_NO_DEPRECATE', 372 # Make sure the STL doesn't try to use exceptions 373 '_HAS_EXCEPTIONS=0', 374 'BUILDING_V8_SHARED=1', 375 'BUILDING_UV_SHARED=1', 376 ], 377 }], 378 [ 'OS in "linux freebsd openbsd solaris aix"', { 379 'cflags': [ '-pthread' ], 380 'ldflags': [ '-pthread' ], 381 }], 382 [ 'OS in "linux freebsd openbsd solaris android aix cloudabi"', { 383 'cflags': [ '-Wall', '-Wextra', '-Wno-unused-parameter', ], 384 'cflags_cc': [ '-fno-rtti', '-fno-exceptions', '-std=gnu++1y' ], 385 'defines': [ '__STDC_FORMAT_MACROS' ], 386 'ldflags': [ '-rdynamic' ], 387 'target_conditions': [ 388 # The 1990s toolchain on SmartOS can't handle thin archives. 389 ['_type=="static_library" and OS=="solaris"', { 390 'standalone_static_library': 1, 391 }], 392 ['OS=="openbsd"', { 393 'cflags': [ '-I/usr/local/include' ], 394 'ldflags': [ '-Wl,-z,wxneeded' ], 395 }], 396 ], 397 'conditions': [ 398 [ 'target_arch=="ia32"', { 399 'cflags': [ '-m32' ], 400 'ldflags': [ '-m32' ], 401 }], 402 [ 'target_arch=="x32"', { 403 'cflags': [ '-mx32' ], 404 'ldflags': [ '-mx32' ], 405 }], 406 [ 'target_arch=="x64"', { 407 'cflags': [ '-m64' ], 408 'ldflags': [ '-m64' ], 409 }], 410 [ 'target_arch=="ppc" and OS!="aix"', { 411 'cflags': [ '-m32' ], 412 'ldflags': [ '-m32' ], 413 }], 414 [ 'target_arch=="ppc64" and OS!="aix"', { 415 'cflags': [ '-m64', '-mminimal-toc' ], 416 'ldflags': [ '-m64' ], 417 }], 418 [ 'target_arch=="s390x"', { 419 'cflags': [ '-m64', '-march=z196' ], 420 'ldflags': [ '-m64', '-march=z196' ], 421 }], 422 [ 'OS=="solaris"', { 423 'cflags': [ '-pthreads' ], 424 'ldflags': [ '-pthreads' ], 425 'cflags!': [ '-pthread' ], 426 'ldflags!': [ '-pthread' ], 427 }], 428 [ 'node_shared=="true"', { 429 'cflags': [ '-fPIC' ], 430 }], 431 ], 432 }], 433 [ 'OS=="aix"', { 434 'variables': { 435 # Used to differentiate `AIX` and `OS400`(IBM i). 436 'aix_variant_name': '<!(uname -s)', 437 }, 438 'cflags': [ '-maix64', ], 439 'ldflags!': [ '-rdynamic', ], 440 'ldflags': [ 441 '-Wl,-bbigtoc', 442 '-maix64', 443 ], 444 'conditions': [ 445 [ '"<(aix_variant_name)"=="OS400"', { # a.k.a. `IBM i` 446 'ldflags': [ 447 '-Wl,-blibpath:/QOpenSys/pkgs/lib:/QOpenSys/usr/lib', 448 '-Wl,-brtl', 449 ], 450 }, { # else it's `AIX` 451 # Disable the following compiler warning: 452 # 453 # warning: visibility attribute not supported in this 454 # configuration; ignored [-Wattributes] 455 # 456 # This is gcc complaining about __attribute((visibility("default")) 457 # in static library builds. Legitimate but harmless and it drowns 458 # out more relevant warnings. 459 'cflags': [ '-Wno-attributes' ], 460 'ldflags': [ 461 '-Wl,-blibpath:/usr/lib:/lib:/opt/freeware/lib/pthread/ppc64', 462 ], 463 }], 464 ], 465 }], 466 ['OS=="android"', { 467 'target_conditions': [ 468 ['_toolset=="target"', { 469 'defines': [ '_GLIBCXX_USE_C99_MATH' ], 470 'libraries': [ '-llog' ], 471 }], 472 ['_toolset=="host"', { 473 'cflags': [ '-pthread' ], 474 'ldflags': [ '-pthread' ], 475 }], 476 ], 477 }], 478 ['OS=="mac"', { 479 'defines': ['_DARWIN_USE_64_BIT_INODE=1'], 480 'xcode_settings': { 481 'ALWAYS_SEARCH_USER_PATHS': 'NO', 482 'GCC_CW_ASM_SYNTAX': 'NO', # No -fasm-blocks 483 'GCC_DYNAMIC_NO_PIC': 'NO', # No -mdynamic-no-pic 484 # (Equivalent to -fPIC) 485 'GCC_ENABLE_CPP_EXCEPTIONS': 'NO', # -fno-exceptions 486 'GCC_ENABLE_CPP_RTTI': 'NO', # -fno-rtti 487 'GCC_ENABLE_PASCAL_STRINGS': 'NO', # No -mpascal-strings 488 'PREBINDING': 'NO', # No -Wl,-prebind 489 'MACOSX_DEPLOYMENT_TARGET': '10.13', # -mmacosx-version-min=10.13 490 'USE_HEADERMAP': 'NO', 491 'OTHER_CFLAGS': [ 492 '-fno-strict-aliasing', 493 ], 494 'WARNING_CFLAGS': [ 495 '-Wall', 496 '-Wendif-labels', 497 '-W', 498 '-Wno-unused-parameter', 499 ], 500 }, 501 'target_conditions': [ 502 ['_type!="static_library"', { 503 'xcode_settings': { 504 'OTHER_LDFLAGS': [ 505 '-Wl,-no_pie', 506 '-Wl,-search_paths_first', 507 ], 508 }, 509 }], 510 ], 511 'conditions': [ 512 ['target_arch=="ia32"', { 513 'xcode_settings': {'ARCHS': ['i386']}, 514 }], 515 ['target_arch=="x64"', { 516 'xcode_settings': {'ARCHS': ['x86_64']}, 517 }], 518 ['target_arch=="arm64"', { 519 'xcode_settings': { 520 'ARCHS': ['arm64'], 521 'OTHER_LDFLAGS!': [ 522 '-Wl,-no_pie', 523 ], 524 }, 525 }], 526 ['clang==1', { 527 'xcode_settings': { 528 'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0', 529 'CLANG_CXX_LANGUAGE_STANDARD': 'gnu++1y', # -std=gnu++1y 530 'CLANG_CXX_LIBRARY': 'libc++', 531 }, 532 }], 533 ], 534 }], 535 ['OS=="freebsd" and node_use_dtrace=="true"', { 536 'libraries': [ '-lelf' ], 537 }], 538 ['OS=="freebsd"', { 539 'ldflags': [ 540 '-Wl,--export-dynamic', 541 ], 542 }], 543 # if node is built as an executable, 544 # the openssl mechanism for keeping itself "dload"-ed to ensure proper 545 # atexit cleanup does not apply 546 ['node_shared_openssl!="true" and node_shared!="true"', { 547 'defines': [ 548 # `OPENSSL_NO_PINSHARED` prevents openssl from dload 549 # current node executable, 550 # see https://github.com/nodejs/node/pull/21848 551 # or https://github.com/nodejs/node/issues/27925 552 'OPENSSL_NO_PINSHARED' 553 ], 554 }], 555 ['node_shared_openssl!="true"', { 556 # `OPENSSL_THREADS` is defined via GYP for openSSL for all architectures. 557 'defines': [ 558 'OPENSSL_THREADS', 559 ], 560 }], 561 ['node_shared_openssl!="true" and openssl_no_asm==1', { 562 'defines': [ 563 'OPENSSL_NO_ASM', 564 ], 565 }], 566 ], 567 } 568} 569