lucasart / Demolito

UCI Chess Engine
GNU General Public License v3.0
45 stars 9 forks source link

Can't compile #156

Closed iandoug closed 4 years ago

iandoug commented 5 years ago

Hi

Something on my system, or something broken? Using gcc on Linux AMD64. Gentoo.

/chess/Demolito-master $ make fatal: not a git repository (or any parent up to mount point /) Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set). gcc -march=native -DPEXT -std=gnu11 -DNDEBUG -O3 -flto -Wfatal-errors -Wall -Wextra -Wshadow -DVERSION=\"\" ./src/*.c -o demolito -s -lm -lpthread In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/immintrin.h:95, from ./src/bitboard.c:20: ./src/bitboard.c: In function ‘slider_index’: /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/bmi2intrin.h:76:1: error: inlining failed in call to always_inline ‘_pext_u64’: target specific option mismatch _pext_u64 (unsigned long long __X, unsigned long long __Y) ^~~~~~~~~ compilation terminated due to -Wfatal-errors. ./src/search.c: In function ‘search_go’: ./src/search.c:617:43: warning: cast between incompatible function types from ‘void (*)(Worker *)’ {aka ‘void (*)(struct <anonymous> *)’} to ‘void * (*)(void *)’ [-Wcast-function-type] pthread_create(&threads[i], NULL, (void*(*)(void*))iterate, &Workers[i]); ^ ./src/uci.c: In function ‘go’: ./src/uci.c:146:34: warning: cast between incompatible function types from ‘int64_t (*)()’ {aka ‘long int (*)()’} to ‘void * (*)(void *)’ [-Wcast-function-type] pthread_create(&Timer, NULL, (void*(*)(void*))search_go, NULL); ^ make: *** [makefile:20: all] Error 1

Thanks, Ian

lucasart commented 5 years ago

As the error message suggest: not a git repository. Did you download it with git clone?

iandoug commented 5 years ago

Whoops, I saw the error message but did not "click" what it meant.... I normally just download the .zip and it works.

Anyway, did a git clone, then default makefile produced this:

~/chess/Demolito (master) $ make clang -march=native -DPEXT -std=gnu11 -DNDEBUG -O3 -flto -Wfatal-errors -Wall -Wextra -Wshadow -DVERSION=\"2019-11-03\" ./src/*.c -o demolito -s -lm -lpthread ./src/bitboard.c:106:12: fatal error: always_inline function '_pext_u64' requires target feature 'bmi2', but would be inlined into function 'slider_index' that is compiled without support for 'bmi2' return _pext_u64(occ, mask); ^ 1 error generated. make: *** [makefile:20: all] Error 1

So I tried using gcc instead of clang, which produced this:

~/chess/Demolito (master) $ make gcc -march=native -DPEXT -std=gnu11 -DNDEBUG -O3 -flto -Wfatal-errors -Wall -Wextra -Wshadow -DVERSION=\"2019-11-03\" ./src/.c -o demolito -s -lm -lpthread In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/immintrin.h:95, from ./src/bitboard.c:20: ./src/bitboard.c: In function ‘slider_index’: /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/bmi2intrin.h:76:1: error: inlining failed in call to always_inline ‘_pext_u64’: target specific option mismatch _pext_u64 (unsigned long long X, unsigned long long Y) ^~~~~ compilation terminated due to -Wfatal-errors. ./src/search.c: In function ‘search_go’: ./src/search.c:617:43: warning: cast between incompatible function types from ‘void ()(Worker )’ {aka ‘void ()(struct )’} to ‘void ()(void )’ [-Wcast-function-type] pthread_create(&threads[i], NULL, (void()(void))iterate, &Workers[i]); ^ ./src/uci.c: In function ‘go’: ./src/uci.c:146:34: warning: cast between incompatible function types from ‘int64_t ()()’ {aka ‘long int ()()’} to ‘void ()(void )’ [-Wcast-function-type] pthread_create(&Timer, NULL, (void()(void*))search_go, NULL); ^ make: *** [makefile:20: all] Error 1

Is this some issue with my system?

Thanks, Ian

lucasart commented 5 years ago

march=native tells the compiler to auto detect CPU features. It turns out that your CPU doesn't have BMI2 instructions. That's ok, just remove -DPEXT and it should work. Demolito will use a fallback technique called magic bitboards instead of hardware instruction PEXT to compute attacks for sliding pieces. A bit slower, but still quite fast.

I should probably make my makefile smarter, and do the auto detect there. But with somany architectures, OS, compilers, libc, etc. it's a real pain.

lucasart commented 5 years ago

Note that windows compiles are produced automatically with each commit, using appveyor. No need to compile for windows users.

iandoug commented 5 years ago

Thanks, compiles and works. Did produce these errors:

~/chess/Demolito (master) $ make gcc -march=native -std=gnu11 -DNDEBUG -O3 -flto -Wfatal-errors -Wall -Wextra -Wshadow -DVERSION=\"2019-11-03\" ./src/.c -o demolito -s -lm -lpthread ./src/search.c: In function ‘search_go’: ./src/search.c:617:43: warning: cast between incompatible function types from ‘void ()(Worker )’ {aka ‘void ()(struct )’} to ‘void ()(void )’ [-Wcast-function-type] pthread_create(&threads[i], NULL, (void()(void))iterate, &Workers[i]); ^ ./src/uci.c: In function ‘go’: ./src/uci.c:146:34: warning: cast between incompatible function types from ‘int64_t ()()’ {aka ‘long int ()()’} to ‘void ()(void )’ [-Wcast-function-type] pthread_create(&Timer, NULL, (void()(void*))search_go, NULL);

Cheers, Ian

lucasart commented 5 years ago

Yes, I know. These warnings are benign, and related to non standard function pointer casting, which are correct and done with intent.