Differences between revisions 4 and 6 (spanning 2 versions)
Revision 4 as of 2019-12-03 17:23:16
Size: 3694
Revision 6 as of 2019-12-03 17:25:07
Size: 3867
Deletions are marked like this. Additions are marked like this.
Line 15: Line 15:

For details on !BeagleBoard-X15 build see next links:

 * https://wiki-archive.linaro.org/Boards/BeagleBoard-X15
 * https://wiki.linaro.org/AOSP/Boards/BeagleboardX15

Author: Sam Protsenko <semen.protsenko at linaro dot org>

Date of last update: 03 Dec 2019

Building Android kernels with clang

This article describes building TI Android kernels with clang.

I only tested that on omap/kernel, which is:

For details on BeagleBoard-X15 build see next links:

Building with clang (64-bit, AM65x)

Google recommends/requires to build all the software with clang (rather than GCC) toolchains. If you want to go with clang for kernel build, use next instructions. Alas, for now we can only build 64-bit kernels with Android-based clang. See below for 32-bit clang build info. This section discusses the build for AM65x (AArch64).


Platform: AM65x EVM (64-bit) Android: TI Android Pie Kernel: TI kernel-4.19

Obtain toolchains

We don't have required clang toolchain version in Android-P, so let's obtain it first from AOSP master (along with GCC-4.9 toolchain):

    $ cd /opt
    $ sudo git clone --depth=1
    $ sudo git clone --depth=1

Configure and build

Configure kernel (don't configure clang environment just yet):

    $ make -j4 ARCH=arm64 distclean
    $ ./ti_config_fragments/defconfig_builder.sh -t ti_sdk_arm64_android_release
    $ make ARCH=arm64 ti_sdk_arm64_android_release_defconfig

Configure the shell environment:

    $ export PATH=/opt/aarch64-gcc-4.9/bin:$PATH
    $ export PATH=/opt/clang-linux-x86/clang-r349610/bin:$PATH
    $ export CLANG_TRIPLE=aarch64-linux-gnu-
    $ export CROSS_COMPILE=aarch64-linux-android-
    $ export ARCH=arm64

Build kernel:

    $ make -j4 CC=clang HOSTCC=clang Image dtbs modules

Building with clang (32-bit, AM57x)

Linux kernel should be build-able for ARM32 now.

Command to build 32-bit kernel with clang:

    $ ./jenkins-scripts/docker-run.sh --distro bionic -- ./jenkins-scripts/tcwg_kernel-build.sh %% artifacts/jenkins/manifest.sh --BUILD_URL https://ci.linaro.org/job/tcwg_kernel-build-llvm-release-arm-mainline-defconfig/341/ '==rr[ci_config]' llvm-release-arm-mainline-defconfig '==rr[llvm_url]' https://github.com/llvm/llvm-project.git '==rr[binutils_url]' no_binutils_url '==rr[gcc_url]' no_gcc_url '==rr[linux_url]' https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git '==rr[llvm_branch]' 0399d5a9682b3cef71c653373e38890c63c4c365 '==rr[linux_branch]' f41def397161053eb0d3ed6861ef65985efbf293

It was taken from:

CI results are here:

(we are interested in linaro-local/ci/tcwg_kernel/llvm-release-arm-mainline-defconfig, etc).

Maxim Kuvyrkov (who works on Linaro toolchains, both GCC and LLVM) sent me those links, so you can ask him for more details.

LMG/Kernel/clang (last modified 2019-12-03 17:25:07)