Re: [PATCH] genksyms: Ignore module scoped _Static_assert()
From: Nick Desaulniers
Date: Thu Dec 10 2020 - 18:06:54 EST
On Thu, Dec 10, 2020 at 8:25 AM Marco Elver <elver@xxxxxxxxxx> wrote:
>
> On Thu, 10 Dec 2020 at 14:29, Miguel Ojeda
> <miguel.ojeda.sandonis@xxxxxxxxx> wrote:
> > On Thu, Dec 10, 2020 at 11:35 AM Marco Elver <elver@xxxxxxxxxx> wrote:
> > >
> > > It looks like there's no clear MAINTAINER for this. :-/
> > > It'd still be good to fix this for 5.11.
> >
> > Richard seems to be the author, not sure if he picks patches (CC'd).
> >
> > I guess Masahiro or akpm (Cc'd) would be two options; otherwise, I
> > could pick it up through compiler attributes (stretching the
> > definition...).
>
> Thanks for the info. I did find that there's an alternative patch to
> fix _Static_assert() with genksyms that was sent 3 days after mine
> (it's simpler, but might miss cases). I've responded there (
> https://lkml.kernel.org/r/X9JI5KpWoo23wkRg@xxxxxxxxxxxxxxxx ).
>
> Now we have some choice. I'd argue for this patch, because it's not
> doing preprocessor workarounds, but in the end I won't make that call.
> :-)
I was half kidding about depending on a production C parser. See
internal reference pa/1432607, choice quotes:
```
...
CONFIG_MODVERSIONS uses scripts/genksyms/genksyms to create a file,
Module.symvers, that is a simple mapping of CRCs of various symbols'
types to the symbol names. It produces these CRCs by using the C
preprocessor, then passing this into genksyms. genksyms has a lex/yacc
based C parser to parse the preprocessed sources of kernel modules. It
turns out that it's incomplete, copied from an upstream project that
ceased development in 2013, and was slated to be removed around the 4.9
kernel release.
...
Some possible solutions:
* Update the kernel's version of genksyms. There's a comment that the
kernel's sources were copied from "modutils." It seems that modutils'
last release was v2.4.27 in 2004, and that development on it has
stopped. Upstream modutils also has the same parsing bug.
...
* Fix the parsing bug in genksysms. While the discussion about removing
CONFIG_MODVERSIONS has started again upstream due to my bugreport,
this would be the optimal solution, if I could just figure out how to
rewrite the parser correctly.
...
A better long term solution would be to replace genksyms's
modutils/lex/yacc based incomplete and dead C parser with a libclang
based one, but such work is beyond the scope of a toolchain update.
For future travelers that would like to take a crack at fixing the
existing parser, I found the develop/build/test/debug cycle to be:
$ rm scripts/genksyms/genksyms
$ make scripts/genksyms/
$ ./scripts/genksyms/genksyms -d < test_case.i
$ ./scripts/genksyms/genksyms -d -d < test_case.i
Best of luck on that endeavor.
```
I was planning on talking about this timebomb at plumbers, but had to
cut it due to the tight time constraints we were allotted.
--
Thanks,
~Nick Desaulniers