Recent

Author Topic: Jni test ( arm ok, x86 crash ) How to solve ?  (Read 25638 times)

simonsayz

  • New Member
  • *
  • Posts: 27
Re: Jni test ( arm ok, x86 crash ) How to solve ?
« Reply #15 on: December 17, 2013, 07:58:07 pm »
@lenz

Really, Really Thanks. :)

It works on Android-x86 and real device.

[Test Result]XP-32bi      : Compiling OK
Win7-64bit : Compiling with Error
                    "Fatal: Can't find unit system used by BuildUnit_bzip2".

Same Code , But Different Results.
But, It really works with X86 so only on X86 Device without libhoudini support.

[My Guess]
Recent FPC 2.7.1 svn may be broken to support X86 android

Thanks again.

Best Regards
Simon,Choi

lenz

  • New Member
  • *
  • Posts: 17
Re: Jni test ( arm ok, x86 crash ) How to solve ?
« Reply #16 on: December 17, 2013, 08:45:03 pm »
I could also succeed to avoid SIGSEGV by using Engkin's suggestions, many thanks! Though in my case it crashed later on during initialization of native activity in AppGlue, but that's a different problem. However, to use Engkin's approach, I had to use older linker and tools from "android-ndk-r8b\toolchains\x86-4.4.3\prebuilt\windows\bin" (my previous attempts were using "android-ndk-r9\toolchains\x86-4.8\prebuilt\windows-x86_64\bin".

However, I'm wondering if it possible to fix FreePascal trunk for x86 Android development?

lenz

  • New Member
  • *
  • Posts: 17
Re: Jni test ( arm ok, x86 crash ) How to solve ?
« Reply #17 on: December 17, 2013, 09:50:23 pm »
Okay, I could finally run application successfully on Android x86 using exactly the same commandline as before, except for using Compiler and RTL from Laz4Android package compiled to i386 Android, as opposed to the trunk. I have used linker from "android-ndk-r9\toolchains\x86-4.8\prebuilt\windows-x86_64\bin".

The question is, what was changed in the trunk that broke Android x86 compilation. I guess this could be a bug somewhere.

lenz

  • New Member
  • *
  • Posts: 17
Re: Jni test ( arm ok, x86 crash ) How to solve ?
« Reply #18 on: December 17, 2013, 10:26:16 pm »
Simon, can you please try replacing file "dllprt0.as" in your FreePascal source folder e.g. c:\fpcsrc\rtl\android\i386\ to the one I have attached (from Laz4Android package), do a full rebuild (remove all units from destination i386-android folder first) and see if it works now?

In my case it solves the problem.

P.S. I filled a bug report here.
« Last Edit: December 17, 2013, 10:35:45 pm by lenz »

simonsayz

  • New Member
  • *
  • Posts: 27
Re: Jni test ( arm ok, x86 crash ) How to solve ?
« Reply #19 on: December 18, 2013, 04:06:21 am »
@lenz

Wow, You are the best.  Solved
Problem is the "rtl\android\i386\dllprt0.as"

new svn has following code, and this code make the crash in android - x86.so
...
        /* Check if environment is NULL */
        cmpl    %eax,0
        jne     env_ok
        leal    EmptyEnv,%eax
env_ok:
...
EmptyEnv:
        .long 0
        .long 0
        .long 0


and would you add the 64bit in your bug report ?


// Summary
// Type 1. 32bit , XP ------------------------------------------------- :)
   [ install lazarus ]
svn co http://svn.freepascal.org/svn/fpc/trunk c:\lazarus\fpc\2.7.1
set path=%path%;C:\android\android-ndk-r9b\toolchains\x86-4.8\prebuilt\windows\bin 
   [ Copy old file to new svn [rtl\android\i386\dllprt0.as] ]
c:\lazarus\fpc\2.6.2\bin\i386-win32\make clean crossinstall FPC=c:\Lazarus\fpc\2.6.2\bin\i386-win32\fpc.exe OS_TARGET=android CPU_TARGET=i386 CROSSBINDIR=c:\android\android-ndk-r9b\toolchains\x86-4.8\prebuilt\windows\i686-linux-android\bin INSTALL_PREFIX=c:\lazarus\fpc\2.7.1
   [ move to units , ppcross386 to 2.6.1 , rename ppcross386 to ppc386 for testing ]
   [ compile & run [ android x86 so only ] ]
   
   ### It Works ###

// Type 2. 64bit , Win7 ------------------------------------------------- :(
   [ install lazarus ]
svn co http://svn.freepascal.org/svn/fpc/trunk c:\lazarus\fpc\2.7.1
set path=%path%;C:\android\android-ndk-r9b\toolchains\x86-4.8\prebuilt\windows-x86_64\bin 
   [ Copy old file to new svn [rtl\android\i386\dllprt0.as] ]
c:\lazarus\fpc\2.6.2\bin\x86_64-win64\make clean crossinstall FPC=c:\Lazarus\fpc\2.6.2\bin\x86_64-win64\fpc.exe OS_TARGET=android CPU_TARGET=i386 CROSSBINDIR=c:\android\android-ndk-r9b\toolchains\x86_64-win64\prebuilt\windows\i686-linux-android\bin INSTALL_PREFIX=c:\lazarus\fpc\2.7.1

   ### Error ###
   c:/lazarus/fpc/2.7.1/compiler/ppc.exe -Ur -Xs -O2 -n -Fui386 -Fusystems -Fuc:/la
   zarus/fpc/2.7.1/rtl/units/x86_64-win64 -Fii386 -FE. -FUi386/units/x86_64-win64 -
   dRELEASE    -di386 -dGDB -dBROWSERLOG -Fux86 -Sew pp.pas
   fpcdefs.inc(258,2) Error: User defined: Cross-compiling from systems without sup
   port for an 80 bit extended floating point type to i386 is not yet supported at
   this time
   fpcdefs.inc(258,2) Error: User defined: Cross-compiling from systems without sup
   port for an 80 bit extended floating point type to i386 is not yet supported at
   this time
   fpcdefs.inc(258,2) Error: User defined: Cross-compiling from systems without sup
   port for an 80 bit extended floating point type to i386 is not yet supported at
   this time
   fpcdefs.inc(258,2) Error: User defined: Cross-compiling from systems without sup
   port for an 80 bit extended floating point type to i386 is not yet supported at
   this time
   constexp.pas(87,1) Fatal: There were 4 errors compiling module, stopping
   Fatal: Compilation aborted



« Last Edit: December 18, 2013, 04:08:58 am by simonsayz »

lenz

  • New Member
  • *
  • Posts: 17
Re: Jni test ( arm ok, x86 crash ) How to solve ?
« Reply #20 on: December 18, 2013, 04:34:39 am »
and would you add the 64bit in your bug report ?
My understanding is that you need to use 32-bit compiler for full rebuild, perhaps 64-bit compiler doesn't support Android target yet?

simonsayz

  • New Member
  • *
  • Posts: 27
Re: Jni test ( arm ok, x86 crash ) How to solve ?
« Reply #21 on: December 18, 2013, 01:55:57 pm »
@lenz

Thanks, I got the android-x86 from 32bit.
and copy files to 64bit system.

Now, I got all systems  :)
( armv6+soft, armv7a + vfpv3, intel )

Best Regard
Simon,Choi

lenz

  • New Member
  • *
  • Posts: 17
Re: Jni test ( arm ok, x86 crash ) How to solve ?
« Reply #22 on: December 18, 2013, 04:20:36 pm »
I think you can safely enable VFPv2 for ARMv6 as I doubt you will find any Android devices without it anyway.

jmpessoa

  • Hero Member
  • *****
  • Posts: 1470
Re: Jni test ( arm ok, x86 crash ) How to solve ?
« Reply #23 on: December 18, 2013, 04:25:14 pm »
@simonsayz
@lenz
@engkin

Anyone can put the "uptodate" laz4android somewhere as did TrueTom?

Sure everyone here would be very grateful!  :D :D

Thanks to all!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

lenz

  • New Member
  • *
  • Posts: 17
Re: Jni test ( arm ok, x86 crash ) How to solve ?
« Reply #24 on: December 18, 2013, 07:37:41 pm »
Anyone can put the "uptodate" laz4android somewhere as did TrueTom?
Up to the moment I've been compiling projects from command line (have batches to compile for armv6, armv7 and x86) and editing with NotePad++. This way I can update FPC sources from the trunk and quickly rebuild all three targets. In some free time, I'll try to see what can I do with Lazarus.

yuriy_sydorov

  • Full Member
  • ***
  • Posts: 152
Re: Jni test ( arm ok, x86 crash ) How to solve ?
« Reply #25 on: December 23, 2013, 01:06:25 pm »
I've fixed the library crash during loading on android-i386 in r26269.

simonsayz

  • New Member
  • *
  • Posts: 27
Re: Jni test ( arm ok, x86 crash ) How to solve ?
« Reply #26 on: December 24, 2013, 03:40:09 am »
@yury sidorov
Thanks you,
It works since r26269 :)

Best Regards
Simon,Choi