GeezerVison is showing github.com — build: add option to enable clang-cl on Windows · nodejs/node@a97ff75
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: common.gypi +26-6Lines changed: 26 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 152 | 152 | 'cflags': [ '-fPIC' ], | 153 | 153 | 'ldflags': [ '-fPIC' ] | 154 | 154 | }], | | 155 | + ['clang==1', { | | 156 | + 'msbuild_toolset': 'ClangCL', | | 157 | + }], | 155 | 158 | ], | 156 | 159 | 'msvs_settings': { | 157 | 160 | 'VCCLCompilerTool': { | | 240 | 243 | 'cflags': [ '-fPIC', '-I<(android_ndk_path)/sources/android/cpufeatures' ], | 241 | 244 | 'ldflags': [ '-fPIC' ] | 242 | 245 | }], | | 246 | + ['clang==1', { | | 247 | + 'msbuild_toolset': 'ClangCL', | | 248 | + }], | 243 | 249 | ], | 244 | 250 | 'msvs_settings': { | 245 | 251 | 'VCCLCompilerTool': { | | 282 | 288 | ], | 283 | 289 | 'msvs_settings': { | 284 | 290 | 'VCCLCompilerTool': { | 285 | | - 'AdditionalOptions': [ | 286 | | - '/Zc:__cplusplus', | 287 | | - # The following option enables c++20 on Windows. This is needed for V8 v12.4+ | 288 | | - '-std:c++20', | 289 | | - # The following option reduces the "error C1060: compiler is out of heap space" | 290 | | - '/Zm2000', | | 291 | + # TODO(targos): Remove condition and always use LanguageStandard options | | 292 | + # once node-gyp supports them. | | 293 | + 'conditions': [ | | 294 | + ['clang==1', { | | 295 | + 'LanguageStandard': 'stdcpp20', | | 296 | + 'LanguageStandard_C': 'stdc11', | | 297 | + 'AdditionalOptions': [ | | 298 | + '/Zc:__cplusplus', | | 299 | + # The following option reduces the "error C1060: compiler is out of heap space" | | 300 | + '/Zm2000', | | 301 | + ], | | 302 | + }, { | | 303 | + 'AdditionalOptions': [ | | 304 | + '/Zc:__cplusplus', | | 305 | + # The following option enables c++20 on Windows. This is needed for V8 v12.4+ | | 306 | + '-std:c++20', | | 307 | + # The following option reduces the "error C1060: compiler is out of heap space" | | 308 | + '/Zm2000', | | 309 | + ], | | 310 | + }], | 291 | 311 | ], | 292 | 312 | 'BufferSecurityCheck': 'true', | 293 | 313 | 'DebugInformationFormat': 1, # /Z7 embed info in .obj files | |
Collapse file Copy file name to clipboardExpand all lines: configure.py +14-2Lines changed: 14 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 946 | 946 | default=None, | 947 | 947 | help=argparse.SUPPRESS) | 948 | 948 |
| | 949 | +parser.add_argument('--clang-cl', | | 950 | + action='store', | | 951 | + dest='clang_cl', | | 952 | + default=None, | | 953 | + help='Configure for clang-cl on Windows. This flag sets the GYP "clang" ' + | | 954 | + 'variable to 1 and "llvm_version" to the specified value.') | | 955 | + | 949 | 956 | (options, args) = parser.parse_known_args() | 950 | 957 |
| 951 | 958 | # Expand ~ in the install prefix now, it gets written to multiple files. | @@ -1122,8 +1129,13 @@ def get_gas_version(cc): | 1122 | 1129 | # quite prepared to go that far yet. | 1123 | 1130 | def check_compiler(o): | 1124 | 1131 | if sys.platform == 'win32': | 1125 | | - o['variables']['clang'] = 0 | 1126 | | - o['variables']['llvm_version'] = '0.0' | | 1132 | + if options.clang_cl: | | 1133 | + o['variables']['clang'] = 1 | | 1134 | + o['variables']['llvm_version'] = options.clang_cl | | 1135 | + else: | | 1136 | + o['variables']['clang'] = 0 | | 1137 | + o['variables']['llvm_version'] = '0.0' | | 1138 | + | 1127 | 1139 | if not options.openssl_no_asm and options.dest_cpu in ('x86', 'x64'): | 1128 | 1140 | nasm_version = get_nasm_version('nasm') | 1129 | 1141 | o['variables']['nasm_version'] = nasm_version | |
Collapse file Copy file name to clipboardExpand all lines: deps/zlib/zlib.gyp +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 28 | 28 | 'xcode_settings': { | 29 | 29 | 'OTHER_CFLAGS': [ '-mssse3' ], | 30 | 30 | }, | | 31 | + 'msvs_settings': { | | 32 | + 'VCCLCompilerTool': { | | 33 | + 'AdditionalOptions': [ '-mssse3' ], | | 34 | + }, | | 35 | + }, | 31 | 36 | }], | 32 | 37 | ], | 33 | 38 | }], | |
Collapse file Copy file name to clipboardExpand all lines: node.gyp +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 610 | 610 | 'msvs_settings': { | 611 | 611 | 'VCLinkerTool': { | 612 | 612 | 'AdditionalOptions': [ | 613 | | - '/WHOLEARCHIVE:<(node_lib_target_name)<(STATIC_LIB_SUFFIX)', | 614 | | - '/WHOLEARCHIVE:<(STATIC_LIB_PREFIX)v8_base_without_compiler<(STATIC_LIB_SUFFIX)', | | 613 | + '/WHOLEARCHIVE:<(PRODUCT_DIR)/lib/<(node_lib_target_name)<(STATIC_LIB_SUFFIX)', | | 614 | + '/WHOLEARCHIVE:<(PRODUCT_DIR)/lib/<(STATIC_LIB_PREFIX)v8_base_without_compiler<(STATIC_LIB_SUFFIX)', | 615 | 615 | ], | 616 | 616 | }, | 617 | 617 | }, | |
Collapse file Copy file name to clipboardExpand all lines: node.gypi +12-8Lines changed: 12 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 65 | 65 | 'NODE_PLATFORM="win32"', | 66 | 66 | '_UNICODE=1', | 67 | 67 | ], | 68 | | - 'msvs_precompiled_header': 'tools/msvs/pch/node_pch.h', | 69 | | - 'msvs_precompiled_source': 'tools/msvs/pch/node_pch.cc', | 70 | | - 'sources': [ | 71 | | - '<(_msvs_precompiled_header)', | 72 | | - '<(_msvs_precompiled_source)', | | 68 | + 'conditions': [ | | 69 | + ['clang==0', { | | 70 | + 'msvs_precompiled_header': 'tools/msvs/pch/node_pch.h', | | 71 | + 'msvs_precompiled_source': 'tools/msvs/pch/node_pch.cc', | | 72 | + 'sources': [ | | 73 | + '<(_msvs_precompiled_header)', | | 74 | + '<(_msvs_precompiled_source)', | | 75 | + ], | | 76 | + }], | 73 | 77 | ], | 74 | 78 | }, { # POSIX | 75 | 79 | 'defines': [ '__POSIX__' ], | | 148 | 152 | 'msvs_settings': { | 149 | 153 | 'VCLinkerTool': { | 150 | 154 | 'AdditionalOptions': [ | 151 | | - '/WHOLEARCHIVE:zlib<(STATIC_LIB_SUFFIX)', | | 155 | + '/WHOLEARCHIVE:<(PRODUCT_DIR)/lib/zlib<(STATIC_LIB_SUFFIX)', | 152 | 156 | ], | 153 | 157 | }, | 154 | 158 | }, | | 187 | 191 | 'msvs_settings': { | 188 | 192 | 'VCLinkerTool': { | 189 | 193 | 'AdditionalOptions': [ | 190 | | - '/WHOLEARCHIVE:libuv<(STATIC_LIB_SUFFIX)', | | 194 | + '/WHOLEARCHIVE:<(PRODUCT_DIR)/lib/libuv<(STATIC_LIB_SUFFIX)', | 191 | 195 | ], | 192 | 196 | }, | 193 | 197 | }, | | 370 | 374 | 'msvs_settings': { | 371 | 375 | 'VCLinkerTool': { | 372 | 376 | 'AdditionalOptions': [ | 373 | | - '/WHOLEARCHIVE:<(openssl_product)', | | 377 | + '/WHOLEARCHIVE:<(PRODUCT_DIR)/lib/<(openssl_product)', | 374 | 378 | ], | 375 | 379 | }, | 376 | 380 | }, | |
Collapse file Copy file name to clipboardExpand all lines: tools/v8_gypfiles/toolchain.gypi +6Lines changed: 6 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 160 | 160 | # -Wno-invalid-offsetof | 161 | 161 | 'GCC_WARN_ABOUT_INVALID_OFFSETOF_MACRO': 'NO', | 162 | 162 | }, | | 163 | + 'msvs_settings': { | | 164 | + 'VCCLCompilerTool': { | | 165 | + 'AdditionalOptions': ['-Wno-invalid-offsetof'], | | 166 | + }, | | 167 | + }, | 163 | 168 | }], | 164 | 169 | ['v8_target_arch=="arm"', { | 165 | 170 | 'defines': [ | | 536 | 541 | 'WIN32', | 537 | 542 | 'NOMINMAX', # Refs: https://chromium-review.googlesource.com/c/v8/v8/+/1456620 | 538 | 543 | '_WIN32_WINNT=0x0602', # Windows 8 | | 544 | + '_SILENCE_ALL_CXX20_DEPRECATION_WARNINGS', | 539 | 545 | ], | 540 | 546 | # 4351: VS 2005 and later are warning us that they've fixed a bug | 541 | 547 | # present in VS 2003 and earlier. | |
Collapse file Copy file name to clipboardExpand all lines: tools/v8_gypfiles/v8.gyp +50-34Lines changed: 50 additions & 34 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 48 | 48 | 'type': 'none', | 49 | 49 | 'toolsets': ['host', 'target'], | 50 | 50 | 'conditions': [ | 51 | | - ['OS=="win"', { | | 51 | + ['OS=="win" and clang==0', { | 52 | 52 | 'direct_dependent_settings': { | 53 | 53 | 'msvs_precompiled_header': '<(V8_ROOT)/../../tools/msvs/pch/v8_pch.h', | 54 | 54 | 'msvs_precompiled_source': '<(V8_ROOT)/../../tools/msvs/pch/v8_pch.cc', | | 381 | 381 | 'target_name': 'v8_snapshot', | 382 | 382 | 'type': 'static_library', | 383 | 383 | 'toolsets': ['target'], | 384 | | - 'conditions': [ | 385 | | - ['want_separate_host_toolset', { | 386 | | - 'conditions': [ | 387 | | - ['v8_target_arch=="arm64"', { | 388 | | - 'msvs_enable_marmasm': 1, | 389 | | - }] | 390 | | - ], | 391 | | - 'dependencies': [ | 392 | | - 'generate_bytecode_builtins_list', | 393 | | - 'run_torque', | 394 | | - 'mksnapshot#host', | 395 | | - 'v8_maybe_icu', | 396 | | - # [GYP] added explicitly, instead of inheriting from the other deps | 397 | | - 'v8_base_without_compiler', | 398 | | - 'v8_compiler_for_mksnapshot', | 399 | | - 'v8_initializers', | 400 | | - 'v8_libplatform', | 401 | | - ] | 402 | | - }, { | 403 | | - 'dependencies': [ | 404 | | - 'generate_bytecode_builtins_list', | 405 | | - 'run_torque', | 406 | | - 'mksnapshot', | 407 | | - 'v8_maybe_icu', | 408 | | - # [GYP] added explicitly, instead of inheriting from the other deps | 409 | | - 'v8_base_without_compiler', | 410 | | - 'v8_compiler_for_mksnapshot', | 411 | | - 'v8_initializers', | 412 | | - 'v8_libplatform', | 413 | | - ] | 414 | | - }], | 415 | | - ], | 416 | 384 | 'sources': [ | 417 | 385 | '<(V8_ROOT)/src/init/setup-isolate-deserialize.cc', | 418 | 386 | ], | | 488 | 456 | ], | 489 | 457 | }, | 490 | 458 | ], | | 459 | + 'conditions': [ | | 460 | + ['want_separate_host_toolset', { | | 461 | + 'dependencies': [ | | 462 | + 'generate_bytecode_builtins_list', | | 463 | + 'run_torque', | | 464 | + 'mksnapshot#host', | | 465 | + 'v8_maybe_icu', | | 466 | + # [GYP] added explicitly, instead of inheriting from the other deps | | 467 | + 'v8_base_without_compiler', | | 468 | + 'v8_compiler_for_mksnapshot', | | 469 | + 'v8_initializers', | | 470 | + 'v8_libplatform', | | 471 | + ] | | 472 | + }, { | | 473 | + 'dependencies': [ | | 474 | + 'generate_bytecode_builtins_list', | | 475 | + 'run_torque', | | 476 | + 'mksnapshot', | | 477 | + 'v8_maybe_icu', | | 478 | + # [GYP] added explicitly, instead of inheriting from the other deps | | 479 | + 'v8_base_without_compiler', | | 480 | + 'v8_compiler_for_mksnapshot', | | 481 | + 'v8_initializers', | | 482 | + 'v8_libplatform', | | 483 | + ] | | 484 | + }], | | 485 | + ['OS=="win" and clang==1', { | | 486 | + 'actions': [ | | 487 | + { | | 488 | + 'action_name': 'asm_to_inline_asm', | | 489 | + 'message': 'generating: >@(_outputs)', | | 490 | + 'inputs': [ | | 491 | + '<(INTERMEDIATE_DIR)/embedded.S', | | 492 | + ], | | 493 | + 'outputs': [ | | 494 | + '<(INTERMEDIATE_DIR)/embedded.cc', | | 495 | + ], | | 496 | + 'process_outputs_as_sources': 1, | | 497 | + 'action': [ | | 498 | + '<(python)', | | 499 | + '<(V8_ROOT)/tools/snapshot/asm_to_inline_asm.py', | | 500 | + '<@(_inputs)', | | 501 | + '<(INTERMEDIATE_DIR)/embedded.cc', | | 502 | + ], | | 503 | + }, | | 504 | + ], | | 505 | + }], | | 506 | + ], | 491 | 507 | }, # v8_snapshot | 492 | 508 | { | 493 | 509 | 'target_name': 'v8_version', | | 1928 | 1944 | }], | 1929 | 1945 | ] | 1930 | 1946 | }], | 1931 | | - ['OS=="win"', { | | 1947 | + ['OS=="win" and clang==0', { | 1932 | 1948 | 'conditions': [ | 1933 | 1949 | ['_toolset == "host" and host_arch == "x64" or _toolset == "target" and target_arch=="x64"', { | 1934 | 1950 | 'sources': [ | |
Collapse file Copy file name to clipboardExpand all lines: vcbuild.bat +5-1Lines changed: 5 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -32,6 +32,7 @@ set ltcg= | 32 | 32 | set target_env= | 33 | 33 | set noprojgen= | 34 | 34 | set projgen= | | 35 | +set clang_cl= | 35 | 36 | set nobuild= | 36 | 37 | set sign= | 37 | 38 | set nosnapshot= | @@ -87,6 +88,7 @@ if /i "%1"=="arm64" set target_arch=arm64&goto arg-ok | 87 | 88 | if /i "%1"=="vs2022" set target_env=vs2022&goto arg-ok | 88 | 89 | if /i "%1"=="noprojgen" set noprojgen=1&goto arg-ok | 89 | 90 | if /i "%1"=="projgen" set projgen=1&goto arg-ok | | 91 | +if /i "%1"=="clang-cl" set clang_cl=1&goto arg-ok | 90 | 92 | if /i "%1"=="nobuild" set nobuild=1&goto arg-ok | 91 | 93 | if /i "%1"=="nosign" set "sign="&echo Note: vcbuild no longer signs by default. "nosign" is redundant.&goto arg-ok | 92 | 94 | if /i "%1"=="sign" set sign=1&goto arg-ok | @@ -190,6 +192,8 @@ if defined nosnapshot set configure_flags=%configure_flags% --without-snap | 190 | 192 | if defined nonpm set configure_flags=%configure_flags% --without-npm | 191 | 193 | if defined nocorepack set configure_flags=%configure_flags% --without-corepack | 192 | 194 | if defined ltcg set configure_flags=%configure_flags% --with-ltcg | | 195 | +:: If clang-cl build is requested, set it to 17.0, which is the version shipped with VS 2022. | | 196 | +if defined clang_cl set configure_flags=%configure_flags% --clang-cl=17.0 | 193 | 197 | if defined release_urlbase set configure_flags=%configure_flags% --release-urlbase=%release_urlbase% | 194 | 198 | if defined download_arg set configure_flags=%configure_flags% %download_arg% | 195 | 199 | if defined enable_vtune_arg set configure_flags=%configure_flags% --enable-vtune-profiling | @@ -750,7 +754,7 @@ set exit_code=1 | 750 | 754 | goto exit | 751 | 755 |
| 752 | 756 | :help | 753 | | -echo vcbuild.bat [debug/release] [msi] [doc] [test/test-all/test-addons/test-doc/test-js-native-api/test-node-api/test-internet/test-tick-processor/test-known-issues/test-node-inspect/test-check-deopts/test-npm/test-v8/test-v8-intl/test-v8-benchmarks/test-v8-all] [ignore-flaky] [static/dll] [noprojgen] [projgen] [small-icu/full-icu/without-intl] [nobuild] [nosnapshot] [nonpm] [nocorepack] [ltcg] [licensetf] [sign] [ia32/x86/x64/arm64] [vs2022] [download-all] [enable-vtune] [lint/lint-ci/lint-js/lint-md] [lint-md-build] [format-md] [package] [build-release] [upload] [no-NODE-OPTIONS] [link-module path-to-module] [debug-http2] [debug-nghttp2] [clean] [cctest] [no-cctest] [openssl-no-asm] | | 757 | +echo vcbuild.bat [debug/release] [msi] [doc] [test/test-all/test-addons/test-doc/test-js-native-api/test-node-api/test-internet/test-tick-processor/test-known-issues/test-node-inspect/test-check-deopts/test-npm/test-v8/test-v8-intl/test-v8-benchmarks/test-v8-all] [ignore-flaky] [static/dll] [noprojgen] [projgen] [clang-cl] [small-icu/full-icu/without-intl] [nobuild] [nosnapshot] [nonpm] [nocorepack] [ltcg] [licensetf] [sign] [ia32/x86/x64/arm64] [vs2022] [download-all] [enable-vtune] [lint/lint-ci/lint-js/lint-md] [lint-md-build] [format-md] [package] [build-release] [upload] [no-NODE-OPTIONS] [link-module path-to-module] [debug-http2] [debug-nghttp2] [clean] [cctest] [no-cctest] [openssl-no-asm] | 754 | 758 | echo Examples: | 755 | 759 | echo vcbuild.bat : builds release build | 756 | 760 | echo vcbuild.bat debug : builds debug build | |
|