Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2018-05

targetandroid

18 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Adriaan van Os

In the past - which was 2013, time flies by - I built an FPC cross-compiler on Mac OS X from the FPC targetandroid branch sources. Together with Android binutils (and a linker patch) this worked well to build for Android on Mac OS X. As far as I remember, that same compiler could then be used for iOS ARM also.

What is the status now ? Can I use a from-the-shelf 3.0.2, 3.0.3 or 3.0.4 compiler for the same purpose ?

Thanks,

Adriaan van Os

Reply by email

Yuriy Sydorov
to Adriaan van Os
Adriaan van Os wrote 5 lines
In the past - which was 2013, time flies by - I built an FPC cross-compiler on Mac OS X from the FPC targetandroid branch sources. Together with Android binutils (and a linker patch) this worked well to build for Android on Mac OS X. As far as I remember, that same compiler could then be used for iOS ARM also. What is the status now ? Can I use a from-the-shelf 3.0.2, 3.0.3 or 3.0.4 compiler for the same purpose ?

The android target was merged to the main FPC sources years ago. Use FPC 3.0.4 sources or trunk to build a crosscompiler for arm-android.

Yuriy.

Reply by email

Adriaan van Os
to Yuriy Sydorov
Yuriy Sydorov wrote
The android target was merged to the main FPC sources years ago. Use FPC 3.0.4 sources or trunk to build a crosscompiler for arm-android.

3.0.4 or the special 3.0.3 version ? Does this support armv8 ? ppca64 (3.0.3) -i doesn't list Android as a target platform.

Regards,

Adriaan van Os

Reply by email

Yuriy Sydorov
to Adriaan van Os
Adriaan van Os wrote 6 lines
Yuriy Sydorov wrote: > The android target was merged to the main FPC sources years ago. Use FPC 3.0.4 sources or trunk to build a > crosscompiler for arm-android. 3.0.4 or the special 3.0.3 version ? Does this support armv8 ? ppca64 (3.0.3) -i doesn't list Android as a target platform.

No special version is needed, use 3.0.4 release sources or trunk sources. arm64 and x86_64 are not supported yet for android. I plan to add support for these CPUs later. Yuriy Sydorov.

Reply by email

Yuriy Sydorov
to Adriaan van Os
Adriaan van Os wrote 6 lines
Yuriy Sydorov wrote: > No special version is needed, use 3.0.4 release sources or trunk sources. > arm64 and x86_64 are not supported yet for android. I plan to add support for these CPUs later. Thanks, armv8 is required for Google Play from August 2019 on <https://android-developers.googleblog.com/2017/12/improving-app-security-and-performance.html>

I know about this and going to add support for 64-bit CPUs before the deadline :)

Yuriy.

Reply by email

Adriaan van Os
to Yuriy Sydorov
Yuriy Sydorov wrote
On 6/4/2018 2:51 PM, Adriaan van Os wrote: > Yuriy Sydorov wrote: >> No special version is needed, use 3.0.4 release sources or trunk >> sources.

I have fpc-3.0.4 installed on OS X 10.6.8. In a separate 3.0.4 sources folder, I issue

make clean crossall crossinstall OS-TARGET=android CPU_TARGET=arm OPT=-Aas-darwin

and get, after the cleaning stuff, the following error

make -C /Users/adriaan/fpc-android/fpc-3.0.4/rtl 'OPT=-Aas-darwin ' all make -C darwin all
/bin/mkdir -p /Users/adriaan/fpc-android/fpc-3.0.4/rtl/units/x86_64-darwin /usr/local/bin/ppcx64 -dNOMOUSE -Ur -dFPC_USE_LIBC -Ur -Xs -O2 -n -Fi../inc -Fi../x86_64 -Fi../unix -Fi../bsd -Fi../bsd/x86_64 -Fi../darwin/x86_64 -FE. -FU/Users/adriaan/fpc-android/fpc-3.0.4/rtl/units/x86_64-darwin -Aas-darwin -dx86_64 -dRELEASE -Us -Sg ../bsd/system.pp
/Users/adriaan/fpc-android/fpc-3.0.4/rtl/units/x86_64-darwin/system.s:4141:suffix or operands invalid for `fcomip'
/Users/adriaan/fpc-android/fpc-3.0.4/rtl/units/x86_64-darwin/system.s:4148:suffix or operands invalid for `fcomip'
system.pp(361) Error: Error while assembling exitcode 1 system.pp(361) Fatal: There were 2 errors compiling module, stopping Fatal: Compilation aborted

This seems to be a 32-bit/64-bit issue. What is the required make command to prevent this ?

Regards,

Adriaan van Os

Reply by email

Karoly Balogh (Charlie/SGR
to Adriaan van Os

Hi,

Adriaan van Os wrote 11 lines
>> Yuriy Sydorov wrote: >>> No special version is needed, use 3.0.4 release sources or trunk >>> sources. I have fpc-3.0.4 installed on OS X 10.6.8. In a separate 3.0.4 sources folder, I issue make clean crossall crossinstall OS-TARGET=android CPU_TARGET=arm OPT=-Aas-darwin and get, after the cleaning stuff, the following error

Not all combinations of assemblers and platforms are supported and work. as-darwin is for native OSX and iOS development using clang. For Android (as it's just a special flavor of Linux), you probably have to use the cross GNU binutils supplied with the Android development kit, or some kind of cross-GNU binutils for ARM (supporting EABIv5 maybe?).

BTW, it's enough if you have your android cross-tools in the path and specify BINUTILSPREFIX=arm-android- or whatever prefix as/ld/etc has for Android...

An additional idea would be to specify the CPU type explicitly as well, because arm has a huge range of CPU subarchitectures which is a constant source of confusion on arm-linux, but I don't think that's the issue here.

Charlie

Reply by email

Adriaan van Os
to Karoly Balogh (Charlie/SGR
Karoly Balogh wrote 24 lines
Hi, On Wed, 13 Jun 2018, Adriaan van Os wrote: >>> Yuriy Sydorov wrote: >>>> No special version is needed, use 3.0.4 release sources or trunk >>>> sources. > I have fpc-3.0.4 installed on OS X 10.6.8. In a separate 3.0.4 sources folder, > I issue > > make clean crossall crossinstall OS-TARGET=android CPU_TARGET=arm > OPT=-Aas-darwin > > and get, after the cleaning stuff, the following error Not all combinations of assemblers and platforms are supported and work. as-darwin is for native OSX and iOS development using clang. For Android (as it's just a special flavor of Linux), you probably have to use the cross GNU binutils supplied with the Android development kit, or some kind of cross-GNU binutils for ARM (supporting EABIv5 maybe?). BTW, it's enough if you have your android cross-tools in the path and specify BINUTILSPREFIX=arm-android- or whatever prefix as/ld/etc has for Android...

I don't think so. When building a cross compiler, the target assembler is needed only when compiling runtime-library code with the new compiler, at the end. And the error happens quite at the begiinning of the process, where 32-bit or 64-bit x86 code is created for the new cross-compiler (which runs as a 32-bit or 64-bit x86 binary).

An additional idea would be to specify the CPU type explicitly as well, because arm has a huge range of CPU subarchitectures which is a constant source of confusion on arm-linux, but I don't think that's the issue here.

I appreciate the reply, but I don't think this has anything to do with it,, for the same reasons as above.

Regards,

Adriaan van Os

Reply by email

Jonas Maebe
to Adriaan van Os: I have fpc-3.0.4 installed on OS X 10.6.8. In a separate 3.0.4 sources folder, I issue…
Adriaan van Os wrote 11 lines
Yuriy Sydorov wrote: > On 6/4/2018 2:51 PM, Adriaan van Os wrote: >> Yuriy Sydorov wrote: >>> No special version is needed, use 3.0.4 release sources or trunk >>> sources. I have fpc-3.0.4 installed on OS X 10.6.8. In a separate 3.0.4 sources folder, I issue     make clean crossall crossinstall OS-TARGET=android CPU_TARGET=arm OPT=-Aas-darwin

Note that it's OS_TARGET, not OS-TARGET.

Show quoted text 20 lines
and get, after the cleaning stuff, the following error make -C /Users/adriaan/fpc-android/fpc-3.0.4/rtl 'OPT=-Aas-darwin  ' all make -C darwin all /bin/mkdir -p /Users/adriaan/fpc-android/fpc-3.0.4/rtl/units/x86_64-darwin /usr/local/bin/ppcx64 -dNOMOUSE -Ur -dFPC_USE_LIBC -Ur -Xs -O2 -n -Fi../inc -Fi../x86_64 -Fi../unix -Fi../bsd -Fi../bsd/x86_64 -Fi../darwin/x86_64 -FE. -FU/Users/adriaan/fpc-android/fpc-3.0.4/rtl/units/x86_64-darwin -Aas-darwin -dx86_64 -dRELEASE -Us -Sg ../bsd/system.pp /Users/adriaan/fpc-android/fpc-3.0.4/rtl/units/x86_64-darwin/system.s:4141:suffix or operands invalid for `fcomip' /Users/adriaan/fpc-android/fpc-3.0.4/rtl/units/x86_64-darwin/system.s:4148:suffix or operands invalid for `fcomip' system.pp(361) Error: Error while assembling exitcode 1 system.pp(361) Fatal: There were 2 errors compiling module, stopping Fatal: Compilation aborted This seems to be a 32-bit/64-bit issue. What is the required make command to prevent this ?

Apple's "as" is extremely outdated and contains many bugs. I have not tested darwin-as anymore recently, so it is quite possible that it no longer works. If you do not wish to use clang as assembler (note that you do not have to use the one provided by Apple; you can use a newer version from Fink/MacPorts/Brew or a self-compiled one), you could try adding more workarounds to Tx86AppleGNUAssembler in compiler/x86/agx86att.pas

The above errors are unrelated to 32/64 bits.

Jonas

Reply by email

Adriaan van Os
to Jonas Maebe
Jonas Maebe wrote 7 lines
Apple's "as" is extremely outdated and contains many bugs. I have not tested darwin-as anymore recently, so it is quite possible that it no longer works. If you do not wish to use clang as assembler (note that you do not have to use the one provided by Apple; you can use a newer version from Fink/MacPorts/Brew or a self-compiled one), you could try adding more workarounds to Tx86AppleGNUAssembler in compiler/x86/agx86att.pas

This seems to be a darwin-as issue indeed as building with the clang assembler does work. Thanks for the reply.

Regards,

Adriaan van Os

Reply by email

Adriaan van Os
to Jonas Maebe: Note that it's OS_TARGET, not OS-TARGET. Apple's "as" is extremely outdated and contains…

Another issue is the following:

/Users/dev1/fpc-android/fpc-3.0.4/compiler/ppcrossarm -Ur -Tandroid -Parm -XParm-linux-androideabi- -Xr -Ur -Xs -O2 -n -Fi../inc -Fi../arm -Fi../unix -Fiarm -Fi../linux -Fi../linux/arm -FE. -FU/Users/dev1/fpc-android/fpc-3.0.4/rtl/units/arm-android -darm -dRELEASE -Us -Sg ../linux/system.pp /Users/dev1/fpc-android/fpc-3.0.4/rtl/units/arm-android/system.s: Assembler messages: /Users/dev1/fpc-android/fpc-3.0.4/rtl/units/arm-android/system.s:84: Error: invalid constant (7f) after fixup

This happens when building ppcrossarm on OS X 10.12 or 10.13, not on 10.10 (but this information is inexact, it could rather depend on the version of Xcode installed).

What I suspect is that, when building the rtl for android, fpcrossarm calls the installed clang assembler rather than the (separately built) arm-linux-androideabi-as. The remedy then would be to specifically instruct fpc what assember (and linker) are to be used.

The make command issued is

sudo make clean crossall crossinstall OS_TARGET=android CPU_TARGET=arm INSTALL_PREFIX=/usr/local BINUTILSPREFIX=arm-linux-androideabi-

The built binutils for Android are in /usr/local/bin

[P20:/usr/local/bin] adriaan% ls arm-linux-androideabi* arm-linux-androideabi-addr2line arm-linux-androideabi-c++filt arm-linux-androideabi-nm arm-linux-androideabi-ranlib arm-linux-androideabi-strings arm-linux-androideabi-ar arm-linux-androideabi-gprof arm-linux-androideabi-objcopy arm-linux-androideabi-readelf arm-linux-androideabi-strip arm-linux-androideabi-as arm-linux-androideabi-ld arm-linux-androideabi-objdump arm-linux-androideabi-size

Regards,

Adriaan van Os

Reply by email

Jonas Maebe
to Adriaan van Os
Adriaan van Os wrote
What I suspect is that, when building the rtl for android, fpcrossarm calls the installed clang assembler rather than the (separately built) arm-linux-androideabi-as.

That would surprise me. With -vx, you can see which external tools the compiler invokes and with which command lines.

Jonas

Reply by email

Adriaan van Os
to Jonas Maebe
Jonas Maebe wrote 8 lines
On 17/06/18 18:00, Adriaan van Os wrote: > What I suspect is that, when building the rtl for android, fpcrossarm > calls the installed clang assembler rather than the (separately built) > arm-linux-androideabi-as. That would surprise me. With -vx, you can see which external tools the compiler invokes and with which command lines.

Indeed

/Applications/Xcode.app/Contents/Developer/usr/bin/make -C android all /bin/mkdir -p /Users/dev1/fpc-android/fpc-3.0.4/rtl/units/arm-android arm-linux-androideabi-as -o /Users/dev1/fpc-android/fpc-3.0.4/rtl/units/arm-android/prt0.o arm/prt0.as arm-linux-androideabi-as -o /Users/dev1/fpc-android/fpc-3.0.4/rtl/units/arm-android/dllprt0.o arm/dllprt0.as
/Users/dev1/fpc-android/fpc-3.0.4/compiler/ppcrossarm -Ur -Tandroid -Parm -XParm-linux-androideabi- -Xr -Ur -Xs -O2 -n -Fi../inc -Fi../arm -Fi../unix -Fiarm -Fi../linux -Fi../linux/arm -FE. -FU/Users/dev1/fpc-android/fpc-3.0.4/rtl/units/arm-android -vx -darm -dRELEASE -Us -Sg ../linux/system.pp
Executing "/usr/local/bin/arm-linux-androideabi-as" with command line "-mfpu=softvfp -o /Users/dev1/fpc-android/fpc-3.0.4/rtl/units/arm-android/system.o /Users/dev1/fpc-android/fpc-3.0.4/rtl/units/arm-android/system.s" /Users/dev1/fpc-android/fpc-3.0.4/rtl/units/arm-android/system.s: Assembler messages: /Users/dev1/fpc-android/fpc-3.0.4/rtl/units/arm-android/system.s:84: Error: invalid constant (7f) after fixup
/Users/dev1/fpc-android/fpc-3.0.4/rtl/units/arm-android/system.s:99: Error: invalid constant (7f) after fixup
/Users/dev1/fpc-android/fpc-3.0.4/rtl/units/arm-android/system.s:114: Error: invalid constant (ff) after fixup

But why would arm-linux-androideabi-as behave differently on OS X 10.12.6 with Xcode 8.3.3 than on OS X 10.10 ? ? Or could it be that the assembly files produced by ppcrossarm are different ?

Regards,

Adriaan van Os

Reply by email

Jonas Maebe
to Adriaan van Os
Adriaan van Os wrote
But why would arm-linux-androideabi-as behave differently on OS X 10.12.6 with Xcode 8.3.3 than on OS X 10.10 ? ? Or could it be that the assembly files produced by ppcrossarm are different ?

If you add CROSSOPT="-a", the generated assembler files won't be deleted and you can compare them.

Jonas

Reply by email

Adriaan van Os
to Jonas Maebe
Jonas Maebe wrote 8 lines
On 17/06/18 21:47, Adriaan van Os wrote: > But why would arm-linux-androideabi-as behave differently on OS X > 10.12.6 with Xcode 8.3.3 than on OS X 10.10 ? ? Or could it be that > the assembly files produced by ppcrossarm are different ? If you add CROSSOPT="-a", the generated assembler files won't be deleted and you can compare them.

Nope, the assembler files are the same. So, the bug is in not in fpc but in the assembler or in configuring the assembler. WIll investigate that.

Regards,

Adriaan van Os

Reply by email

Adriaan van Os
to Jonas Maebe: If you add CROSSOPT="-a", the generated assembler files won't be deleted and you can…

There is an optimization bug in the LLVM C compiler that ships with Xcode 7. This "major leap in technology" as Apple would call it, produces a faulty assembler for Android on systems that have that C compiler installed. There is a work-around in the bug report <https://sourceware.org/bugzilla/show_bug.cgi?id=19311> that solves the issue. The fpc ppcrossarm compiler for Android builds now, even on systems with Xcode 7.

Regards,

Adriaan van Os

Reply by email