cross compile setup

Hey Paul,

I was wondering if you could post your cross compile Linaro setup. That would be great as a starting point as I look into testing/reworking some of the Linux constants and start gearing up on some alternate architecture support.

Much appreciated!

Todd Fiala

Hi Todd,

I'll describe it soon (I guess tomorrow).


Thanks, Paul! No rush, just would love to see what that looks like so I can replicate it over here at some point.

Hi Todd,

As I promissed:

Host: Gentoo Linux x86_64 (a.k.a. amd64)
Target: FoundationV8 ARM64 emulator running minimal Linux rootfs image
Objective: cross-compile as much as possible of llvm + clang + lldb + compiler_rt from master branch of their repositories for ARM64/AArch64 architecture then try to execute lldb and lldb-gdbserver on the Target; try to fulfil ncurses and Python dependency

I'm using CMake throughout all the process. Note that I'm building everything in home directory and (with all required development tools installed), I don't need superuser privileges at any stage.

Gentoo specific issues:
1. Currently, default C/C++ compiler for Gentoo systems is gcc 4.7.x. Latest llvm/clang/lldb code requires at least gcc 4.8.x for proper compilation. Gcc 4.8.3 must be installed in a separate slot (Gentoo-specific approach for holding multiple versions of the software); CC and CXX shell variables must be set for CMake to indicate which compiler should be used
2. get_python_lib Python function from distutils.sysconfig returns path which contains '/lib64/' part no matter how first two boolean parameters are set (see revision D4058 for fix proposed by me; also patch attached to bug report 20206 touches crucial lines of one of affected files); this is important only when you plan to do 'make install' (and my approach relys on this)
3. Python 2.7 in Gentoo is compiled with unicode ucs4, while Python 2.7 installed on the Target is compiled with unicode ucs2 - separate local Python installation must be used during cross-compilation in order to make swig happy (installation procedure will be described later).
4. Python 2.7 is not the default Python interpreter in Gentoo (currently it is Python 3.x) while lldb requires version 2.7; fortunately, many different versions of Python interpreter can co-exist in one system - whenever required, exact version can be specified to use.

Target specific issues:
1. The target architecture is recognised as aarch64 not ARM64, I prepared two revisions that try address this issue: D4381 and D4379.
2. Ncurses library installed on target is not complete, i.e. libpanel part is missing; also two other required libraries aren't there: libedit and libxml2.
3. Python 2.7 installed on the Target is compiled with unicode ucs2.

Two stages process:
1. Building for PC
2. Building for Target

This process is split into two stages since the second stage requires llvm-tblgen and clang-tblgen built at the first stage (and since we're working with the most recent code, older versions of those two cannot be used).

Getting repositories

In my home directory I'm having following directory structure:

$HOME/llvm.git - llvm repository cloned
$HOME/llvm.git/projects/compiler-rt - compiler-rt repository cloned
$HOME/llvm.git/tools/clang - clang repository cloned
$HOME/llvm.git/tools/lldb - lldb repository cloned, that's where the magic happens

Building for PC

Hey Paul,

Thanks for all the details!