[fpc-pascal] Cross compile from x86 to Pi

Michael Ring mail at michael-ring.org
Tue Aug 18 10:24:05 CEST 2015


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

Am 18.08.15 um 04:16 schrieb Chris Moody:
>
>
> 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  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20150818/8d3aa5ca/attachment.html>


More information about the fpc-pascal mailing list