Skip to content

Conversation

@jack-pappas
Copy link
Collaborator

While trying to work out a compile error for #120 when compiling with Linux/GCC, I tried compiling with clang-cl and MSVC to see if I could easily reproduce the error that way. I wasn't quite able to get riptide_cpp to compile with clang-cl (and VS 2022.0), but I did make some progress towards getting it compiling -- mainly I needed to add the existing compile options for Clang to the options for clang-cl (detected as MSVC + Clang).

It might be useful to set up a clang-cl build for riptide_cpp in the future. To that end, I'm submitting the CMakeLists.txt changes I tried, so when someone has time to sort out the remaining issue(s) they'll have a better starting point.

The remaining issues I see when attempting to compile:

Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

  libzstd_static.vcxproj -> F:\riptide_cpp\build\temp.win-amd64-3.8\Release\external\zstd\build\cmake\lib\Release\zstd_static.lib
  In file included from F:\riptide_cpp\src\one_input.cpp:2:
  In file included from F:\riptide_cpp\src/one_input_impl.h:7:
F:\riptide_cpp\src/basic_ops.h(43,53): error : template argument for template type parameter must be a type [F:\riptide_cpp\build\temp.win-amd64-3.8\Release\src\riptide_cpp.vcxproj]
C:\Program Files\Visual Studio 2022\VC\Tools\MSVC\14.30.30705\include\xtr1common(67,29): message : template parameter is declared here [F:\riptide_cpp\build\temp.win-amd64-3.8\Release\src\riptide_cpp.vcxproj]
  In file included from F:\riptide_cpp\src\one_input.cpp:2:
  In file included from F:\riptide_cpp\src/one_input_impl.h:7:
F:\riptide_cpp\src/basic_ops.h(47,52): error : template argument for template type parameter must be a type [F:\riptide_cpp\build\temp.win-amd64-3.8\Release\src\riptide_cpp.vcxproj]
C:\Program Files\Visual Studio 2022\VC\Tools\MSVC\14.30.30705\include\xtr1common(67,29): message : template parameter is declared here [F:\riptide_cpp\build\temp.win-amd64-3.8\Release\src\riptide_cpp.vcxproj]
  In file included from F:\riptide_cpp\src\one_input.cpp:2:
  In file included from F:\riptide_cpp\src/one_input_impl.h:7:
F:\riptide_cpp\src/basic_ops.h(51,53): error : template argument for template type parameter must be a type [F:\riptide_cpp\build\temp.win-amd64-3.8\Release\src\riptide_cpp.vcxproj]
C:\Program Files\Visual Studio 2022\VC\Tools\MSVC\14.30.30705\include\xtr1common(67,29): message : template parameter is declared here [F:\riptide_cpp\build\temp.win-amd64-3.8\Release\src\riptide_cpp.vcxproj]
  In file included from F:\riptide_cpp\src\one_input.cpp:2:
  In file included from F:\riptide_cpp\src/one_input_impl.h:7:
F:\riptide_cpp\src/basic_ops.h(73,30): error : suggest braces around initialization of subobject [-Werror,-Wmissing-braces] [F:\riptide_cpp\build\temp.win-amd64-3.8\Release\src\riptide_cpp.vcxproj]
F:\riptide_cpp\src/basic_ops.h(81,30): error : suggest braces around initialization of subobject [-Werror,-Wmissing-braces] [F:\riptide_cpp\build\temp.win-amd64-3.8\Release\src\riptide_cpp.vcxproj]
F:\riptide_cpp\src/basic_ops.h(92,9): error : suggest braces around initialization of subobject [-Werror,-Wmissing-braces] [F:\riptide_cpp\build\temp.win-amd64-3.8\Release\src\riptide_cpp.vcxproj]
F:\riptide_cpp\src/basic_ops.h(103,33): error : suggest braces around initialization of subobject [-Werror,-Wmissing-braces] [F:\riptide_cpp\build\temp.win-amd64-3.8\Release\src\riptide_cpp.vcxproj]
F:\riptide_cpp\src/basic_ops.h(113,30): error : suggest braces around initialization of subobject [-Werror,-Wmissing-braces] [F:\riptide_cpp\build\temp.win-amd64-3.8\Release\src\riptide_cpp.vcxproj]
F:\riptide_cpp\src/basic_ops.h(123,33): error : suggest braces around initialization of subobject [-Werror,-Wmissing-braces] [F:\riptide_cpp\build\temp.win-amd64-3.8\Release\src\riptide_cpp.vcxproj]
F:\riptide_cpp\src/basic_ops.h(133,36): error : suggest braces around initialization of subobject [-Werror,-Wmissing-braces] [F:\riptide_cpp\build\temp.win-amd64-3.8\Release\src\riptide_cpp.vcxproj]
F:\riptide_cpp\src/basic_ops.h(143,30): error : suggest braces around initialization of subobject [-Werror,-Wmissing-braces] [F:\riptide_cpp\build\temp.win-amd64-3.8\Release\src\riptide_cpp.vcxproj]
F:\riptide_cpp\src/basic_ops.h(151,26): error : suggest braces around initialization of subobject [-Werror,-Wmissing-braces] [F:\riptide_cpp\build\temp.win-amd64-3.8\Release\src\riptide_cpp.vcxproj]
F:\riptide_cpp\src/basic_ops.h(159,26): error : suggest braces around initialization of subobject [-Werror,-Wmissing-braces] [F:\riptide_cpp\build\temp.win-amd64-3.8\Release\src\riptide_cpp.vcxproj]
  In file included from F:\riptide_cpp\src\one_input.cpp:2:
  In file included from F:\riptide_cpp\src/one_input_impl.h:11:
F:\riptide_cpp\src/simd/avx2.h(3210,28): error : use of undeclared identifier '_mm256_max_epi64' [F:\riptide_cpp\build\temp.win-amd64-3.8\Release\src\riptide_cpp.vcxproj]
F:\riptide_cpp\src/simd/avx2.h(3223,28): error : use of undeclared identifier '_mm256_max_epi64' [F:\riptide_cpp\build\temp.win-amd64-3.8\Release\src\riptide_cpp.vcxproj]
F:\riptide_cpp\src/simd/avx2.h(3236,28): error : use of undeclared identifier '_mm256_min_epi64' [F:\riptide_cpp\build\temp.win-amd64-3.8\Release\src\riptide_cpp.vcxproj]
F:\riptide_cpp\src/simd/avx2.h(3249,28): error : use of undeclared identifier '_mm256_min_epi64' [F:\riptide_cpp\build\temp.win-amd64-3.8\Release\src\riptide_cpp.vcxproj]
F:\riptide_cpp\src/simd/avx2.h(3658,28): error : use of undeclared identifier '_mm256_max_epu64' [F:\riptide_cpp\build\temp.win-amd64-3.8\Release\src\riptide_cpp.vcxproj]
F:\riptide_cpp\src/simd/avx2.h(3671,28): error : use of undeclared identifier '_mm256_max_epu64' [F:\riptide_cpp\build\temp.win-amd64-3.8\Release\src\riptide_cpp.vcxproj]

One other thing that surprised me (that seems worth investigating) -- even though the root CMakeLists.txt in the repo specifies the C++17 standard is required and that's respected when building with MSVC, building with clang-cl (via python setup.py build) doesn't appear to respect the setting and falls back to compiling with C++14. I'm using CMake 3.22.1 in case it matters. From one build log:

-- Enabling additional flags: -DCMAKE_CXX_STANDARD=14
-- Performing Test HAVE_STD_REGEX -- success
-- Enabling additional flags: -DCMAKE_CXX_STANDARD=14
-- Performing Test HAVE_GNU_POSIX_REGEX -- failed to compile
-- Enabling additional flags: -DCMAKE_CXX_STANDARD=14

add_compile_options(-permissive- -d2FH4- -Zc:strictStrings-)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_compile_options(-Wno-unused-variable -Wno-unused-function)
add_compile_options(-march=haswell)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

FYI: I used this because specifying -mavx2 -mbmi2 like the script is doing for regular GCC/Clang wasn't enough. I got the following error about missing lzcnt support, and using -march=haswell fixed it:

src\BasicMath.cpp(2154,46): error : always_inline function '_lzcnt_u64' requires target feature 'lzcnt', but would be inlined into function 'PossiblyUpcast' that is compiled without support for 'lzcnt'

Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] pls add indent

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ugh, sorry, I missed this comment before merging. Next time I'm poking around in here I'll fix the indentation.

@jack-pappas jack-pappas requested a review from staffantj March 23, 2022 16:41
@jack-pappas
Copy link
Collaborator Author

If you want to try compiling with clang-cl, you'll need to make the following change in addition to this PR:

setup.py

@@ -27,11 +27,12 @@ class CMakeBuild(build_ext):
             "-DRIPTIDE_PYTHON_VER=" + platform.python_version()
             ]
 
         if platform.system() == 'Windows':
             cmake_args += [
-                '-GVisual Studio 16 2019'
+                '-GVisual Studio 17 2022',
+                '-TClangCL'
                 ]
         elif platform.system() == 'Linux':
             if find_executable('ninja'):
                 cmake_args += [
                     '-GNinja'

@jack-pappas jack-pappas merged commit 0d5dd79 into master Mar 23, 2022
@jack-pappas jack-pappas deleted the maint/support-clang-cl branch March 23, 2022 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants