Open visar opened 5 years ago
Ugh, that looks like your kernel is built with the structleak GCC plugin, and being a GCC plugin it won't run on clang, which we use to parse the header files.
I think that structleak doesn't change the ABI, so you ought to be able to filter out the argument and have things work. Can you try modifying build.rs (or kernel-cflags-finder itself) to skip it? It might be as simple as adding an if !arg.contains("structleak") {...}
around the call to builder.clang_arg
, or something.
Same happens on arch linux (kernel version 5.3.5-arch1-1-ARCH) with clang 9. Problem is that the kernel-cflags-finder uses clang to compile a dummy module but clang doesn't support this feature. I worked around it by modifying /lib/modules/5.3.5-arch1-1-ARCH/build/scripts/Makefile.gcc-plugins to not add GCC_PLUGINS_CFLAGS to KBUILD_CFLAGS.
Changing the flag finder make call to $(MAKE) GCC_PLUGINS_CFLAGS= -C $(KDIR) M=$(CURDIR) CC=$(CLANG)
also stops the flags, in my experience.
Added benefit, no need to modify kernel sources.
Hi, how to filter -Wno-unused-but-set-variable
flag?
CLANG: 9, 10 OS: Manjaro Linix 20.0.3 kernel: 5.6.19-2
@mjaric that issue should be fixed by #227
For plugins in general, I think the challenge is that randstruct does change the ABI and we need to break the build if you have it (or at least tell you to find a version of clang that supports randstruct), so we can't just set GCC_PLUGINS_CFLAGS to empty for everyone. I suspect none of the other plugins change the ABI, but we should check that carefully, and have a positive list of known safe plugins.
I'm going to try to tackle this after some build system work - I'm trying to revive the change from #185 to move the logic of kernel-cflags-finder into build.rs, and I have that almost working. Once that's done, we can write this filtering logic in Rust instead of in make.
randstruct is the only one that adds itself to modversions.
But, I looked through them all to confirm:
fsanitize-coverage=trace-pc
(which clang supports) is equivalent, I wonder if they're compatible. (But even if not, this is at most "kcov will misbehave," not "the module will misbehave")__stack_chk_guard
, but I think there is no ABI impact other than that, and I think nobody has any legitimate business accessing that value beyond the core kernel init/entry/exit functions anyway. That variable isn't exported to modules if this plugin is enabled, so at least for the purposes of modules, I think it's fine. (I am confused why it's exported at all!)Sigh. So I have a fix for the plugin issue, but it turns out you can't actually compile it after last night's refactoring to drive the build with CC=clang because clang as called by Kbuild to link the .ko gets thrown the -fplugin arguments. So I have a Rust .o that built fine because I filtered them out in build.rs, but I can't turn that into a kernel module. :( We'll need to figure out some Kbuild magic somehow.
Also, note that this is going to require LLVM/Clang 11 (currently release candidate) because Manjaro is on a new enough kernel that it's using asm inline
, which Clang just got support for https://reviews.llvm.org/D75563 . It doesn't seem to be packaged in Arch/Manjaro, but I'm using the binaries built by LLVM and setting CLANG and LLVM_CONFIG_PATH and that seems to be enough.
For the sake of pushing my work-in-progress somewhere, 68ad09b6641e1032c5498640ab8a5bbbe0e8b7a7 does compile on Manjaro's 5.6 kernel, but there are some definite Makefile crimes in there :)
Trying to build
hello-world
as described here, but I'm getting this error:I'm on Manjaro Linux 18.0.4, with Linux kernel 5.2.8-1.