Standardized instructions for cross-compiling toolchain?

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

 



All,

First let me say if this is not the best mailing list for this, I
apologize. I figure it's the closest I can get with active users.

I have spent the last week trying to build a cross compiler from
scratch. I have looked at a few blog posts, and dug through
crosstool-ng logs to try and formulate a set of instructions that will
generate a cross-compiler. Previously I just used crosstools-ng, but I
wanted to build gcc 5.3/6.1 and currently the latest release of
crosstools doesn't support anything newer than 5.2. So I'm trying to
do it the old fashioned way, by myself.

I finally have an end-result toolchain after many configuration
experiments, but it appears it's not quite fully configured right
because at the linking stage (sorry, I know this is binutils), it says
that it can't find libpthread as a dependency of librt (but they're
both in my sysroot directories for my toolchain).

However, my question is more general than that. Are there some
widely-used, accepted steps for building a cross-compiling toolchain
with gcc? I noticed that crosstool-ng does a 3 stage build, where it
builds an initial gcc for libc start files, then rebuilds gcc for
libc, then rebuilds gcc yet again with libc. Other blogs suggest that
two stages are enough. I settled on doing a 2 stage build. I think my
steps are fine, but I think some of my configure options may need help
(prefix vs sysroot vs prefix+target, etc). But every set of
instructions I look at are different, and it seems no two blog posts,
pdfs, wikis have landed on the same procedure.

When I look at my build output, I think the biggest issue I have left
is where libraries end up going. Crosstools-ng symlinks most of the
lib/ directories to a single lib/ directory, so that most libraries
end up in one place. I didn't do that, so I have libraries throughout
$PREFIX and $SYSROOT. It seems this may be my last remaining problem.
But I haven't seen any steadfast rule about what directories should be
used for SYSROOT vs PREFIX, etc.

I elected to do the following:

PREFIX = /path/to/top/level/toolchain
TARGET = x86_64-vendor-linux-gnu
SYSROOT = $PREFIX/$TARGET/sysroot

It appears binutils installs under $PREFIX/$TARGET, gcc installs in
$PREFIX, and glibc installs in a mix of $PREFIX and $SYSROOT. It's
actually even more complicated than that, with some files ending up in
$SYSROOT/lib64 and others in $SYSROOT/usr/lib64, etc.

I know this question is a bit everywhere, but hopefully someone can
help clarify some of my woes with this toolchain build.

For posterity, here is my procedure at a very high level, basically
merging crosstools and some blog posts:

-Install kernel headers
-Build binutils for target
-Build gcc bootstrap (all-gcc/install-gcc)
-Build libc start files (headers, stubs, crtX)
-Build and install gcc libraries (all-target-libgcc/install-target-libgcc)
-Build libc (all)
-Build remaining gcc (all, install)

If anyone's interested in my actual ./configure options, I will gladly
post all the detailed steps I am  using.

Thanks all,
Michael



[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