Difference between revisions of "FPC Version Switcher"
m |
m |
||
Line 1: | Line 1: | ||
== About == | == About == | ||
The FPC version switcher package integrates with the Lazarus IDE in order to allow easy switching of fpc versions. | The FPC version switcher package integrates with the Lazarus IDE in order to allow easy switching of fpc versions. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
Line 88: | Line 83: | ||
Now, if the installations of the different fpc versions differ only by the version number (eg /usr/lib/fpc/2.6.4 and /usr/lib/fpc/3.1.1), then one can specify paths based on that macro (eg /usr/lib/fpc/$(UseFPCVersion)). Moreover, any IDE macro other than $(FPCVER) and that doesn't depend on it can be used in the paths (eg $Env(HOME)/fpc/lib/$(UseFPCVersion)). | Now, if the installations of the different fpc versions differ only by the version number (eg /usr/lib/fpc/2.6.4 and /usr/lib/fpc/3.1.1), then one can specify paths based on that macro (eg /usr/lib/fpc/$(UseFPCVersion)). Moreover, any IDE macro other than $(FPCVER) and that doesn't depend on it can be used in the paths (eg $Env(HOME)/fpc/lib/$(UseFPCVersion)). | ||
+ | |||
+ | === Pre-requisites === | ||
+ | #Having multiple fpc versions installed | ||
+ | #Having a homogeneous directory structure (paths for different fpc versions should differ only by version number) | ||
+ | #Not having fpc related paths in the environment PATH variable | ||
+ | #Having "fpc" as compiler executable in the IDE's Tools/Options/Files | ||
+ | |||
+ | === Installation === | ||
+ | Open fpcversionswitcher.lpk in the lazarus/components/fpcversionswitcher folder, compile and install it and restart the IDE. A new frame will be available in Tools/Options/Compiler Version. | ||
+ | |||
+ | === FPC version selection === | ||
+ | Enter or select the required FPC version using the dropdown list. This will set the $(UseFPCVersion) macro accordingly. Note that this macro is different from the IDE's $(FPCVER) macro. | ||
+ | |||
+ | === Setting the fpc frontend executable path === | ||
+ | Enter or locate the absolute path of the fpc frontend executable. You can use $(UseFPCVersion) and/or any IDE macro other than and/or doesn't depend on $(FPCVER). | ||
+ | |||
+ | Select how the IDE should locate the fpc frontend: | ||
+ | *By adding the path to the environment PATH variable | ||
+ | *By calling the fpc executable with a fully qualified path | ||
+ | |||
+ | === Setting the actual compiler executable path === | ||
+ | Enter or locate the absolute path of the actual compiler executable. You can use $(UseFPCVersion) and/or any IDE macro other than and/or doesn't depend on $(FPCVER). | ||
+ | |||
+ | Select how the IDE should locate the actual compiler: | ||
+ | *By adding the path to the environment PATH variable | ||
+ | *By calling the fpc executable with the Xp switch and a fully qualified path | ||
+ | |||
+ | === Setting the fpc tools path === | ||
+ | Enter or locate the absolute path of the fpc tools (these are usually in the same folder as the fpc frontend). You can use $(UseFPCVersion) and/or any IDE macro other than and/or doesn't depend on $(FPCVER). | ||
+ | |||
+ | Select how the IDE should locate the actual compiler: | ||
+ | *By adding the path to the environment PATH variable | ||
+ | *By calling the fpc executable with the FD switch and a fully qualified path | ||
+ | *By assuming that the FD switch is used in fpc.cfg | ||
+ | |||
+ | === Enabling the suffix for the actual compiler === | ||
+ | Check "ppc executable has suffix" if the actual compilers or symlinks pointing to them have the fpc version suffixed (eg ppc386-3.1.1) | ||
+ | |||
+ | === Use === | ||
+ | Every time the fpc version needs to be changed, it is enough to go to Tools/Options/Compiler version and select the required FPC version. You can then compile your projects or the IDE with that version. | ||
+ | |||
+ | === Use cases with different fpc and ppc folders setups === | ||
+ | For sake of brevity, the fpc frontend executable folder and the actual compiler folder will be denoted as the bin and lib folders respectively, | ||
+ | |||
+ | ==== Common bin folder and separate lib folders ==== | ||
+ | *fpc executable path: /usr/local/bin | ||
+ | *ppcxxx executable path: /usr/local/lib/fpc/$(UseFPCVersion) | ||
+ | |||
+ | ==== Separate bin folders and separate lib folders ==== | ||
+ | *fpc executable path: <fpctopfolder>/$(UseFPCVersion)/bin | ||
+ | *ppcxxx executable path: <fpctopfolder>/$(UseFPCVersion)/lib/fpc/$(UseFPCVersion) | ||
+ | |||
+ | ==== Common bin folder (fpc executable + ppcxxx-XYZ symlinks) and separate lib folders using symlinks /usr/local/bin/ppcxxx-$(UseFPCVersion) -> /usr/local/lib/fpc/$(UseFPCVersion)/ppcXYZ ==== | ||
+ | *fpc executable path: /usr/local/bin | ||
+ | *ppcxxx executable path: None | ||
+ | *ppc executable has suffix: Yes |
Revision as of 11:23, 25 February 2015
About
The FPC version switcher package integrates with the Lazarus IDE in order to allow easy switching of fpc versions.
Background
Actual compiler naming convention
The actual FPC compiler / cross-compiler is usually ppcxxx or ppcrossxxx where xxx denotes the cpu target.
For an i386 (32 bit) system:
- ppc386 is the actual compiler
- ppcrossx64 is the actual x86_64 cross compiler (produces 64 bit binaries)
- ppcrossarm is the actual arm cross compiler (produces arm binaries)
etc...
For an x86_64 (64 bit) system:
- ppcx64 is the actual compiler
- ppcross386 is the actual i386 cross compiler (produces 32 bit binaries)
- ppcrossarm is the actual arm cross compiler (produces arm binaries)
etc...
The fpc frontend executable
Rather than letting one guess the actual compiler name for a certain target cpu and call it directly, FPC provides the fpc front end executable, which takes care of calling the right actual compiler for the required target cpu. To do that, 3 things are needed:
- The OS should be able to locate the fpc executable by either:
- adding the fpc executable path to the environment PATH variable (eg export PATH=/usr/bin;$PATH) and just calling "fpc".
- providing a fully qualified path (eg /usr/bin/fpc).
- The fpc executable should be told what the target cpu is by using the -P<target_cpu> switch so that it can deduce by itself the actual compiler name.
- The fpc executable should be able to locate the actual compiler by either:
- adding the actual compiler (ppcxxx) path to the environment PATH variable (eg export PATH=/usr/lib/fpc;$PATH)
- calling fpc with the -Xp<ppcxxx_path> switch to inform it about the location of the actual compiler (eg: fpc -Xp/usr/lib/fpc)
Some users opt to create in one folder symlinks with the fpc version suffixed (eg ppc386-3.1.1), and pointing to the actual compilers. The -V<version> switch lets the fpc executable append <version> to the actual compiler name (eg fpc -V3.1.1 on a 386 system will look for ppc386-3.1.1).
To sum up, calling fpc can take different forms:
- fpc -P<cpu_target>
- /usr/bin/fpc -Xp/usr/lib/fpc -P<cpu_target>
- /usr/bin/fpc -Xp/usr/lib/fpc -V3.1.1 -P<cpu_target>
etc...
Checking fpc's mechanism
The -PP switch just displays the processor name.
- On an i386 system (32 bit), the output of fpc -PP is i386
- On an x86_64 system (64 bit), the output of fpc -PP is x86_64
The -PB switch will make fpc just display the actual compiler name for a target cpu.
On an i386 system (32 bit):
- fpc -PB will output ppc386 (default cpu target)
- fpc -Pi386 -PB will output ppc386
- fpc -Px86_64 -PB will output ppcrossx64
- fpc -Parm -PB will output ppcrossarm
etc...
On an x86_64 system (64 bit):
- fpc -PB will output ppcx64 (default cpu target)
- fpc -Px86_64 -PB will output ppcx64
- fpc -Pi386 -PB will output ppcross386
- fpc -Parm -PB will output ppcrossarm
etc...
One can even use it as follows:
<path_to_fpc_bin>/fpc -Xp<<path_to_fpc_lib> -V<fpc_version> -P<cpu_target> -PB
FPC tools
The actual compiler, once called, may need to locate some fpc utilities or tool. The path can be specified by either:
- Adding the fpc tools path to the environment PATH variable (eg export PATH=/usr/local/bin/fpctools;$PATH)
- Adding the -FD<fpc_tools_path> switch to fpc.cfg (eg: -FD/usr/local/bin/fpctools)
- Calling fpc with the -FD<fpc_tools_path> switch (eg: fpc -FD/usr/local/bin/fpctools)
Cross binutils
For cross compiling, the cross binutils (cross assembler, cross linker, ...) folder should be in the environment PATH variable.
FPC Version Switcher
The FPC version switcher package allows tweaking all the above options and even providing a dropdown list in the IDE Tools/Options/Compiler Version in order to select the required fpc version, and set the $(UseFPCVersion) macro accordingly.
Now, if the installations of the different fpc versions differ only by the version number (eg /usr/lib/fpc/2.6.4 and /usr/lib/fpc/3.1.1), then one can specify paths based on that macro (eg /usr/lib/fpc/$(UseFPCVersion)). Moreover, any IDE macro other than $(FPCVER) and that doesn't depend on it can be used in the paths (eg $Env(HOME)/fpc/lib/$(UseFPCVersion)).
Pre-requisites
- Having multiple fpc versions installed
- Having a homogeneous directory structure (paths for different fpc versions should differ only by version number)
- Not having fpc related paths in the environment PATH variable
- Having "fpc" as compiler executable in the IDE's Tools/Options/Files
Installation
Open fpcversionswitcher.lpk in the lazarus/components/fpcversionswitcher folder, compile and install it and restart the IDE. A new frame will be available in Tools/Options/Compiler Version.
FPC version selection
Enter or select the required FPC version using the dropdown list. This will set the $(UseFPCVersion) macro accordingly. Note that this macro is different from the IDE's $(FPCVER) macro.
Setting the fpc frontend executable path
Enter or locate the absolute path of the fpc frontend executable. You can use $(UseFPCVersion) and/or any IDE macro other than and/or doesn't depend on $(FPCVER).
Select how the IDE should locate the fpc frontend:
- By adding the path to the environment PATH variable
- By calling the fpc executable with a fully qualified path
Setting the actual compiler executable path
Enter or locate the absolute path of the actual compiler executable. You can use $(UseFPCVersion) and/or any IDE macro other than and/or doesn't depend on $(FPCVER).
Select how the IDE should locate the actual compiler:
- By adding the path to the environment PATH variable
- By calling the fpc executable with the Xp switch and a fully qualified path
Setting the fpc tools path
Enter or locate the absolute path of the fpc tools (these are usually in the same folder as the fpc frontend). You can use $(UseFPCVersion) and/or any IDE macro other than and/or doesn't depend on $(FPCVER).
Select how the IDE should locate the actual compiler:
- By adding the path to the environment PATH variable
- By calling the fpc executable with the FD switch and a fully qualified path
- By assuming that the FD switch is used in fpc.cfg
Enabling the suffix for the actual compiler
Check "ppc executable has suffix" if the actual compilers or symlinks pointing to them have the fpc version suffixed (eg ppc386-3.1.1)
Use
Every time the fpc version needs to be changed, it is enough to go to Tools/Options/Compiler version and select the required FPC version. You can then compile your projects or the IDE with that version.
Use cases with different fpc and ppc folders setups
For sake of brevity, the fpc frontend executable folder and the actual compiler folder will be denoted as the bin and lib folders respectively,
Common bin folder and separate lib folders
- fpc executable path: /usr/local/bin
- ppcxxx executable path: /usr/local/lib/fpc/$(UseFPCVersion)
Separate bin folders and separate lib folders
- fpc executable path: <fpctopfolder>/$(UseFPCVersion)/bin
- ppcxxx executable path: <fpctopfolder>/$(UseFPCVersion)/lib/fpc/$(UseFPCVersion)
Common bin folder (fpc executable + ppcxxx-XYZ symlinks) and separate lib folders using symlinks /usr/local/bin/ppcxxx-$(UseFPCVersion) -> /usr/local/lib/fpc/$(UseFPCVersion)/ppcXYZ
- fpc executable path: /usr/local/bin
- ppcxxx executable path: None
- ppc executable has suffix: Yes