there is no "installation" section of the GCC Manual

Jim Wilson
Mon Jun 10 22:44:00 GMT 2019

On Sun, Jun 9, 2019 at 10:21 AM Dennis Clarke <> wrote:
> Something that seems missing is the a whole section for actually
> building GCC from its sources and getting it installed.  There is
> no such section in the manual itself.  There are instuctions of
> course ( ) but they skim over most
> details with little or zero explanation of such things as the
> wide assortment of foo_FOR_BUILD env vars and foo_FOR_TARGET that
> are needed to get gcc workable on some target machine.  Things
> such as --sysroot are even more mysterious.

You shouldn't need to set any env vars in general.

The easy way to handle gmp/mpfr/mpc are to drop the sources into the
top level gcc dir, alongside libgcc and libstdc++, and let the gcc
makefile build them as gcc libraries.

Using a sysroot is the easiest way to build a cross compiler for an
existing OS target.  A sysroot contains everything the compiler needs,
which traditionally means /usr/include, /usr/lib, and /lib, but the
exact set of dirs may depend on the OS target.  If you have access to
the target root file system, then make a copy of these dirs and copy
someplace onto the build machine.  This is now your sysroot, and can
be specified when configuring binutils and gcc.  This assumes you have
a working target that already has a C library built and installed.

If you need to build a C library as part of the toolchain build, and
the C library isn't newlib, then yes, I'd say use crosstool-NG as this
is complicated.  Or at least read the crosstool-NG docs that explain
how to do a canadian cross build, as this gets really complicated
pretty quickly.

When I did a canadian cross build last year to get my first native
Fedora RISC-V Ada compiler, I just did this

Build the cross toolchain...
gamma05:2183$ cat x-binutils.script
../binutils-2.30/configure --target=riscv64-unknown-linux-gnu
gamma05:2184$ cat x-gcc.script
../gcc-7.3.0/configure --target=riscv64-unknown-linux-gnu
--with-sysroot=/scratch/jimw/fedora-cross/sysroot --disable-multilib

Put $prefix/bin on my path and build the canadian cross toolchain...
gamma05:2185$ cat h-binutils.script
../binutils-2.30/configure --host=riscv64-unknown-linux-gnu
gamma05:2186$ cat h-gcc.script
../gcc-7.3.0/configure --host=riscv64-unknown-linux-gnu
--with-sysroot=/scratch/jimw/fedora-cross/sysroot --disable-multilib

Then copy h-install to the target and use it to build a clean native toolchain.

I think you are trying to do a FreeBSD canadian cross build.  I
primarily have experience doing Linux canadian cross builds.  But in
theory it should work the same.


More information about the Gcc-help mailing list