Brad For Dem Bedded

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Tuesday, 9 November 2010

What's Going On in CLFS Chapter 5? [/tools and /cross-tools]

Posted on 05:19 by Unknown
In building the CLFS PowerPC cross compiler the instructions say to create both the /tools and /cross-tools directories (these are actually symlinks to directories of your choosing but it's the easiest way to reference what I'm talking about).  I didn't fully understand why this is the case so I did some Googling and re-read parts of the CLFS book.

Turns out it's briefly described across various sections, including: 4.2 (Creating the /tools Directory), 4.3 (Creating the /cross-tools Directory), 5.4 (Linux-Headers), and 6.1 (Introduction to chapter 6).

The /cross-tools directory is where the actual cross compiler and its assorted "friends" will live.  The /tools directory is where we're building a temporary system that can actually build a real system.  The entire goal of chapter 5 is to build a GCC cross compiler that executes on your desktop PC and builds executables for some other computer system (in my case, my desktop's an x86_64 box running Debian Lenny and I'm wanting to create executables for PowerPC Linux).

A fun problem is that in order to build a cross compiler, we need a compiler (and a bunch of other stuff).  There may be a shorter method to achieving this, but I outline the CLFS way of doing things:
  • Starting off with section 5.4 (Linux Headers), just the header files for a Linux kernel are installed into /tools/include.  The headers will be needed later to build Glibc.   
  • In section 5.5 (File), we build and install File into /cross-tools (File lets us figure out what type any given file is).  This version of File we build is a native application on our desktop PC and is used by other steps.
  • Section 5.6 (Cross Binutils) has us build a set of binutils, again these are native to our desktop PC.  No cross compiling yet.  Binutils assists in compiling and linking programs.  We'll use this set of binutils to build our cross compiler, GCC.  Binutils gets installed into /cross-tools.
  • Now we get to some compiler compiling, section 5.7 (Cross GCC - Static).  Here we build a very simple, statically linked version (it includes all libraries it needs internally to itself rather than reference them being installed in another location) of GCC that can only compile C programs.  GCC is actually built without any C library (Glibc) as we don't yet have it.  GCC goes into /cross-tools.
  • Section 5.8 (Glibc) finally gets us to the C library.  When configuring Glibc, we must tell the configuration script how to find all the different items we've already installed, as they're in non-standard locations.  Glibc gets built using our statically linked GCC and our kernel headers, it has just enough ability to do so, and installed into the /tools directory.  The kernel headers are needed as some of the implementation of the C library involves making system calls, thus the C library needs to know how to make those system calls.
  • Now we can finally create an actual cross compiler.  Section 5.9 (Cross GCC - Final) finally has us build a real C and C++ cross compiler.  This step uses the previously built statically linked GCC and Glibc to create a real, dynamically linked, version of GCC.  Now we have a cross compiler!

I'm curious to see how much of what was used to build our cross compiler is still needed in order to complete the CLFS book.  Maybe this is a job for git (another thing I'd like to learn).
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Posted in clfs, embedded, open source | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • Downsides and Upsides of Altera's Configuration Via Protocol
    Yesterday, I wrote a little about reconfigurable FPGAs attached to the PCI-Express bus as an addition to the general purpose computer. The...
  • Toolchain, Check! Kernel, Check!
    I've been working on the CLFS embedded book for a few months now.  I've been learning a lot and my goal has been to get a CLFS embe...
  • KDE4 Sucks
    I upgraded to Debian 6 Squeeze last weekend on my desktop.  I was very excited to get some more up-to-date packages (git, gcc, kernel, and c...
  • Low Cost ARM Computer
    I was thinking about my ARM + FPGA computer idea some more.  There's already a lot of competition in the single board computer space an...
  • Crypto Load Balancer Using Off The Shelf Hardware
    At my day job, I work a reasonable amount of time with cryptographic and authentication systems. Lately, I've been reading about OpenCL...
  • Embedded Linux and Long Term Support / Updates - Part 2
    In my previous post about embedded Linux long term support, I neglected Ubuntu. I had not realized how much effort Canonical are putting i...
  • The TuxedoBoard has a Brain! (picked out)
    I've chosen an ARM SoC (system on chip) for the TuxedoBoard! The Texas Instruments AM1707 ARM9 core will meet my requirements. The AM1...
  • Pick an ARM ABI When Building GCC
    If you follow the CLFS embedded book for ARM , you'll see that your ABI choice isn't used until compiling packages (ie: after you...
  • SanDisk iNAND
    I stumbled upon SanDisk's iNAND products today while doing some searching about SD cards. The iNAND idea looks very appealing to me co...
  • I'm Writing a Book
    I'm writing a book about embedded Linux but I'm not going to compete with traditional technical books.  O'Reilly isn't my co...

Categories

  • beagleboard
  • blog
  • book review
  • business
  • c
  • chairs
  • clfs
  • community
  • computers
  • crypto
  • db
  • debian
  • disapointment
  • embedded
  • energy
  • fedora
  • flash
  • fpga
  • gcc
  • git
  • google
  • health
  • hp
  • internet
  • iOS
  • learning
  • license
  • linux
  • market
  • microsoft
  • movie review
  • my book
  • next steps
  • open source
  • pandaboard
  • rails
  • software
  • SOPA
  • tuxedo
  • web 2.0
  • webOS
  • windows
  • work

Blog Archive

  • ►  2012 (10)
    • ►  January (10)
  • ►  2011 (70)
    • ►  December (10)
    • ►  November (9)
    • ►  October (7)
    • ►  September (8)
    • ►  August (1)
    • ►  July (3)
    • ►  June (3)
    • ►  May (3)
    • ►  April (8)
    • ►  March (4)
    • ►  February (5)
    • ►  January (9)
  • ▼  2010 (16)
    • ►  December (6)
    • ▼  November (9)
      • Being Clear About The Work I Want To Do
      • LED Lighting to Replace Fluorescents, The Future!
      • Computer Configuration User Interfaces Suck
      • Open Source (at my Fortune 500)
      • What's Going On in CLFS Chapter 5? [/tools and /cr...
      • Cross-Compiled Linux From Scratch
      • Short and Sweet, But Not Always
      • Revolution OS
      • Rework, Drive, and Linchpin
    • ►  October (1)
Powered by Blogger.

About Me

Unknown
View my complete profile