[lkml]   [2017]   [Aug]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectClang patch stacks for LTS kernels (v4.4 and v4.9) and status update

Over the past months efforts have been made to upstream the remaining
LLVMLinux patches ( and to address
other outstanding issues in order to build a usable kernel with clang.
To my knowledge upstream is in a relatively good shape by now for x86
and arm64 (I heard the same about PowerPC, but have no first hand
experience), most of the patches are already in Linus' tree, others
have landed in maintainer trees.

Since many projects use an LTS kernel rather than the latest upstream
I thought it could be useful for others to share my upstreamish
patch stacks (derived from my work on Chrome OS) for building v4.4 and
v4.9 with clang:

These two branches only have the basic patches needed to build an x86
or arm64 kernel with clang, additional fixes for warnings can be found

For reference also a stack for v4.13(-rc6):

If v4.14 (LTS) misses important patches I will create a stack for it.

To retrieve the patches (v4.9):

git fetch refs/sandbox/mka/llvm/v4.9
git checkout -b llvm_v4.9 FETCH_HEAD

To build the kernel with clang:

make CC=clang

or cross compilation:

make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- CC=aarch64-linux-gnu-clang

A short description of the tags used in the patches:

UPSTREAM From Linus' tree
BACKPORT From Linus' tree, conflicts had to be resolved
FROMGIT From a maintainer tree, will eventually propagate to UPSTREAM
FROMLIST Patch sent to one or more kernel mailing lists, but not
picked up (yet)
HACK Workaround for an issue, not upstreamable, proper fix needed
CUSTOM Similar to HACK, but less hacky, mainly used for older kernels
OBSOLETE Workaround for issue fixed in upstream clang, not needed
with recent clang version (more info in the commit message)

The branches are subject to rebasing (e.g. to promote FROMGIT patches
to UPSTREAM, or to incorporate proper fixes for HACKs). If anyone
really needs a static branch for some reason let me know.

Pending issues (incomplete):
- x86: incompatible inline assembly to force generation of stack
frames. A possible solution is under development:
- x86: maintainers raised concerns that clang does not support asm goto,
LLVM devs do not plan to implement it.
- arm64: inconsistent behavior of -mgeneral-regs-only
( A fix is being worked on.
- build errors in different drivers. Arnd Bergmann put together a
bunch of patches that can serve as starting point for upstream fixes:
- warnings: clang raises more warnings than gcc. Most warnings for x86
and arm64 defconfig have been fixed, others still need to be addressed.
- ...

Thanks to everybody who contributed/s to this effort!


 \ /
  Last update: 2017-08-23 01:14    [W:0.029 / U:3.416 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site