# Installing GCC: Configuration

Like most GNU software, GCC must be configured before it can be built. This document describes the recommended configuration procedure for both native and cross targets.

We use srcdir to refer to the toplevel source directory for GCC; we use objdir to refer to the toplevel build/object directory.

If you obtained the sources via CVS, srcdir must refer to the top `gcc` directory, the one where the `MAINTAINERS` can be found, and not its `gcc` subdirectory, otherwise the build will fail.

First, we highly recommend that GCC be built into a separate directory than the sources which does not reside within the source tree. This is how we generally build GCC; building where srcdir == objdir should still work, but doesn't get extensive testing; building where objdir is a subdirectory of srcdir is unsupported.

If you have previously built GCC in the same directory for a different target machine, do `make distclean` to delete all files that might be invalid. One of the files this deletes is `Makefile`; if `make distclean` complains that `Makefile` does not exist, it probably means that the directory is already suitably clean. However, with the recommended method of building in a separate objdir, you should simply use a different objdir for each target.

Second, when configuring a native system, either `cc` or `gcc` must be in your path or you must set `CC` in your environment before running configure. Otherwise the configuration scripts may fail.

Note that the bootstrap compiler and the resulting GCC must be link compatible, else the bootstrap will fail with linker errors about incompatible object file formats. Several multilibed targets are affected by this requirement, see host/target specific installation notes.

To configure GCC:

       % mkdir objdir
       % cd objdir
       % srcdir/configure [options] [target]

## Target specification

- GCC has code to correctly determine the correct value for target for nearly all native systems. Therefore, we highly recommend you not provide a configure target when configuring a native compiler.
- target must be specified as `--target=target` when configuring a cross compiler; examples of valid targets would be i960-rtems, m68k-coff, sh-elf, etc.
- Specifying just target instead of `--target=target` implies that the host defaults to target.

## Options specification

Use options to override several configure time options for GCC. A partial list of supported options:

`--prefix=dirname`
  Specify the toplevel installation directory. This is the recommended way to install the tools into a directory other than the default. The toplevel installation directory defaults to `/usr/local`.

  We highly recommend against dirname being the same or a subdirectory of objdir or vice versa.

  These additional options control where certain parts of the distribution are installed. Normally you should not need to use these options.

  `--exec-prefix=dirname`
    Specify the toplevel installation directory for architecture-dependent files. The default is `prefix`.
  `--bindir=dirname`
    Specify the installation directory for the executables called by users (such as `gcc` and `g++`). The default is `exec-prefix/bin`.
  `--libdir=dirname`
    Specify the installation directory for object code libraries and internal parts of GCC. The default is `exec-prefix/lib`.
  `--with-slibdir=dirname`
    Specify the installation directory for the shared libgcc library. The default is `libdir`.
  `--infodir=dirname`
    Specify the installation directory for documentation in info format. The default is `prefix/info`.
  `--mandir=dirname`
    Specify the installation directory for manual pages. The default is `prefix/man`. (Note that the manual pages are only extracts from the full GCC manuals, which are provided in Texinfo format. The `g77` manpage is unmaintained and may be out of date; the others are derived by an automatic conversion process from parts of the full manual.)
  `--with-gxx-include-dir=dirname`
    Specify the installation directory for G++ header files. The default is `prefix/include/g++-v3`.
`--with-local-prefix=dirname`
  Specify the installation directory for local include files. The default is `/usr/local`. Specify this option if you want the compiler to search directory `dirname/include` for locally installed header files instead of `/usr/local/include`.

  You should specify `--with-local-prefix` only if your site has a different convention (not `/usr/local`) for where to put site-specific files.

  The default value for `--with-local-prefix` is `/usr/local` regardless of the value of `--prefix`. Specifying `--prefix` has no effect on which directory GCC searches for local header files. This may seem counterintuitive, but actually it is logical.

  The purpose of `--prefix` is to specify where to install GCC. The local header files in `/usr/local/include`--if you put any in that directory--are not part of GCC. They are part of other programs--perhaps many others. (GCC installs its own header files in another directory which is based on the `--prefix` value.)

  Do not specify `/usr` as the `--with-local-prefix`! The directory you use for `--with-local-prefix` must not contain any of the system's standard header files. If it did contain them, certain programs would be miscompiled (including GNU Emacs, on certain targets), because this would override and nullify the header file corrections made by the `fixincludes` script.

  Indications are that people who use this option use it based on mistaken ideas of what it is for. People use it as if it specified where to install part of GCC. Perhaps they make this assumption because installing GCC creates the directory.

`--enable-shared[=package[,...]]`
  Build shared versions of libraries, if shared libraries are supported on the target platform. Unlike GCC 2.95.x and earlier, shared libraries are enabled by default on all platforms that support shared libraries, except for `libobjc` which is built as a static library only by default.

  If a list of packages is given as an argument, build shared libraries only for the listed packages. For other packages, only static libraries will be built. Package names currently recognized in the GCC tree are `libgcc` (also known as `gcc`), `libstdc++` (not `libstdc++-v3`), `libffi`, `zlib`, `boehm-gc` and `libjava`. Note that `libobjc` does not recognize itself by any name, so, if you list package names in `--enable-shared`, you will only get static Objective-C libraries. `libf2c` and `libiberty` do not support shared libraries at all.

  Use `--disable-shared` to build only static libraries. Note that `--disable-shared` does not accept a list of package names as argument, only `--enable-shared` does.

`--with-gnu-as`
  Specify that the compiler should assume that the assembler it finds is the GNU assembler. However, this does not modify the rules to find an assembler and will result in confusion if found assembler is not actually the GNU assembler. (Confusion will also result if the compiler finds the GNU assembler but has not been configured with `--with-gnu-as`.) If you have more than one assembler installed on your system, you may want to use this option in connection with `--with-as=pathname`.

  The systems where it makes a difference whether you use the GNU assembler are `hppa1.0-any-any`, `hppa1.1-any-any`, `i386-any-sysv`, `i386-any-isc`, `i860-any-bsd`, `m68k-bull-sysv`, `m68k-hp-hpux`, `m68k-sony-bsd`, `m68k-altos-sysv`, `m68000-hp-hpux`, `m68000-att-sysv`, `any-lynx-lynxos`, and `mips-any`. On any other system, `--with-gnu-as` has no effect.

  On the systems listed above (except for the HP-PA, for ISC on the 386, and for `mips-sgi-irix5.*`), if you use the GNU assembler, you should also use the GNU linker (and specify `--with-gnu-ld`).

`--with-as=pathname`
  Specify that the compiler should use the assembler pointed to by pathname, rather than the one found by the standard rules to find an assembler, which are:
  - Check the `exec_prefix/lib/gcc-lib/target/version` directory, where exec_prefix defaults to prefix which defaults to `/usr/local` unless overridden by the `--prefix=pathname` switch described above. target is the target system triple, such as `sparc-sun-solaris2.7`, and version denotes the GCC version, such as 3.0.
  - Check operating system specific directories (e.g. `/usr/ccs/bin` on Sun Solaris 2).
  Note that these rules do not check for the value of `PATH`. You may want to use `--with-as` if no assembler is installed in the directories listed above, or if you have multiple assemblers installed and want to choose one that is not found by the above rules.
`--with-gnu-ld`
  Same as `--with-gnu-as` but for linker.
`--with-ld=pathname`
  Same as `--with-as`, but for the linker.
`--with-stabs`
  Specify that stabs debugging information should be used instead of whatever format the host normally uses. Normally GCC uses the same debug format as the host system.

  On MIPS based systems and on Alphas, you must specify whether you want GCC to create the normal ECOFF debugging format, or to use BSD-style stabs passed through the ECOFF symbol table. The normal ECOFF debug format cannot fully handle languages other than C. BSD stabs format can handle other languages, but it only works with the GNU debugger GDB.

  Normally, GCC uses the ECOFF debugging format by default; if you prefer BSD stabs, specify `--with-stabs` when you configure GCC.

  No matter which default you choose when you configure GCC, the user can use the `-gcoff` and `-gstabs+` options to specify explicitly the debug format for a particular compilation.

  `--with-stabs` is meaningful on the ISC system on the 386, also, if `--with-gas` is used. It selects use of stabs debugging information embedded in COFF output. This kind of debugging information supports C++ well; ordinary COFF debugging information does not.

  `--with-stabs` is also meaningful on 386 systems running SVR4. It selects use of stabs debugging information embedded in ELF output. The C++ compiler currently (2.6.0) does not support the DWARF debugging information normally used on 386 SVR4 platforms; stabs provide a workable alternative. This requires gas and gdb, as the normal SVR4 tools can not generate or interpret stabs.

`--disable-multilib`
  Specify that multiple target libraries to support different target variants, calling conventions, etc should not be built. The default is to build a predefined set of them.

  Some targets provide finer-grained control over which multilibs are built (e.g., `--disable-softfloat`):

  `arc-*-elf*`
    biendian.
  `arm-*-*`
    fpu, 26bit, underscore, interwork, biendian, nofmult.
  `m68*-*-*`
    softfloat, m68881, m68000, m68020.
  `mips*-*-*`
    single-float, biendian, softfloat.
  `powerpc*-*-*, rs6000*-*-*`
    aix64, pthread, softfloat, powercpu, powerpccpu, powerpcos, biendian, sysv, aix.
`--enable-threads`
  Specify that the target supports threads. This affects the Objective-C compiler and runtime library, and exception handling for other languages like C++ and Java. On some systems, this is the default.

  In general, the best (and, in many cases, the only known) threading model available will be configured for use. Beware that on some systems, gcc has not been taught what threading models are generally available for the system. In this case, `--enable-threads` is an alias for `--enable-threads=single`.

`--disable-threads`
  Specify that threading support should be disabled for the system. This is an alias for `--enable-threads=single`.
`--enable-threads=lib`
  Specify that lib is the thread support library. This affects the Objective-C compiler and runtime library, and exception handling for other languages like C++ and Java. The possibilities for lib are:
  `aix`
    AIX thread support.
  `dce`
    DCE thread support.
  `mach`
    Generic MACH thread support, known to work on NeXTSTEP. (Please note that the file needed to support this configuration, `gthr-mach.h`, is missing and thus this setting will cause a known bootstrap failure.)
  `no`
    This is an alias for `single`.
  `posix`
    Generic POSIX thread support.
  `pthreads`
    Same as `posix` on arm*-*-linux*, *-*-chorusos* and *-*-freebsd* only. A future release of gcc might remove this alias or extend it to all platforms.
  `rtems`
    RTEMS thread support.
  `single`
    Disable thread support, should work for all platforms.
  `solaris`
    Sun Solaris 2 thread support.
  `vxworks`
    VxWorks thread support.
  `win32`
    Microsoft Win32 API thread support.
`--with-cpu=cpu`
  Specify which cpu variant the compiler should generate code for by default. This is currently only supported on the some ports, specifically arm, powerpc, and SPARC. If configure does not recognize the model name (e.g. arm700, 603e, or ultrasparc) you provide, please check the configure script for a complete list of supported models.
`--enable-target-optspace`
  Specify that target libraries should be optimized for code space instead of code speed. This is the default for the m32r platform.
`--disable-cpp`
  Specify that a user visible `cpp` program should not be installed.
`--with-cpp-install-dir=dirname`
  Specify that the user visible `cpp` program should be installed in `prefix/dirname/cpp`, in addition to bindir.
`--enable-maintainer-mode`
  The build rules that regenerate the GCC master message catalog `gcc.pot` are normally disabled. This is because it can only be rebuilt if the complete source tree is present. If you have changed the sources and want to rebuild the catalog, configuring with `--enable-maintainer-mode` will enable this. Note that you need a recent version of the `gettext` tools to do so.
`--enable-version-specific-runtime-libs`
  Specify that runtime libraries should be installed in the compiler specific subdirectory (`libsubdir`) rather than the usual places. In addition, `libstdc++`'s include files will be installed in `libsubdir/include/g++` unless you overruled it by using `--with-gxx-include-dir=dirname`. Using this option is particularly useful if you intend to use several versions of GCC in parallel. This is currently supported by `libf2c` and `libstdc++`, and is the default for `libobjc` which cannot be changed in this case.
`--enable-languages=lang1,lang2,...`
  Specify that only a particular subset of compilers and their runtime libraries should be built. For a list of valid values for langN you can issue the following command in the `gcc` directory of your GCC source tree:

      grep language= */config-lang.in

  Currently, you can use any of the following: `c`, `c++`, `f77`, `java` and `objc`. `CHILL` is not currently maintained, and will almost certainly fail to compile.
  If you do not pass this flag, all languages available in the `gcc` sub-tree will be configured. Re-defining `LANGUAGES` when calling `make bootstrap` does not work anymore, as those language sub-directories might not have been configured!
`--disable-libgcj`
  Specify that the run-time libraries used by GCJ should not be built. This is useful in case you intend to use GCJ with some other run-time, or you're going to install it separately, or it just happens not to build on your particular machine. In general, if the Java front end is enabled, the GCJ libraries will be enabled too, unless they're known to not work on the target platform. If GCJ is enabled but `libgcj` isn't built, you may need to port it; in this case, before modifying the top-level `configure.in` so that `libgcj` is enabled by default on this platform, you may use `--enable-libgcj` to override the default.
`--with-dwarf2`
  Specify that the compiler should use DWARF 2 debugging information as the default.
`--enable-win32-registry`
`--enable-win32-registry=key`
`--disable-win32-registry`
  The `--enable-win32-registry` option enables Windows-hosted GCC to look up installations paths in the registry using the following key:

      HKEY_LOCAL_MACHINE\SOFTWARE\Free Software Foundation\key

  key defaults to GCC version number, and can be overridden by the `--enable-win32-registry=key` option. Vendors and distributors who use custom installers are encouraged to provide a different key, perhaps one comprised of vendor name and GCC version number, to avoid conflict with existing installations. This feature is enabled by default, and can be disabled by `--disable-win32-registry` option. This option has no effect on the other hosts.

`--nfp`
  Specify that the machine does not have a floating point unit. This option only applies to `m68k-sun-sunosn` and `m68k-isi-bsd`. On any other system, `--nfp` has no effect.
`--enable-checking`
`--enable-checking=list`
  When you specify this option, the compiler is built to perform checking of tree node types when referencing fields of that node, and some other internal consistency checks. This does not change the generated code, but adds error checking within the compiler. This will slow down the compiler and may only work properly if you are building the compiler with GCC. This is on by default when building from CVS or snapshots, but off for releases. More control over the checks may be had by specifying list; the categories of checks available are `misc`, `tree`, `gc`, `rtl` and `gcac`. The default when list is not specified is `misc,tree,gc`; the checks `rtl` and `gcac` are very expensive.
`--enable-nls`
`--disable-nls`
  The `--enable-nls` option enables Native Language Support (NLS), which lets GCC output diagnostics in languages other than American English. Native Language Support is enabled by default if not doing a canadian cross build. The `--disable-nls` option disables NLS.
`--with-included-gettext`
  If NLS is enabled, the `--with-included-gettext` option causes the build procedure to prefer its copy of GNU `gettext`.
`--with-catgets`
  If NLS is enabled, and if the host lacks `gettext` but has the inferior `catgets` interface, the GCC build procedure normally ignores `catgets` and instead uses GCC's copy of the GNU `gettext` library. The `--with-catgets` option causes the build procedure to use the host's `catgets` in this situation.

Some options which only apply to building cross compilers:

`--with-headers=dir`
  Specifies a directory which has target include files. This options is required when building a cross compiler, if `prefix/target/sys-include` doesn't pre-exist. These include files will be copied into the `gcc` install directory. Fixincludes will be run on these files to make them compatible with GCC.
`--with-libs=``dir1 dir2 ... dirN''`
  Specifies a list of directories which contain the target runtime libraries. These libraries will be copied into the `gcc` install directory.
`--with-newlib`
  Specifies that `newlib` is being used as the target C library. This causes `__eprintf` to be omitted from `libgcc.a` on the assumption that it will be provided by `newlib`.

Note that each `--enable` option has a corresponding `--disable` option and that each `--with` option has a corresponding `--without` option.

Return to the GCC Installation page