Skip to content

Commit

Permalink
fix build on clangcl, except for v8 assembly (#9)
Browse files Browse the repository at this point in the history
1. To avoid many warnings, this PR declares the C and C++ standards separately.
2. This PR extends gyp so that we can build with AVX-512. Nevertheless, getting runtime dispatching with ClangCl through Visual Studio is challenging, so we disable it. It only affects one component of zip, so the effect on runtime performance should be negligible. Note that other dependencies such as simdutf do not need to this build support for runtime dispatching (so you still get AVX2, AVX-512 support in these dependencies).
  • Loading branch information
lemire authored and targos committed Apr 30, 2024
1 parent 6ec7554 commit 1f149ca
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
7 changes: 5 additions & 2 deletions common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -285,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
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
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
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"},
prefix="/arch:",
)
cflags.extend(
Expand Down

0 comments on commit 1f149ca

Please sign in to comment.