|
|
Log in / Subscribe / Register

Building the kernel with clang

Building the kernel with clang

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

I think it's more the sheer quantity of hand-written assembly in various bits of the kernel has been written to a "be overly tolerant with input, and overly strict with output" mantra, which includes what assembly (inline for standalone files) the GNU assembler accepts versus what the CLANG project will accept.


to post comments

Building the kernel with clang

Posted Sep 20, 2017 0:51 UTC (Wed) by ncm (guest, #165) [Link] (5 responses)

Being over-tolerant of bad input ends up doing the world no favors. I wonder how many CVEs we got from that policy, as applied to internet services. (Hint: lots!) Now it holds us back from building Linux with other toolchains, and for what? Did it really make writing the asm code noticeably easier?

Any sequence that is rejected by the current version of a tool is a candidate for syntax to mean something useful later on.

Being hard-ass about input grammar is good for everybody.

Building the kernel with clang

Posted Sep 20, 2017 7:18 UTC (Wed) by joib (subscriber, #8541) [Link] (1 responses)

> Being over-tolerant of bad input ends up doing the world no favors.

https://tools.ietf.org/html/draft-thomson-postel-was-wron... lays it out in more detail.

Building the kernel with clang

Posted Sep 21, 2017 22:04 UTC (Thu) by jani (subscriber, #74547) [Link]

I like to call this the Crapustness Principle: The software design guideline based on the illusion of ability to happily process any crap that you're given as if it was actually meaningful. This is when GIGO and the robustness principle collide.

Building the kernel with clang

Posted Sep 20, 2017 14:33 UTC (Wed) by aaron (guest, #282) [Link] (2 responses)

"Be pedantic in what you accept, and arbitrarily brutal in what you send" -- Malcolm Ray

Building the kernel with clang

Posted Sep 21, 2017 1:25 UTC (Thu) by marcH (subscriber, #57642) [Link] (1 responses)

> "Be pedantic in what you accept, and arbitrarily brutal in what you send"

Or... not :-(

http://www.wall.org/~larry/natural.html
https://youtu.be/ju1IMxGSuNE?t=165

Building the kernel with clang

Posted Sep 21, 2017 18:01 UTC (Thu) by niner (guest, #26151) [Link]

What does this have to do with aaron's post?

Building the kernel with clang

Posted Sep 20, 2017 18:01 UTC (Wed) by valarauca (guest, #109490) [Link]

I believe you are correct.

By default Clang/LLVM tracks _closely_ to GAS, but with less magic https://llvm.org/docs/LangRef.html#inline-assembler-expre...

Small things like `add` on x64 requires a suffix to state if its an `addw`, `addq`, etc. for example https://clang.llvm.org/compatibility.html#inline-asm


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