lukasmonk / lucaschessR2

Lucas Chess R Version 2
GNU General Public License v3.0
255 stars 36 forks source link

feature request: arm64 support #71

Closed ernia666 closed 1 year ago

ernia666 commented 1 year ago

Hi, i'm an happy linux amd64 user, i would like to have Lucas Chess in a raspberry pi 4 too but i can't build it. I'm not a developer, i tried to build on Manjaro arm which has Pyside2 as a package (no pyside2 wheel for arm64 and debian package does not get detected by pip when installing requirements) but there is a problem in bin/_fastercode/source/irina/util.c, it builts but at runtime says :

File "/usr/lib/python3.10/site-packages/shiboken2/files.dir/shibokensupport/feature.py", line 139, in _import return original_import(name, *args, **kwargs) ImportError: /home/fabio/lucaschess/bin/OS/linux/FasterCode.cpython-310-aarch64-linux-gnu.so: undefined symbol: __builtin_cpu_supports

Maybe gcc on arm64 does not support that method and does not return a value. If i hack util.c at line 19 into

int is_bmi2() { //builtin_cpu_init (); //return builtin_cpu_supports("bmi2"); return 0; } Lucas Chess runs but disappear and i get this bug.log

File "/home/fabio/lucaschess/bin/Code/Sound/Sound.py", line 139, in relations add("MC", _("Beep after move"), "BEEP") TypeError: 'NoneType' object is not callable

I think this is due to the processor that does not return something but i don't have the skills to understand it so here i am :-) Thanks for the time taken to read this and for your program. Fabio

lukasmonk commented 1 year ago

Code is python 3.7/3.8 compatible.

ernia666 commented 1 year ago

Hi, i tried with the irina util.c hack from my previous post, pyenv with python 3.7.16, rebuilding and installing the manjaro pyside2 packages against the pyenv python, same output:

[fabio@manberry lucaschess]$ python -V Python 3.7.16

[fabio@manberry lucaschess]$ pip install -r requirements.txt Requirement already satisfied: chardet>=3.0.4 in /home/fabio/.pyenv/versions/3.7.16/lib/python3.7/site-packages (from -r requirements.txt (line 1)) (5.1.0) Requirement already satisfied: sortedcontainers>=2.1.0 in /home/fabio/.pyenv/versions/3.7.16/lib/python3.7/site-packages (from -r requirements.txt (line 2)) (2.4.0) Requirement already satisfied: python-chess>=0.28.3 in /home/fabio/.pyenv/versions/3.7.16/lib/python3.7/site-packages (from -r requirements.txt (line 3)) (1.999) Requirement already satisfied: pillow>=7.0.0 in /home/fabio/.pyenv/versions/3.7.16/lib/python3.7/site-packages (from -r requirements.txt (line 4)) (9.4.0) Requirement already satisfied: pyside2>=5.14.0 in /home/fabio/.pyenv/versions/3.7.16/lib/python3.7/site-packages (from -r requirements.txt (line 5)) (5.15.8) Requirement already satisfied: cython>=0.29.14 in /home/fabio/.pyenv/versions/3.7.16/lib/python3.7/site-packages (from -r requirements.txt (line 6)) (0.29.33) Requirement already satisfied: psutil>=5.8.0 in /home/fabio/.pyenv/versions/3.7.16/lib/python3.7/site-packages (from -r requirements.txt (line 7)) (5.9.4) Requirement already satisfied: polib>=1.1.1 in /home/fabio/.pyenv/versions/3.7.16/lib/python3.7/site-packages (from -r requirements.txt (line 8)) (1.1.1) Requirement already satisfied: chess<2,>=1 in /home/fabio/.pyenv/versions/3.7.16/lib/python3.7/site-packages (from python-chess>=0.28.3->-r requirements.txt (line 3)) (1.9.4) Requirement already satisfied: shiboken2==5.15.8 in /home/fabio/.pyenv/versions/3.7.16/lib/python3.7/site-packages (from pyside2>=5.14.0->-r requirements.txt (line 5)) (5.15.8)

[fabio@manberry lucaschess]$ cd bin/_fastercode && chmod a+x ./linux64.sh && ./linux64.sh

:: Building FasterCode

lc.c: In function ‘pgn2pv’: lc.c:169:29: warning: ‘sprintf’ argument 3 overlaps destination object ‘pv’ [-Wrestrict] 169 | if( promotion ) sprintf(pv, "%s%c", pv, promotion); | ^~~~~~~~~~ lc.c:13:30: note: destination object referenced by ‘restrict’-qualified argument 1 was declared here 13 | int pgn2pv(char pgn, char pv) | ~~~^~ lc.c: In function ‘get_move’: lc.c:211:26: warning: ‘sprintf’ argument 3 overlaps destination object ‘pv’ [-Wrestrict] 211 | if( move.promotion ) sprintf(pv, "%s%c", pv, tolower(NAMEPZ[move.promotion])); | ^~~~~~~~~~~~ lc.c:206:32: note: destination object referenced by ‘restrict’-qualified argument 1 was declared here 206 | void get_move( int num, char pv ) | ~~~^~ lc.c: In function ‘get_move_ex’: lc.c:255:5: warning: ‘sprintf’ argument 3 overlaps destination object ‘info’ [-Wrestrict] 255 | sprintf(info, "%s%c%c%c", info, promotion, castle, en_passant); | ^~~~~~~~~~~~~~ lc.c:236:35: note: destination object referenced by ‘restrict’-qualified argument 1 was declared here 236 | void get_move_ex( int num, char info ) | ~^~ lc.c: In function ‘to_san’: lc.c:306:25: warning: ‘sprintf’ argument 3 overlaps destination object ‘san_move’ [-Wrestrict] 306 | if( is_amb_ah ) sprintf(san_move,"%s%c", san_move, POS_AH[move.from][0]); | ^~~~~~~~~~~~ lc.c:258:30: note: destination object referenced by ‘restrict’-qualified argument 1 was declared here 258 | char to_san(int num, char san_move) | ~~^~~~ lc.c:307:25: warning: ‘sprintf’ argument 3 overlaps destination object ‘san_move’ [-Wrestrict] 307 | if( is_amb_18 ) sprintf(san_move,"%s%c", san_move, POS_AH[move.from][1]); | ^~~~~~~~~~~~ lc.c:258:30: note: destination object referenced by ‘restrict’-qualified argument 1 was declared here 258 | char to_san(int num, char san_move) | ~~^~~~ lc.c:308:26: warning: ‘sprintf’ argument 3 overlaps destination object ‘san_move’ [-Wrestrict] 308 | if(move.capture) sprintf(san_move,"%sx", san_move); | ^~~~~~~~~ lc.c:258:30: note: destination object referenced by ‘restrict’-qualified argument 1 was declared here 258 | char to_san(int num, char san_move) | ~~^~~~ lc.c:309:9: warning: ‘sprintf’ argument 3 overlaps destination object ‘san_move’ [-Wrestrict] 309 | sprintf(san_move,"%s%s", san_move, POS_AH[move.to]); | ^~~~~~~~~~~ lc.c:258:30: note: destination object referenced by ‘restrict’-qualified argument 1 was declared here 258 | char to_san(int num, char san_move) | ~~^~~~ lc.c:288:13: warning: ‘sprintf’ argument 3 overlaps destination object ‘san_move’ [-Wrestrict] 288 | sprintf(san_move, "%s=%c", san_move, toupper(NAMEPZ[move.promotion])); | ^~~~~~~~~~~~~~~~~ lc.c:258:30: note: destination object referenced by ‘restrict’-qualified argument 1 was declared here 258 | char to_san(int num, char san_move) | ~~^~~~ lc.c:318:13: warning: ‘sprintf’ argument 3 overlaps destination object ‘san_move’ [-Wrestrict] 318 | sprintf(san_move,"%s+", san_move); | ^~~~~~~~~ lc.c:258:30: note: destination object referenced by ‘restrict’-qualified argument 1 was declared here 258 | char to_san(int num, char san_move) | ~~^~~~ lc.c:316:13: warning: ‘sprintf’ argument 3 overlaps destination object ‘san_move’ [-Wrestrict] 316 | sprintf(san_move,"%s#", san_move); | ^~~~~~~~~ lc.c:258:30: note: destination object referenced by ‘restrict’-qualified argument 1 was declared here 258 | char to_san(int num, char san_move) | ~~^~~~ board.c: In function ‘board_fen’: board.c:250:5: warning: ‘sprintf’ argument 3 overlaps destination object ‘fen’ [-Wrestrict] 250 | sprintf(fen, "%s %d %d", fen, board.fifty, board.fullmove); | ^~~~~~~~~~~~~~ board.c:191:23: note: destination object referenced by ‘restrict’-qualified argument 1 was declared here 191 | char board_fen(char fen) { | ~~^~~ util.c: In function ‘get_ms’: util.c:71:5: warning: ‘ftime’ is deprecated: Use gettimeofday or clock_gettime instead [-Wdeprecated-declarations] 71 | ftime(&buffer); | ^~~~~ In file included from util.c:2: /usr/include/sys/timeb.h:29:12: note: declared here 29 | extern int ftime (struct timeb *__timebuf) | ^~~~~ parser.c: In function ‘parse_pgn’: parser.c:71:13: warning: ‘strncpy’ output may be truncated copying 63 bytes from a string of length 255 [-Wstringop-truncation] 71 | strncpy(fen, value, 63); | ^~~~~~~ Compiling FasterCode.pyx because it changed. [1/1] Cythonizing FasterCode.pyx running build_ext building 'FasterCode' extension creating build creating build/temp.linux-aarch64-3.7 gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/home/fabio/.pyenv/versions/3.7.16/include/python3.7m -c FasterCode.c -o build/temp.linux-aarch64-3.7/FasterCode.o gcc -shared -L/home/fabio/.pyenv/versions/3.7.16/lib -Wl,-rpath=/home/fabio/.pyenv/versions/3.7.16/lib -L/home/fabio/.pyenv/versions/3.7.16/lib -Wl,-rpath=/home/fabio/.pyenv/versions/3.7.16/lib build/temp.linux-aarch64-3.7/FasterCode.o -L. -L/home/fabio/.pyenv/versions/3.7.16/lib -lirina -lpython3.7m -o /home/fabio/lucaschess/bin/_fastercode/source/FasterCode.cpython-37m-aarch64-linux-gnu.so

:: Building Complete

[fabio@manberry _fastercode]$ cd ~/lucaschess/bin/_genicons/ [fabio@manberry _genicons]$ python gentema.py [fabio@manberry _genicons]$ cd ~/lucaschess/bin [fabio@manberry bin]$ chmod a+x LucasR.py [fabio@manberry bin]$ ./LucasR.py [fabio@manberry bin]$ cat bug.log Version R 2.05d Traceback (most recent call last): File "./LucasR.py", line 19, in Code.Base.Init.init() File "/home/fabio/lucaschess/bin/Code/Base/Init.py", line 19, in init resp = Gui.run_gui(main_procesador) File "/home/fabio/lucaschess/bin/Code/MainWindow/Gui.py", line 35, in run_gui procesador.start_with_user(user) File "/home/fabio/lucaschess/bin/Code/Procesador.py", line 121, in start_with_user Code.runSound.read_sounds() File "/home/fabio/lucaschess/bin/Code/Sound/Sound.py", line 104, in read_sounds self.write_sounds() File "/home/fabio/lucaschess/bin/Code/Sound/Sound.py", line 82, in write_sounds wav = self.relations[key]["WAVKEY"] + ".wav" File "/home/fabio/lucaschess/bin/Code/Sound/Sound.py", line 139, in relations add("MC", ("Beep after move"), "BEEP") TypeError: 'NoneType' object is not callable

For me it's like trying to defeat Magnus Carlsen, very out of my reach :-) Please, let me know if i'm doing something wrong and if i can help somehow. Thank you

ernia666 commented 1 year ago

This is bug.log if i don't hack util.c :

[fabio@manberry bin]$ ./LucasR.py Traceback (most recent call last): File "./LucasR.py", line 17, in import Code.Base.Init File "/home/fabio/lucaschess/bin/Code/Base/Init.py", line 5, in from Code import Procesador File "/home/fabio/lucaschess/bin/Code/Procesador.py", line 10, in from Code import ManagerEntPos File "/home/fabio/.pyenv/versions/3.7.16/lib/python3.7/site-packages/shiboken2/files.dir/shibokensupport/feature.py", line 139, in _import return original_import(name, *args, kwargs) File "/home/fabio/lucaschess/bin/Code/ManagerEntPos.py", line 5, in from Code import FNSLine File "/home/fabio/.pyenv/versions/3.7.16/lib/python3.7/site-packages/shiboken2/files.dir/shibokensupport/feature.py", line 139, in _import return original_import(name, *args, *kwargs) File "/home/fabio/lucaschess/bin/Code/FNSLine.py", line 1, in from Code.Base import Game, Position File "/home/fabio/.pyenv/versions/3.7.16/lib/python3.7/site-packages/shiboken2/files.dir/shibokensupport/feature.py", line 139, in _import return original_import(name, args, kwargs) File "/home/fabio/lucaschess/bin/Code/Base/Game.py", line 1, in import FasterCode File "/home/fabio/.pyenv/versions/3.7.16/lib/python3.7/site-packages/shiboken2/files.dir/shibokensupport/feature.py", line 139, in _import return original_import(name, *args, **kwargs) ImportError: /home/fabio/lucaschess/bin/OS/linux/FasterCode.cpython-37m-aarch64-linux-gnu.so: undefined symbol: __builtin_cpu_supports

Thank you again

lukasmonk commented 1 year ago

Once compiled FasterCode, removing __builtin_cpusupports, as indicated in the first message, the problem is that it has not loaded the function that does the translations, and I don't know the reason.

ernia666 commented 1 year ago

Ok, i give up, thank you for your time. Fabio