How to properly use --with-sysroot in canadian cross?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

even after careful study of https://gcc.gnu.org/install/configure.html
and looking around the internet I can't really find a satisfying
answer to this question.

When building native or cross compiler, it's quite easy,
--with-sysroot points to the place where the new compiler should look
for include and library files (i.e. <sysroot>/usr).

>From the description of --with-build-sysroot I would say that if I
wish to use different sysroot for building (i.e. during compilation of
the new compiler) I should use this option and specify --with-sysroot
with the path I'm interested to use when the new compiler is used.

I struggle to understand how to use these two options when I want to
build a compiler which is supposed to run on another machine.

For example, I want to build a compiler which I will place in the
target machine's /usr/bin. So, if "arm-linux-gnueabihf-gcc
-print-sysroot" prints "/usr/arm-linux-gnueabihf", I would naively
expect this to work:

./configure --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
--prefix=/usr --with-build-sysroot=/usr/arm-linux-gnueabihf (other
options omitted)

I didn't specify --with-sysroot because I want it to use its default
value (which is an empty string I believe, so the includes/libraries
are searched in <sysroot>/usr = /usr by default).

What happens however is that gcc's configure starts picking up stuff
from my Linux's /usr folder, like detecting headers which are not in
/usr/arm-linux-gnueabihf/usr/include (for example <sys/sdt.h>) or
running the "fixing includes" process on includes from /usr/include
instead of my build sysroot.

Documentation for --with-build-sysroot says "This option is only
useful when you are already using --with-sysroot" which could imply
that I have to specify --with-sysroot to make it really work. So I
did:

./configure --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
--prefix=/usr --with-sysroot=""
--with-build-sysroot=/usr/arm-linux-gnueabihf (other options omitted)

Same result. Then I got an idea to specify
--with-sysroot=/non-existent-dir and voila, it worked! However now the
new gcc prints its sysroot as "/non-existent-dir" and is used as one
of its search paths (what can be quite fatal if I wanted to have
target's sysroot outside /usr -- and yes, I am aware of gcc's
--sysroot command line parameter, I'm talking about its default
setting).

As a desperate attempt, I tried to specify --with-sysroot="/" and this
worked, too. This leads to nearly perfect result, search paths are
/lib, /usr/lib and so on however the new gcc naturally still prints
its sysroot as "/" which I believe is wrong (paths then should look
like //usr/include, //usr/lib etc what we clearly don't want). Plus it
is a cosmetic bug, normally gcc doesn't print anything if it is
configured with an empty sysroot.

I guess my question is then: shouldn't --with-build-sysroot work
autonomously from --with-sysroot? I.e. if I specify
--with-build-sysroot, it should be used exactly as with --with-sysroot
however the final gcc would use --with-sysroot value instead.

Or is there something else I'm missing?

Thanks,
Miro



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux