I am trying to figure out what instruction set (x86_64, IA-32, etc.) is used by the RPi's Broadcom chip (really an ARM 1176JZF-S), because I'd like to understand how linux can run on it.

My understanding is that Linux (Raspbian, Debian, Ubuntu, etc.) is compiled via gcc which uses the x86_64 instruction set.

So unless this ARM chip supports the x86_64 instruction set, I'm totally clueless as to how the RPi ccan even run linux! Thoughts?


You seem to have a misunderstanding about how software is compiled. Linux is essentially a giant piece of software written in the C programming language.

One of the primary benefits of writing software in a higher level language than assembly is that it allows for software to be written independently from the CPU's architecture. The same code (written in C) can be compiled for multiple architecture types.

If you type gcc into your RPi's terminal, you'll see it's installed there. To see the compiler in action, use the "hello world" tutorial below and compile it with the -S flag on both an x86 PC and the RPi. If you compare the two, you'll see the assembly output is significantly different, even though both outputs were produced by the same C code. The Linux OS operates in the same manner.

Sample C Code:

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
    printf("Hello, World!\n");

gcc -S output on a Xeon (x86-64):

        .file   "hello.c"
        .section        .rodata
        .string "Hello, World!"
        .globl  main
        .type   main, @function
        pushq   %rbp
        .cfi_def_cfa_offset 16
        .cfi_offset 6, -16
        movq    %rsp, %rbp
        .cfi_def_cfa_register 6
        subq    $16, %rsp
        movl    %edi, -4(%rbp)
        movq    %rsi, -16(%rbp)
        movl    $.LC0, %edi
        call    puts
        movl    $0, %edi
        call    exit
        .size   main, .-main
        .ident  "GCC: (Ubuntu 5.4.0-6ubuntu1~16.04.1) 5.4.0 20160609"
        .section        .note.GNU-stack,"",@progbits

gcc -S output on a Raspberry Pi 2 (Cortex-A7):

        .arch armv6
        .eabi_attribute 27, 3
        .eabi_attribute 28, 1
        .fpu vfp
        .eabi_attribute 20, 1
        .eabi_attribute 21, 1
        .eabi_attribute 23, 3
        .eabi_attribute 24, 1
        .eabi_attribute 25, 1
        .eabi_attribute 26, 2
        .eabi_attribute 30, 6
        .eabi_attribute 34, 1
        .eabi_attribute 18, 4
        .file   "hello.c"
        .section        .rodata
        .align  2
        .ascii  "Hello, World!\000"
        .align  2
        .global main
        .type   main, %function
        @ args = 0, pretend = 0, frame = 8
        @ frame_needed = 1, uses_anonymous_args = 0
        stmfd   sp!, {fp, lr}
        add     fp, sp, #4
        sub     sp, sp, #8
        str     r0, [fp, #-8]
        str     r1, [fp, #-12]
        ldr     r0, .L2
        bl      puts
        mov     r0, #0
        bl      exit
        .align  2
        .word   .LC0
        .size   main, .-main
        .ident  "GCC: (Raspbian 4.9.2-10) 4.9.2"
        .section        .note.GNU-stack,"",%progbits
  • Thanks @Jacobm001 (+1) but I think you completely missed my question. I know what a compiler is (although I'm a Java guy, not a C guy), and it is my understanding that linux distros are typically compiled via gcc targeting the x86_64 instruction set. Have I missed something? – smeeb May 15 '15 at 19:43
  • Yes, they are usually compiled for x86, however nothing is stopping someone from taking the code and compiling it themselves and targeting a different architecture. To make Raspbian, the RPi foundation essentially took the source code for Debian, tweaked it, and compiled it targeting the ARM6 platform. – Jacobm001 May 15 '15 at 19:46

GCC is a cross-platform compiler; I'd guess it is used on more architectures than any other contemporary compiler -- not just x86_64 (which is more.

The linux kernel is similarly highly portable, which is a major reason for its success and why it is used on the armv6j pre-2 pis, and for that matter the armv7 pi 2's.

The foundation of the GNU userspace on a GNU/Linux distribution is usually glibc (or its near twin, eglibc), as portable as the kernel and GCC, which is why GNU/Linux is the most portable operating system in the contemporary world.

Broadcom chip (really an ARM 1176JZF-S)

This is a bit like saying an i5 processor is "really an x86_64" (an instruction set architecture -- ISA -- actually introduced by AMD, not Intel).

It gets a bit confusing because "ARM 11" (..."76JZF-S") is a really a processor core design (microprocessor architecture) implementing latter versions of the ARMv6 instruction set. I believe this is the difference between the high level instruction set architecture and the more specific microprocessor architecture. The Broadcom SoC uses that microprocessor architecture, which implements the ARMv6(Z) instruction set.

Raspbian, Debian, Ubuntu,

Individual GNU/Linux distributions are usually made up of pre-compiled binaries, and these tend to be more limited than the aforementioned possibilities -- commonly x86, x86_64, PowerPC (old Macs), MIPS, SPARC, ARM. You could roll one for a whole host of other things though; there's a few dozen arch's in the vanilla kernel source, and the source code for the rest of the userspace is publicly available.

That's exactly what was done to create Raspbian, in fact, except that support for the BCM2708 was added to the kernel.

  • Thanks @goldilocks (+1) - however I'm still a bit confused.Take the Ubuntu downloads page, for instance. Nowhere on that page do I see downloads for ARM processors, only 32- and 64-bit variants. Does this mean that Ubuntu can't run on RPi's ARM chip, or just that I would need to "hack" (recompile/cross-compile, etc.) the core Ubuntu libraries in order to make them RPi/ARM compliant? Thanks again! – smeeb May 15 '15 at 19:40
  • 1
    It just has to do with how the distros structure their websites, I think. For example, there's two Ubuntu ARMv7 distributions used on the Pi 2, "Snappy Core" (which is pushed by the foundation, and targets embedded projects with a read-only userland) and plain 'ol ubuntu. Unfortunately finding that out takes some digging (e.g., I was just searching around to make sure there are really mainstream distros for MIPS and SPARC). – goldilocks May 15 '15 at 19:44

My understanding is that Linux (Raspbian, Debian, Ubuntu, etc.) is compiled via gcc


which uses the x86_64 instruction set.

It isn't restricted to that, gcc itself can be compiled on many architectures and on any of them it can be run to target (produce executables for) many other different architectures (including many different instruction sets)

As an example, see Debian installation images, which lists

The following are image files which are up to 280 MB in size. Choose your processor architecture below.

  • amd64
  • arm64
  • armel
  • armhf
  • i386
  • mips
  • mipsel
  • powerpc
  • ppc64el
  • s390x

My beaglebone black runs Debian. It used to run Ubuntu, even. It comes with GCC, already all compiled to code-generate for ARM. The same mechanism is used for the Pi, I used to use one of those: See:

Debian GNU/Linux 7

BeagleBoard.org BeagleBone Debian Image 2014-05-14

Support/FAQ: http://elinux.org/Beagleboard:BeagleBoneBlack_Debian
Last login: Fri May 15 01:59:56 2015 from puck.fios-router.home
root@mmbackup:~# gcc -v
Using built-in specs.
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Debian 4.6.3-14' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-sjlj-exceptions --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
Thread model: posix
gcc version 4.6.3 (Debian 4.6.3-14) 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.