-
Notifications
You must be signed in to change notification settings - Fork 27
Bindgen fails on Arch Linux 5.2.8-arch1-1-ARCH #1
Comments
Hi, @pluth, thanks for your report. @lizhuohua and I will look into this issue and get back to you later. Thanks. |
This looks like kernel-cflags-finder (which is from our upstream project - see https://github.com/fishinabarrel/linux-kernel-module-rust/tree/master/kernel-cflags-finder which has a README) isn't returning quite the right thing on Arch. I've only tested it on Debian and Ubuntu so that's not totally surprising. (And fundamentally kernel-cflags-finder is a huge hack, there's no direct way to extract the kernel's CFLAGS for use in bindgen, so we scrape it out of a Makefile's output :) ) Can you directly run In particular on my Debian box I also get various defines like |
Actually I can repro this with the Debian 5.2 kernel, so it's not an Arch packaging thing. |
It seems like clang doesn't support Some references: |
Yeah, this is complicated. 4.19 works fine (it's what I'm using at the moment), but torvalds/linux@e9666d1 in 5.0 changed the asm goto check from a build-time check to a config-time check. Therefore if your kernel was configured with gcc, the build system tries to use asm gotos for modules, even if you're compiling the modules with clang. Before that, it would correctly detect CC=clang at build time and skip it. I don't see a way to override the config option from inside a module. (Also since torvalds/linux@cdd750b in v5.2 you need to change |
Oh, the code review in your second link https://reviews.llvm.org/D56571 looks like it was closed in June 3, so maybe a very recent version of clang works? |
Yes, this works for me on Debian with the LLVM 9 snapshot from https://apt.llvm.org . @pluth - can you try
|
I made this change to kernel-cflags-finder to make it 5.2 compatible: fishinabarrel/linux-kernel-module-rust@f7f85515 This project should probably pick up the same change. Also I have some robustness changes for kernel-cflags-finder in fishinabarrel/linux-kernel-module-rust@985985c7 that are worth picking up too. |
I installed clang-10 from llvm-minimal-git (difference to llvm-git as far as i can tell is that it's not building lldb, lld and polly). Now its failing with a different error:
Full output is here. Its quite long since it contains about 600 more unknown attribute 'user' warnings. There don't seem to be any pre-built packages for Arch, so compiling from git seems to be the best I can do. Anyways, as I understand llvm 9 is supposed to be release next week so I guess I'll just wait for that. |
Did you edit kernel-cflags-finder/Makefile to change |
Yes, I did.
You meant this, right? |
Yes. Hm, also try running |
Doesn't change anything.
|
There is some commented out code in build.rs that removes options. If I do that for the two unknown options to that, then cargo runs successfully |
We've since fixed this in https://github.com/fishinabarrel/linux-kernel-module-rust (which is where kernel-cflags-finder comes from) - we've removed kernel-cflags-finder and set up Kbuild to call cargo and pass the appropriate flags. Importantly, it picks up the flags as if CC is clang so we no longer need to do the trick with ignoring unknown options. |
Hi, I just saw this on reddit and want to try. But bindgen seems to fail on my machine running Arch Linux with kernel version 5.2.8-arch1-1-ARCH
I have no experience in kernel development, so I'm not sure what the issue is here. The errors seems to come from clang:
Full output:
The text was updated successfully, but these errors were encountered: