This is the mail archive of the
mailing list for the Cygwin project.
Re: cygport cross-compiling beta1
On Fri, 2010-07-23 at 16:32 +0100, Dave Korn wrote:
> I must be missing something. Shouldn't what's under the sysroot be
> basically an exact copy with the same layout as what would be on the host's
> own native filesystem? That's what I get from the description of
> --with-sysroot at http://gcc.gnu.org/install/configure.html#TOC3.
Well, sort of. As far as GCC is concerned, yes: the default search
paths become $sysroot$prefix/include and $sysroot$prefix/lib (where
prefix=/mingw for *-*-mingw*, and /usr for most other systems), so you
can for example take a linux glibc package, unpack it under the linux
sysroot, and voila, you're ready to build a linux cross-gcc. (In fact,
that's exactly what I did in order to bootstrap.)
pkg-config also provides support for sysroots with an environment
variable, so a package built with prefix=/usr unpacked under the sysroot
will produce -I$sysroot/usr/include/foo CFLAGS (and no -L flags in the
usual case where the library is in $sysroot/usr/lib).
So ideally, one could cross-configure a package with --prefix=$prefix,
build it w/o any hard-coding of the sysroot, then either install with
DESTDIR=$D$sysroot and use it in your sysroot, or with DESTDIR=$D and
use it on the host.
Unfortunately, libtool isn't (yet?) aware of sysroots, so when a package
is configured with --prefix=/usr, it hardcodes the libdir as /usr/lib
and takes that literally, adding -L/usr/lib flags which cause the build
The other problem is foo-config scripts (installed into $sysroot
$prefix/bin), most of which are prone to adding -I/usr/include* and
-L/usr/lib flags, which GCC will accept literally, causing it to compile
and (try to) link with the native version of the dependency instead of
the cross-compiled one in the sysroot.
For these reasons, Fedora's mingw packages build with --prefix=$sysroot
$prefix. GCC's sysroot still helps: you can #include <foo.h> and
link with -lfoo w/o -I and -L, and you can still drop a native-built
package into the sysroot (providing it doesn't have foo-config, .la,
or .pc files). But it does mean that building for the sysroot and
building for usage on the host are two different things.