On Fri, Jul 26, 2024 at 1:21 AM Matthew Maurer <mmaurer@xxxxxxxxxx> wrote: > > Rust supports KASAN via LLVM, but prior to this patch, the flags aren't > set properly. > > Suggested-by: Miguel Ojeda <ojeda@xxxxxxxxxx> > Signed-off-by: Matthew Maurer <mmaurer@xxxxxxxxxx> Hi Matthew, > CFLAGS_KASAN_MINIMAL := -fsanitize=kernel-address > +RUSTFLAGS_KASAN_MINIMAL := -Zsanitizer=kernel-address -Zsanitizer-recover=kernel-address If I recall correctly, the reason we need CFLAGS_KASAN_MINIMAL is because older compilers don't support some of the additional options. With Rust, this shouldn't be needed, as it requires a modern compiler that does support all needed options. E.g., for CONFIG_KASAN_SW_TAGS, we also don't have the MINIMAL thing for the same reason. (Possibly, we also already don't need this for GENERIC KASAN, as the GCC version requirement was raised a few times since KASAN was introduced.) > # Now add all the compiler specific options that are valid standalone > CFLAGS_KASAN := $(CFLAGS_KASAN_SHADOW) \ > $(call cc-param,asan-globals=1) \ > $(call cc-param,asan-instrumentation-with-call-threshold=$(call_threshold)) \ > $(call cc-param,asan-instrument-allocas=1) > + ifdef CONFIG_RUST > + RUSTFLAGS_KASAN := $(RUSTFLAGS_KASAN_SHADOW) \ > + $(call rustc-param,asan-globals=1) \ > + $(call rustc-param,asan-instrumentation-with-call-threshold=$(call_threshold)) \ > + $(call rustc-param,asan-instrument-allocas=1) I'm wondering if there's a way to avoid duplicating all options for Rust. Perhaps, some kind of macro? Thanks!