Crafty 25.3 MSVS 2019

Discussion of chess software programming and technical issues.

Moderators: bob, hgm, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
jhaglund2
Posts: 34
Joined: Mon Jan 16, 2017 5:28 pm

Crafty 25.3 MSVS 2019

Post by jhaglund2 » Sun Sep 08, 2019 11:23 am

I'm back again trying to compile Crafty v25.3, with Microsoft VS 2019. :idea:

thread.c(455): warning C4028: formal parameter 1 different from declaration
thread.c(888): warning C4028: formal parameter 1 different from declaration

utility.c(2558): warning C4477: 'printf' : format string '%llu' requires an argument of type 'unsigned __int64', but variadic argument 1 has type 'DWORD'
utility.c(2591): warning C4477: 'printf' : format string '%I64d' requires an argument of type '__int64', but variadic argument 1 has type 'ULONG'

tbprobe.c(28): fatal error C1083: Cannot open include file: 'stdatomic.h': No such file or directory

Compile halts.
Removed tb support... crafty.c (line 28) //tbprobe.c

book.c(1439): error C2440: 'function': cannot convert from 'int (__fastcall *)(const void *,const void *)' to '_CoreCrtNonSecureSearchSortCompareFunction'
book.c(1439): warning C4024: 'qsort': different types for formal and actual parameter 4

option.c(878): error C2708: '__builtin_clzll': actual parameters length in bytes differs from previous call or reference
option.c(920): error C2708: '__builtin_clzll': actual parameters length in bytes differs from previous call or reference
option.c(957): error C2708: '__builtin_clzll': actual parameters length in bytes differs from previous call or reference

Compiler halts.
--------------------------------------------------------------------------------------------------------

Warnings:
thread.c(455): warning C4028: formal parameter 1 different from declaration

Code: Select all

int ThreadSplit(TREE * tree, int ply, int depth, int alpha, int o_alpha, int done)
thread.c(888): warning C4028: formal parameter 1 different from declaration

Code: Select all

TREE *GetBlock(TREE * RESTRICT parent, int tid) {
change: utility.c, line 2558

utility.c(2558): warning C4477: 'printf' : format string '%llu' requires an argument of type 'unsigned __int64', but variadic argument 1 has type 'DWORD'

Code: Select all

 printf("Current ideal CPU is %llu\n", dwCPU);
to

Code: Select all

 printf("Current ideal CPU is %lu\n", dwCPU);
change: utility.c, line 2591

utility.c(2591): warning C4477: 'printf' : format string '%I64d' requires an argument of type '__int64', but variadic argument 1 has type 'ULONG'

Code: Select all

 printf("Starting thread on node " PRId64 " CPU mask %I64d\n", ulNumaNode,
to

Code: Select all

printf("Starting thread on node " PRId64 " CPU mask %ld\n", ulNumaNode,
book.c(1439): error C2440: 'function': cannot convert from 'int (__fastcall *)(const void *,const void *)' to '_CoreCrtNonSecureSearchSortCompareFunction'

book.c(1439): warning C4024: 'qsort': different types for formal and actual parameter 4

book.c, line 1439 seems incorrect.

Code: Select all

qsort((char *) buffer, number, sizeof(BB_POSITION), BookupCompare);
option.c(878): error C2708: '__builtin_clzll': actual parameters length in bytes differs from previous call or reference

Code: Select all

hash_table_size = ((1ull) << MSB(new_hash_size)) / 16;
option.c(920): error C2708: '__builtin_clzll': actual parameters length in bytes differs from previous call or reference

Code: Select all

 hash_path_size = ((1ull) << MSB(new_hash_size / sizeof(HPATH_ENTRY)));
option.c(957): error C2708: '__builtin_clzll': actual parameters length in bytes differs from previous call or reference

Code: Select all

         1ull << MSB(new_hash_size / sizeof(PAWN_HASH_ENTRY));
I have no solutions to compile Crafty 25.3 with Microsoft Visual Studio 2019, with or without TB support. :cry:

jdart
Posts: 3816
Joined: Fri Mar 10, 2006 4:23 am
Location: http://www.arasanchess.org

Re: Crafty 25.3 MSVS 2019

Post by jdart » Sun Sep 08, 2019 6:18 pm

I believe Bob uses Linux exclusively. So it probably wasn't ever tested with MSVC. Try cygwin maybe?

--Jon

User avatar
xr_a_y
Posts: 733
Joined: Sat Nov 25, 2017 1:28 pm
Location: France

Re: Crafty 25.3 MSVS 2019

Post by xr_a_y » Sun Sep 08, 2019 7:08 pm

Always good to build on various system. Often catch weird bug this way !

MSVC is good to warn about strange parenthesis, bit-wise operator, ...

Might be good to clean the code using this opportunity.

jhaglund2
Posts: 34
Joined: Mon Jan 16, 2017 5:28 pm

Re: Crafty 25.3 MSVS 2019

Post by jhaglund2 » Mon Sep 09, 2019 12:48 pm

A couple changes for Crafty 25.3 to compile on MS VS 2019.

crafty.c(28)
Added what was missing.

Code: Select all

#include "boolean.c"
Omitted TB support because it's still not compatible.
(e.g., tbcore.c(11): fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory)
Also, (18) sys/mann.h, tbcore.h(9) pthread.h etc. ...

Code: Select all

//#include "tbprobe.c"
book.c(1439): error C2440: 'function': cannot convert from 'int (__fastcall *)(const void *,const void *)' to '_CoreCrtNonSecureSearchSortCompareFunction'
book.c(1439): warning C4024: 'qsort': different types for formal and actual parameter 4

chess.h:358

Code: Select all

int BookupCompare(const void *, const void *);
to

Code: Select all

int __cdecl BookupCompare(const void *, const void *);
book.c:1524

Code: Select all

int BookupCompare(const void *pos1, const void *pos2)
to

Code: Select all

int __cdecl BookupCompare(const void *pos1, const void *pos2)
chess.h(331)
Omitted because conflicted with boolean.c(19): error C2059: syntax error: 'constant'

Code: Select all

int MSB(uint64_t arg1) {

Code: Select all

//#define MSB(v)    (63 - __builtin_clzll(v))
utility.c(2558): warning C4477: 'printf' : format string '%llu' requires an argument of type 'unsigned __int64', but variadic argument 1 has type 'DWORD'

Code: Select all

printf("Current ideal CPU is %llu\n", dwCPU);
to

Code: Select all

printf("Current ideal CPU is %lu\n", dwCPU);
utility.c(2591): warning C4477: 'printf' : format string '%I64d' requires an argument of type '__int64', but variadic argument 1 has type 'ULONG'

Code: Select all

 printf("Starting thread on node " PRId64 " CPU mask %I64d\n", ulNumaNode, ullMask);
to

Code: Select all

 printf("Starting thread on node " PRId64 " CPU mask %Id\n", ulNumaNode,  ullMask);
crafty.obj : error LNK2001: unresolved external symbol @sleep@4
iterate(182)
Not windows compatible. Sleep() vs sleep();
changed:

Code: Select all

  if (elo_sleep) sleep (time_limit/167);
to

Code: Select all

if (elo_sleep) Sleep ((time_limit*1000)/167);
Makefile.xp - makefile is outdated.
Removed egtb.obj and egtb.cpp references.

I don't know how some of these changes will impact Crafty, but I do agree, we need to clean and update syntax along the way (/W3 flag).

Maybe someone can work on that TB compatibility with MS? Pretty please?

and after ...

Code: Select all

nmake -f Makefile.xp

Code: Select all

Microsoft (R) Program Maintenance Utility Version 14.22.27905.0
Copyright (C) Microsoft Corporation.  All rights reserved.

crafty.c
C:\Users\Superman\Downloads\src\thread.c(455): warning C4028: formal parameter 1 different from declaration
C:\Users\Superman\Downloads\src\thread.c(888): warning C4028: formal parameter 1 different from declaration
        link /LTCG crafty.obj /out:crafty.exe
Microsoft (R) Incremental Linker Version 14.22.27905.0
Copyright (C) Microsoft Corporation.  All rights reserved.
Generating code
Finished generating code
You can find Crafty 25.3 - 64 CPU (no TB) http://www.filedropper.com/crafty253vs2019
crafty253vs2019.zip
(239.52 KiB) Downloaded 48 times

jdart
Posts: 3816
Joined: Fri Mar 10, 2006 4:23 am
Location: http://www.arasanchess.org

Re: Crafty 25.3 MSVS 2019

Post by jdart » Mon Sep 09, 2019 2:26 pm

I think Crafty is now using the latest Fathom code, in which case tbcore.h/tbcore.c should be no longer used (these are from the older version before 7-man support was added). Btw your archive only has the .exe - did you mean to include source?

jhaglund2
Posts: 34
Joined: Mon Jan 16, 2017 5:28 pm

Re: Crafty 25.3 MSVS 2019

Post by jhaglund2 » Mon Sep 09, 2019 3:30 pm

jdart wrote:
Mon Sep 09, 2019 2:26 pm
I think Crafty is now using the latest Fathom code, in which case tbcore.h/tbcore.c should be no longer used (these are from the older version before 7-man support was added). Btw your archive only has the .exe - did you mean to include source?
Yes, no source. All changes were posted. I will take a look. Thanks

jhaglund2
Posts: 34
Joined: Mon Jan 16, 2017 5:28 pm

Re: Crafty 25.3 MSVS 2019

Post by jhaglund2 » Mon Sep 09, 2019 5:03 pm

In the previous successful attempt I must of switched src with old one (with elo_play & elo_play retracted).

tbprobe.c(28): fatal error C1083: Cannot open include file: 'stdatomic.h': No such file or directory
Halts there.

I forgot to mention I had to omit these in option.c
lines 923, 965, 1001 (old)

Code: Select all

 //  hash_table_size = ((1ull) << MSB(new_hash_size)) / 16;
 //  hash_path_size = ((1ull) << MSB(new_hash_size / sizeof(HPATH_ENTRY)));
 //  pawn_hash_table_size = 1ull << MSB(new_hash_size / sizeof(PAWN_HASH_ENTRY));
It seems doing the same things doesn't get rid of the errors.

crafty.obj : error LNK2001: unresolved external symbol @__builtin_popcountll@8
crafty.obj : error LNK2001: unresolved external symbol @__builtin_clzll@8
crafty.obj : error LNK2001: unresolved external symbol @__builtin_ctzll@8

Will look at it again later.

jdart
Posts: 3816
Joined: Fri Mar 10, 2006 4:23 am
Location: http://www.arasanchess.org

Re: Crafty 25.3 MSVS 2019

Post by jdart » Mon Sep 09, 2019 5:29 pm

tbprobe.c requires a C99 compiler. So for MSVC you need to specify that as the language, or compile that file as C++.

--Jon

jhaglund2
Posts: 34
Joined: Mon Jan 16, 2017 5:28 pm

Re: Crafty 25.3 MSVS 2019

Post by jhaglund2 » Mon Sep 09, 2019 5:44 pm

Update: It compiles the same, without TB.

Crafty 25.3 - VS 2019 source http://www.filedropper.com/crafty-253-vs2019

Crafty 25.3 - 64 CPU
crafty.zip
(239.18 KiB) Downloaded 49 times

jdart
Posts: 3816
Joined: Fri Mar 10, 2006 4:23 am
Location: http://www.arasanchess.org

Re: Crafty 25.3 MSVS 2019

Post by jdart » Tue Sep 10, 2019 1:06 am

I think it would be very helpful if this was hosted on a proper version control system such as Github. I know there was some unofficial hosting there but really it should be authorized by Bob. If that is done it is possible to submit patches via pull request. And there is a place to go for the latest code. Just IMO. I did not use version control for many, many years but since starting to, I have found it indispensable.

--JOn

Post Reply