installing cross fpc in parallel to systems fpc

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

installing cross fpc in parallel to systems fpc

Marc Santhoff-2
Hi,

how does fpc and it's makefiles handle the case of installing a cross
compiler on a system having fpc installed?

The target path will differ and I can set that, but how is the config
file .fpc.cfg handled?
I'm a bit afraid to mess up the installation not because of fpc but
because I'm not really knowing what I'm doing. ;)

Additionally there seems to be no compiler switch for changing the
configuration file to use, only -n for ignoring it. Is ist possible to
name the .cfg on the command line or how would it be done better?

TIA,
Marc


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: installing cross fpc in parallel to systems fpc

Christo Crause
On Thu, 2017-11-09 at 02:36 +0100, Marc Santhoff wrote:
> Additionally there seems to be no compiler switch for changing the
> configuration file to use, only -n for ignoring it. Is ist possible
> to
> name the .cfg on the command line or how would it be done better?

Yes, specify alternative config file using the @ option.  Use in
conjunction with -n if you want to exclude the default config file.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: installing cross fpc in parallel to systems fpc

Marc Santhoff-2
On Do, 2017-11-09 at 20:05 +0200, Christo wrote:
> On Thu, 2017-11-09 at 02:36 +0100, Marc Santhoff wrote:
> > Additionally there seems to be no compiler switch for changing the
> > configuration file to use, only -n for ignoring it. Is ist possible
> > to
> > name the .cfg on the command line or how would it be done better?
>
> Yes, specify alternative config file using the @ option.  Use in
> conjunction with -n if you want to exclude the default config file.

In fact you're right, I ovelooked that option. Now that the name ist
known:

 > ./ppcrossarm -h | grep @
  @<x>   Read compiler options from <x> in addition to the default fpc.cfg

That solves most problems for now.

Thanks,
Marc

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: installing cross fpc in parallel to systems fpc

Giuliano Colla
In reply to this post by Marc Santhoff-2
Il 09/11/2017 02:36, Marc Santhoff ha scritto:

> how does fpc and it's makefiles handle the case of installing a cross
> compiler on a system having fpc installed?
>
> The target path will differ and I can set that, but how is the config
> file .fpc.cfg handled?

You may edit your fpc.cfg for your different target using an IFDEF/ENDIF
pair.

Under Linux I have in my home directory a .fpc.cfg sort of:

#include /etc/fpc.cfg  <--- to get all the defaults
#IFDEF CPUARM
---- here all the ARM specific paths and options
#ENDIF

That's the basic idea. All that's between #IFDEF -- #ENDIF is ignored
when you're *not* cross-compiling.
All that's between #IFDEF -- #ENDIF overrides the previous settings when
you're cross-compiling

Giuliano
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: installing cross fpc in parallel to systems fpc

Marc Santhoff-2
On Do, 2017-11-09 at 21:31 +0100, Giuliano Colla wrote:

> Il 09/11/2017 02:36, Marc Santhoff ha scritto:
>
> > how does fpc and it's makefiles handle the case of installing a cross
> > compiler on a system having fpc installed?
> >
> > The target path will differ and I can set that, but how is the config
> > file .fpc.cfg handled?
>
> You may edit your fpc.cfg for your different target using an IFDEF/ENDIF
> pair.
>
> Under Linux I have in my home directory a .fpc.cfg sort of:
>
> #include /etc/fpc.cfg  <--- to get all the defaults
> #IFDEF CPUARM
> ---- here all the ARM specific paths and options
> #ENDIF

I see, so when using fpc for ARM these define is automatically set?
And would that be CPUAVR for Atmels chips?

> That's the basic idea. All that's between #IFDEF -- #ENDIF is ignored
> when you're *not* cross-compiling.
> All that's between #IFDEF -- #ENDIF overrides the previous settings when
> you're cross-compiling

I have thought about this solution, but did not know the details. Next
step will be to generate a default fpc.cfg for the arm cross compiler
and merge that into the .fpc.cfg using ifdefs.

Fine, now I know the way. :)

Thanks,
Marc

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: installing cross fpc in parallel to systems fpc

Giuliano Colla
Il 09/11/2017 22:56, Marc Santhoff ha scritto:

> I see, so when using fpc for ARM these define is automatically set?
Yes
> And would that be CPUAVR for Atmels chips?
Not sure about that. I never used fpc on Atmel chips. When I'm in doubt
about the conditional defines, I either google or take advantage of
Lazarus: in project->options I select the target CPU family and the
target processor, and then I use "show all options" to see which defines
are set.

Giuliano

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: installing cross fpc in parallel to systems fpc

Free Pascal - General mailing list
> When I'm in doubt
about the conditional defines, I either google or take advantage of
Lazarus: in project->options I select the target CPU family and the
target processor, and then I use "show all options" to see which defines
are set.

fpc -vc is your friend here.



--
Sent from: http://free-pascal-general.1045716.n5.nabble.com/
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: installing cross fpc in parallel to systems fpc

Marco van de Voort
In reply to this post by Marc Santhoff-2
In our previous episode, Marc Santhoff said:
> > #ENDIF
>
> I see, so when using fpc for ARM these define is automatically set?
> And would that be CPUAVR for Atmels chips?

(easiest is to just fpc -va some dummy source and then grep for CPU, or look
in the compiler sources (options.pas or systems/ iirc)

You can select a different cpu then the default using fpc -P<architecture>

So if you have a x86 compiled fpc.exe, you can get it to select ppcx64 using
fpc -Px86_64 and then e.g. -Twin64 for the target.  Then all the relevant
directives (CPU64, cpux86_64, win64, mswindows etc) are defined.

(I use windows now because I know those defines by heart, for arm it is the
same).

The buildfaq (document section on the FPC site), though somewhat outdated,
has some info and examples on this.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: installing cross fpc in parallel to systems fpc

Marc Santhoff-2
In reply to this post by Marc Santhoff-2
Hi again,

(too many sub threads, answering here - thanks to all helpers!)

OK, "$FPC -va | grep CPU" does the trick. If using the ppcrossarm:

marc@puma:/home/marc/program/fpc-cross/src/fpc/compiler > ./ppcrossarm -va|grep CPU
[0.004] Macro defined: CPUARMEL
[0.004] Macro defined: FPC_CPUCROSSCOMPILING
[0.004] Macro defined: CPUARM
[0.004] Macro defined: CPU32
[0.004] Macro defined: CPUINT32
[0.020] interpreting file option "#IFNDEF CPUI386"
[0.020] interpreting file option "#IFNDEF CPUAMD64"

See, an arm compiler. But when using the ppc binary in the same dir it
looks different. Here we go:

marc@puma:/home/marc/program/fpc-cross/src/fpc/compiler > ./ppc -va | grep CPU
[0.008] Macro defined: CPUX86_64
[0.008] Macro defined: CPUAMD64
[0.008] Macro defined: CPU64
[0.008] Macro defined: CPUX64
[0.008] Macro defined: CPUINT64
[0.023] interpreting file option "#IFNDEF CPUI386"
[0.023] interpreting file option "#IFNDEF CPUAMD64"

What is that, is ppc used for bootstrapping the cross compiler
regardless of any other fpc maybe installed?

Next question is how to get started with lazarus and multiple compilers.
How do you do it, using configuration files for lazarus and starting
like "lazarus --primary-config-path= <path>"? Or are there other
possibilities to try?


Marc

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: installing cross fpc in parallel to systems fpc

Karoly Balogh (Charlie/SGR)
Hi,

On Fri, 10 Nov 2017, Marc Santhoff wrote:

> What is that, is ppc used for bootstrapping the cross compiler
> regardless of any other fpc maybe installed?

Yes. First that ppc gets built with the "other FPC" installed. Or you can
specify a startup compiler explicitly with FPC= argument to the make. It
doesn't even need the rtl or anything, just the "ppcXXX" native compiler.

During the first round it builds this new native compiler + rtl which will
be used to bootstrap the actual crosscompiler then.

Charlie
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: installing cross fpc in parallel to systems fpc

Mattias Gaertner
In reply to this post by Marc Santhoff-2
On Fri, 10 Nov 2017 17:47:11 +0100
Marc Santhoff <[hidden email]> wrote:

> Hi again,
>
> (too many sub threads, answering here - thanks to all helpers!)
>
> OK, "$FPC -va | grep CPU" does the trick. If using the ppcrossarm:
>
> marc@puma:/home/marc/program/fpc-cross/src/fpc/compiler > ./ppcrossarm -va|grep CPU
> [0.004] Macro defined: CPUARMEL
> [0.004] Macro defined: FPC_CPUCROSSCOMPILING
> [0.004] Macro defined: CPUARM
> [0.004] Macro defined: CPU32
> [0.004] Macro defined: CPUINT32
> [0.020] interpreting file option "#IFNDEF CPUI386"
> [0.020] interpreting file option "#IFNDEF CPUAMD64"
>
> See, an arm compiler. But when using the ppc binary in the same dir it
> looks different. Here we go:
>
> marc@puma:/home/marc/program/fpc-cross/src/fpc/compiler > ./ppc -va | grep CPU

What is ppc?
Where is fpc?


> Next question is how to get started with lazarus and multiple compilers.
> How do you do it, using configuration files for lazarus and starting
> like "lazarus --primary-config-path= <path>"? Or are there other
> possibilities to try?

Lazarus supports multiple compilers.
You can either use fpc and switch the target OS and /or processor.
Or you can switch the compiler binary: Project / Project Options /
Compiler Options / Compiler Command. Replace the default
value '$(CompPath)' with the path.

You can use build modes to switch with a mouse click between various
sets of compiler options.

Mattias

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: installing cross fpc in parallel to systems fpc

Marc Santhoff-2
On Fr, 2017-11-10 at 18:25 +0100, Mattias Gaertner wrote:

> On Fri, 10 Nov 2017 17:47:11 +0100
> Marc Santhoff <[hidden email]> wrote:
>
> > Hi again,
> >
> > (too many sub threads, answering here - thanks to all helpers!)
> >
> > OK, "$FPC -va | grep CPU" does the trick. If using the ppcrossarm:
> >
> > marc@puma:/home/marc/program/fpc-cross/src/fpc/compiler > ./ppcrossarm -va|grep CPU
> > [0.004] Macro defined: CPUARMEL
> > [0.004] Macro defined: FPC_CPUCROSSCOMPILING
> > [0.004] Macro defined: CPUARM
> > [0.004] Macro defined: CPU32
> > [0.004] Macro defined: CPUINT32
> > [0.020] interpreting file option "#IFNDEF CPUI386"
> > [0.020] interpreting file option "#IFNDEF CPUAMD64"
> >
> > See, an arm compiler. But when using the ppc binary in the same dir it
> > looks different. Here we go:
> >
> > marc@puma:/home/marc/program/fpc-cross/src/fpc/compiler > ./ppc -va | grep CPU
>
> What is ppc?
> Where is fpc?

That happens in the directory of a built but not yet installed cross
compiler. The build command following those instructions:

http://j-software.dk/stm32f103.php

was:

gmake clean buildbase installbase CROSSINSTALL=1 CROSSOPT="-XParm-elf-"
OS_TARGET=embedded CPU_TARGET=arm SUBARCH=armv7m PREFIX=../../fpc-arm

IIRC. But actually the path from the PREFIX does not exist. Sth. to
investigate or redo for me.

>
> > Next question is how to get started with lazarus and multiple compilers.
> > How do you do it, using configuration files for lazarus and starting
> > like "lazarus --primary-config-path= <path>"? Or are there other
> > possibilities to try?
>
> Lazarus supports multiple compilers.
> You can either use fpc and switch the target OS and /or processor.

That solution isnt't doable, that would require a compiler for X86_64
and ARM.

> Or you can switch the compiler binary: Project / Project Options /
> Compiler Options / Compiler Command. Replace the default
> value '$(CompPath)' with the path.

Aha, OK.

> You can use build modes to switch with a mouse click between various
> sets of compiler options.

Beautiful, may take a while to get there, but very handy. :)

Marc

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: installing cross fpc in parallel to systems fpc

Marc Santhoff-2
In reply to this post by Karoly Balogh (Charlie/SGR)
On Fr, 2017-11-10 at 18:22 +0100, Karoly Balogh (Charlie/SGR) wrote:

> Hi,
>
> On Fri, 10 Nov 2017, Marc Santhoff wrote:
>
> > What is that, is ppc used for bootstrapping the cross compiler
> > regardless of any other fpc maybe installed?
>
> Yes. First that ppc gets built with the "other FPC" installed. Or you can
> specify a startup compiler explicitly with FPC= argument to the make. It
> doesn't even need the rtl or anything, just the "ppcXXX" native compiler.
>
> During the first round it builds this new native compiler + rtl which will
> be used to bootstrap the actual crosscompiler then.

Ok. So I have a newer compiler for the base system built on the fly,
nice.

Thanks,
Marc

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: installing cross fpc in parallel to systems fpc

Mattias Gaertner
In reply to this post by Marc Santhoff-2
On Fri, 10 Nov 2017 18:57:19 +0100
Marc Santhoff <[hidden email]> wrote:

>[...]
> > You can either use fpc and switch the target OS and /or processor.  
>
> That solution isnt't doable, that would require a compiler for X86_64
> and ARM.

fpc -Parm calls ppcarm, fpc -Px86_64 calls ppcx64.

Mattias
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: installing cross fpc in parallel to systems fpc

Free Pascal - General mailing list
In reply to this post by Marc Santhoff-2
Am 10.11.2017 18:59 schrieb "Marc Santhoff" <[hidden email]>:
On Fr, 2017-11-10 at 18:22 +0100, Karoly Balogh (Charlie/SGR) wrote:
> Hi,
>
> On Fri, 10 Nov 2017, Marc Santhoff wrote:
>
> > What is that, is ppc used for bootstrapping the cross compiler
> > regardless of any other fpc maybe installed?
>
> Yes. First that ppc gets built with the "other FPC" installed. Or you can
> specify a startup compiler explicitly with FPC= argument to the make. It
> doesn't even need the rtl or anything, just the "ppcXXX" native compiler.
>
> During the first round it builds this new native compiler + rtl which will
> be used to bootstrap the actual crosscompiler then.

Ok. So I have a newer compiler for the base system built on the fly,
nice.

Not really, because only the compiler and RTL are rebuild for the native system when cross building FPC, all the packages are still missing. So you nevertheless need to do a complete build for your host life you had done for your cross compilation target. 

Regards, 
Sven 

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: installing cross fpc in parallel to systems fpc

Marc Santhoff-2
In reply to this post by Mattias Gaertner
On Fr, 2017-11-10 at 19:07 +0100, Mattias Gaertner wrote:

> On Fri, 10 Nov 2017 18:57:19 +0100
> Marc Santhoff <[hidden email]> wrote:
>
> >[...]
> > > You can either use fpc and switch the target OS and /or processor.  
> >
> > That solution isnt't doable, that would require a compiler for X86_64
> > and ARM.
>
> fpc -Parm calls ppcarm, fpc -Px86_64 calls ppcx64.

Besides the language - fpc and lazarus are so cool tools!

Thank you,
Marc

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: installing cross fpc in parallel to systems fpc

Marco van de Voort
In our previous episode, Marc Santhoff said:
> > fpc -Parm calls ppcarm, fpc -Px86_64 calls ppcx64.
>
> Besides the language - fpc and lazarus are so cool tools!

and fpc  -V-1.0 calls ppc386-1.0  etc etc :-)
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: installing cross fpc in parallel to systems fpc

Marco van de Voort
In our previous episode, Marco van de Voort said:
> > > fpc -Parm calls ppcarm, fpc -Px86_64 calls ppcx64.
> >
> > Besides the language - fpc and lazarus are so cool tools!
>
> and fpc  -V-1.0 calls ppc386-1.0  etc etc :-)

Whoops, that should be -V1.0 of course. The idea is that you can give
releases suffixes, though that is mainly useful for different versions
(since then you can each version share a fpc.cfg using version #ifdefs)
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal