Sign in Join
Wiki copytemporary

FPC Version Switcher

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:

etc...

For an x86_64 (64 bit) system:

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:

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:

etc...

Checking fpc's mechanism

Processor name

The -PP switch just displays the processor name.

Actual compiler name name

The -PB switch will make fpc just display the actual compiler name for a target cpu.

On an i386 system (32 bit):

etc...

On an x86_64 system (64 bit):

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

Compiler utilities

The actual compiler, once called, may need to locate some utilities. The path can be specified by either:

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

  1. Having multiple fpc versions installed
  2. Having a homogeneous directory structure (paths for different fpc versions should differ only by version number)
  3. Modifying all paths in fpc.cfg to depend on FPC's $FPCVERSION macro (where applicable)
  4. Not having fpc related paths in the environment PATH variable (except as outlined in #Setting the fpc frontend executable path)
  5. 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 doesn't depend on $(FPCVER).

Select how the IDE should locate the fpc frontend:

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 doesn't depend on $(FPCVER).

Select how the IDE should locate the actual compiler:

Setting the compiler utilities path

Enter or locate the absolute path of the compiler utilities. You can use $(UseFPCVersion) and any IDE macro other than and/or doesn't depend on $(FPCVER).

Select how the IDE should locate the actual compiler:

Enabling the version 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)

Mechanism

Verifying the settings

The check button will display:

Usage

To change the fpc version, 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 the 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

Separate bin folders and separate lib folders

Common bin folder (fpc executable + ppcxxx-XYZ symlinks) and separate lib folders using symlinks /usr/local/bin/ppcxxx-$(UseFPCVersion) -> /usr/local/lib/fpc/$(UseFPCVersion)/ppcxxx

Known issues

This is a work in progress and therefore not all options are functional. What needs to be completed is the prefix/suffix link between FPC Version Switcher and the IDE. Therefore options that pass paths or switches to the IDE should not be used for now.

Wishlist


From the Free Pascal wiki, page "FPC Version Switcher", as it stood on 2015-02-27 after a change by Stephano, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 2, last changed by WikiArchive .

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.