Chess For Android, DroidFish, and my issues

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

AndrewGrant
Posts: 1756
Joined: Tue Apr 19, 2016 6:08 am
Location: U.S.A
Full name: Andrew Grant

Re: Chess For Android, DroidFish, and my issues

Post by AndrewGrant »

The short form is not to use static linkage with regard to the C standard library. For my engine, I'm just linking dynamically for the Android version, and it works. In fact, the reason why the NDK has a totally outdated C standard library for static linkage is that nobody uses it.
I still do not know what you mean by this. I take that as "Compile without the -static flag, and it should just work on your phone", which is very much not the case. Where are the dlls I need ? Do I need dlls ? Should they already be on the phone ? Should I be targeting exactly one android version to ensure those dlls are present ?
#WeAreAllDraude #JusticeForDraude #RememberDraude #LeptirBigUltra
"Those who can't do, clone instead" - Eduard ( A real life friend, not this forum's Eduard )
Ras
Posts: 2488
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: Chess For Android, DroidFish, and my issues

Post by Ras »

Ok, so I tried it the other way around - I have built Ethereal 10.31 (without the range checks and other stuff) for Android ARM64, and I played a game under Droidfish against it. Works without problems, both with 1 thread and with 4 threads. OS is Android 8.0. Dynamic linkage.

When I use the "file" command (under Cygwin), I get the following output on the binary:

Code: Select all

ethereal_1031_x64: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /system/bin/linker64, stripped
Here is my build script - for Windows, but should be similar under Linux:

Code: Select all

@echo off

rem currently, Android NDK r16b has been used with the standalone toolchain generated with:
rem make_standalone_toolchain.py --arch arm64 --api 21 --install-dir c:\android-standalone-64
rem the script make_standalone_toolchain.py is in the NDK under: build\tools

set "compiler_path_64=C:\android-standalone-64\bin"
set "compiler_64=%compiler_path_64%\clang"
set "OLD_PATH=%PATH%"
set "PATH=%compiler_path_64%;%OLD_PATH%"
echo Generating Ethereal 64 bit for ARM-Android.
set "compiler_options=-m64 -march=armv8-a -pie -fPIE -Wl,-pie -Wall -Wextra -Werror -O2 -std=c11 -lm -fno-strict-aliasing -fno-strict-overflow -ffunction-sections -fdata-sections -Wl,--gc-sections -Wl,-s"
cmd /c "%compiler_64%" %compiler_options% -o ethereal_1031_x64 *.c fathom\tbprobe.c

pause
I have zipped the build script and the generated Ethereal ARM64 binary here:
https://www.ct800.net/download/ethereal.zip

Can you test the binary whether you can run it? Can you configure your NDK buildchain with the same settings?
Rasmus Althoff
https://www.ct800.net
Ras
Posts: 2488
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: Chess For Android, DroidFish, and my issues

Post by Ras »

AndrewGrant wrote: Mon Jul 02, 2018 6:05 amI take that as "Compile without the -static flag, and it should just work on your phone", which is very much not the case.
It is, at least with the NDK - I just tested it. Please note that I didn't install anything on the Android 8.0 phone, except Droidfish via the store, and I just copied over the engine's executable via USB. Of course, my engine's executable was already there, but I also had just copied it over. Means, nothing special installed.
Where are the dlls I need ? Do I need dlls ? Should they already be on the phone ?
The C standard library is already there. Otherwise, every little system executable would need static linkage, and that would bloat the system.
Should I be targeting exactly one android version to ensure those dlls are present ?
You just need to target API level 21 for 64 bit, corresponding to Android 5.0, because this is the minimum where position independent code works. Newer Androids require position independent code, or else they will refuse to run the executable. So the generated executable will run on Android 5.0 or newer.
Rasmus Althoff
https://www.ct800.net
User avatar
abik
Posts: 819
Joined: Fri Dec 01, 2006 10:46 pm
Location: Mountain View, CA, USA
Full name: Aart Bik

Re: Chess For Android, DroidFish, and my issues

Post by abik »

I was about to make a proper binary for you, but Rasmus beat me to it. His binary, which is somewhat humorously called "ethereal_1031_x64", runs fine on recent arm-based Android versions. Let me know if you want me to test other versions.
AndrewGrant
Posts: 1756
Joined: Tue Apr 19, 2016 6:08 am
Location: U.S.A
Full name: Andrew Grant

Re: Chess For Android, DroidFish, and my issues

Post by AndrewGrant »

Success!

Okay -- so here was the crucial issue. So I was unable to run the binary provided by Rasmus. Which leads me to believe I cannot run 64 bit binaries ... even though I have in the past built and run using -march=armv8-a. So I Followed the original instructions for building for 32 bit, which produced a binary and runs, and thus far works without issue.

So while I cannot test the 64bit one's I will produce, I am fairly confident that if I follow the instructions Rasmus provided, then I will get a working end product. Furthermoe, this shores up my concerns about Ethereal being the issue, which was driving me absolutely insane.

Thanks to both of you for your time and patience. All this Android business really has me out of my element.

However, I am still insane, so I will be playing games for the next hour or so just to be certain.
#WeAreAllDraude #JusticeForDraude #RememberDraude #LeptirBigUltra
"Those who can't do, clone instead" - Eduard ( A real life friend, not this forum's Eduard )