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

[MSVC] DCTL failed to build due to error C2039 with msvc on Windows #25

Open
Zhaojun-Liu opened this issue Jun 17, 2024 · 11 comments
Open

Comments

@Zhaojun-Liu
Copy link

Hi,
We build dctl with msvc on Windows, it failed due to the below errors, it looks a regression issue from 06cd028, can you help look this issue? Thanks.

C:\gitP\rhalbersma\dctl\include\dctl/core/board/mask.hpp(21): error C2039: 'bit_set_fast': is not a member of 'xstd'
C:\gitP\rhalbersma\dctl\..\bit_set\include\xstd/bit_set.hpp(28): note: see declaration of 'xstd'
C:\gitP\rhalbersma\dctl\include\dctl/core/board/mask.hpp(21): note: the template instantiation context (the oldest one first) is
C:\gitP\rhalbersma\dctl\include\dctl/core/board/mask.hpp(18): note: while compiling class template 'dctl::core::basic_mask'
C:\gitP\rhalbersma\dctl\include\dctl/core/board/mask.hpp(21): error C2061: syntax error: identifier 'bit_set_fast'
C:\gitP\rhalbersma\dctl\include\dctl/core/board/mask.hpp(22): error C2653: 'set_type': is not a class or namespace name
C:\gitP\rhalbersma\dctl\include\dctl/core/board/mask.hpp(22): error C3861: 'max_size': identifier not found
C:\gitP\rhalbersma\dctl\include\dctl/core/board/mask.hpp(22): error C2975: 'MaxValue': invalid template argument for 'boost::uint_value_t', expected compile-time constant expression
C:/gitP/Microsoft/vcpkg/installed/x64-windows/include\boost/integer.hpp(216): note: see declaration of 'MaxValue'
C:\gitP\rhalbersma\dctl\include\dctl/core/board/mask.hpp(25): error C3878: syntax error: unexpected token 'table' following 'expression'
C:\gitP\rhalbersma\dctl\include\dctl/core/board/mask.hpp(25): note: error recovery skipped: 'identifier'
C:\gitP\rhalbersma\dctl\include\dctl/core/board/mask.hpp(30): error C2059: syntax error: '('
C:\gitP\rhalbersma\dctl\include\dctl/core/board/mask.hpp(35): error C2988: unrecognizable template declaration/definition
C:\gitP\rhalbersma\dctl\include\dctl/core/board/mask.hpp(35): error C2143: syntax error: missing ',' before '<end Parse>'
C:\gitP\rhalbersma\dctl\include\dctl/core/board/mask.hpp(35): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
C:\gitP\rhalbersma\dctl\include\dctl/core/board/mask.hpp(46): error C3861: 'set_type': identifier not found
C:\gitP\rhalbersma\dctl\include\dctl/core/board/mask.hpp(57): error C2143: syntax error: missing ')' before ';'
C:\gitP\rhalbersma\dctl\include\dctl/core/board/mask.hpp(57): error C2988: unrecognizable template declaration/definition
C:\gitP\rhalbersma\dctl\include\dctl/core/board/mask.hpp(57): error C2059: syntax error: ')'
C:\gitP\rhalbersma\dctl\include\dctl/core/board/mask.hpp(60): error C3861: 'set_type': identifier not found
C:\gitP\rhalbersma\dctl\include\dctl/core/board/mask.hpp(76): error C2062: type 'void' unexpected
C:\gitP\rhalbersma\dctl\include\dctl/core/board/mask.hpp(76): error C2238: unexpected token(s) preceding ';'
C:\gitP\rhalbersma\dctl\include\dctl/core/board/mask.hpp(76): error C2062: type 'void' unexpected
C:\gitP\rhalbersma\dctl\include\dctl/core/board/mask.hpp(76): error C2238: unexpected token(s) preceding ';'
C:\gitP\rhalbersma\dctl\include\dctl/core/board/mask.hpp(77): error C2988: unrecognizable template declaration/definition
C:\gitP\rhalbersma\dctl\include\dctl/core/board/mask.hpp(77): error C2059: syntax error: 'return'
C:\gitP\rhalbersma\dctl\include\dctl/core/board/mask.hpp(77): error C2238: unexpected token(s) preceding ';'
C:\gitP\rhalbersma\dctl\include\dctl/core/board/mask.hpp(80): error C2144: syntax error: 'auto' should be preceded by ';'
C:\gitP\rhalbersma\dctl\include\dctl/core/board/mask.hpp(25): error C2760: syntax error: 'table' was unexpected here; expected ';'
C:\gitP\rhalbersma\dctl\include\dctl/core/board/mask.hpp(30): error C2059: syntax error: ')'
......

More info:
the related repos and commit I used as follows:
dctl commit: de565a1
bit_set commit: c91bdd5
Tabula commit: ab6451c
Xstd commit: 4a1625d

Repro steps:

  1. Download the attachment divide.txt.
  2. Open VS2022 x64 Native Tools command.
  3. Run command: cl divide.txt /TP /c /EHsc /std:c++latest

Repro file:
divide.txt

By the way, I found that for the bit_set repository, all commits after commit c91bdd5 cause the git clone command to fail on Windows with the following error message:

......
Resolving deltas: 100% (2055/2055), done.
fatal: cannot create directory at 'include/aux': Invalid argument
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry with 'git restore --source=HEAD :/'
@rhalbersma
Copy link
Owner

@Zhaojun-Liu the error is on my part, I have been changing the bit_set repo and not ported back some of the API changes to dependent repos like dctl. I will try and get this working again but it might take a week or two.

@Zhaojun-Liu
Copy link
Author

@Zhaojun-Liu the error is on my part, I have been changing the bit_set repo and not ported back some of the API changes to dependent repos like dctl. I will try and get this working again but it might take a week or two.

Okay, thank you for the quickly reply. 😃

@rhalbersma
Copy link
Owner

@Zhaojun-Liu can you please open an issue on dctl as well?

@Zhaojun-Liu
Copy link
Author

@Zhaojun-Liu can you please open an issue on dctl as well?

Ok, see rhalbersma/dctl#33.

@rhalbersma
Copy link
Owner

bit_set itself builds cleanly and I've exposed all necessary methods for dependent project (add() and pop() members had been disabled). Closing this issue, but please check the dctl issue.

@rhalbersma
Copy link
Owner

@Zhaojun-Liu I have pushed a new commit removing some C++23 constructs currently not supported by MSVC. Could you please update your copy of this repo and do the canonical CMake steps as follows:

cd bit_set
mkdir build
cd build
cmake ..
cmake --build . 
ctest -E bench

Once this works succesfully, I can take a look at the DCTL repo again.

@Zhaojun-Liu
Copy link
Author

Zhaojun-Liu commented Jun 19, 2024

Hi @rhalbersma,
Let me first talk about the test results: after I updated bit_set to the latest commit (4e951b0), the DCTL build was fine, but when I followed your steps to build bit_set itself, it failed, you can check the attachments.

For details (with VS2022 x64 Native Tools command):
The full steps I followed to build DCTL are as follows, and now it built fine.

  1. vcpkg.exe install --recurse boost-accumulators boost-graph boost-test --triplet x64-windows --clean-after-build
  2. cd C:\gitP\rhalbersma
  3. git clone https://github.com/rhalbersma/dctl & git clone https://github.com/rhalbersma/bit_set & git clone https://github.com/rhalbersma/tabula & git clone https://github.com/rhalbersma/xstd
  4. mkdir C:\gitP\rhalbersma\dctl\build_amd64 & cd C:\gitP\rhalbersma\dctl\build_amd64
  5. cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_SYSTEM_VERSION=10.0.22621.0 -DCMAKE_TOOLCHAIN_FILE=C:\gitP\Microsoft\vcpkg\scripts\buildsystems\vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows ..
  6. msbuild /m /p:Platform=x64 /p:Configuration=Release dctl.sln /t:Rebuild

Steps to build bit_set , based on your steps, I just updated the cmake step and added the extra 3 packages using vcpkg as follows, it failed and I attached the build log "cmake_build_bs.log", I also tried to build with msbuild, that is replace step 6 with msbuild /m /p:Platform=x64 /p:Configuration=Release bit_set.sln /t:Rebuild 2>&1 >msbuild_bs.log, the log has also been uploaded as an attachment.

  1. vcpkg.exe install --recurse benchmark fmt range-v3 --triplet x64-windows --clean-after-build 2>&1
  2. cd bit_set
  3. mkdir build
  4. cd build
  5. cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_SYSTEM_VERSION=10.0.22621.0 -DCMAKE_TOOLCHAIN_FILE=C:\gitP\Microsoft\vcpkg\scripts\buildsystems\vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows ..
  6. cmake --build . > cmake_build_bs.log

bit_set build logs (same failures in the 2 logs):
cmake_build_bs.log
msbuild_bs.log

@rhalbersma
Copy link
Owner

rhalbersma commented Jun 19, 2024

@Zhaojun-Liu sorry, I missed a few size_t literals (just grepped for 0 and 1, but there were a few more) in the unit tests. Should be fixed now. Thanks for testing this so thoroughly. Note that you might also have to link to Google Benchmark (not sure how if it's within vcpkg yet) to build all the benchmarks.

@Zhaojun-Liu
Copy link
Author

@Zhaojun-Liu sorry, I missed a few size_t literals (just grepped for 0 and 1, but there were a few more) in the unit tests. Should be fixed now. Thanks for testing this so thoroughly. Note that you might also have to link to Google Benchmark (not sure how if it's within vcpkg yet) to build all the benchmarks.

Hi @rhalbersma, I installed Google Benchmark with vcpkg, it is in vcpkg, you can see https://github.com/microsoft/vcpkg/blob/master/ports/benchmark/vcpkg.json, but with latest commit(0c182bb), it still failed, please see the attachment. I'm not sure if there's anything else I need to configure?
cmake_build_bs2.log

@rhalbersma
Copy link
Owner

rhalbersma commented Jun 20, 2024

At this point I'll have to bite the bullet and install msvc I think. The remaining errors in the test are benign and related to function template argument deduction in combination with named concepts and or the typename keyword, I suspect. I have some ideas to work around it. Will take the weekend probably.

@rhalbersma
Copy link
Owner

@Zhaojun-Liu I managed to successfully compile and run most of the unit tests. Only the benchmarks and the sieve tests are not compiling. MSVC doesn't grok the proxy references in all instances, and I had to write out a 2-legged range call to std::ranges::equal to the 4-legged iterator version.

You should be able to compile and then run `ctest -E "benchmark|sieve" and get 100%. For now this is good enough. I might try and investigate the other errors later.

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

No branches or pull requests

2 participants