Revision of RelocatableHOWTOforMinGW from 2009, May 17 - 21:10

Printer-friendly version

HOWTO Understanding effects of build directory options on a relocatable MinGW GCC default's paths

1 Summury and purpose of this document

There are some things which are still marked as TODO is in this. This gonna be done later.

Target of this document: trying to better understand the effect of build time options on the resulting MinGW GCC's default paths. This is done testing the effect of some configuration options. These tests target the wish to have a multi-arch singled-versioned and relocatable installation directory. Comments and analysies given in this document, all goes to this direction. This document may not fullfill expectations from peoples with other wishes.

Test builds are done on Windows (XP or whatever below and above will probably give the same result) using MinGW as the C compiler and mSys as the build environnement (this is mandatory to run configuration and make scripts).

The document is divided into two main parts: tests at build time and tests with a relocated installation directory (the bigest part).

2 Tests at build time

2.1 The build was done with the following options:

2.1.1 Script variables:

  • mypkgname=....
  • name=gcc
  • package=gcc-4.2.1-2
  • build=i386-mingw32
  • host=i386-mingw32
  • target=i386-mingw32
  • prefix=/<my-msys-personal-home-dir>/$name
  • temp=$name

2.1.2 Options:

  • --with-pkgversion=$mypkgname
  • --build=$build
  • --host=$host
  • --target=$target
  • --prefix=$prefix
  • --with-sysroot=$prefix/$target/test1
  • --with-local-prefix=$prefix/$target/test2
  • --with-build-sysroot=$prefix/$target/test3
  • --disable-rpath
  • --disable-version-specific-runtime-libs
  • --enable-languages=c
  • --enable-libada
  • --enable-threads
  • --disable-shared
  • --disable-sjlj-exceptions
  • --disable-win32-registry
  • --enable-nls
  • --disable-bootstrap
  • --with-gnu-gcc
  • --with-gnu-as
  • --with-gnu-ld
  • --with-stabs

2.2 Comments

Do not forget:

  • Sysroot is set to /<install-dir>/<arch>/test1
  • Local prefix is set to /<install-dir>/<arch>/test2
  • Build sysroot is set to /<install-dir>/<arch>/test3
  • Prefix will be refered as /<install-dir>

A native compiler will be built the same way as if it was a cross compiler, to have a cleaner installation (each archs beside of each others, even the native one).

You will see these test1, test2, test3 in some paths list later. Do not forget what it is standing for (see above).

The build was started frm a build directory beside the source directory, with an installation directory bside the two laters, the a make and a make install was runned. The installation directory initially only contains <arch> and <arch>/test1 and <arch>/test2 and <arch>/test3.

Some thing was then deduced from error messages during the build process.

The build process expect a mingw/include in <install-dir>/<arch>/test3 (the build sysroot directory). It has complained with this message :

> The directory that should contain system headers does not exist:
> /<install-dir>/<arch>/test3/mingw/include

This mingw/include directory is mandatory during the build process, but it may be empty (the build process can terminates normally with an empty mingw/include).

The build process obviously complains about missing includes. Some test were done to list all directory where theses includes may be found.

2.3 Includes search when configuring gcc during the build process:

  • Searched in /<install-dir>/<arch>/include
  • Not searched in /<install-dir>/<arch>/test1/include (sysroot/include)
  • Not searched in /<install-dir>/<arch>/test1/mingw/include (sysroot/mingw/include)
  • Not searched in /<install-dir>/<arch>/test2/include (localprefix/include)
  • Not searched in /<install-dir>/<arch>/test2/mingw/include (localprefix/mingw/include)
  • Not searched in /<install-dir>/<arch>/test3/include (buildsysroot/include)
  • Searched in /<install-dir>/<arch>/test3/mingw/include (buildsysroot/mingw/include)

2.4 Comments

The <install-dir> did not contained any libs. The build still terminates normally.

3 Tests on a relocated installation directory (get and drop anywhere)

3.1 The resulting gcc, after relocation, use the following default paths:

Next, <install-dir> is renamed into an <reloc-dir>, to test how install relocation works.

  • Install:
    • <install-dir>/lib/gcc/<arch>/<version>/
  • Programs:
    • <reloc-dir>/libexec/gcc/<arch>/<version>/
    • <reloc-dir>/libexec/gcc/
    • <install-dir>/libexec/gcc/<arch>/<version>/
    • <install-dir>/libexec/gcc/<arch>/<version>/
    • <install-dir>/libexec/gcc/<arch>/
    • <install-dir>/lib/gcc/<arch>/<version>/
    • <install-dir>/lib/gcc/<arch>/
    • /usr/libexec/gcc/<arch>/<version>/
    • /usr/libexec/gcc/<arch>/
    • /usr/lib/gcc/<arch>/<version>/
    • /usr/lib/gcc/<arch>/
    • <reloc-dir>/<arch>/bin/<arch>/<version>/
    • <reloc-dir>/<arch>/bin/
    • <install-dir>/<arch>/bin/<arch>/<version>/
    • <install-dir>/<arch>/bin/
  • Libraries:
    • <reloc-dir>/lib/gcc/<arch>/<version>/
    • <reloc-dir>/lib/gcc/
    • <install-dir>/lib/gcc/<arch>/<version>/
    • /usr/lib/gcc/<arch>/<version>/
    • <reloc-dir>/<arch>/lib/<arch>/<version>/
    • <reloc-dir>/<arch>/lib/
    • <install-dir>/<arch>/lib/<arch>/<version>/
    • <install-dir>/<arch>/lib/
    • <reloc-dir>/lib/<arch>/<version>/
    • <reloc-dir>/lib/
    • <install-dir>/lib/<arch>/<version>/
    • <install-dir>/lib/
    • <reloc-dir>/<arch>/test1/mingw/lib/<arch>/<version>/
    • <reloc-dir>/<arch>/test1/mingw/lib/
  • Includes:
    • <reloc-dir>/<arch>/test1<install-dir>/include
    • <install-dir>/lib/gcc/<arch>/<version>/include
    • <install-dir>/<arch>/include
    • <reloc-dir>/<arch>/test1/mingw/include
    • <reloc-dir>/lib/gcc/<arch>/<version>/include

3.2 Comments

Note: this list was obtained with “./gcc --print-search-dirs and” “./gcc -v -c test.c”, after reformating and canonicalization of paths, followed by some symbolic substitutions.

Suspected bug: Did you notice the first include path ? It seems there is a bug here. Two absolute paths are appended. I've meet it every time during all the teste I've made. I've also found some buggy paths concatenation in some Configure.log files. I dunno if it is a MinGW GCC bug or a configuration script bug or an mSys bug.

Note: some paths were printed with “/” as the path separator while some other was printed with “\” as the path separator. I've substitued all with “/” as MinGW GCC accept both.

Notice that <arch>/include only exist with the <install-dir> prefix. This may be a trouble (we will see later for the reason why).

Notice that the directory test3, which stands for --build-sysroot does not exist any more in the default search paths. It is only used at build time.

3.3 In the purpose of a relocatable installation, the list may be reduced to:

  • Programs:
    • <reloc-dir>/libexec/gcc/<arch>/<version>/
    • <reloc-dir>/libexec/gcc/
    • <reloc-dir>/<arch>/bin/<arch>/<version>/
    • <reloc-dir>/<arch>/bin/
  • Libraries:
    • <reloc-dir>/lib/gcc/<arch>/<version>/
    • <reloc-dir>/lib/gcc/
    • <reloc-dir>/<arch>/lib/<arch>/<version>/
    • <reloc-dir>/<arch>/lib/
    • <reloc-dir>/lib/<arch>/<version>/
    • <reloc-dir>/lib/
    • <reloc-dir>/<arch>/test1/mingw/lib/<arch>/<version>/
    • <reloc-dir>/<arch>/test1/mingw/lib/
  • Includes:
    • <reloc-dir>/<arch>/test1/mingw/include
    • <reloc-dir>/lib/gcc/<arch>/<version>/include

3.4 Comments

Note: this list is obtained removing all paths starting with <install-dir> and paths which are POSIX paths (ex. “/usr/libexec”), thus keeping only paths starting with <reloc-dir>. The first include buggy path was removed too (unusable anyway).

3.5 In the purpose to have a clean single versioned relocatable installation, the list may be reduced again to:

  • Programs:
    • <reloc-dir>/libexec/gcc/
    • <reloc-dir>/<arch>/bin/
  • Libraries:
    • <reloc-dir>/lib/gcc/
    • <reloc-dir>/<arch>/lib/
    • <reloc-dir>/lib/
    • <reloc-dir>/<arch>/test1/mingw/lib/
  • Includes:
    • <reloc-dir>/<arch>/test1/mingw/include

3.6 Comments

Note: this list was obtained removing all paths containing <version>.

In the purpose of a multi-arch single versioned and relocatable installation, we notice there gonna be a trouble with the default include paths : it only looks in <reloc-dir>/<arch>/test1/mingw/include.

The favorite path for programs would probably be <reloc-dir>/<arch>/bin/, the favorite paths for libs would probably be <reloc-dir>/lib/ and <reloc-dir>/<arch>/lib/. There are no good candidates for includes (an <arch>/include would be nice).

A special specs file may be needed to workaround the default include paths problem (this is still TODO).

TODOs

  • TODO: a workaround for the default include paths (probably using the specs file)
  • TODO: run the same test and the same analysies with some others
    • --with-sysroot=...
    • --with-local-prefix=...
    • --with-build-sysroot=...

The first one to do should be using the <arch> path for --with-sysroot and --with-build-sysroot.

  • TODO: run the same test and the analysies without a setting for --with-build-sysroot.

--~~~~

Site Status

Site maintenance performed successfully, site online Dec 13th 12:00 AM Eastern.