Skip to content

Cross Compiling for the Cowardly Coder

Jason Charney edited this page Jan 21, 2015 · 2 revisions

Cross Compiling is the process of using one machine with one type of computer architecture to compile code for another machine that uses a different kind of computer architecture.

But first a little bit of computer science

Using the phrase computer archtecture is a misnomer actually as computer architecture is generally defined as the set of disciplines that describes a computer system by specifying its parts and their relations. What we really refer to is a specific topic of computer architecture which is (in a sense) tangeble: the instruction set architecture, or ISA, or simply instruction set.

But first, let's start from the very beginning...the very beginning.

Before we had all these complex systems, we just had electricity, the set of physical phenomena associated with the presence and flow of electric charge. We've know about it for millenia, but we could never understand how to use it until the late 19th century and throughout the 20th century we learned how to manipulate electricity.

We learned how to create electronic components which when put together created an electrical circuit. One circuit became a network of circuits. Over time we realized how to make these analog components into digital components by elevating the energy levels like locks in canal. Those parts became even smaller when we realized certain materials had conductive properties that when put together could create a device called a semiconductor. These semiconductors became part of integrated circuits (ICs) that could be used to execute instructions just by modifying the level of potential difference known as voltage. From there a whole bunch of ICs were put together to make a device called a microprocessors. Various microprocessors were designed to handle certain tasks like arthimetic and logic (ALUs), digital signal processing, whatever. When a whole bunch of microprocessors with various task were put together in a single microprocessor they form the Central Processing Unit (CPU).

Chances are throughout your life you have used hundreds, if not thousands, of these devices from just using a TV remote, to using a calculator, to using the computer you are currently reading this article on, or maybe even the printer that prints out this page. That used a CPU and ICs and electronic components.

But how they are put together can often determine how functional our machines are.

The two major instruction sets are Complex Instruction Set Computing (CISC) and Reduced Instruction Set Computing (RISC). Throughout your life you have no doubt used plenty of electronics that has a CPU that uses one of these two instruction sets.

CISC can generally be found in desktop, laptops, gaming consoles, anything that needs to compute complex computing instruction quickly.

RISC can generally be found in cellphones, tablets, [Single-board computers](Single-board computer), and various small electronic devices where a computer is needed. Oddly enough, most electronics will use this set. If you need something that just needs to do at least one task, RISC will be there. Thus you'll likely find RISC in TVs, DVD players, Streaming media devices, computer routers, computer modems, automotive dashboards, etc.

One particular kind of RISC architecture that is often used is called ARM which originally stood for "Acorn RISC Machine" where Acorn Computers was the company that developed it in 1983 before changing their name to Advanced RISC Machines Ltd in 1990 and the acronym to "Advanced RISC Machines" after a joint venture between Acorn, Apple Computer (now just Apple, Inc.) and VLSI Technology. The ARM company it self was a victim of the Dot-Com Bubble and in 2000, thanks to some shareholder meddling at Morgan Stanley Dean Witter Group, Acorn which was renamed Elemenet 14, was picked up by Broadcom.

The ARM name continues to exist as a holding company ARM Holdings plc. Broadcom having access to ARM technology used the ARM architecture to develop the [Raspberry Pi](Raspberry Pi). However Broadcom has been accused many times by the Free Software Foundation of not being open to open source development even though the Raspberry Pi is a Linux computer. There is evidence to back this up as Hardkernel Co., Ltd, a company based out of South Korea than makes another ARM based SBC called Odroid was asked not to create their own version of the Raspberry Pi called the Odroid-W which used a Broadcom BCM2835 ARM11 CPU.

Personally, I see this as no loss to the Odroid people even though they were looking to make a more affordable version of their Odroid SBCs, most of which outperform the Raspberry Pi. But if one company wants to sell an SBC for $35 and another wants to sell theirs for $65 with 16 times more power that that $35 SBC, does that $35 SBC still look interesting or does paying $65 for something better pique your interest?

OK, enough science and history. Time for some programming!

Cross Compiling

The general set up is we are going to need to use a machine with a CISC instruction set (which generally will have an i386 or x86_64 architecture) to create an image file generally ending with .iso. Basically this is creating an image that often would be mounted on optical media, but can also be mounted on a thumb drive or SD card.

See also

  • [Linux From Scratch](Linux From Scratch)
  • [Linux From Scratch in an Hour](Linux From Scratch in an Hour)

External Links

Clone this wiki locally