Monthly Archives: November 2015

Cross Building Linux With ELLCC: Part 1

Update: Cross Building Linux With ELLCC: Part 2 – Raspberry Pi B+
ELLCC is a clang/LLVM based cross compilation tool chain. It is available pre-compiled for several different host systems and unlike GCC can generate programs for several targets with one set of tools. This week I thought it would be fun to try to compiler the Linux kernel using ELLCC. In this post I’ll build the patched Linux kernel from the LLVMLinux project git repository.

You need to be using ELLCC version 0.1.18 or ELLCC svn-5503 or later to build Linux. Download one of the ELLCC binary releases or follow the instructions for building ELLCC from source.

Create a directory next to the ELLCC directory. For example if the ELLCC directory is ~/ellcc:

[~] dev% mkdir ~/llvmlinux
[~] dev% cd ~/llvmlinux

We’re going to follow the instructions on the LLVMLinux site to get the pre-patched Linux kernel sources:

[~/llvmlinux] dev% git clone git://git.linuxfoundation.org/llvmlinux/kernel.git

There is a copy of the little ‘m’ makefile modified for ELLCC in the ELLCC distribution. Make a symbolic link to it:

[~/llvmlinux/kernel] dev% ln -s ../../ellcc/libecc/llvmlinux/makefile .

This little “m” makefile is set up to build Linux for the ARM. You can modify it to select another target.

Configure the kernel:

[~/llvmlinux/kernel] dev% make menuconfig

For now, under System Type, choose Dummy Virtual Machine.
Disable the following devices (LLVM bugs submitted):

  • Device Drivers->Serial ATA and Parallel ATA drivers (libata)->OPTI FireStar PATA support (Very Experimental) – LLVM bug 25330
  • Device Drivers->Network device support->Ethernet driver support->Exar Xframe 10Gb Ethernet Adapter – LLVM bug 25332
  • Device Drivers->Sound card support->Advanced Linux Sound Architecture->PCI sound devices->Aztech AZF3328 / PCI168 – LLVM bug 25330
  • Kernel hacking->Build targets in Documentation/ tree

Exit and save the configuration.

Build Linux:

[~/llvmlinux] dev% cd kernel/
[~/llvmlinux/kernel] dev% make
make[1]: Entering directory '/home/rich/llvmlinux/kernel'
  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
make[2]: 'include/generated/mach-types.h' is up to date.
  CALL    scripts/checksyscalls.sh
  CHK     include/generated/compile.h
  CHK     include/generated/uapi/linux/version.h
  Kernel: arch/arm/boot/Image is ready
  LD      arch/arm/boot/compressed/vmlinux
following symbols must have non local/private scope:
$d
$d
$d
arch/arm/boot/compressed/Makefile:190: recipe for target 'arch/arm/boot/compressed/vmlinux' failed
make[3]: *** [arch/arm/boot/compressed/vmlinux] Error 1
arch/arm/boot/Makefile:52: recipe for target 'arch/arm/boot/compressed/vmlinux' failed
make[2]: *** [arch/arm/boot/compressed/vmlinux] Error 2
arch/arm/Makefile:310: recipe for target 'zImage' failed
make[1]: *** [zImage] Error 2
make[1]: Leaving directory '/home/rich/llvmlinux/kernel'
makefile:71: recipe for target 'all' failed
make: *** [all] Error 2
[~/llvmlinux/kernel] dev%

So the kernel and a bunch of modules get built but subsequent processing fails. In the next part of this post I’ll try to track down what the problem is.