### 9.4 Working with two compilers

This functionality is intended for people whose projects need to be compiled with a specific (old) version of the GNAT toolchain, while still desiring to take full advantage of up-to-date associated tools for non-compilation actions, such as checking the code against a coding standard, getting better cross-reference browsing in GPS, computing metrics and so on.

GPS now allows you to handle this case. To configure GPS to make it handle two compiler toolchains, you need to use the `Build->Settings->Toolchains` menu. This will open a dialog where you can activate the multiple-toolchains mode.

In this dialog, two paths need to be configured: the compiler path and the tools path. The first one is used to actually compile the code, while the second one is used to run up-to-date tools to get more functionalities or accurate results.

Note that GPS will only enable the `OK` button when the two paths are set to different location, since otherwise it does not make sense to enable the multiple toolchains set up.

From this dialog, you can also activate an automated cross-reference generation. The cross-reference files are the .ali files generated by the GNAT compiler together with the compiled object. Those files are used by GPS for several functionalities, such as cross-reference browsing or documentation generation. Having those .ali files produced by a recent compiler helps having more accurate results with those functionalities, but might interract badly with an old compiler also reading those .ali files for compiling a project.

If the automated xref generation is activated, then GPS will generate those .ali files using the compiler found in the tools path, and place them in a directory distinct from the one used by the actual compiler. This allows GPS to take full benefit of up-to-date cross-reference files, while keeping the old toolchain happy as its .ali files remain untouched.

Note that the cross-reference files generation does not output anything in the "Messages" window, so as to not confuse the output of the regular build process. If needed, you can see the output of the cross-ref generation command by selecting the `Tools->Consoles->Auxiliary Builds` menu.

#### 9.4.1 Interaction with the remote mode

The ability to work with two compilers has impacts on the remote mode configuration: paths defined here are local paths, so they have no meaning on the server side.

To handle the case of using a specific compiler version on the remote side while still wanting up-to-date tools, the following behavior is applied when both a remote compilation server is defined, and the multiple toolchains mode is activated:

- The compiler path is ignored when a remote build server is defined. All compilation actions are then performed normally on the build server.
- The tools path is however taken into account, and all related actions are performed on the local machine using this path.
- The cross-reference files are taken care of by the rsync mechanism so that they don't get overwritten during local and remote host synchronisations, as build and cross-reference generation actions occur at the same time, on the local machine and on the distant server.