Sign in Join

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

Mailing lists / fpc-pascal / 2015-08

Cross compile from x86 to Pi

28 messages · 7 people · –

Reply by email Subscribe to this list Your subscription

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

Chris Moody

Hi all,

I think my project is almost done, wanted to see how fast it ran under the Pi which its destined to be on. After spending a long time trying to get it to compile there I decided I'd see if cross compiling may be any faster.

Is there a better guide on how to do this than:
http://wiki.freepascal.org/fpcup#Linux_ARM_cross_compiler ? specifically as far as this sentence is concerned:

* Linux/Unix build or install the relevant crossbinutils (Linux, unix)

Thanks in advance!

Chris

Karoly Balogh (Charlie/SGR
to Chris Moody

Hi,

Chris Moody wrote 5 lines
Is there a better guide on how to do this than: http://wiki.freepascal.org/fpcup#Linux_ARM_cross_compiler ? specifically as far as this sentence is concerned: * Linux/Unix build or install the relevant crossbinutils (Linux, unix)

With Ubuntu/Debian:
- apt-get install binutils-arm-linux-gnueabihf

The various binutils executables will be available then as arm-linux-gnueabihf-*, so you need to use parameter -XParm-linux-gnueabihf- when invoking the compiler.

If you're using a different Linux distribution, look up a similar package in your distribution, most bigger distros provide cross-binutils packages these days for ARM.

You can also build cross-binutils from source, but that's not FPC specific at all. Among many others, this GCC cross-howto explains how to build a cross binutils (see chapter 1):

http://preshing.com/20141119/how-to-build-a-gcc-cross-compiler/

But on the RPi, instead of TARGET=aarch64-linux one has to use TARGET=arm-linux-gnueabihf, if I'm correct.

Charlie

Chris Moody
to Karoly Balogh (Charlie/SGR
Karoly Balogh wrote 31 lines
Hi, On Sat, 15 Aug 2015, Chris Moody wrote: > Is there a better guide on how to do this than: > http://wiki.freepascal.org/fpcup#Linux_ARM_cross_compiler ? specifically as far as this > sentence is concerned: > > * Linux/Unix build or install the relevant crossbinutils (Linux, unix) With Ubuntu/Debian: - apt-get install binutils-arm-linux-gnueabihf The various binutils executables will be available then as arm-linux-gnueabihf-*, so you need to use parameter -XParm-linux-gnueabihf- when invoking the compiler. If you're using a different Linux distribution, look up a similar package in your distribution, most bigger distros provide cross-binutils packages these days for ARM. You can also build cross-binutils from source, but that's not FPC specific at all. Among many others, this GCC cross-howto explains how to build a cross binutils (see chapter 1): http://preshing.com/20141119/how-to-build-a-gcc-cross-compiler/ But on the RPi, instead of TARGET=aarch64-linux one has to use TARGET=arm-linux-gnueabihf, if I'm correct. Charlie

Thanks for that Charlie, I now have that installed. Do I have to do the compile with fpc? or can I do it via Lazarus?

Karoly Balogh (Charlie/SGR
to Chris Moody

Hi,

Chris Moody wrote 13 lines
> > Is there a better guide on how to do this than: > > http://wiki.freepascal.org/fpcup#Linux_ARM_cross_compiler ? specifically > > as far as this > > sentence is concerned: > > > > * Linux/Unix build or install the relevant crossbinutils (Linux, unix) > With Ubuntu/Debian: > - apt-get install binutils-arm-linux-gnueabihf > > **snip** Thanks for that Charlie, I now have that installed. Do I have to do the compile with fpc? or can I do it via Lazarus?

I'm pretty sure it's possible with Lazarus, but I can't give exact instructions, because I rarely use Lazarus, I prefer using the compiler itself directly from the command line.

However, this page has some pointers:
http://wiki.lazarus.freepascal.org/Setup_Cross_Compile_For_ARM#Make_your_first_arm-linux_project_in_Lazarus

Charlie

Chris Moody
to Karoly Balogh (Charlie/SGR
Karoly Balogh wrote 26 lines
Hi, On Sat, 15 Aug 2015, Chris Moody wrote: >>> Is there a better guide on how to do this than: >>> http://wiki.freepascal.org/fpcup#Linux_ARM_cross_compiler ? specifically >>> as far as this >>> sentence is concerned: >>> >>> * Linux/Unix build or install the relevant crossbinutils (Linux, unix) >> With Ubuntu/Debian: >> - apt-get install binutils-arm-linux-gnueabihf >> >> **snip** > Thanks for that Charlie, I now have that installed. Do I have to do the > compile with fpc? or can I do it via Lazarus? I'm pretty sure it's possible with Lazarus, but I can't give exact instructions, because I rarely use Lazarus, I prefer using the compiler itself directly from the command line. However, this page has some pointers: http://wiki.lazarus.freepascal.org/Setup_Cross_Compile_For_ARM#Make_your_first_arm-linux_project_in_Lazarus Charlie _______________________________________________

Looks like I need to recompile FPC (or make a special compile of it) to be able to compile to ARM.

That URL you gave me says how to compile it, but not sure about if I need to have some special cross compile code for the CROSSBINDIR=/home/user/lazarus/fpc/binutils/ portion of it, or do I just point it to where Linux installed the items installed with apt-get install binutils-arm-linux-gnueabihf ?

Thanks once again!

Chris

Martin Schreiber
to Chris Moody: I think my project is almost done, wanted to see how fast it ran under the Pi which its…
Chris Moody wrote 7 lines
Hi all, I think my project is almost done, wanted to see how fast it ran under the Pi which its destined to be on. After spending a long time trying to get it to compile there I decided I'd see if cross compiling may be any faster.

I use MSEide in order to cross compile and do remote debugging from Linux x86 to Raspberry Pi. With that setup it is possible to work on the X86 PC like locally on the Pi - solely faster.
Linux x86 -> arm cross environments with cross FPC, cross binutils and cross gdb are here:
http://sourceforge.net/projects/mseide-msegui/files/fpcrossarm/

MSEide has a project template for cross-Pi development, please read MSEide+MSEgui README.TXT.
For GUI on the Pi I use MSEgui which is extremely fast. Also MSEide runs amazingly fast on Pi, the problem is long FPC compilation times.

FPC fixes_3_0 needs current git master MSEide+MSEgui from here: https://gitlab.com/mseide-msegui/mseide-msegui

Please ask questions on the mailinglist:
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk Mail archive:

NNTP gateway:
nntp://news.gmane.org/gmane.comp.ide.mseide.user

Martin

Chris Moody
to Martin Schreiber
Martin Schreiber wrote 33 lines
On Sunday 16 August 2015 02:33:24 Chris Moody wrote: > Hi all, > > I think my project is almost done, wanted to see how fast it ran under > the Pi which its destined to be on. After spending a long time trying to > get it to compile there I decided I'd see if cross compiling may be any > faster. > I use MSEide in order to cross compile and do remote debugging from Linux x86 to Raspberry Pi. With that setup it is possible to work on the X86 PC like locally on the Pi - solely faster. Linux x86 -> arm cross environments with cross FPC, cross binutils and cross gdb are here: http://sourceforge.net/projects/mseide-msegui/files/fpcrossarm/ MSEide has a project template for cross-Pi development, please read MSEide+MSEgui README.TXT. For GUI on the Pi I use MSEgui which is extremely fast. Also MSEide runs amazingly fast on Pi, the problem is long FPC compilation times. FPC fixes_3_0 needs current git master MSEide+MSEgui from here: https://gitlab.com/mseide-msegui/mseide-msegui Please ask questions on the mailinglist: https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk Mail archive: NNTP gateway: nntp://news.gmane.org/gmane.comp.ide.mseide.user Martin _______________________________________________

Thanks for that Martin, my app is actually just console based (I used Lazarus because I didn't want to use the text based IDE), would you still recommend this route?

Thanks,

Chris

Michael Schnell
to Martin Schreiber: I use MSEide in order to cross compile and do remote debugging from Linux x86 to…
Martin Schreiber wrote
MSEide has a project template for cross-Pi development,

Great, Martin ! (As always :-) )

I once unsuccessfully tried to do cross compiling and remote debugging for my ARM based (GUI-less) QNAP NAS. I finally compiled the project locally which was no real problem, as I could test the complete software on a PC before moving it to the NAS.

-Michael

Karoly Balogh (Charlie/SGR
to Michael Schnell: Cross compiling with fpc is not for that faint of heard. (Been there some years ago)…

Hi,

Michael Schnell wrote
Cross compiling with fpc is not for that faint of heard. (Been there some years ago)

Well, I do it 8 hours a day for a living, actually... :) I think it's really easy these days, if you know some basics about the build system (most of which is available from the Wiki), and how the some of the dependencies work (binutils, mainly). Basically you can have a working crosscompiler setup with a *single* make command in about two minutes, to almost any system which you have binutils installed for. I wouldn't call that hard.

And it's especially super-easy these days, when you can test most of your cross-setup outputs on a Linux/x86 box, thanks to the user-space emulation of a good binfmts/QEMU setup (again, available out-of-box with some packages on Ubuntu/Debian). You don't even have to copy over to an ARM (etc.) box...

Of course, wiring it into an IDE is a different question, that I don't know (and don't use)...

Charlie

Michael Schnell
to Karoly Balogh (Charlie/SGR
Karoly Balogh wrote
Of course, wiring it into an IDE is a different question, that I don't know (and don't use)...

That is what I was trying to do.

In fact Lazarus provides settings for OS and Arch to be used. But I did not get this to work at that time.

Configuring a remote debugger for Lazarus is even harder.

There are two possible ways to do that: "remote gdb" and using the normal gdb on the target and connecting via SSH.

Remote gdb:
- I had not been able to create the gdb (x85) / gdbserver(ARM) pair (not an fpc issue at all)
- I read that remote gdb does not allow for manually stopping a running program under debug if no breakpoint is reached (so it does not seem very desirable)

SSH:
There is code for this in Lazarus, but it is commented out. I did not have enough spare time to take a deeper we (me and a nice guy from Vienna who already started to write a documentation on Lazarus cross compiling and remote debugging, which I promised to translate into English) gave up.

-Michael

Chris Moody
to Karoly Balogh (Charlie/SGR: Well, I do it 8 hours a day for a living, actually... :) I think it's really easy these…
Karoly Balogh wrote 26 lines
Hi, On Mon, 17 Aug 2015, Michael Schnell wrote: > Cross compiling with fpc is not for that faint of heard. (Been there some > years ago) Well, I do it 8 hours a day for a living, actually... :) I think it's really easy these days, if you know some basics about the build system (most of which is available from the Wiki), and how the some of the dependencies work (binutils, mainly). Basically you can have a working crosscompiler setup with a *single* make command in about two minutes, to almost any system which you have binutils installed for. I wouldn't call that hard. And it's especially super-easy these days, when you can test most of your cross-setup outputs on a Linux/x86 box, thanks to the user-space emulation of a good binfmts/QEMU setup (again, available out-of-box with some packages on Ubuntu/Debian). You don't even have to copy over to an ARM (etc.) box... Of course, wiring it into an IDE is a different question, that I don't know (and don't use)... Charlie _______________________________________________

Hi again Charlie,

Do you use the MSEide software to do the cross compiling? or do you just call fpc with the right parameters?

Mind sharing your setup?

Thanks,

Chris

Chris Moody
to Chris Moody: Looks like I need to recompile FPC (or make a special compile of it) to be able to…
Chris Moody wrote 41 lines
On 08/15/2015 07:40 PM, Karoly Balogh (Charlie/SGR) wrote: > Hi, > > On Sat, 15 Aug 2015, Chris Moody wrote: > >>>> Is there a better guide on how to do this than: >>>> http://wiki.freepascal.org/fpcup#Linux_ARM_cross_compiler ? specifically >>>> as far as this >>>> sentence is concerned: >>>> >>>> * Linux/Unix build or install the relevant crossbinutils (Linux, unix) >>> With Ubuntu/Debian: >>> - apt-get install binutils-arm-linux-gnueabihf >>> >>> **snip** >> Thanks for that Charlie, I now have that installed. Do I have to do the >> compile with fpc? or can I do it via Lazarus? > I'm pretty sure it's possible with Lazarus, but I can't give exact > instructions, because I rarely use Lazarus, I prefer using the compiler > itself directly from the command line. > > However, this page has some pointers: > http://wiki.lazarus.freepascal.org/Setup_Cross_Compile_For_ARM#Make_your_first_arm-linux_project_in_Lazarus > > Charlie > _______________________________________________ > Looks like I need to recompile FPC (or make a special compile of it) to be able to compile to ARM. That URL you gave me says how to compile it, but not sure about if I need to have some special cross compile code for the CROSSBINDIR=/home/user/lazarus/fpc/binutils/ portion of it, or do I just point it to where Linux installed the items installed with apt-get install binutils-arm-linux-gnueabihf ? Thanks once again! Chris

So I tried to compile a special version of FPC for arm, I installed: binutils-2.25

And I got as far as this:

/home/chris/Documents/fp/fpcbuild-2.6.4/binutils/bin/as -o /home/chris/Documents/fp/fpcbuild-2.6.4/fpcsrc/rtl/units/arm-linux/prt0.o arm/prt0.as arm/prt0.as: Assembler messages:
arm/prt0.as:46: Error: unrecognized symbol type "" arm/prt0.as:49: Error: expecting operand after ','; got nothing arm/prt0.as:50: Error: no such instruction: `ldmia sp!,{a2}' arm/prt0.as:53: Error: no such instruction: `ldr
ip,=operatingsystem_parameter_argc'
arm/prt0.as:54: Error: no such instruction: `ldr
a3,=operatingsystem_parameter_argv'
arm/prt0.as:55: Error: invalid char '[' beginning operand 2 `[ip]' arm/prt0.as:58: Error: too many memory references for `add' arm/prt0.as:59: Error: too many memory references for `add' arm/prt0.as:60: Error: no such instruction: `ldr
ip,=operatingsystem_parameter_envp'
arm/prt0.as:62: Error: invalid char '[' beginning operand 2 `[a3]' arm/prt0.as:63: Error: invalid char '[' beginning operand 2 `[ip]' arm/prt0.as:66: Error: no such instruction: `ldr ip,=__stkptr' arm/prt0.as:67: Error: invalid char '[' beginning operand 2 `[ip]' arm/prt0.as:69: Error: too many memory references for `sub' arm/prt0.as:72: Error: no such instruction: `bl PASCALMAIN' arm/prt0.as:75: Error: unrecognized symbol type "" arm/prt0.as:78: Error: no such instruction: `swi 0x900001' arm/prt0.as:79: Error: no such instruction: `b _haltproc' arm/prt0.as:82: Error: unrecognized symbol type "" arm/prt0.as:84: Error: no such instruction: `ldr r0,=operatingsystem_result' arm/prt0.as:85: Error: no such instruction: `ldrb r0,[r0]' arm/prt0.as:86: Error: expecting operand after ','; got nothing arm/prt0.as:87: Error: no such instruction: `swi 0x0' arm/prt0.as:88: Error: no such instruction: `b _haltproc_eabi' make[6]: *** [prt0.o] Error 1
make[6]: Leaving directory
`/home/chris/Documents/fp/fpcbuild-2.6.4/fpcsrc/rtl/linux' make[5]: *** [linux_all] Error 2
make[5]: Leaving directory
`/home/chris/Documents/fp/fpcbuild-2.6.4/fpcsrc/rtl' make[4]: *** [rtl] Error 2
make[4]: Leaving directory
`/home/chris/Documents/fp/fpcbuild-2.6.4/fpcsrc/compiler' make[3]: *** [cycle] Error 2
make[3]: Leaving directory
`/home/chris/Documents/fp/fpcbuild-2.6.4/fpcsrc/compiler' make[2]: *** [compiler_cycle] Error 2
make[2]: Leaving directory `/home/chris/Documents/fp/fpcbuild-2.6.4/fpcsrc' make[1]: *** [build-stamp.arm-linux] Error 2
make[1]: Leaving directory `/home/chris/Documents/fp/fpcbuild-2.6.4/fpcsrc' make: *** [fpcsrc/build-stamp.arm-linux] Error 2

Martin Schreiber
to Michael Schnell: GREAT ! So MSE IDE does use GDBServer and not native ARM GDB remote controlled by SSH ?…
Michael Schnell wrote 8 lines
On 08/17/2015 09:55 PM, Martin Schreiber wrote: > > This works with MSEide. > GREAT ! So MSE IDE does use GDBServer and not native ARM GDB remote controlled by SSH ?

Yes. Or a local gdbserver which communicates by a proxy with a hardware debug interface like Segger J-Link or "AVR ONE!" for example.

Or is this selectable ?

I assume one could setup a ssh tunnel -> remote native ARM gdb too, I never tried it.

Martin

Martin Schreiber
to Michael Schnell: I feel it even would be easier to do than using gdbserver, as - after setting up the SSH…
Michael Schnell wrote 12 lines
On 08/18/2015 08:54 AM, Martin Schreiber wrote: > > I assume one could setup a ssh tunnel -> remote native ARM gdb too, I > never tried it. > I feel it even would be easier to do than using gdbserver, as - after setting up the SSH connection - the IDE would just use the same commands with the remote gdb as it would with a local one and there would not need to be a dedicated X86->ARM-Cross - "gdbremote" executable on the IDE site not a (rather uncommon) GDBServer executable on the ARM site.

The already several times mentioned cross environment from here: http://sourceforge.net/projects/mseide-msegui/files/fpcrossarm/ works well for me.

Martin

Michael Schnell
to Martin Schreiber: This works with MSEide. Martin
Martin Schreiber wrote
This works with MSEide.

GREAT !

So MSE IDE does use GDBServer and not native ARM GDB remote controlled by SSH ? Or is this selectable ?

When I did that research, I had the impression that SSH would be preferable (whenever Ethernet is installed).

(Now as there will be new fast low-power Intel CPUs available for embedded use (e.g. on Q7 boards) I have no hope any more that the company ever will port the huge Delphi project they maintain to ARM. So I am free to privately move from Lazarus to MSEIDE :-) :-) :-) )

-Michael

Michael Schnell
to Martin Schreiber: Yes. Or a local gdbserver which communicates by a proxy with a hardware debug interface…
Martin Schreiber wrote
I assume one could setup a ssh tunnel -> remote native ARM gdb too, I never tried it.

I feel it even would be easier to do than using gdbserver, as - after setting up the SSH connection - the IDE would just use the same commands with the remote gdb as it would with a local one and there would not need to be a dedicated X86->ARM-Cross - "gdbremote" executable on the IDE site not a (rather uncommon) GDBServer executable on the ARM site.

The big advantage of a GDBRemote/GDBServer setup is that it can use a serial interface and that it uses up very little RAM on the ARM Site. But I feel that this nowadays is not very important any more.

-Michael

Michael Ring
to Chris Moody: So I tried to compile a special version of FPC for arm, I installed: binutils-2.25 And I…

This is how I build fpc trunk cross compiler:

echo "Building fpchf-linux from trunk"
SUBARCH=armv7
CROSSOPT="-dREVINC -dFPC_ARMHF -CX -CpARMV7A -CfVFPV3_D16 -OpARMV7A -O2 -OoFASTMATH -XX -Xs"

   //CROSSOPT="-dREVINC -dFPC_ARMHF -CX -CpARMV6 -CfVFPV2 -OpARMV6 -O2

-OoFASTMATH -XX -Xs"
OPT="-dFPC_ARMHF"
make clean buildbase CROSSINSTALL=1 OS_TARGET=linux CPU_TARGET=arm OPT="$OPT" OVERRIDEVERSIONCHECK=1 CROSSOPT="$CROSSOPT" BINUTILSPREFIX=arm-linux-gnueabihf- || exit 1
sudo make installbase CROSSINSTALL=1 OS_TARGET=linux CPU_TARGET=arm OPT="$OPT" OVERRIDEVERSIONCHECK=1 CROSSOPT="$CROSSOPT" BINUTILSPREFIX=arm-linux-gnueabihf- || exit 1
sudo mv /usr/local/lib/fpc/3.1.1/ppcrossarm
/usr/local/lib/fpc/3.1.1/ppcrossarmhf

Please note that the rtl is fine for Raspberry Pi 2 (the new quad core board) as this is a version that uses armv7 commandset.

For old Raspberry Pi you need to use the commented out CROSSOPT, this will create rtl that is suitable for old raspberries.

You should not try to use fpc 2.6.4 as this compiler does not support armhf. Most likely the 3.0 pre-release will compile the same way, but I never tried.

You need to have cross-binutils installed as you need arm-linux-gnueabihf-* tools to be able to successfully compile.

Michael

Chris Moody wrote 107 lines
On 08/15/2015 08:46 PM, Chris Moody wrote: > > > On 08/15/2015 07:40 PM, Karoly Balogh (Charlie/SGR) wrote: >> Hi, >> >> On Sat, 15 Aug 2015, Chris Moody wrote: >> >>>>> Is there a better guide on how to do this than: >>>>> http://wiki.freepascal.org/fpcup#Linux_ARM_cross_compiler ? specifically >>>>> as far as this >>>>> sentence is concerned: >>>>> >>>>> * Linux/Unix build or install the relevant crossbinutils (Linux, unix) >>>> With Ubuntu/Debian: >>>> - apt-get install binutils-arm-linux-gnueabihf >>>> >>>> **snip** >>> Thanks for that Charlie, I now have that installed. Do I have to do the >>> compile with fpc? or can I do it via Lazarus? >> I'm pretty sure it's possible with Lazarus, but I can't give exact >> instructions, because I rarely use Lazarus, I prefer using the compiler >> itself directly from the command line. >> >> However, this page has some pointers: >> http://wiki.lazarus.freepascal.org/Setup_Cross_Compile_For_ARM#Make_your_first_arm-linux_project_in_Lazarus >> >> Charlie >> _______________________________________________ >> > Looks like I need to recompile FPC (or make a special compile of it) > to be able to compile to ARM. > > That URL you gave me says how to compile it, but not sure about if I > need to have some special cross compile code for the > CROSSBINDIR=/home/user/lazarus/fpc/binutils/ portion of it, or do I > just point it to where Linux installed the items installed with > apt-get install binutils-arm-linux-gnueabihf ? > > Thanks once again! > > Chris So I tried to compile a special version of FPC for arm, I installed: binutils-2.25 And I got as far as this: /home/chris/Documents/fp/fpcbuild-2.6.4/binutils/bin/as -o /home/chris/Documents/fp/fpcbuild-2.6.4/fpcsrc/rtl/units/arm-linux/prt0.o arm/prt0.as arm/prt0.as: Assembler messages: arm/prt0.as:46: Error: unrecognized symbol type "" arm/prt0.as:49: Error: expecting operand after ','; got nothing arm/prt0.as:50: Error: no such instruction: `ldmia sp!,{a2}' arm/prt0.as:53: Error: no such instruction: `ldr ip,=operatingsystem_parameter_argc' arm/prt0.as:54: Error: no such instruction: `ldr a3,=operatingsystem_parameter_argv' arm/prt0.as:55: Error: invalid char '[' beginning operand 2 `[ip]' arm/prt0.as:58: Error: too many memory references for `add' arm/prt0.as:59: Error: too many memory references for `add' arm/prt0.as:60: Error: no such instruction: `ldr ip,=operatingsystem_parameter_envp' arm/prt0.as:62: Error: invalid char '[' beginning operand 2 `[a3]' arm/prt0.as:63: Error: invalid char '[' beginning operand 2 `[ip]' arm/prt0.as:66: Error: no such instruction: `ldr ip,=__stkptr' arm/prt0.as:67: Error: invalid char '[' beginning operand 2 `[ip]' arm/prt0.as:69: Error: too many memory references for `sub' arm/prt0.as:72: Error: no such instruction: `bl PASCALMAIN' arm/prt0.as:75: Error: unrecognized symbol type "" arm/prt0.as:78: Error: no such instruction: `swi 0x900001' arm/prt0.as:79: Error: no such instruction: `b _haltproc' arm/prt0.as:82: Error: unrecognized symbol type "" arm/prt0.as:84: Error: no such instruction: `ldr r0,=operatingsystem_result' arm/prt0.as:85: Error: no such instruction: `ldrb r0,[r0]' arm/prt0.as:86: Error: expecting operand after ','; got nothing arm/prt0.as:87: Error: no such instruction: `swi 0x0' arm/prt0.as:88: Error: no such instruction: `b _haltproc_eabi' make[6]: *** [prt0.o] Error 1 make[6]: Leaving directory `/home/chris/Documents/fp/fpcbuild-2.6.4/fpcsrc/rtl/linux' make[5]: *** [linux_all] Error 2 make[5]: Leaving directory `/home/chris/Documents/fp/fpcbuild-2.6.4/fpcsrc/rtl' make[4]: *** [rtl] Error 2 make[4]: Leaving directory `/home/chris/Documents/fp/fpcbuild-2.6.4/fpcsrc/compiler' make[3]: *** [cycle] Error 2 make[3]: Leaving directory `/home/chris/Documents/fp/fpcbuild-2.6.4/fpcsrc/compiler' make[2]: *** [compiler_cycle] Error 2 make[2]: Leaving directory `/home/chris/Documents/fp/fpcbuild-2.6.4/fpcsrc' make[1]: *** [build-stamp.arm-linux] Error 2 make[1]: Leaving directory `/home/chris/Documents/fp/fpcbuild-2.6.4/fpcsrc' make: *** [fpcsrc/build-stamp.arm-linux] Error 2 _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Chris Moody
to Michael Ring: This is how I build fpc trunk cross compiler: echo "Building fpchf-linux from trunk"…
Michael Ring wrote 33 lines
This is how I build fpc trunk cross compiler: echo "Building fpchf-linux from trunk" SUBARCH=armv7 CROSSOPT="-dREVINC -dFPC_ARMHF -CX -CpARMV7A -CfVFPV3_D16 -OpARMV7A -O2 -OoFASTMATH -XX -Xs" //CROSSOPT="-dREVINC -dFPC_ARMHF -CX -CpARMV6 -CfVFPV2 -OpARMV6 -O2 -OoFASTMATH -XX -Xs" OPT="-dFPC_ARMHF" make clean buildbase CROSSINSTALL=1 OS_TARGET=linux CPU_TARGET=arm OPT="$OPT" OVERRIDEVERSIONCHECK=1 CROSSOPT="$CROSSOPT" BINUTILSPREFIX=arm-linux-gnueabihf- || exit 1 sudo make installbase CROSSINSTALL=1 OS_TARGET=linux CPU_TARGET=arm OPT="$OPT" OVERRIDEVERSIONCHECK=1 CROSSOPT="$CROSSOPT" BINUTILSPREFIX=arm-linux-gnueabihf- || exit 1 sudo mv /usr/local/lib/fpc/3.1.1/ppcrossarm /usr/local/lib/fpc/3.1.1/ppcrossarmhf Please note that the rtl is fine for Raspberry Pi 2 (the new quad core board) as this is a version that uses armv7 commandset. For old Raspberry Pi you need to use the commented out CROSSOPT, this will create rtl that is suitable for old raspberries. You should not try to use fpc 2.6.4 as this compiler does not support armhf. Most likely the 3.0 pre-release will compile the same way, but I never tried. You need to have cross-binutils installed as you need arm-linux-gnueabihf-* tools to be able to successfully compile. Michael

Hi Michael,

Just to make sure, I run the script on the desktop right? just to make sure its not to be ran on the Pi.

Thanks again!

Chris

John Lee
to Chris Moody

Did I miss something? - where does it it get the rtl & compiler source? TIA John

Chris Moody wrote 51 lines
On 08/18/2015 01:24 AM, Michael Ring wrote: This is how I build fpc trunk cross compiler: echo "Building fpchf-linux from trunk" SUBARCH=armv7 CROSSOPT="-dREVINC -dFPC_ARMHF -CX -CpARMV7A -CfVFPV3_D16 -OpARMV7A -O2 -OoFASTMATH -XX -Xs" //CROSSOPT="-dREVINC -dFPC_ARMHF -CX -CpARMV6 -CfVFPV2 -OpARMV6 -O2 -OoFASTMATH -XX -Xs" OPT="-dFPC_ARMHF" make clean buildbase CROSSINSTALL=1 OS_TARGET=linux CPU_TARGET=arm OPT="$OPT" OVERRIDEVERSIONCHECK=1 CROSSOPT="$CROSSOPT" BINUTILSPREFIX=arm-linux-gnueabihf- || exit 1 sudo make installbase CROSSINSTALL=1 OS_TARGET=linux CPU_TARGET=arm OPT="$OPT" OVERRIDEVERSIONCHECK=1 CROSSOPT="$CROSSOPT" BINUTILSPREFIX=arm-linux-gnueabihf- || exit 1 sudo mv /usr/local/lib/fpc/3.1.1/ppcrossarm /usr/local/lib/fpc/3.1.1/ppcrossarmhf Please note that the rtl is fine for Raspberry Pi 2 (the new quad core board) as this is a version that uses armv7 commandset. For old Raspberry Pi you need to use the commented out CROSSOPT, this will create rtl that is suitable for old raspberries. You should not try to use fpc 2.6.4 as this compiler does not support armhf. Most likely the 3.0 pre-release will compile the same way, but I never tried. You need to have cross-binutils installed as you need arm-linux-gnueabihf-* tools to be able to successfully compile. Michael Hi Michael, Just to make sure, I run the script on the desktop right? just to make sure its not to be ran on the Pi. Thanks again! Chris _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Michael Ring
to John Lee

You first need to check out the sourcecode from svn:

svn checkout http://svn.freepascal.org/svn/fpc/trunk fpc

then change into the fpc directory and enter the build commands line by line.

and yes, this is all done on the host, not on the raspberry pi; Host means a linux or a mac system, I understand that Chris is using a linux system so the commands should be fine.

Michael

John Lee wrote 62 lines
Did I miss something? - where does it it get the rtl & compiler source? TIA John On 18 August 2015 at 16:27, Chris Moody < > wrote: On 08/18/2015 01:24 AM, Michael Ring wrote: > This is how I build fpc trunk cross compiler: > > echo "Building fpchf-linux from trunk" > SUBARCH=armv7 > CROSSOPT="-dREVINC -dFPC_ARMHF -CX -CpARMV7A -CfVFPV3_D16 > -OpARMV7A -O2 -OoFASTMATH -XX -Xs" > //CROSSOPT="-dREVINC -dFPC_ARMHF -CX -CpARMV6 -CfVFPV2 -OpARMV6 > -O2 -OoFASTMATH -XX -Xs" > OPT="-dFPC_ARMHF" > make clean buildbase CROSSINSTALL=1 OS_TARGET=linux > CPU_TARGET=arm OPT="$OPT" OVERRIDEVERSIONCHECK=1 > CROSSOPT="$CROSSOPT" BINUTILSPREFIX=arm-linux-gnueabihf- || exit 1 > sudo make installbase CROSSINSTALL=1 OS_TARGET=linux > CPU_TARGET=arm OPT="$OPT" OVERRIDEVERSIONCHECK=1 > CROSSOPT="$CROSSOPT" BINUTILSPREFIX=arm-linux-gnueabihf- || exit 1 > sudo mv /usr/local/lib/fpc/3.1.1/ppcrossarm > /usr/local/lib/fpc/3.1.1/ppcrossarmhf > > Please note that the rtl is fine for Raspberry Pi 2 (the new quad > core board) as this is a version that uses armv7 commandset. > > For old Raspberry Pi you need to use the commented out CROSSOPT, > this will create rtl that is suitable for old raspberries. > > You should not try to use fpc 2.6.4 as this compiler does not > support armhf. Most likely the 3.0 pre-release will compile the > same way, but I never tried. > > You need to have cross-binutils installed as you need > arm-linux-gnueabihf-* tools to be able to successfully compile. > > Michael > Hi Michael, Just to make sure, I run the script on the desktop right? just to make sure its not to be ran on the Pi. Thanks again! Chris _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Jonas Maebe
to Chris Moody: So I tried to compile a special version of FPC for arm, I installed: binutils-2.25 And I…

Chris Moody wrote on Tue, 18 Aug 2015:

Show quoted text 12 lines
So I tried to compile a special version of FPC for arm, I installed: binutils-2.25 And I got as far as this: /home/chris/Documents/fp/fpcbuild-2.6.4/binutils/bin/as -o /home/chris/Documents/fp/fpcbuild-2.6.4/fpcsrc/rtl/units/arm-linux/prt0.o arm/prt0.as arm/prt0.as: Assembler messages: arm/prt0.as:46: Error: unrecognized symbol type "" arm/prt0.as:49: Error: expecting operand after ','; got nothing arm/prt0.as:50: Error: no such instruction: `ldmia sp!,{a2}'

[snip]

These errors suggest that
/home/chris/Documents/fp/fpcbuild-2.6.4/binutils/bin/as is not an assembler for ARM. If you execute
/home/chris/Documents/fp/fpcbuild-2.6.4/binutils/bin/as --version

the last line should tell you what target it was built for.

Jonas

Chris Moody
to Jonas Maebe
Jonas Maebe wrote
/home/chris/Documents/fp/fpcbuild-2.6.4/binutils/bin/as --version

Somehow this was for x86 linux, not sure how that happened. Will have to look again.

Chris

Jonas Maebe
to Chris Moody

Chris Moody wrote on Wed, 19 Aug 2015:

On 08/19/2015 12:57 AM, Jonas Maebe wrote: > /home/chris/Documents/fp/fpcbuild-2.6.4/binutils/bin/as --version Somehow this was for x86 linux, not sure how that happened. Will have to look again.

One more thing: as has been mentioned before, FPC 2.6.4 cannot be used to build for the Raspberry Pi, because it does not have support for the ABI used by that platform. You need FPC 3.x. You can get RC1 of FPC 3.0 from
http://svn.freepascal.org/svn/fpcbuild/tags/release_3_0_0_rc1/ (the official builds will be up in a few weeks, although I don't know whether there will be ARM cross-compilers, or for which ARM/Linux platforms there will be native compilers).

Jonas

Jonas Maebe
to Jonas Maebe

Jonas Maebe wrote on Wed, 19 Aug 2015:

Show quoted text 10 lines
Chris Moody wrote on Wed, 19 Aug 2015: > On 08/19/2015 12:57 AM, Jonas Maebe wrote: >> /home/chris/Documents/fp/fpcbuild-2.6.4/binutils/bin/as --version > Somehow this was for x86 linux, not sure how that happened. Will > have to look again. One more thing: as has been mentioned before, FPC 2.6.4 cannot be used to build for the Raspberry Pi, because it does not have support for the ABI used by that platform.

Small addendum: a Debian developer backported the required support on top of FPC 2.6.4, and hence if you use Debian or a Debian-derived Linux distribution, you can get an FPC 2.6.4 on your Raspberry Pi via standard apt-get. Note that this version is not supported by us due to the fact that it's a custom port.

Jonas