8000 GitHub - fthain/build-tool-chain: GNU cross-compiler and tool-chain generator
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fthain/build-tool-chain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Tool Chain
https://github.com/fthain/build-tool-chain
(c) 2004-2017 Finn Thain


PURPOSE

These scripts (collectively called "btc") are designed for experimenting with
new releases of GNU tools, for building cross-tool-chains and for cross-
compiling the Linux kernel.

They differ from other similar scripts in that they work under both Mac OS X
and Linux. Development of btc began before crosstool supported Mac OS X and
NPTL but it is mostly a useful and educational exercise for its author.

The tool-chains built by btc include (e)glibc (with NPTL or linuxthreads) and
permit cross-compilation of packages using shared libraries. UClibc is also
catered for to some extent. You can chroot your target machine into the
tool-chain sysroot for testing, or export the sysroot for use as an NFS root
filesystem.

An alternative to btc for building a tool-chain is crosstool (or its
successors). Or if you need to cross-build an entire glibc-based system, you
may want to check out Cross Linux From Scratch (CLFS). Also see bitbake,
Buildroot and OpenEmbedded.


NOTA BENE

The resulting tools are not expected to be bug free. If you want more
confidence in the results, you may wish to use mature package sources such
as those maintained by CodeSourcery and the various Linux distro's.

This script applies numerous patches to hack around build issues. Use these
patches at your peril.

As with any cross compiler, test suites can't be run easily and no stage 2 or
stage 3 GCC is built. Bootstrapping GCC natively on the target may improve
your chances of getting correct results.

The same applies to glibc. According to the glibc documentation, you should
build glibc under the latest glibc (!) Eglibc, on the other hand, is
intended to permit cross-compilation.


INSTRUCTIONS (not a good substitute for reading the scripts)

- Untar or checkout the btc distribution.

- Edit the build-tool-chain script as follows:

  + Adjust the BTC_DIST definition to the absolute pathname of the btc
    directory or workarea.

  + Modify the BTC_PRODUCE definition to be the absolute pathname of the
    directory to hold the build results. This needs to be a filesystem with
    plenty of free space (around 4 GB to build recent tools). It must be a
    case-sensitive filesystem. A disk image is a convenient way to obtain this
    on Mac OS X, which has a case-insensitive root filesystem by default.

  + Change MAKE_OPTS if you want to increase parallelism.

  + Change BTC_MIRROR if you want to download sources from a local cache. The
    necessary source packages will be downloaded into the $BTC_SOURCES
    directory as and when required.

  + Create an appropriate profile for your target system or select one
    of the provided ones. The profile is sourced by build-tool-chain in order
    to define the variables specifying what to build and how to do so.

    In particular, the profile will define the TARGET and the build METHOD
    as well as package versions given in the variables BINUTILS_DIST,
    GCC_DIST, GLIBC_DIST, GLIBC_ADD_ONS and LINUX_DIST. The profile should also
    specify LINUX_ARCH and UCLIBC_ARCH if these do not match the arch from the
    TARGET tuple.

- Any given host system will probably lack some of the necessary tools.

  The GNU compilers and libc are not very portable in that they require GNU
  versions of awk, sed, make, gettext and one or two other commands. So these
  are built by btc and added to the search path before the host's binaries.

  To build the older GCC you will need autoconf-2.13. Also, texinfo and
  ncurses-dev may have to be installed on Debian-based systems. Gentoo systems
  do not need any extra tools installed other than the old bison and flex
  which btc provides. Some Linux systems use mawk so btc provides gawk.

  GMP and MPFR are required by gcc-4.3 and later. PPL and CLOOG
  are required by gcc-4.4 and later. These tools in turn require a recent m4.
  MPC and libelf are used by gcc-4.5 or later.

  The old bison is needed to build gcc-2.95. flex is for binutils-2.12.
  loadkeys (from kbd) is used for generating linux-2.2 keymaps.

- If you provide a Linux configuration in the $BTC_CONFIGS directory it will be
  used in preference to the default config. Name it something like
  linux-2.4.27-powerpc-dot-config

  Do not enable symbol versioning (CONFIG_MODVERSIONS) or you may end up
  with modules that cannot be loaded. genksyms for the target is not
  available at build time and may be required for some kernel releases.

- Run build-tool-chain, as an unprivileged user, as follows. Substitute
  your choice of PROFILE, e.g. 'profiles/4.4-m68k'.

scripts/build-tool-chain -p PROFILE

- Cleanup the build directory with:

scripts/build-tool-chain -p PROFILE -c 'rm -rf ${BTC_BUILD}'

- If you then want to build a tool-chain for a different architecture,
  for example, just run the script again:

scripts/build-tool-chain -p ANOTHER_PROFILE

  The resulting tools will be installed under a unique $TC_PREFIX determined
  by the profile.

- If you want to unpack the Linux source and build it using one of the
  cross-compilers that you have built, you could do so as follows.

scripts/build-tool-chain -p PROFILE -c bash # set environment and spawn shell
prep_kernel linux-2.6.39
cd ..
build_kernel linux-2.6.39
package_kernel linux-2.6.39
exit

  To simply use the cross-compiler as would any other tool, just use the PATH
  setting that the build-tool-chain script itself uses:

scripts/build-tool-chain -p PROFILE -c 'echo $PATH'


ACKNOWLEDGEMENTS

btc was inspired by Philippe Trottier's Xcompiler V0.93. Ryan Oliver provided
encouragement and crucial assistance with the build method, as well as patches
for glibc. Some ideas come from Dan Kegel's crosstool and other scripts
elsewhere on the 'Net. Martin Schaffner contributed some changes to the Linux
make commands. I am grateful to the Gentoo, LFS and Debian projects and
many mailing list denizens who have published patches to make this stuff
actually work.

About

GNU cross-compiler and tool-chain generator

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0