Discussion:
targetandroid
(too old to reply)
Adriaan van Os
2018-05-30 13:41:43 UTC
Permalink
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
_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepas
Yuriy Sydorov
2018-05-30 16:47:20 UTC
Permalink
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.
_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.fre
Adriaan van Os
2018-06-04 11:51:21 UTC
Permalink
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>

Regards,

Adriaan van Os
_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/
Yuriy Sydorov
2018-06-04 13:01:02 UTC
Permalink
Post by Adriaan van Os
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.
_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org
Adriaan van Os
2018-06-13 15:40:07 UTC
Permalink
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

_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-
Karoly Balogh (Charlie/SGR)
2018-06-13 15:51:52 UTC
Permalink
Hi,
Post by Adriaan van Os
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
_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.f
Adriaan van Os
2018-06-13 18:47:31 UTC
Permalink
Post by Karoly Balogh (Charlie/SGR)
Hi,
Post by Adriaan van Os
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).
Post by Karoly Balogh (Charlie/SGR)
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
_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/
Jonas Maebe
2018-06-13 18:55:22 UTC
Permalink
Post by Adriaan van Os
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.
Post by Adriaan van Os
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
_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailm
Adriaan van Os
2018-06-15 09:30:20 UTC
Permalink
Post by Jonas Maebe
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
_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cg
Adriaan van Os
2018-06-17 16:00:22 UTC
Permalink
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

_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-deve
Jonas Maebe
2018-06-17 16:05:39 UTC
Permalink
Post by Adriaan van Os
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
_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://li
Adriaan van Os
2018-06-17 19:47:23 UTC
Permalink
Post by Jonas Maebe
Post by Adriaan van Os
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

_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fp
Jonas Maebe
2018-06-17 20:13:03 UTC
Permalink
Post by Adriaan van Os
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
_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-dev
Adriaan van Os
2018-06-18 06:31:47 UTC
Permalink
Post by Jonas Maebe
Post by Adriaan van Os
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

_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-
Adriaan van Os
2018-06-18 09:43:14 UTC
Permalink
It's this bug
<http://bug-binutils.gnu.narkive.com/Cd0LBSs7/bug-binutils-19311-new-arm-linux-as-build-on-mac-os-x-with-xcode7-fails-to-assemble-code-from>

Regards,

Adriaan van Os

_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-d
Adriaan van Os
2018-06-18 17:55:31 UTC
Permalink
Post by Adriaan van Os
It's this bug
<http://bug-binutils.gnu.narkive.com/Cd0LBSs7/bug-binutils-19311-new-arm-linux-as-build-on-mac-os-x-with-xcode7-fails-to-assemble-code-from>
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

_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.o

Loading...