common.gypi 15.9 KB
Newer Older
1 2
{
  'variables': {
3
    'asan%': 0,
4 5 6 7 8 9 10 11
    'werror': '',                     # Turn off -Werror in V8 build.
    'visibility%': 'hidden',          # V8's visibility setting
    'target_arch%': 'ia32',           # set v8's target architecture
    'host_arch%': 'ia32',             # set v8's host architecture
    'want_separate_host_toolset%': 0, # V8 should not build target and host
    'library%': 'static_library',     # allow override to 'shared_library' for DLL/.so builds
    'component%': 'static_library',   # NB. these names match with what V8 expects
    'msvs_multi_core_compile': '0',   # we do enable multicore compiles, but not using the V8 way
12
    'python%': 'python',
13

14 15 16 17 18 19
    'node_shared%': 'false',
    'force_dynamic_crt%': 0,
    'node_use_v8_platform%': 'true',
    'node_use_bundled_v8%': 'true',
    'node_module_version%': '',

20 21 22
    'node_tag%': '',
    'uv_library%': 'static_library',

23 24
    'openssl_fips%': '',

25 26 27
    # Default to -O0 for debug builds.
    'v8_optimized_debug%': 0,

28 29 30 31
    # Reset this number to 0 on major V8 upgrades.
    # Increment by one for each non-official patch applied to deps/v8.
    'v8_embedder_string': '-node.5',

32 33 34 35 36
    # Enable disassembler for `--print-code` v8 options
    'v8_enable_disassembler': 1,

    # Don't bake anything extra into the snapshot.
    'v8_use_external_startup_data%': 0,
37

38 39 40 41
    # Disable V8 untrusted code mitigations.
    # See https://github.com/v8/v8/wiki/Untrusted-code-mitigations
    'v8_untrusted_code_mitigations': 'false',

42 43 44 45
    # Some STL containers (e.g. std::vector) do not preserve ABI compatibility
    # between debug and non-debug mode.
    'disable_glibcxx_debug': 1,

46 47 48
    # Don't use ICU data file (icudtl.dat) from V8, we use our own.
    'icu_use_data_file_flag%': 0,

49
    'conditions': [
50
      ['GENERATOR=="ninja"', {
51 52 53 54 55 56 57 58
        'obj_dir': '<(PRODUCT_DIR)/obj',
        'conditions': [
          [ 'build_v8_with_gn=="true"', {
            'v8_base': '<(PRODUCT_DIR)/obj/deps/v8/gypfiles/v8_monolith.gen/gn/obj/libv8_monolith.a',
          }, {
            'v8_base': '<(PRODUCT_DIR)/obj/deps/v8/gypfiles/libv8_base.a',
          }],
        ]
59
       }, {
60 61
        'obj_dir%': '<(PRODUCT_DIR)/obj.target',
        'v8_base': '<(PRODUCT_DIR)/obj.target/deps/v8/gypfiles/libv8_base.a',
62
      }],
63 64 65
      ['OS == "win"', {
        'os_posix': 0,
        'v8_postmortem_support%': 'false',
66 67
        'obj_dir': '<(PRODUCT_DIR)/obj',
        'v8_base': '<(PRODUCT_DIR)/lib/v8_libbase.lib',
68 69 70
      }, {
        'os_posix': 1,
        'v8_postmortem_support%': 'true',
71
      }],
72 73 74 75 76 77 78 79 80 81 82 83
      ['OS == "mac"', {
        'obj_dir%': '<(PRODUCT_DIR)/obj.target',
        'v8_base': '<(PRODUCT_DIR)/libv8_base.a',
      }],
      ['build_v8_with_gn == "true"', {
        'conditions': [
          ['GENERATOR == "ninja"', {
            'v8_base': '<(PRODUCT_DIR)/obj/deps/v8/gypfiles/v8_monolith.gen/gn/obj/libv8_monolith.a',
          }, {
            'v8_base': '<(PRODUCT_DIR)/obji.target/v8_monolith/geni/gn/obj/libv8_monolith.a',
          }],
        ],
84
      }],
85
      ['openssl_fips != ""', {
86
        'openssl_product': '<(STATIC_LIB_PREFIX)crypto<(STATIC_LIB_SUFFIX)',
87
      }, {
88
        'openssl_product': '<(STATIC_LIB_PREFIX)openssl<(STATIC_LIB_SUFFIX)',
89 90 91 92 93 94
      }],
      ['OS=="mac"', {
        'clang%': 1,
      }, {
        'clang%': 0,
      }],
95
    ],
96 97 98
  },

  'target_defaults': {
99
    'default_configuration': 'Release',
100 101
    'configurations': {
      'Debug': {
102 103 104
        'variables': {
          'v8_enable_handle_zapping': 1,
        },
105
        'defines': [ 'DEBUG', '_DEBUG', 'V8_ENABLE_CHECKS' ],
106
        'cflags': [ '-g', '-O0' ],
107 108 109 110
        'conditions': [
          ['target_arch=="x64"', {
            'msvs_configuration_platform': 'x64',
          }],
111
          ['OS=="aix"', {
112
            'variables': {'real_os_name': '<!(uname -s)',},
113 114
            'cflags': [ '-gxcoff' ],
            'ldflags': [ '-Wl,-bbigtoc' ],
115 116 117 118 119 120 121 122
            'conditions': [
              ['"<(real_os_name)"=="OS400"', {
                'ldflags': [
                  '-Wl,-blibpath:/QOpenSys/pkgs/lib:/QOpenSys/usr/lib',
                  '-Wl,-brtl',
                ],
              }],
            ],
123
          }],
124 125 126
          ['OS == "android"', {
            'cflags': [ '-fPIE' ],
            'ldflags': [ '-fPIE', '-pie' ]
127 128 129 130 131 132 133 134 135 136 137 138 139 140
          }],
          ['node_shared=="true"', {
            'msvs_settings': {
             'VCCLCompilerTool': {
               'RuntimeLibrary': 3, # MultiThreadedDebugDLL (/MDd)
             }
            }
          }],
          ['node_shared=="false"', {
            'msvs_settings': {
              'VCCLCompilerTool': {
                'RuntimeLibrary': 1 # MultiThreadedDebug (/MTd)
              }
            }
141
          }]
142
        ],
143 144 145
        'msvs_settings': {
          'VCCLCompilerTool': {
            'Optimization': 0, # /Od, no optimization
146
            'MinimalRebuild': 'false',
147 148
            'OmitFramePointers': 'false',
            'BasicRuntimeChecks': 3, # /RTC1
149 150 151 152
            'AdditionalOptions': [
              '/bigobj', # prevent error C1128 in VS2015
              '/MP', # compile across multiple CPUs
            ],
153 154 155 156 157
          },
          'VCLinkerTool': {
            'LinkIncremental': 2, # enable incremental linking
          },
        },
158 159 160
        'xcode_settings': {
          'GCC_OPTIMIZATION_LEVEL': '0', # stop gyp from defaulting to -Os
        },
161 162
      },
      'Release': {
163 164 165
        'variables': {
          'v8_enable_handle_zapping': 0,
        },
166
        'cflags': [ '-O3' ],
167 168 169 170
        'conditions': [
          ['target_arch=="x64"', {
            'msvs_configuration_platform': 'x64',
          }],
171 172 173 174
          ['OS=="solaris"', {
            # pull in V8's postmortem metadata
            'ldflags': [ '-Wl,-z,allextract' ]
          }],
175 176 177
          ['OS!="mac" and OS!="win"', {
            'cflags': [ '-fno-omit-frame-pointer' ],
          }],
178 179 180
          ['OS == "android"', {
            'cflags': [ '-fPIE' ],
            'ldflags': [ '-fPIE', '-pie' ]
181 182 183 184 185 186 187 188 189 190 191 192 193 194
          }],
          ['node_shared=="true"', {
            'msvs_settings': {
             'VCCLCompilerTool': {
               'RuntimeLibrary': 2 # MultiThreadedDLL (/MD)
             }
            }
          }],
          ['node_shared=="false"', {
            'msvs_settings': {
              'VCCLCompilerTool': {
                'RuntimeLibrary': 0 # MultiThreaded (/MT)
              }
            }
195
          }]
196 197 198
        ],
        'msvs_settings': {
          'VCCLCompilerTool': {
199
            'Optimization': 3, # /Ox, full optimization
200
            'FavorSizeOrSpeed': 1, # /Ot, favor speed over size
201 202 203 204 205
            'InlineFunctionExpansion': 2, # /Ob2, inline anything eligible
            'WholeProgramOptimization': 'true', # /GL, whole program optimization, needed for LTCG
            'OmitFramePointers': 'true',
            'EnableFunctionLevelLinking': 'true',
            'EnableIntrinsicFunctions': 'true',
206
            'RuntimeTypeInfo': 'false',
207 208 209 210 211 212 213 214 215 216 217 218 219
            'AdditionalOptions': [
              '/MP', # compile across multiple CPUs
            ],
          },
          'VCLibrarianTool': {
            'AdditionalOptions': [
              '/LTCG', # link time code generation
            ],
          },
          'VCLinkerTool': {
            'OptimizeReferences': 2, # /OPT:REF
            'EnableCOMDATFolding': 2, # /OPT:ICF
            'LinkIncremental': 1, # disable incremental linking
220 221 222
            'AdditionalOptions': [
              '/LTCG:INCREMENTAL', # incremental link-time code generation
            ],
223 224 225 226
          },
        },
      }
    },
227 228 229 230
    # Forcibly disable -Werror.  We support a wide range of compilers, it's
    # simply not feasible to squelch all warnings, never mind that the
    # libraries in deps/ are not under our control.
    'cflags!': ['-Werror'],
231 232 233 234 235 236
    'msvs_settings': {
      'VCCLCompilerTool': {
        'StringPooling': 'true', # pool string literals
        'DebugInformationFormat': 3, # Generate a PDB
        'WarningLevel': 3,
        'BufferSecurityCheck': 'true',
237
        'ExceptionHandling': 0, # /EHsc
238
        'SuppressStartupBanner': 'true',
239 240 241 242
        # Disable "warning C4267: conversion from 'size_t' to 'int',
        # possible loss of data".  Many originate from our dependencies
        # and their sheer number drowns out other, more legitimate warnings.
        'DisableSpecificWarnings': ['4267'],
243 244 245
        'WarnAsError': 'false',
      },
      'VCLinkerTool': {
246
        'conditions': [
247 248 249 250 251 252 253 254
          ['target_arch=="ia32"', {
            'TargetMachine' : 1, # /MACHINE:X86
            'target_conditions': [
              ['_type=="executable"', {
                'AdditionalOptions': [ '/SubSystem:Console,"5.01"' ],
              }],
            ],
          }],
255
          ['target_arch=="x64"', {
256 257 258 259 260 261
            'TargetMachine' : 17, # /MACHINE:AMD64
            'target_conditions': [
              ['_type=="executable"', {
                'AdditionalOptions': [ '/SubSystem:Console,"5.02"' ],
              }],
            ],
262 263
          }],
        ],
264
        'GenerateDebugInformation': 'true',
265 266
        'GenerateMapFile': 'true', # /MAP
        'MapExports': 'true', # /MAPINFO:EXPORTS
267 268 269 270 271 272
        'RandomizedBaseAddress': 2, # enable ASLR
        'DataExecutionPrevention': 2, # enable DEP
        'AllowIsolation': 'true',
        'SuppressStartupBanner': 'true',
      },
    },
273
    'msvs_disabled_warnings': [4351, 4355, 4800],
274
    'conditions': [
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
      ['asan == 1 and OS != "mac"', {
        'cflags+': [
          '-fno-omit-frame-pointer',
          '-fsanitize=address',
          '-DLEAK_SANITIZER'
        ],
        'cflags!': [ '-fomit-frame-pointer' ],
        'ldflags': [ '-fsanitize=address' ],
      }],
      ['asan == 1 and OS == "mac"', {
        'xcode_settings': {
          'OTHER_CFLAGS+': [
            '-fno-omit-frame-pointer',
            '-gline-tables-only',
            '-fsanitize=address',
            '-DLEAK_SANITIZER'
          ],
          'OTHER_CFLAGS!': [
            '-fomit-frame-pointer',
          ],
        },
        'target_conditions': [
          ['_type!="static_library"', {
            'xcode_settings': {'OTHER_LDFLAGS': ['-fsanitize=address']},
          }],
        ],
      }],
302 303 304 305 306 307 308 309 310 311
      ['OS == "win"', {
        'msvs_cygwin_shell': 0, # prevent actions from trying to use cygwin
        'defines': [
          'WIN32',
          # we don't really want VC++ warning us about
          # how dangerous C functions are...
          '_CRT_SECURE_NO_DEPRECATE',
          # ... or that C implementations shouldn't use
          # POSIX names
          '_CRT_NONSTDC_NO_DEPRECATE',
312 313
          # Make sure the STL doesn't try to use exceptions
          '_HAS_EXCEPTIONS=0',
314 315
          'BUILDING_V8_SHARED=1',
          'BUILDING_UV_SHARED=1',
316 317
        ],
      }],
318
      [ 'OS in "linux freebsd openbsd solaris aix"', {
319
        'cflags': [ '-pthread' ],
320 321
        'ldflags': [ '-pthread' ],
      }],
322
      [ 'OS in "linux freebsd openbsd solaris android aix cloudabi"', {
323
        'cflags': [ '-Wall', '-Wextra', '-Wno-unused-parameter', ],
324
        'cflags_cc': [ '-fno-rtti', '-fno-exceptions', '-std=gnu++1y' ],
325
        'ldflags': [ '-rdynamic' ],
326
        'target_conditions': [
327 328 329
          # The 1990s toolchain on SmartOS can't handle thin archives.
          ['_type=="static_library" and OS=="solaris"', {
            'standalone_static_library': 1,
330
          }],
331
          ['OS=="openbsd"', {
332
            'cflags': [ '-I/usr/local/include' ],
333 334
            'ldflags': [ '-Wl,-z,wxneeded' ],
          }],
335
        ],
336 337 338 339 340
        'conditions': [
          [ 'target_arch=="ia32"', {
            'cflags': [ '-m32' ],
            'ldflags': [ '-m32' ],
          }],
341 342 343 344
          [ 'target_arch=="x32"', {
            'cflags': [ '-mx32' ],
            'ldflags': [ '-mx32' ],
          }],
345 346 347
          [ 'target_arch=="x64"', {
            'cflags': [ '-m64' ],
            'ldflags': [ '-m64' ],
348
          }],
349
          [ 'target_arch=="ppc" and OS!="aix"', {
350 351 352
            'cflags': [ '-m32' ],
            'ldflags': [ '-m32' ],
          }],
353
          [ 'target_arch=="ppc64" and OS!="aix"', {
354 355 356
	    'cflags': [ '-m64', '-mminimal-toc' ],
	    'ldflags': [ '-m64' ],
	   }],
357
          [ 'target_arch=="s390"', {
358 359
            'cflags': [ '-m31', '-march=z196' ],
            'ldflags': [ '-m31', '-march=z196' ],
360 361
          }],
          [ 'target_arch=="s390x"', {
362 363
            'cflags': [ '-m64', '-march=z196' ],
            'ldflags': [ '-m64', '-march=z196' ],
364
          }],
365 366 367 368 369
          [ 'OS=="solaris"', {
            'cflags': [ '-pthreads' ],
            'ldflags': [ '-pthreads' ],
            'cflags!': [ '-pthread' ],
            'ldflags!': [ '-pthread' ],
370
          }],
371
          [ 'OS=="aix"', {
372
            'variables': {'real_os_name': '<!(uname -s)',},
373 374 375 376 377 378 379 380
            'conditions': [
              [ 'target_arch=="ppc"', {
                'ldflags': [ '-Wl,-bmaxdata:0x60000000/dsa' ],
              }],
              [ 'target_arch=="ppc64"', {
                'cflags': [ '-maix64' ],
                'ldflags': [ '-maix64' ],
              }],
381 382 383 384 385 386
              ['"<(real_os_name)"=="OS400"', {
                'ldflags': [
                  '-Wl,-blibpath:/QOpenSys/pkgs/lib:/QOpenSys/usr/lib',
                  '-Wl,-brtl',
                ],
              }],
387
            ],
388
            'ldflags': [ '-Wl,-bbigtoc' ],
389 390
            'ldflags!': [ '-rdynamic' ],
          }],
391 392 393
          [ 'node_shared=="true"', {
            'cflags': [ '-fPIC' ],
          }],
394 395
        ],
      }],
396 397 398 399 400 401 402
      ['OS=="android"', {
        'target_conditions': [
          ['_toolset=="target"', {
            'defines': [ '_GLIBCXX_USE_C99_MATH' ],
            'libraries': [ '-llog' ],
          }],
        ],
403
      }],
404
      ['OS=="mac"', {
405
        'defines': ['_DARWIN_USE_64_BIT_INODE=1'],
406 407 408 409 410 411 412 413 414 415
        'xcode_settings': {
          'ALWAYS_SEARCH_USER_PATHS': 'NO',
          'GCC_CW_ASM_SYNTAX': 'NO',                # No -fasm-blocks
          'GCC_DYNAMIC_NO_PIC': 'NO',               # No -mdynamic-no-pic
                                                    # (Equivalent to -fPIC)
          'GCC_ENABLE_CPP_EXCEPTIONS': 'NO',        # -fno-exceptions
          'GCC_ENABLE_CPP_RTTI': 'NO',              # -fno-rtti
          'GCC_ENABLE_PASCAL_STRINGS': 'NO',        # No -mpascal-strings
          'GCC_THREADSAFE_STATICS': 'NO',           # -fno-threadsafe-statics
          'PREBINDING': 'NO',                       # No -Wl,-prebind
416
          'MACOSX_DEPLOYMENT_TARGET': '10.7',       # -mmacosx-version-min=10.7
417 418 419 420 421 422 423 424 425 426 427 428 429
          'USE_HEADERMAP': 'NO',
          'OTHER_CFLAGS': [
            '-fno-strict-aliasing',
          ],
          'WARNING_CFLAGS': [
            '-Wall',
            '-Wendif-labels',
            '-W',
            '-Wno-unused-parameter',
          ],
        },
        'target_conditions': [
          ['_type!="static_library"', {
430 431 432 433 434 435
            'xcode_settings': {
              'OTHER_LDFLAGS': [
                '-Wl,-no_pie',
                '-Wl,-search_paths_first',
              ],
            },
436 437
          }],
        ],
438 439 440 441 442 443 444
        'conditions': [
          ['target_arch=="ia32"', {
            'xcode_settings': {'ARCHS': ['i386']},
          }],
          ['target_arch=="x64"', {
            'xcode_settings': {'ARCHS': ['x86_64']},
          }],
445 446 447
          ['clang==1', {
            'xcode_settings': {
              'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0',
448
              'CLANG_CXX_LANGUAGE_STANDARD': 'gnu++1y',  # -std=gnu++1y
449
              'CLANG_CXX_LIBRARY': 'libc++',
450 451
            },
          }],
452
        ],
453
      }],
454 455
      ['OS=="freebsd" and node_use_dtrace=="true"', {
        'libraries': [ '-lelf' ],
456 457
      }],
      ['OS=="freebsd"', {
458
        'conditions': [
459
          ['"0" < llvm_version < "4.0"', {
460 461 462 463 464 465 466
            # Use this flag because on FreeBSD std::pairs copy constructor is non-trivial.
            # Doesn't apply to llvm 4.0 (FreeBSD 11.1) or later.
            # Refs: https://lists.freebsd.org/pipermail/freebsd-toolchain/2016-March/002094.html
            # Refs: https://svnweb.freebsd.org/ports/head/www/node/Makefile?revision=444555&view=markup
            'cflags': [ '-D_LIBCPP_TRIVIAL_PAIR_COPY_CTOR=1' ],
          }],
        ],
467 468 469
        'ldflags': [
          '-Wl,--export-dynamic',
        ],
470
      }]
471 472 473
    ],
  }
}