[fpc-pascal] Is this the correct way to configure fpc for multiple arm-embedded subarchs?

Michael Ring mail at michael-ring.org
Sun Nov 26 17:19:10 CET 2017


I am looking for an easy way to have all cortex-m compilers available at 
the same time to be able to do automated building/testing

Inspired by the -V parameter of fpc I started my journey and ended up 
with something different.

My question is now did I go down the correct path or is there a better 
way to fulfill my requirements:

- I want to be able to switch between armv6m, armv7m and armv7em without 
the need to build the matching compiler/rtl

- I want lazarus to use fpc as start compiler, I want to be able to 
configure the whole compiler switching via Project settings.

- I want to be able to use lazbuild so that I can do automated builds of 
my lazarus projects.

I found this helpful page:

http://wiki.freepascal.org/FPC_Version_Switcher#Setting_the_fpc_frontend_executable_path

but in the end this approach did not work for me, FPC version switcher 
is not available in lazarus svn (or I am too blind to find it) and in 
the end I had some issues with using lazbuild when defining the -V 
switch in my project settings.


In the end I came up with the following approach:

Build ppcrossarm and make sure that the rtls do end up in those directories:

/usr/local/lib/fpc/3.1.1/units/arm-embedded/armv6m/rtl
/usr/local/lib/fpc/3.1.1/units/arm-embedded/armv7m/rtl
/usr/local/lib/fpc/3.1.1/units/arm-embedded/armv7em/rtl

created a softlink so that the crosscompiler can be caled via 
/usr/local/bin/fpc

ln -sf /usr/local/lib/fpc/3.1.1/ppcrossarm /usr/local/bin/ppcarm

added the following to my /etc/fpc.cfg:

#ifdef embedded
-Fu/usr/local/lib/fpc/$fpcversion/units/$fpctarget/$fpcsubarch/rtl
#endif

and then I add the following lines to the user-defined project settings 
in Lazarus:

-Cparmv7em
-XP/usr/local/bin/arm-none-eabi-
-Wpnucleof411re
-dnucleof411re

I thought about putting

-Fu/usr/local/lib/fpc/3.1.1/units/arm-embedded/armv7em/rtl

in the project Settings so that I do not need to tweak /etc/fpc.cfg but 
I do not like the fact that I have to hardcode paths there, is there a 
better way? If yes then I'd prefer that a lot over tweaking /etc/fpc.cfg


Michael

------

Here's how I build the cross-compiler:

SUBARCH=armv6m

#SUBARCH=armv7m

#SUBARCH=armv7em

make clean buildbase CROSSINSTALL=1 OS_TARGET=embedded CPU_TARGET=arm 
SUBARCH=$SUBARCH CROSSOPT="$CROSSOPT" BINUTILSPREFIX=arm-none-eabi- || 
exit 1
make installbase CROSSINSTALL=1 OS_TARGET=embedded CPU_TARGET=arm 
SUBARCH=$SUBARCH CROSSOPT="$CROSSOPT" BINUTILSPREFIX=arm-none-eabi- 
INSTALL_UNITDIR=/usr/local/lib/fpc/3.1.1/units/arm-embedded/$SUBARCH/rtl 
|| exit 1
cp /usr/local/lib/fpc/3.1.1/ppcrossarm 
/usr/local/lib/fpc/3.1.1/ppcrossarm-$SUBARCH

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


More information about the fpc-pascal mailing list