diff --git a/common.gypi b/common.gypi index 57e434f3f4e232..638343db79d7f6 100644 --- a/common.gypi +++ b/common.gypi @@ -152,8 +152,10 @@ 'cflags': [ '-fPIC' ], 'ldflags': [ '-fPIC' ] }], + ['clang==1', { + 'msbuild_toolset': 'ClangCL', + }], ], - 'msbuild_toolset': 'ClangCL', 'msvs_settings': { 'VCCLCompilerTool': { 'BasicRuntimeChecks': 3, # /RTC1 @@ -241,8 +243,10 @@ 'cflags': [ '-fPIC', '-I<(android_ndk_path)/sources/android/cpufeatures' ], 'ldflags': [ '-fPIC' ] }], + ['clang==1', { + 'msbuild_toolset': 'ClangCL', + }], ], - 'msbuild_toolset': 'ClangCL', 'msvs_settings': { 'VCCLCompilerTool': { 'conditions': [ diff --git a/configure.py b/configure.py index 4ccd7e4358973e..1969595addaab8 100755 --- a/configure.py +++ b/configure.py @@ -866,6 +866,13 @@ default=None, help=argparse.SUPPRESS) +parser.add_argument('--clang-cl', + action='store', + dest='clang_cl', + default=None, + help='Configure for clang-cl on Windows. This flag sets the GYP "clang" ' + + 'variable to 1 and "llvm_version" to the specified value.') + (options, args) = parser.parse_known_args() # Expand ~ in the install prefix now, it gets written to multiple files. @@ -1042,9 +1049,9 @@ def get_gas_version(cc): # quite prepared to go that far yet. def check_compiler(o): if sys.platform == 'win32': - o['variables']['clang'] = 1 - # Visual Studio 2022 ships with this version. - o['variables']['llvm_version'] = '17.0' + if options.clang_cl: + o['variables']['clang'] = 1 + o['variables']['llvm_version'] = options.clang_cl if not options.openssl_no_asm and options.dest_cpu in ('x86', 'x64'): nasm_version = get_nasm_version('nasm') o['variables']['nasm_version'] = nasm_version diff --git a/vcbuild.bat b/vcbuild.bat index 8461fd7e7eaa7b..310ab8de88f611 100644 --- a/vcbuild.bat +++ b/vcbuild.bat @@ -32,6 +32,7 @@ set ltcg= set target_env= set noprojgen= set projgen= +set clang_cl= set nobuild= set sign= set nosnapshot= @@ -87,6 +88,7 @@ if /i "%1"=="arm64" set target_arch=arm64&goto arg-ok if /i "%1"=="vs2022" set target_env=vs2022&goto arg-ok if /i "%1"=="noprojgen" set noprojgen=1&goto arg-ok if /i "%1"=="projgen" set projgen=1&goto arg-ok +if /i "%1"=="clang-cl" set clang_cl=1&goto arg-ok if /i "%1"=="nobuild" set nobuild=1&goto arg-ok if /i "%1"=="nosign" set "sign="&echo Note: vcbuild no longer signs by default. "nosign" is redundant.&goto arg-ok if /i "%1"=="sign" set sign=1&goto arg-ok @@ -190,6 +192,8 @@ if defined nosnapshot set configure_flags=%configure_flags% --without-snap if defined nonpm set configure_flags=%configure_flags% --without-npm if defined nocorepack set configure_flags=%configure_flags% --without-corepack if defined ltcg set configure_flags=%configure_flags% --with-ltcg +:: If clang-cl build is requested, set it to 17.0, which is the version shipped with VS 2022. +if defined clang_cl set configure_flags=%configure_flags% --clang-cl=17.0 if defined release_urlbase set configure_flags=%configure_flags% --release-urlbase=%release_urlbase% if defined download_arg set configure_flags=%configure_flags% %download_arg% if defined enable_vtune_arg set configure_flags=%configure_flags% --enable-vtune-profiling @@ -750,7 +754,7 @@ set exit_code=1 goto exit :help -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] +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] [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] echo Examples: echo vcbuild.bat : builds release build echo vcbuild.bat debug : builds debug build