Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: enable Clang-cl Windows builds #35433

Closed
wants to merge 12 commits into from
18 changes: 9 additions & 9 deletions .github/workflows/build-tarball.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
name: Build from tarball

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths-ignore:
- .mailmap
- '**.md'
- AUTHORS
- doc/**
- .github/**
- '!.github/workflows/build-tarball.yml'
# pull_request:
# types: [opened, synchronize, reopened, ready_for_review]
# paths-ignore:
# - .mailmap
# - '**.md'
# - AUTHORS
# - doc/**
# - .github/**
# - '!.github/workflows/build-tarball.yml'
push:
branches:
- main
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/coverage-linux.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
name: Coverage Linux

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- lib/**/*.js
- Makefile
- src/**/*.cc
- src/**/*.h
- test/**
- tools/gyp/**
- tools/test.py
- .github/workflows/coverage-linux.yml
# pull_request:
# types: [opened, synchronize, reopened, ready_for_review]
# paths:
# - lib/**/*.js
# - Makefile
# - src/**/*.cc
# - src/**/*.h
# - test/**
# - tools/gyp/**
# - tools/test.py
# - .github/workflows/coverage-linux.yml
push:
branches:
- main
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/test-asan.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
name: Test ASan

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths-ignore:
- .mailmap
- '**.md'
- AUTHORS
- doc/**
- .github/**
- '!.github/workflows/test-asan.yml'
# pull_request:
# types: [opened, synchronize, reopened, ready_for_review]
# paths-ignore:
# - .mailmap
# - '**.md'
# - AUTHORS
# - doc/**
# - .github/**
# - '!.github/workflows/test-asan.yml'
push:
branches:
- main
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/test-linux.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: Test Linux

on:
pull_request:
paths-ignore:
- README.md
- .github/**
- '!.github/workflows/test-linux.yml'
types: [opened, synchronize, reopened, ready_for_review]
# pull_request:
# paths-ignore:
# - README.md
# - .github/**
# - '!.github/workflows/test-linux.yml'
# types: [opened, synchronize, reopened, ready_for_review]
push:
branches:
- main
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/test-macos.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
name: Test macOS

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths-ignore:
- .mailmap
- '**.md'
- AUTHORS
- doc/**
- .github/**
- '!.github/workflows/test-macos.yml'
# pull_request:
# types: [opened, synchronize, reopened, ready_for_review]
# paths-ignore:
# - .mailmap
# - '**.md'
# - AUTHORS
# - doc/**
# - .github/**
# - '!.github/workflows/test-macos.yml'
push:
branches:
- main
Expand Down
8 changes: 6 additions & 2 deletions common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@

'conditions': [
['OS == "win"', {
'clang%': 1,
'os_posix': 0,
'v8_postmortem_support%': 0,
'obj_dir': '<(PRODUCT_DIR)/obj',
Expand Down Expand Up @@ -284,10 +285,13 @@
],
'msvs_settings': {
'VCCLCompilerTool': {
# Node has C and C++ dependencies: we want to specify the standards
# independently. Recent versions of Visual Studio support C11 and C17
# https://learn.microsoft.com/en-us/cpp/overview/install-c17-support?view=msvc-170
'LanguageStandard': 'stdcpp20',
'LanguageStandard_C': 'stdc11',
'AdditionalOptions': [
'/Zc:__cplusplus',
# The following option enables c++20 on Windows. This is needed for V8 v12.4+
'-std:c++20',
# The following option reduces the "error C1060: compiler is out of heap space"
'/Zm2000',
],
Expand Down
3 changes: 2 additions & 1 deletion deps/icu-small/source/tools/toolutil/pkg_genc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -846,8 +846,9 @@ getArchitecture(uint16_t *pCPU, uint16_t *pBits, UBool *pIsBigEndian, const char
// for all architectures though.
# if defined(_M_IX86)
*pCPU = IMAGE_FILE_MACHINE_I386;
// TODO: detect ARM64
# else
*pCPU = IMAGE_FILE_MACHINE_UNKNOWN;
*pCPU = IMAGE_FILE_MACHINE_AMD64;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for #34201

Comment on lines +849 to +851
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried an ARM64 build and got an error connected to these changes.

After some investigation, I found that dealing with a TODO: detect ARM64 added here would be tricky. This file is a part of a host project, thus it is always compiled for x64 in our case. Ideally, we'd use _M_ARM64/_M_AMD64 and set different IMAGE_FILE_MACHINE_... based on that in a target architecture project, but that cannot be used here.

What we can do, is add another option to genccode_host (genccode.c) that we'd use for setting the *pCPU. The issue with it is that the files I'd change in the process are part of the deps so we'd be making a floating patch on similar to the ones we have on V8, which is not great, but currently I see no other way (although there might be some).

# endif
# if defined(_M_IA64) || defined(_M_AMD64) || defined (_M_ARM64)
*pBits = 64; // Doesn't seem to be used for anything interesting though?
Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/heap/cppgc/heap-base.h
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ class V8_EXPORT_PRIVATE HeapBase : public cppgc::HeapHandle {
friend class cppgc::testing::Heap;
};

class V8_NODISCARD V8_EXPORT_PRIVATE ClassNameAsHeapObjectNameScope final {
class ClassNameAsHeapObjectNameScope final {
targos marked this conversation as resolved.
Show resolved Hide resolved
public:
explicit ClassNameAsHeapObjectNameScope(HeapBase& heap);
~ClassNameAsHeapObjectNameScope();
Expand Down
2 changes: 2 additions & 0 deletions deps/zlib/crc_folding.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include <inttypes.h>
#include <emmintrin.h>
#include <immintrin.h>
#include <smmintrin.h>
#include <tmmintrin.h>
targos marked this conversation as resolved.
Show resolved Hide resolved
#include <wmmintrin.h>

#define CRC_LOAD(s) \
Expand Down
6 changes: 2 additions & 4 deletions deps/zlib/zlib.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@
'type': 'static_library',
'conditions': [
['target_arch in "ia32 x64" and OS!="ios"', {
'defines': [ 'ADLER32_SIMD_SSSE3' ],
'conditions': [
['OS=="win"', {
'defines': [ 'X86_WINDOWS' ],
},{
'defines': [ 'X86_NOT_WINDOWS' ],
'defines': [ 'X86_NOT_WINDOWS', 'ADLER32_SIMD_SSSE3' ],
}],
['OS!="win" or llvm_version!="0.0"', {
'cflags': [ '-mssse3' ],
Expand All @@ -40,12 +39,11 @@
'direct_dependent_settings': {
'conditions': [
['target_arch in "ia32 x64" and OS!="ios"', {
'defines': [ 'ADLER32_SIMD_SSSE3' ],
'conditions': [
['OS=="win"', {
'defines': [ 'X86_WINDOWS' ],
},{
'defines': [ 'X86_NOT_WINDOWS' ],
'defines': [ 'X86_NOT_WINDOWS', 'ADLER32_SIMD_SSSE3' ],
}],
],
}],
Expand Down
4 changes: 2 additions & 2 deletions node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -608,8 +608,8 @@
'msvs_settings': {
'VCLinkerTool': {
'AdditionalOptions': [
'/WHOLEARCHIVE:<(node_lib_target_name)<(STATIC_LIB_SUFFIX)',
'/WHOLEARCHIVE:<(STATIC_LIB_PREFIX)v8_base_without_compiler<(STATIC_LIB_SUFFIX)',
'/WHOLEARCHIVE:<(PRODUCT_DIR)/lib/<(node_lib_target_name)<(STATIC_LIB_SUFFIX)',
'/WHOLEARCHIVE:<(PRODUCT_DIR)/lib/<(STATIC_LIB_PREFIX)v8_base_without_compiler<(STATIC_LIB_SUFFIX)',
],
},
},
Expand Down
9 changes: 6 additions & 3 deletions node.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
],
'msvs_precompiled_header': 'tools/msvs/pch/node_pch.h',
'msvs_precompiled_source': 'tools/msvs/pch/node_pch.cc',
'include_dirs': [
'tools/msvs/pch',
],
'sources': [
'<(_msvs_precompiled_header)',
'<(_msvs_precompiled_source)',
Expand Down Expand Up @@ -152,7 +155,7 @@
'msvs_settings': {
'VCLinkerTool': {
'AdditionalOptions': [
'/WHOLEARCHIVE:zlib<(STATIC_LIB_SUFFIX)',
'/WHOLEARCHIVE:<(PRODUCT_DIR)/lib/zlib<(STATIC_LIB_SUFFIX)',
],
},
},
Expand Down Expand Up @@ -191,7 +194,7 @@
'msvs_settings': {
'VCLinkerTool': {
'AdditionalOptions': [
'/WHOLEARCHIVE:libuv<(STATIC_LIB_SUFFIX)',
'/WHOLEARCHIVE:<(PRODUCT_DIR)/lib/libuv<(STATIC_LIB_SUFFIX)',
],
},
},
Expand Down Expand Up @@ -370,7 +373,7 @@
'msvs_settings': {
'VCLinkerTool': {
'AdditionalOptions': [
'/WHOLEARCHIVE:<(openssl_product)',
'/WHOLEARCHIVE:<(PRODUCT_DIR)/lib/<(openssl_product)',
],
},
},
Expand Down
3 changes: 3 additions & 0 deletions tools/gyp/pylib/gyp/MSVSSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,8 @@ def _ValidateSettings(validators, settings, stderr):
# Options that have the same name in MSVS and MSBuild
_Same(_compile, "AdditionalIncludeDirectories", _folder_list) # /I
_Same(_compile, "AdditionalOptions", _string_list)
_Same(_compile, "LanguageStandard", _string)
_Same(_compile, "LanguageStandard_C", _string)
_Same(_compile, "AdditionalUsingDirectories", _folder_list) # /AI
_Same(_compile, "AssemblerListingLocation", _file_name) # /Fa
_Same(_compile, "BrowseInformationFile", _file_name)
Expand Down Expand Up @@ -675,6 +677,7 @@ def _ValidateSettings(validators, settings, stderr):
"NoExtensions", # /arch:IA32 (vs2012+)
# This one only exists in the new msbuild format.
"AdvancedVectorExtensions2", # /arch:AVX2 (vs2013r2+)
"AdvancedVectorExtensions512", # (vs2019+)
]
),
)
Expand Down
6 changes: 3 additions & 3 deletions tools/gyp/pylib/gyp/generator/msvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,7 @@ def _AddConfigurationToMSVSProject(p, spec, config_type, config_name, config):
_ToolAppend(tools, "VCPostBuildEventTool", "CommandLine", postbuild)
# Turn on precompiled headers if appropriate.
if precompiled_header:
precompiled_header = os.path.split(precompiled_header)[1]
# precompiled_header = os.path.split(precompiled_header)[1]
_ToolAppend(tools, "VCCLCompilerTool", "UsePrecompiledHeader", "2")
_ToolAppend(
tools, "VCCLCompilerTool", "PrecompiledHeaderThrough", precompiled_header
Expand Down Expand Up @@ -3036,7 +3036,7 @@ def _GetMSBuildLocalProperties(msbuild_toolset):
[
"PropertyGroup",
{"Label": "Locals"},
["PlatformToolset", msbuild_toolset],
["PlatformToolset", "ClangCL"],
targos marked this conversation as resolved.
Show resolved Hide resolved
]
]
return properties
Expand Down Expand Up @@ -3416,7 +3416,7 @@ def _FinalizeMSBuildSettings(spec, configuration):
)
# Turn on precompiled headers if appropriate.
if precompiled_header:
precompiled_header = os.path.split(precompiled_header)[1]
# precompiled_header = os.path.split(precompiled_header)[1]
targos marked this conversation as resolved.
Show resolved Hide resolved
_ToolAppend(msbuild_settings, "ClCompile", "PrecompiledHeader", "Use")
_ToolAppend(
msbuild_settings, "ClCompile", "PrecompiledHeaderFile", precompiled_header
Expand Down
2 changes: 1 addition & 1 deletion tools/gyp/pylib/gyp/msvs_emulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ def GetCflags(self, config):
cl("AdditionalOptions", prefix="")
cl(
"EnableEnhancedInstructionSet",
map={"1": "SSE", "2": "SSE2", "3": "AVX", "4": "IA32", "5": "AVX2"},
map={"1": "SSE", "2": "SSE2", "3": "AVX", "4": "IA32", "5": "AVX2", "6": "AVX512"},
targos marked this conversation as resolved.
Show resolved Hide resolved
prefix="/arch:",
)
cflags.extend(
Expand Down
62 changes: 41 additions & 21 deletions tools/v8_gypfiles/v8.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
'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',
'include_dirs': [
'tools/msvs/pch',
],
'sources': [
'<(_msvs_precompiled_header)',
'<(_msvs_precompiled_source)',
Expand Down Expand Up @@ -444,11 +447,14 @@
'<(mksnapshot_exec)',
],
'outputs': [
'<(INTERMEDIATE_DIR)/snapshot.cc',
# snapshot.cc is always built in the 'asm_to_inline_asm' step.
'<(INTERMEDIATE_DIR)/embedded.S',
],
'process_outputs_as_sources': 1,
'conditions': [
# When not under Windows, embedded.S will be compiled directly.
['OS != "win"', {
'process_outputs_as_sources': 1,
}],
['v8_random_seed', {
'variables': {
'mksnapshot_flags': ['--random-seed', '<(v8_random_seed)'],
Expand Down Expand Up @@ -487,6 +493,39 @@
'>@(mksnapshot_flags)',
],
},
{
# This action is only useful on Windows.
# Under non-Windows systems, we effectively ignore
# the output of this action.
'action_name': 'asm_to_inline_asm',
'message': 'generating: >@(_outputs)',
'inputs': [
'<(INTERMEDIATE_DIR)/embedded.S',
],
'conditions': [
# Under Windows, we need to generate snapshot.cc and embedded.cc.
['OS == "win"', {
'outputs': [
'<(INTERMEDIATE_DIR)/snapshot.cc',
'<(INTERMEDIATE_DIR)/embedded.cc',
],
'action': [
'<(python)',
'<(V8_ROOT)/tools/snapshot/asm_to_inline_asm.py',
'<@(_inputs)',
'<(INTERMEDIATE_DIR)/embedded.cc', # important: embedded.cc is only ever generated if OS == "win"
],
}],
# Under non-Windows systems, we effectively ignore the output of this
# action. We do need to build snapshot.cc, however.
['OS != "win"', {
'outputs': ['<(INTERMEDIATE_DIR)/snapshot.cc'],
'action': [],
}],
],
'process_outputs_as_sources': 1,

},
],
}, # v8_snapshot
{
Expand Down Expand Up @@ -1928,25 +1967,6 @@
}],
]
}],
['OS=="win"', {
'conditions': [
['_toolset == "host" and host_arch == "x64" or _toolset == "target" and target_arch=="x64"', {
'sources': [
'<(V8_ROOT)/src/heap/base/asm/x64/push_registers_masm.asm',
],
}],
['_toolset == "host" and host_arch == "ia32" or _toolset == "target" and target_arch=="ia32"', {
'sources': [
'<(V8_ROOT)/src/heap/base/asm/ia32/push_registers_masm.asm',
],
}],
['_toolset == "host" and host_arch == "arm64" or _toolset == "target" and target_arch=="arm64"', {
'sources': [
'<(V8_ROOT)/src/heap/base/asm/arm64/push_registers_masm.S',
],
}],
],
}],
],
},
}, # v8_heap_base
Expand Down