Go to the first, previous, next, last section, table of contents.



Multilibs

For some targets gcc may have different processor requirements depending upon command line options. An obvious example is the `-msoft-float' option supported on several processors. This option means that the floating point registers are not available, which means that floating point operations must be done by calling an emulation subroutine rather than by using machine instructions.

For such options, gcc is often configured to compile target libraries twice: once with `-msoft-float' and once without. When gcc compiles target libraries more than once, the resulting libraries are called multilibs.

Multilibs are not really part of the GNU configure and build system, but we discuss them here since they require support in the `configure' scripts and `Makefile's used for target libraries.

Multilibs in gcc

In gcc, multilibs are defined by setting the variable `MULTILIB_OPTIONS' in the target `Makefile' fragment. Several other `MULTILIB' variables may also be defined there. See section `The Target Makefile Fragment' in Using and Porting GNU CC.

If you have built gcc, you can see what multilibs it uses by running it with the `-print-multi-lib' option. The output `.;' means that no multilibs are used. In general, the output is a sequence of lines, one per multilib. The first part of each line, up to the `;', is the name of the multilib directory. The second part is a list of compiler options separated by `@' characters.

Multilibs are built in a tree of directories. The top of the tree, represented by `.' in the list of multilib directories, is the default library to use when no special compiler options are used. The subdirectories of the tree hold versions of the library to use when particular compiler options are used.

Multilibs in Target Libraries

The target libraries in the Cygnus tree are automatically built with multilibs. That means that each library is built multiple times.

This default is set in the top level `configure.in' file, by adding `--enable-multilib' to the list of arguments passed to configure when it is run for the target libraries (see section Host and Target Libraries).

Each target library uses the shell script `config-ml.in', written by Doug Evans, to prepare to build target libraries. This shell script is invoked after the `Makefile' has been created by the `configure' script. If multilibs are not enabled, it does nothing, otherwise it modifies the `Makefile' to support multilibs.

The `config-ml.in' script makes one copy of the `Makefile' for each multilib in the appropriate subdirectory. When configuring in the source directory (which is not recommended), it will build a symlink tree of the sources in each subdirectory.

The `config-ml.in' script sets several variables in the various `Makefile's. The `Makefile.in' must have definitions for these variables already; `config-ml.in' simply changes the existing values. The `Makefile' should use default values for these variables which will do the right thing in the subdirectories.

`MULTISRCTOP'
`config-ml.in' will set this to a sequence of `../' strings, where the number of strings is the number of multilib levels in the source tree. The default value should be the empty string.
`MULTIBUILDTOP'
`config-ml.in' will set this to a sequence of `../' strings, where the number of strings is number of multilib levels in the object directory. The default value should be the empty string. This will differ from `MULTISRCTOP' when configuring in the source tree (which is not recommended).
`MULTIDIRS'
In the top level `Makefile' only, `config-ml.in' will set this to the list of multilib subdirectories. The default value should be the empty string.
`MULTISUBDIR'
`config-ml.in' will set this to the installed subdirectory name to use for this subdirectory, with a leading `/'. The default value shold be the empty string.
`MULTIDO'
`MULTICLEAN'
In the top level `Makefile' only, `config-ml.in' will set these variables to commands to use when doing a recursive make. These variables should both default to the string `true', so that by default nothing happens.

All references to the parent of the source directory should use the variable `MULTISRCTOP'. Instead of writing `$(srcdir)/..', you must write `$(srcdir)/$(MULTISRCTOP)..'.

Similarly, references to the parent of the object directory should use the variable `MULTIBUILDTOP'.

In the installation target, the libraries should be installed in the subdirectory `MULTISUBDIR'. Instead of installing `$(libdir)/libfoo.a', install `$(libdir)$(MULTISUBDIR)/libfoo.a'.

The `config-ml.in' script also modifies the top level `Makefile' to add `multi-do' and `multi-clean' targets which are used when building multilibs.

The default target of the `Makefile' should include the following command:

@$(MULTIDO) $(FLAGS_TO_PASS) DO=all multi-do

This assumes that `$(FLAGS_TO_PASS)' is defined as a set of variables to pass to a recursive invocation of `make'. This will build all the multilibs. Note that the default value of `MULTIDO' is `true', so by default this command will do nothing. It will only do something in the top level `Makefile' if multilibs were enabled.

The `install' target of the `Makefile' should include the following command:

@$(MULTIDO) $(FLAGS_TO_PASS) DO=install multi-do

In general, any operation, other than clean, which should be performed on all the multilibs should use a `$(MULTIDO)' line, setting the variable `DO' to the target of each recursive call to `make'.

The `clean' targets (`clean', `mostlyclean', etc.) should use `$(MULTICLEAN)'. For example, the `clean' target should do this:

@$(MULTICLEAN) DO=clean multi-clean


Go to the first, previous, next, last section, table of contents.