Re: [PATCH 2/3] kbuild: rust: apply `CONFIG_WERROR` to all Rust targets

From: Masahiro Yamada
Date: Wed May 22 2024 - 06:14:29 EST


On Tue, May 21, 2024 at 5:05 PM Miguel Ojeda
<miguel.ojeda.sandonis@xxxxxxxxx> wrote:
>
> On Tue, May 21, 2024 at 6:15 AM Masahiro Yamada <masahiroy@kernelorg> wrote:
> >
> > Rust started to do something different from C.
> >
> > KBUILD_HOSTCFLAGS is not affected by any CONFIG option.
> >
> > The reason is because HOSTCC is needed for building Kconfig.
> > If the flags for HOSTCC is changed by a CONFIG option,
> > it would be a chicken-egg problem.
> > Also, some host programs might be compiled even
> > without .config at all. (e.g. scripts/unifdef)
> >
> > I know Rust will not become a part of the core infrastructure
> > of the build system, but IMHO, host programs should not be
> > affected by any CONFIG option.
> >
> > I do not like this patch.
>
> Thanks Masahiro -- yeah, I can see how it makes sense for C host
> programs, and consistency with those may be best, even if it is not
> used for core infrastructure in the case of Rust.
>
> Do you think it would be OK if we do it only for everything else, i.e.
> no host programs?


What does "everything else" mean exactly?


I just noticed that $(rust_common_flags) is passed
not only to RUSTC but also to RUSTDOC.


It seems to be intentional because it explicitly says
"requires kernel .config".


@echo ' rustdoc - Generate Rust documentation'
@echo ' (requires kernel .config)'


This is different from how other "make htmldocs" etc. work.

Why is the .config required for generating documentation?









> That covers most of the Rust things so far and would
> have helped with the warning I linked above (which is why I would like
> to change this -- one can pass the flag manually, of course, but
> having more targets affected by `CONFIG_WERROR` means more developers
> will have it enabled and thus notice earlier).
>
> (I am also thinking whether it could make sense to eventually
> explicitly mark the C host programs that would be exempt from
> `CONFIG_WERROR` so that we could apply it to everything else -- I
> guess it could be easy to get wrong and/or forget when new ones are
> added.)
>
> Cheers,
> Miguel



--
Best Regards
Masahiro Yamada