-
Notifications
You must be signed in to change notification settings - Fork 120
-DMODULE
CFLAG doesn't propagate correctly to cargo on Arch Linux
#241
Comments
Yup, I ran into that last night and I don't exactly know why / what the proper fix is, yet. To be fair, Also I wonder if this is actually a change in upstream Kbuild and it's just that Arch/Manjaro use very recent kernel, but nothing sticks out at me yet... It seems like this is probably the |
This is (fortunately?) not Arch-specific - I can repro the same error with Debian unstable's kernel:
5.2 is fine, so it's something in between the two of those.... |
OK, this seems to be torvalds/linux@986662b from v5.4. I'm guessing the thing we're doing "wrong" here is that our Makefile target is in a subdirectory (target/debug/...) and so the refactored rule doesn't pick it up, but the old rule worked with targets in subdirectories because of the magic of Makefile patterns. Not sure yet what the best thing to do about it is. |
I think the idea to just add |
KBUILD_CFLAGS_MODULE=-DMODULE isn't included in c_flags anymore on Linux 5.4+ due to some Makefile refactoring. We just do it ourselves for now. Fixes fishinabarrel#241.
KBUILD_CFLAGS_MODULE=-DMODULE isn't included in c_flags anymore on Linux 5.4+ due to some Makefile refactoring. We just do it ourselves for now. Fixes #241.
I'm unfamiliar with the kernel build system but it seems that at least on Arch Linux the
c_flags
environment variable doesn't contain-DMODULE
when cargo is invoked when building the hello-world example. This causes issues since__this_module
is then incorrectly defined. It seems-DMODULE
is only included inc_flags
when invokingld
in the other make target.c_flags
of$(src)/target/x86_64-linux-kernel/debug/libhello_world.a
:c_flags
of%.rust.o
:(look at the very end of each line)
The issue is probably that the build system thinks
libhello_world.a
is not part of the module which causesKBUILD_CFLAGS_MODULE=-DMODULE
to not be included inc_flags
. Unfortunately I'm not sure what the proper way to fix this is. (What does definitely work is just appending the value ofKBUILD_CFLAGS_MODULE
to the rest of the cflags inbuild.rs
.)(edit: And surely enough just after posting I see that #152 (comment) already noticed this problem.)
The text was updated successfully, but these errors were encountered: