Google Play New problem : 64bits

All topics about ZGameEditor goes here.

Moderator: Moderators

Post Reply
User avatar
Ats
Posts: 769
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Google Play New problem : 64bits

Post by Ats »

Hi everyone,

I just received a new email from Google Play asking my apk to have a 64bits version by August. Or else...
- Or else?
- Exactly

Details here: https://android-developers.googleblog.c ... 4-bit.html

In order to compile a 64bits apk from ZGE, do I have something to do in ZGE, or is it just some boxes to check in the Android SDK/NDK/wathever... ?

It feels like I spend my time repairing my game for that kind of turnover instead of working on the game itself... :roll:
User avatar
VilleK
Site Admin
Posts: 2358
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: Google Play New problem : 64bits

Post by VilleK »

Hi,

If you have the time then please try setting up Freepascal to output Android 64-bit target (yes this likely requires you to redo most of the steps you did last time to set up Freepascal). Then I can help with any errors you get when trying to build ZGE.

Areas in ZGE that may need attention for Android 64-bit: NanoJpeg.pas has a asm-function (needed if your game uses jpeg images), ZExpression.pas asm-code to call external modules from ZGE scripting. So if your game calls OpenGL or other native lib directly we need to adapt that code in ZGE too.
User avatar
Ats
Posts: 769
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: Google Play New problem : 64bits

Post by Ats »

So today I'm feeling a bit motivated to attack that. How should I setup Freepascal to output Android 64 bits ?
I supposed it should be here?

Code: Select all

make clean crossall crossinstall OS_TARGET=android CPU_TARGET=arm CROSSOPT="-dANDROID -CpARMv6 -CfVFPv2"
from my Android setup environment tutorial
User avatar
VilleK
Site Admin
Posts: 2358
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: Google Play New problem : 64bits

Post by VilleK »

I think you should use "aarch64" as CPU_TARGET. Try that to begin with :)
User avatar
Ats
Posts: 769
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: Google Play New problem : 64bits

Post by Ats »

Noob question before I break everything:
Since I have to build Free Pascal trunk first, and then build Free Pascal cross Android Trunk, and since it take quite a lot of time to do that, can I just build android 64 over the previous two, or should I make a new output folder and build fp and fp android 64 in it?
User avatar
VilleK
Site Admin
Posts: 2358
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: Google Play New problem : 64bits

Post by VilleK »

I think other platforms cross compilers need to be built with specific Fpc build. So you can install standard Fpc (latest distribution 3.0.4) and then use that to build your crosscompiler.
User avatar
Ats
Posts: 769
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: Google Play New problem : 64bits

Post by Ats »

All right. And what should I replace argument -CpARMv6 with?
(because it breaks everything)

Code: Select all

C:/FPC/fpc/compiler/ppcrossa64.exe -Ur -Tandroid -Paarch64 -XPaarch64-linux-android- -Xr -Ur -Xs -O2 -n -Fi../inc -Fi../aarch64 -Fi../unix -Fiaarch64 -Fi../linux -Fi../linux/aarch64 -FE. -FUC:/FPC/fpc/rtl/units/aarch64-android -daarch64 -dRELEASE -dANDROID -CpARMv6 -CfVFPv2  -Us -Sg ../linux/system.pp
Error: Illegal parameter: -CpARMv6
make[4]: *** [system.ppu] Error 1
make[4]: Leaving directory `C:/FPC/fpc/rtl/android'
make[3]: *** [android_all] Error 2
make[3]: Leaving directory `C:/FPC/fpc/rtl'
make[2]: *** [rtl_all] Error 2
make[2]: Leaving directory `C:/FPC/fpc'
make[1]: *** [build-stamp.aarch64-android] Error 2
make[1]: Leaving directory `C:/FPC/fpc'
make: *** [crossall] Error 2
User avatar
VilleK
Site Admin
Posts: 2358
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: Google Play New problem : 64bits

Post by VilleK »

For now, try removing "-CpARMv6 -CfVFPv2". Because I think they are only relevant for 32-bit.
User avatar
Ats
Posts: 769
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: Google Play New problem : 64bits

Post by Ats »

Ok, it worked. Now, to ZGE :)
What should I change in those 3 lines?

Code: Select all

if not exist "java\libs\armeabi\" mkdir java\libs\armeabi
if not exist "lib\arm-linux\" mkdir lib\arm-linux

C:\FPC\trunk\bin\i386-win32\ppcrossarm -B -MDelphi -Sghi -O3 -Tandroid -Parm -XXis -vw -Filib\arm-linux -FlC:\Android\android-ndk-r18b\platforms\android-26\arch-arm\usr\lib -Fu. -Fu..\.. -FUlib\arm-linux\ -FEjava\libs\armeabi\ -olibzgeandroid.so -dANDROID -dMINIMAL -Xd -CpARMV6 -CfVFPv2 zgeandroid.pas
I suppose android-26\arch-arm\usr\lib is replaced by android-26\arch-arm64\usr\lib, but what about lib\arm-linux and armeabi?
User avatar
VilleK
Site Admin
Posts: 2358
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: Google Play New problem : 64bits

Post by VilleK »

It seems "armeabi" should be replaced with "arm64-v8a".

And remove "-CpARMV6 -CfVFPv2" here also.

What happens if you try that?
User avatar
Ats
Posts: 769
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: Google Play New problem : 64bits

Post by Ats »

It seems the previous step didn't produce the needed ppcrossarm.exe
It is present in the trunk(32)\bin\i386-win32 but not in the trunk64\bin\i386-win32 folder.
User avatar
VilleK
Site Admin
Posts: 2358
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: Google Play New problem : 64bits

Post by VilleK »

If the build step finished ok then you should have an updated ppcrossarm.exe somewhere. Perhaps search the whole folder tree for it?
User avatar
Ats
Posts: 769
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: Google Play New problem : 64bits

Post by Ats »

I'm back and I managed to find why I couldn't find ppcrossarm.exe, it's because it's named ppcrossa64.exe
Here's the new error:

Code: Select all

C:\zgameeditor-master\Build\android>C:\FPC\a64\bin\i386-win32\ppcrossa64 -B -MDelphi -Sghi -O3 -Tandroid -Parm -XXis -vw -Filib\arm-linux -FlC:\Android\android-ndk-r18b\platforms\android-28\arch-arm64\usr\lib -Fu. -Fu..\.. -FUlib\arm-linux\ -FEjava\libs\arm64-v8a\ -olibzgeandroid.so -dANDROID -dMINIMAL -Xd zgeandroid.pas
Error: Unsupported target architecture -Parm, invoke the "fpc" compiler driver instead.
So I listed the options of ppcrossa64.exe but there is no -P, only -pg (Generate profile code for gprof (defines FPC_PROFILE))
By the way, that option does not appear in ppcrossarm.exe too, so I just removed it and got a brand-new error:

Code: Select all

C:\zgameeditor-master\Build\android>C:\FPC\a64\bin\i386-win32\ppcrossa64 -B -MDelphi -Sghi -O3 -Tandroid -XXis -vw -Filib\arm-linux -FlC:\Android\android-ndk-r18b\platforms\android-28\arch-arm64\usr\lib -Fu. -Fu..\.. -FUlib\arm-linux\ -FEjava\libs\arm64-v8a\ -olibzgeandroid.so -dANDROID -dMINIMAL -Xd zgeandroid.pas
jni.pas(539) Error: Assembler aarch64-linux-android-as.exe not found, switching to external assembling
I don't know what to do as that file is nowhere to be found...

Edit: oh! It should be in the android toolchain, not in the FPC folder. I'm on it!
Last edited by Ats on Fri Jul 19, 2019 12:04 am, edited 1 time in total.
User avatar
Ats
Posts: 769
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: Google Play New problem : 64bits

Post by Ats »

So I had to add

Code: Select all

Path C:\Android\android-ndk-r18b\toolchains\aarch64-linux-android-4.9\prebuilt\windows-x86_64\bin
in m.bat (the one to make ZGE)

Here's the new error log:

Code: Select all

ZClasses.pas(585,5) Warning: Constructor should be public
ZMath.pas(652,1) Warning: Function result variable does not seem to be initialized
GLDrivers.pas(572,32) Warning: Conversion between ordinals and pointers is not portable
GLDrivers.pas(577,43) Warning: Conversion between ordinals and pointers is not portable
GLDrivers.pas(586,40) Warning: Conversion between ordinals and pointers is not portable
GLDrivers.pas(949,54) Warning: Conversion between ordinals and pointers is not portable
GLDrivers.pas(955,63) Warning: Conversion between ordinals and pointers is not portable
GLDrivers.pas(962,56) Warning: Conversion between ordinals and pointers is not portable
ZApplication.pas(1105,8) Warning: Conversion between ordinals and pointers is not portable
Renderer.pas(805,17) Warning: Converting pointers to signed integers may result in wrong comparison results and range errors, use an unsigned type instead.
Renderer.pas(972,23) Warning: Local variable "TextBuf" does not seem to be initialized
Renderer.pas(1465,20) Warning: Converting pointers to signed integers may result in wrong comparison results and range errors, use an unsigned type instead.
Renderer.pas(1466,20) Warning: Converting pointers to signed integers may result in wrong comparison results and range errors, use an unsigned type instead.
Renderer.pas(1606,66) Warning: Local variable "ScaledGravity" does not seem to be initialized
ZExpressions.pas(649,5) Warning: Function result variable does not seem to be initialized
ZExpressions.pas(1901,28) Warning: Local variable "Dest" does not seem to be initialized
ZExpressions.pas(2039,15) Warning: Arithmetic "+" on untyped pointer is unportable to {$T+}, suggest typecast
ZExpressions.pas(2042,13) Error: Unknown identifier "R0"
ZExpressions.pas(2043,13) Error: Unknown identifier "R1"
ZExpressions.pas(2044,13) Error: Unknown identifier "R3"
ZExpressions.pas(2046,13) Error: Unknown identifier "R2"
ZExpressions.pas(2046,16) Error: Invalid reference syntax
ZExpressions.pas(2046,22) Fatal: Internal error 2014122002
I tried to take a look at ZExpressions.pas, but those are assembly lines to make direct calls at ARM, so I'm a bit in a haze... :shock:

Edit: After reading through https://en.wikipedia.org/wiki/Calling_convention#ARM
I would gladly replace r0-3 by x0-3, and r4 by x9, just for the fun of trying, but I don't find a replacement for r13 (stack pointer) in arm64...

Edit 2: So I suppose r13 equals x29. I'm going to try that!
... and it seems to work. Now I have a problem with two mnemonics:

Code: Select all

ZExpressions.pas(2051,7) Error: Unrecognized opcode bgt
ZExpressions.pas(2051,11) Error: Assembler syntax error
ZExpressions.pas(2062,5) Error: Unrecognized opcode blx
ZExpressions.pas(2062,9) Error: Assembler syntax error
User avatar
VilleK
Site Admin
Posts: 2358
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: Google Play New problem : 64bits

Post by VilleK »

Hi, nice progress!

Does your project make direct OpenGL calls from ZGE scripting? If not, then you would not need to adapt the ZExpression TExternalFunctionCall for now and could just comment it out.

You could try compiling a short program and keep the resulting assembly code with "-al" option.

Code: Select all

program test;

procedure f(x1,x2 : integer);
begin
  writeln('test');
end;

begin
  f(1,2);
end.
Then you should find "test.s" in the output folder, and you can post that file here.
Post Reply