official-stockfish / Stockfish

A free and strong UCI chess engine
https://stockfishchess.org/
GNU General Public License v3.0
11.33k stars 2.25k forks source link

SF build failed with mingw(msys 1.0) gcc 5.1.0 on Windows 32-bit #1948

Closed d3vv closed 5 years ago

d3vv commented 5 years ago
$ make build ARCH=x86-32

Config:
debug: 'no'
sanitize: 'no'
optimize: 'yes'
arch: 'i386'
bits: '32'
kernel: 'MINGW32_NT-5.2'
os: 'Windows_NT'
prefetch: 'yes'
popcnt: 'no'
sse: 'yes'
pext: 'no'

Flags:
CXX: g++
CXXFLAGS: -Wall -Wcast-qual -fno-exceptions -std=c++11  -pedantic -Wextra -Wshad
ow -m32 -DNDEBUG -O3 -msse -flto
LDFLAGS:  -m32 -Wl,--no-as-needed -lpthread -Wall -Wcast-qual -fno-exceptions -s
td=c++11  -pedantic -Wextra -Wshadow -m32 -DNDEBUG -O3 -msse -flto

Testing config sanity. If this fails, try 'make help' ...

make ARCH=x86-32 COMP=gcc all
make[1]: Entering directory `/home/dew/Stockfish-master/src'
g++ -Wall -Wcast-qual -fno-exceptions -std=c++11  -pedantic -Wextra -Wshadow -m3
2 -DNDEBUG -O3 -msse -flto   -c -o benchmark.o benchmark.cpp
g++ -Wall -Wcast-qual -fno-exceptions -std=c++11  -pedantic -Wextra -Wshadow -m3
2 -DNDEBUG -O3 -msse -flto   -c -o bitbase.o bitbase.cpp
g++ -Wall -Wcast-qual -fno-exceptions -std=c++11  -pedantic -Wextra -Wshadow -m3
2 -DNDEBUG -O3 -msse -flto   -c -o bitboard.o bitboard.cpp
g++ -Wall -Wcast-qual -fno-exceptions -std=c++11  -pedantic -Wextra -Wshadow -m3
2 -DNDEBUG -O3 -msse -flto   -c -o endgame.o endgame.cpp
g++ -Wall -Wcast-qual -fno-exceptions -std=c++11  -pedantic -Wextra -Wshadow -m3
2 -DNDEBUG -O3 -msse -flto   -c -o evaluate.o evaluate.cpp
g++ -Wall -Wcast-qual -fno-exceptions -std=c++11  -pedantic -Wextra -Wshadow -m3
2 -DNDEBUG -O3 -msse -flto   -c -o main.o main.cpp
g++ -Wall -Wcast-qual -fno-exceptions -std=c++11  -pedantic -Wextra -Wshadow -m3
2 -DNDEBUG -O3 -msse -flto   -c -o material.o material.cpp
g++ -Wall -Wcast-qual -fno-exceptions -std=c++11  -pedantic -Wextra -Wshadow -m3
2 -DNDEBUG -O3 -msse -flto   -c -o misc.o misc.cpp
misc.cpp:37:23: error: typedef 'fun1_t' is initialized (use decltype instead)
 typedef bool(*fun1_t)(LOGICAL_PROCESSOR_RELATIONSHIP,
                       ^
misc.cpp:37:23: error: 'LOGICAL_PROCESSOR_RELATIONSHIP' was not declared in this
 scope
misc.cpp:38:23: error: 'PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX' was not declar
ed in this scope
                       PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, PDWORD);
                       ^
misc.cpp:38:71: error: expected primary-expression before ')' token
                       PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, PDWORD);
                                                                       ^
misc.cpp:39:31: error: 'PGROUP_AFFINITY' has not been declared
 typedef bool(*fun2_t)(USHORT, PGROUP_AFFINITY);
                               ^
misc.cpp:40:37: error: 'GROUP_AFFINITY' does not name a type
 typedef bool(*fun3_t)(HANDLE, CONST GROUP_AFFINITY*, PGROUP_AFFINITY);
                                     ^
misc.cpp:40:54: error: 'PGROUP_AFFINITY' has not been declared
 typedef bool(*fun3_t)(HANDLE, CONST GROUP_AFFINITY*, PGROUP_AFFINITY);
                                                      ^
misc.cpp: In function 'int WinProcGroup::best_group(size_t)':
misc.cpp:241:16: error: 'fun1_t' was not declared in this scope
   auto fun1 = (fun1_t)(void(*)())GetProcAddress(k32, "GetLogicalProcessorInform
ationEx");
                ^
misc.cpp:241:24: error: expected primary-expression before 'void'
   auto fun1 = (fun1_t)(void(*)())GetProcAddress(k32, "GetLogicalProcessorInform
ationEx");
                        ^
misc.cpp:246:12: error: 'RelationAll' was not declared in this scope
   if (fun1(RelationAll, nullptr, &returnLength))
            ^
misc.cpp:250:3: error: 'SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX' was not declare
d in this scope
   SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *buffer, *ptr;
   ^
misc.cpp:250:44: error: 'buffer' was not declared in this scope
   SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *buffer, *ptr;
                                            ^
misc.cpp:250:53: error: 'ptr' was not declared in this scope
   SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *buffer, *ptr;
                                                     ^
misc.cpp:251:59: error: expected primary-expression before ')' token
   ptr = buffer = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*)malloc(returnLength)
;
                                                           ^
misc.cpp:254:13: error: 'RelationAll' was not declared in this scope
   if (!fun1(RelationAll, buffer, &returnLength))
             ^
misc.cpp:262:32: error: 'RelationNumaNode' was not declared in this scope
       if (ptr->Relationship == RelationNumaNode)
                                ^
misc.cpp:265:37: error: 'RelationProcessorCore' was not declared in this scope
       else if (ptr->Relationship == RelationProcessorCore)
                                     ^
misc.cpp:268:47: error: 'LTP_PC_SMT' was not declared in this scope
           threads += (ptr->Processor.Flags == LTP_PC_SMT) ? 2 : 1;
                                               ^
misc.cpp:273:54: error: expected primary-expression before ')' token
       ptr = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*)(((char*)ptr) + ptr->Size
);
                                                      ^
misc.cpp:240:11: warning: unused variable 'k32' [-Wunused-variable]
   HMODULE k32 = GetModuleHandle("Kernel32.dll");
           ^
misc.cpp: In function 'void WinProcGroup::bindThisThread(size_t)':
misc.cpp:316:3: error: 'GROUP_AFFINITY' was not declared in this scope
   GROUP_AFFINITY affinity;
   ^
misc.cpp:317:20: error: 'affinity' was not declared in this scope
   if (fun2(group, &affinity))
                    ^
make[1]: *** [misc.o] Error 1
make[1]: Leaving directory `/home/dew/Stockfish-master/src'
make: *** [build] Error 2
mcostalba commented 5 years ago

Please try to edit misc.cpp addingthe below line;

extern "C" {
  struct SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX; // Add this line!!!
  typedef bool(*fun1_t)(LOGICAL_PROCESSOR_RELATIONSHIP,
         PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, PDWORD);
d3vv commented 5 years ago

@mcostalba

g++ -Wall -Wcast-qual -fno-exceptions -std=c++11  -pedantic -Wextra -Wshadow -m3
2 -DNDEBUG -O3 -msse -flto   -c -o misc.o misc.cpp
misc.cpp:38:23: error: typedef 'fun1_t' is initialized (use decltype instead)
 typedef bool(*fun1_t)(LOGICAL_PROCESSOR_RELATIONSHIP,
                       ^
misc.cpp:38:23: error: 'LOGICAL_PROCESSOR_RELATIONSHIP' was not declared in this
 scope
misc.cpp:39:23: error: 'PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX' was not declar
ed in this scope
                       PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, PDWORD);
                       ^
misc.cpp:39:71: error: expected primary-expression before ')' token
                       PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, PDWORD);
                                                                       ^
misc.cpp:40:31: error: 'PGROUP_AFFINITY' has not been declared
 typedef bool(*fun2_t)(USHORT, PGROUP_AFFINITY);
                               ^
misc.cpp:41:37: error: 'GROUP_AFFINITY' does not name a type
 typedef bool(*fun3_t)(HANDLE, CONST GROUP_AFFINITY*, PGROUP_AFFINITY);
                                     ^
misc.cpp:41:54: error: 'PGROUP_AFFINITY' has not been declared
 typedef bool(*fun3_t)(HANDLE, CONST GROUP_AFFINITY*, PGROUP_AFFINITY);
                                                      ^
misc.cpp: In function 'int WinProcGroup::best_group(size_t)':
misc.cpp:242:16: error: 'fun1_t' was not declared in this scope
   auto fun1 = (fun1_t)(void(*)())GetProcAddress(k32, "GetLogicalProcessorInform
ationEx");
                ^
misc.cpp:242:24: error: expected primary-expression before 'void'
   auto fun1 = (fun1_t)(void(*)())GetProcAddress(k32, "GetLogicalProcessorInform
ationEx");
                        ^
misc.cpp:247:12: error: 'RelationAll' was not declared in this scope
   if (fun1(RelationAll, nullptr, &returnLength))
            ^
misc.cpp:255:13: error: 'RelationAll' was not declared in this scope
   if (!fun1(RelationAll, buffer, &returnLength))
             ^
misc.cpp:263:14: error: invalid use of incomplete type 'struct SYSTEM_LOGICAL_PR
OCESSOR_INFORMATION_EX'
       if (ptr->Relationship == RelationNumaNode)
              ^
misc.cpp:37:9: note: forward declaration of 'struct SYSTEM_LOGICAL_PROCESSOR_INF
ORMATION_EX'
  struct SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX; // Add this line!!!
         ^
misc.cpp:263:32: error: 'RelationNumaNode' was not declared in this scope
       if (ptr->Relationship == RelationNumaNode)
                                ^
misc.cpp:266:19: error: invalid use of incomplete type 'struct SYSTEM_LOGICAL_PR
OCESSOR_INFORMATION_EX'
       else if (ptr->Relationship == RelationProcessorCore)
                   ^
misc.cpp:37:9: note: forward declaration of 'struct SYSTEM_LOGICAL_PROCESSOR_INF
ORMATION_EX'
  struct SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX; // Add this line!!!
         ^
misc.cpp:266:37: error: 'RelationProcessorCore' was not declared in this scope
       else if (ptr->Relationship == RelationProcessorCore)
                                     ^
misc.cpp:269:26: error: invalid use of incomplete type 'struct SYSTEM_LOGICAL_PR
OCESSOR_INFORMATION_EX'
           threads += (ptr->Processor.Flags == LTP_PC_SMT) ? 2 : 1;
                          ^
misc.cpp:37:9: note: forward declaration of 'struct SYSTEM_LOGICAL_PROCESSOR_INF
ORMATION_EX'
  struct SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX; // Add this line!!!
         ^
misc.cpp:269:47: error: 'LTP_PC_SMT' was not declared in this scope
           threads += (ptr->Processor.Flags == LTP_PC_SMT) ? 2 : 1;
                                               ^
misc.cpp:273:24: error: invalid use of incomplete type 'struct SYSTEM_LOGICAL_PR
OCESSOR_INFORMATION_EX'
       byteOffset += ptr->Size;
                        ^
misc.cpp:37:9: note: forward declaration of 'struct SYSTEM_LOGICAL_PROCESSOR_INF
ORMATION_EX'
  struct SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX; // Add this line!!!
         ^
misc.cpp:274:74: error: invalid use of incomplete type 'struct SYSTEM_LOGICAL_PR
OCESSOR_INFORMATION_EX'
       ptr = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*)(((char*)ptr) + ptr->Size
);
                                                                          ^
misc.cpp:37:9: note: forward declaration of 'struct SYSTEM_LOGICAL_PROCESSOR_INF
ORMATION_EX'
  struct SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX; // Add this line!!!
         ^
misc.cpp:241:11: warning: unused variable 'k32' [-Wunused-variable]
   HMODULE k32 = GetModuleHandle("Kernel32.dll");
           ^
misc.cpp: In function 'void WinProcGroup::bindThisThread(size_t)':
misc.cpp:317:3: error: 'GROUP_AFFINITY' was not declared in this scope
   GROUP_AFFINITY affinity;
   ^
misc.cpp:318:20: error: 'affinity' was not declared in this scope
   if (fun2(group, &affinity))
                    ^
make[1]: *** [misc.o] Error 1
make[1]: Leaving directory `/home/dew/Stockfish-master/src'
make: *** [build] Error 2
d3vv commented 5 years ago

I have find out that my compiler has no LOGICAL_PROCESSOR_RELATIONSHIP declaration into winnt.h which assumed is used from windows.h by Stockfish developers.. I don't know if it is serious fault of compiler cause it can produce code for any win32 system since windows 95, ReactOS and etc.. In any cases we can understand now that minimal requirements for Stockfish it is:

Windows Vista, Windows XP Professional x64 Edition [desktop apps only] Windows Server 2003 [desktop apps only]

as described by document below:

https://docs.microsoft.com/en-us/windows/desktop/api/winnt/ne-winnt-_logical_processor_relationship