From 27f8d9e9d20e33eeaf7d36627ee4c629b3b15aa1 Mon Sep 17 00:00:00 2001 From: Stefan Stojanovic Date: Fri, 11 Oct 2024 12:28:55 +0200 Subject: [PATCH] build,win: enable pch for clang-cl Fixes: https://github.com/nodejs/node/issues/55208 PR-URL: https://github.com/nodejs/node/pull/55249 Reviewed-By: Yagiz Nizipli --- node.gypi | 14 +++++--------- tools/gyp/pylib/gyp/generator/msvs.py | 6 +++++- tools/v8_gypfiles/v8.gyp | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/node.gypi b/node.gypi index 44780fe3b12..9c989022a9a 100644 --- a/node.gypi +++ b/node.gypi @@ -65,15 +65,11 @@ 'NODE_PLATFORM="win32"', '_UNICODE=1', ], - 'conditions': [ - ['clang==0', { - 'msvs_precompiled_header': 'tools/msvs/pch/node_pch.h', - 'msvs_precompiled_source': 'tools/msvs/pch/node_pch.cc', - 'sources': [ - '<(_msvs_precompiled_header)', - '<(_msvs_precompiled_source)', - ], - }], + 'msvs_precompiled_header': 'tools/msvs/pch/node_pch.h', + 'msvs_precompiled_source': 'tools/msvs/pch/node_pch.cc', + 'sources': [ + '<(_msvs_precompiled_header)', + '<(_msvs_precompiled_source)', ], }, { # POSIX 'defines': [ '__POSIX__' ], diff --git a/tools/gyp/pylib/gyp/generator/msvs.py b/tools/gyp/pylib/gyp/generator/msvs.py index 92bf078ae86..bea6e643488 100644 --- a/tools/gyp/pylib/gyp/generator/msvs.py +++ b/tools/gyp/pylib/gyp/generator/msvs.py @@ -3412,7 +3412,11 @@ def _FinalizeMSBuildSettings(spec, configuration): ) # Turn on precompiled headers if appropriate. if precompiled_header: - precompiled_header = os.path.split(precompiled_header)[1] + # While MSVC works with just file name eg. "v8_pch.h", ClangCL requires + # the full path eg. "tools/msvs/pch/v8_pch.h" to find the file. + # P.S. Only ClangCL defines msbuild_toolset, for MSVC it is None. + if configuration.get("msbuild_toolset") != 'ClangCL': + precompiled_header = os.path.split(precompiled_header)[1] _ToolAppend(msbuild_settings, "ClCompile", "PrecompiledHeader", "Use") _ToolAppend( msbuild_settings, "ClCompile", "PrecompiledHeaderFile", precompiled_header diff --git a/tools/v8_gypfiles/v8.gyp b/tools/v8_gypfiles/v8.gyp index 627b30fbee2..e7ffde40d85 100644 --- a/tools/v8_gypfiles/v8.gyp +++ b/tools/v8_gypfiles/v8.gyp @@ -48,7 +48,7 @@ 'type': 'none', 'toolsets': ['host', 'target'], 'conditions': [ - ['OS=="win" and clang==0', { + ['OS=="win"', { 'direct_dependent_settings': { 'msvs_precompiled_header': '<(V8_ROOT)/../../tools/msvs/pch/v8_pch.h', 'msvs_precompiled_source': '<(V8_ROOT)/../../tools/msvs/pch/v8_pch.cc',