Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 410945 - The Linux kernel does not compile with Clang
Summary: The Linux kernel does not compile with Clang
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: Lowest enhancement with 7 votes (vote)
Assignee: Gentoo Kernel Bug Wranglers and Kernel Maintainers
URL: http://llvm.linuxfoundation.org/index...
Whiteboard:
Keywords: Goal, LATER, NeedPatch
Depends on: 427352
Blocks: systemwide-clang
  Show dependency tree
 
Reported: 2012-04-05 20:26 UTC by Richard Yao
Modified: 2021-03-29 08:01 UTC (History)
12 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Yao gentoo-dev 2012-04-05 20:26:39 UTC
Qualcomm is working on compiling the Linux kernel with LLVM/Clang. It would be nice to leverage their work on Gentoo.

Rather than clutter bug #408963, I decided to file this bug to keep track of progress on this issue. It will be closed when sys-kernel/gentoo-sources can be compiled with Clang.
Comment 1 Dirkjan Ochtman gentoo-dev 2012-05-22 09:28:56 UTC
IIRC there's a bit of a problem here in that the kernel devs aren't particularly interested in supporting compilers other than gcc.
Comment 2 Richard Yao gentoo-dev 2012-05-22 09:35:02 UTC
That is historically true, but there is a Linux Foundation subdomain being used by the wiki for that project, so it seems possible. It should be okay to keep track of it here until the final status of that effort is known.
Comment 4 Mark Wood 2012-08-20 13:40:46 UTC
The git tree now has patches for clang+llvm+kernel than are claimed to produce a working kernel for i586 and x86_64

http://git.linuxfoundation.org/?p=llvm-setup.git;a=tree;hb=HEAD
Comment 5 Kamalavelan 2017-11-25 19:52:11 UTC
https://lkml.org/lkml/2017/11/22/943

4.4, 4.9 and 4.14 seem to be supported. I am using 4.14.2 built via clang, haven't gotten into trouble so far.
Comment 6 Kamalavelan 2017-11-26 03:03:57 UTC
(In reply to Kamalavelan from comment #5)
> I am using 4.14.2 built via clang, haven't gotten into trouble so far.

This means the chromium kernel(mentioned in the mail), not gentoo-sources or mainline, using Clang 5.0.
Comment 7 Peter Levine 2019-09-26 02:20:47 UTC
This appears to be resolved with clang-9, at least with x86/x64 and any ARCHes not requiring CONFIG_JUMP_LABEL=y in the kernel .config.
See: https://releases.llvm.org/9.0.0/tools/clang/docs/ReleaseNotes.html#linux-kernel
Comment 8 Amit Prakash Ambasta 2019-11-05 04:40:47 UTC
Tried compiling the latest kernel with clang. Works fine (and boots fine too on nomodeset) but segfaults on amdgpu
Comment 9 Peter Levine 2019-11-05 07:34:57 UTC
(In reply to Amit Prakash Ambasta from comment #8)
> Tried compiling the latest kernel with clang. Works fine (and boots fine too
> on nomodeset) but segfaults on amdgpu

It might be some weird ABI incompatibility. Did you also rebuild x11-drivers/xf86-video-amdgpu with clang before reboot?
Comment 10 Peter Levine 2019-11-05 07:35:59 UTC
(In reply to Peter Levine from comment #9)
> (In reply to Amit Prakash Ambasta from comment #8)
> > Tried compiling the latest kernel with clang. Works fine (and boots fine too
> > on nomodeset) but segfaults on amdgpu
> 
> It might be some weird ABI incompatibility. Did you also rebuild
> x11-drivers/xf86-video-amdgpu with clang before reboot?

And/or reinstall all kernel modules?
Comment 11 Amit Prakash Ambasta 2019-11-10 10:45:27 UTC
For one, I don't use xorg (or its drivers). Entirely on KMS + mesa + sway, so rebuilding xorg-drivers isn't required.

Second, I don't have module support in kernel, so everything is built-in. The kernel segfaults on switching to amdgpudrmfb, but boots fine on nomodeset. 

Finally, booting directly via efistub, so I am not sure how I can debug what went wrong with amdgpu
Comment 12 12101111 2020-02-15 09:44:41 UTC
The amdgpu issue is fixed by upstream in commit c868868f6b6a5272350781f9a19b3a5ba1c00b02
Comment 13 Amit Prakash Ambasta 2020-02-20 08:17:06 UTC
Well, can't boot into the kernel at all now (immediately bootloops)

kernel versions tried - all variations of 5.x
Comment 14 Alice Ferrazzi Gentoo Infrastructure gentoo-dev 2021-03-29 07:58:30 UTC
currently I see problems with clang on 4.9.263 (http://140.211.166.173:10080/scheduler/job/136) and 5.4.108 (https://kernel1.amd64.dev.gentoo.org/#/builders/76/builds/8/steps/8/logs/stdio)
Comment 15 Alice Ferrazzi Gentoo Infrastructure gentoo-dev 2021-03-29 08:01:06 UTC
All other kernel version compile and boot for me on clang 4.14.227 4.19.183 5.10.26 5.11.10
Comment 16 Alice Ferrazzi Gentoo Infrastructure gentoo-dev 2021-03-29 08:01:40 UTC
all tests are here:
https://kernel1.amd64.dev.gentoo.org/#/builders