This repo is used to build a Clang toolchain, sysroot, compiler-rt, libcxxabi, and libcxx.
The default sysroot created is the latest Raspbian rootfs.
The default triple is arm-linux-gnueabihf.
These defaults are overridable, for use with other sysroots, such as a Yocto SDK.
Tested with GCC (Trusty, Xenial, and Bionic), and Clang (macOS Mojave). Sysroot install step will fail on Windows native, should work on Cygwin or Mingw.
I will be supporting Windows builds soon.
I also have an upcoming simplified scheme to deal with a foreign sysroot.
Note: If you don't have a commercial account, your travis build will fail due to the build time exceeding max. If you do have a commercial account, you will need to request a max build time setting of 180 minutes.
-
CMake 3.11 or greater
-
Host capable of building something
sudo apt-get update sudo apt install gcc clang build-essentials make subversion texinfo bison flex
Alternatively install LLVM/Clang
-
sysroot generation uses rsync, or ln, 7z, and curl.
git clone https://github.com/jwinarske/clang_toolchain.git
cd clang_toolchain && mkdir build && cd build
cmake .. -DBUILD_PLATFORM_RPI=ON -DBUILD_PLATFORM_SYSROOT=OFF -DBUILD_MRAA=ON -DSDK_ROOT_DIR=/home/joel/rpi
make -j$(numproc)
When passing path values to CMake use aboslute paths
If you want to force a rebuild of a sub-project, either delete the specific folder from your build folder, or delete to appropriate flags from the sub projects build folder.
-DLLVM_TARGETS_TO_BUILD="ARM"
-DBUILD_PLATFORM_RPI=ON
-DTARGET_HOSTNAME=pi@raspberrypi.local
-DBUILD_MRAA=ON
-DLLVM_VERSION=tags/RELEASE_900/rc2/
-DLLVM_VER_DIR=9.0.0
-DBUILD_PLATFORM_RPI=ON
-DBUILD_PLATFORM_SYSROOT=ON
-DBUILD_MRAA=ON
-DSDK_ROOT_DIR=/home/joel/rpi
-DTOOLCHAIN_FILE_DIR=/home/joel/rpi/sdk/build/cmake
-DLLVM_TARGETS_TO_BUILD="ARM"
-DBUILD_PLATFORM_RPI=ON
-DTARGET_HOSTNAME=pi@raspberrypi.local
-DBUILD_MRAA=ON
-DLLVM_VERSION=tags/RELEASE_800/rc2/
-DLLVM_VER_DIR=8.0.0
-DTARGET_ARCH=x86_64
-DTARGET_TRIPLE=x86_64-linux-gnu
-DLLVM_TARGETS_TO_BUILD="X86" -DTARGET_HOSTNAME=atomic@atomicpi.local
-DBUILD_MRAA=ON
-DTARGET_ARCH=x86_64
-DTARGET_TRIPLE=x86_64-linux-gnu
-DLLVM_TARGETS_TO_BUILD="X86" -DTARGET_HOSTNAME=atomic@atomicpi.local
-DBUILD_MRAA=ON
-DLLVM_VERSION=tags/RELEASE_800/rc2/
-DLLVM_VER_DIR=8.0.0
Sequence to build 8.0.1 Toolchain, populate sysroot from target, build hello-wayland, push to target, and execute
ssh atomic@atomicpi.local
sudo apt-get install wayland-protocols libwayland-dev
exit
mkdir -p ~/git && cd ~/git
git clone https://github.com/jwinarske/clang_toolchain.git
cd clang_toolchain && mkdir build && cd build
cmake .. -DTARGET_ARCH=x86_64 -DTARGET_TRIPLE=x86_64-linux-gnu -DTARGET_HOSTNAME=atomic@atomicpi.local -DBUILD_WAYLAND=ON
make -j$(nproc)
scp ./target/bin/hello_wayland atomic@atomicpi.local:/home/atomicpi
ssh atomic@atomicpi.local
./hello-wayland
Build Platform Raspberry Pi
Build Platform sysroot. This currently only affects RPI. You either provide your own, or create from scratch.
Build hello-wayland app
Checkout and build LLVM Linker for host. Defaults to ON
Download and build binutils for host. Defaults to OFF
Checkout and build LLVM Debugger for host. Defaults to OFF. Enables use of -fuse-ld=gold
Checkout and build compiler-rt. Defaults to ON
Checkout and build libcxxabi for target. Defaults to ON
Build c++abi with exception support Defaults to ON
Checkout and build libunwind for target. Defaults to ON
Checkout and build libcxx for target. Defaults to ON
Defaults to http://director.downloads.raspberrypi.org/raspbian/archive/
Defaults to 2018-11-15-21:02
Note: When changing this you may need to adjust dangling/missing symlinks specific to selected version. See cmake/rpi/sysroot.cmake
Defaults to ${CMAKE_SOURCE_DIR}/third_party
Defaults to ${CMAKE_SOURCE_DIR}
Defaults to ${CMAKE_BINARY_DIR}
Defaults to ${SDK_ROOT_DIR}/sdk/toolchain
Defaults to ${SDK_ROOT_DIR}/sdk/sysroot
Defaults to arm-linux-gnueabihf
Defaults to OFF. This variable affects all subprojects. Alternatively use:
make VERBOSE=1
Defaults to X86|ARM|AArch64. One example setting would be
-DLLVM_TARGETS_TO_BUILD="ARM"
Note: This only affects LLVM/Clang (host), not target builds; compiler-rt, libunwind, libcxxabi, and libcxx.
Regardless of this value, the LLVM/Clang build as a minimum will build support for the host triple.
Defaults to tags/RELEASE_701/final/
Some examples
-DLLVM_VERSION=trunk/
-DLLVM_VERSION=tags/RELEASE_800/rc1/
-DLLVM_VERSION=branches/release_80/
Note: LLVM_VER_DIR needs to match selected version, in order for compiler-rt to install into the proper location.
Defaults to 7.0.1. This must match LLVM version, or use of compiler-rt will fail, as library will not be found. This variable is only used for installation of compiler-rt libraries.
The triple has the general format <arch><sub>-<vendor>-<sys>-<abi>
, where:
arch = x86_64, i386, arm, thumb, mips, etc.
sub = for ex. on ARM: v5, v6m, v7a, v7m, etc.
vendor = pc, apple, nvidia, ibm, etc.
sys = none, linux, win32, darwin, cuda, etc.
abi = eabi, gnu, android, macho, elf, etc.
The sub-architecture options are available for their own architectures, of course, so "x86v7a" doesn’t make sense. The vendor needs to be specified only if there’s a relevant change, for instance between PC and Apple. Most of the time it can be omitted (and Unknown) will be assumed, which sets the defaults for the specified architecture. The system name is generally the OS (linux, darwin), but could be special like the bare-metal “none”.
When a parameter is not important, it can be omitted, or you can choose unknown and the defaults will be used. If you choose a parameter that Clang doesn’t know, like blerg, it’ll ignore and assume unknown, which is not always desired, so be careful.