|
|
Subscribe / Log in / New account

Building the kernel with clang

Building the kernel with clang

Posted Sep 19, 2017 20:08 UTC (Tue) by ndesaulniers (subscriber, #110768)
In reply to: Building the kernel with clang by sfeam
Parent article: Building the kernel with Clang

Behan Webster was explaining to me at LPC that this was mostly due to ARM's "Unified Assembly Language" in that gcc will pass inline assembly through to the assembler without validation, while Clang will validate the inline assembly is valid by UAL rules. If the arch/arm[64] code was converted to all use UAL, then I think the major obstacle for LLVM would be removed. Though it might be worthwhile to disable that functionality in LLVM, if it were implemented.


to post comments

Building the kernel with clang

Posted Sep 19, 2017 21:17 UTC (Tue) by ndesaulniers (subscriber, #110768) [Link] (7 responses)

I just spoke with Greg more about UAL so that I might better understand the context around the issue. It seems that UAL is an issue for ARM (pre ARMv8, so 32b ARM). He likened the situation to: "imagine you have a code base written in AT&T syntax, and your assembler only works with GAS, or vice versa." I'm not sure what the situation is for ARMv8, so I'm going to give it a shot (disabling `-no-integrated-as`) and see what breaks.

Building the kernel with clang

Posted Sep 19, 2017 21:21 UTC (Tue) by ndesaulniers (subscriber, #110768) [Link] (1 responses)

Turns out it breaks pretty quick. Warnings about "DWARF2 only supporting one section per compilation unit," and errors around unexpected tokens and intruction mnemonics. Ok, bugs for another day.

Building the kernel with clang

Posted Sep 25, 2017 14:58 UTC (Mon) by mwsealey (subscriber, #71282) [Link]

Try building with DWARF4.. :)

Building the kernel with clang

Posted Sep 19, 2017 23:05 UTC (Tue) by Sesse (subscriber, #53779) [Link] (1 responses)

You mean Intel and not GAS in your metaphor? (The gas default x86 syntax is AT&T.)

Building the kernel with clang

Posted Sep 20, 2017 0:00 UTC (Wed) by ndesaulniers (subscriber, #110768) [Link]

Yes, sorry! objdump -M intel -d <...>

Building the kernel with clang

Posted Sep 20, 2017 7:04 UTC (Wed) by alison (subscriber, #63752) [Link] (2 responses)

I take it then that there is no hope for building ARM32 with clang? Increasingly it feels like ARM32 users should upgrade to ARM64 in ordert to get not only clang support but also eBPF.

Building the kernel with clang

Posted Sep 20, 2017 21:00 UTC (Wed) by ndesaulniers (subscriber, #110768) [Link]

Personally, my professional work is on arm64 devices, and for a hobby I have x86-64 machines. All other architectures are important to support, but I don't have the bandwidth to support them all. My hope is that work we do on arm64 and x86-64 encourages others to step up and help support their favorite architectures.

Building the kernel with clang

Posted Sep 21, 2017 16:38 UTC (Thu) by mkaehlcke (guest, #61834) [Link]

I have no first hand experience with supporting arm32 builds with clang, but given that the kernel now has the generic/kbuild bits for supporting clang and that there are older patch sets for arm32 out there I imagine it shouldn't be that hard. The stack shared by Arnd Bergmann in April could be a starting point: https://git.kernel.org/pub/scm/linux/kernel/git/arnd/play... / https://www.spinics.net/lists/linux-fsdevel/msg109823.html

Building the kernel with clang

Posted Sep 21, 2017 21:28 UTC (Thu) by behanw (guest, #90443) [Link]

The issue, last I checked, was that there was a lot of pre-UAL assembly in the ARM arch. The gas specific non-UAL way of doing things is unlikely to be supported by any other assembler (including the Integrated Assembler in clang) because it's non-standard, and not completely documented. Essentially "fixing clang" isn't an option here; instead the offending ASM in the kernel needs to be rewritten to follow UAL. This by itself was a controversial idea in the past. No idea whether people would be open to it today.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds