mbox series

[0/9] misc sparse patches

Message ID 53dc6269-3884-ab48-94bb-550718e4e3ce@ramsayjones.plus.com (mailing list archive)
Headers show
Series misc sparse patches | expand

Message

Ramsay Jones Nov. 19, 2018, 8:44 p.m. UTC
Hi Luc,

I noticed a couple of days ago, that the git.kernel.org sparse repo had
suddenly 'fast-forwarded' to just two commits behind the master branch
of your github sparse.git repo. As I mentioned before, I have been using
that branch as a base for my own patches (so that I don't suffer the
'sysmacros' warnings on newer versions of Linux). Tonight, I noticed
that it has 'fast-forwarded' again and is now at the same commit as the
base for my patches. So, I thought I may as well send these along ...
:-D

So, the base for these patches is commit 06a4545:

    $ git log --oneline master~1..dev
    8764999 (HEAD -> dev) constant: add -Wconstant-size warning
    5ed6580 pre-processor: add some pre-defined macros
    ffab79b pre-process: add the -dM option to dump macro definitions
    0449136 pre-process: print variable argument macros correctly
    49c61c8 pre-process: don't put spaces in macro parameter list
    c4b224c pre-process: print macros containing # and ## correctly
    4a45aea pre-process: suppress trailing space when dumping macros
    c9398e7 sparsei: add the --[no-]jit options
    dd6a13e sparsec: use a compatible exception model on cygwin
    06a4545 (origin/master, origin/HEAD, luc/master, master, luc-master) tokenize: check show_string() for NULL pointer
    $ 

Note that the final patch is marked RFC (see below).

Some brief notes about the patches:

  0001-sparsec-use-a-compatible-exception-model-on-cygwin.patch
  0002-sparsei-add-the-no-jit-options.patch

    The first two patches fix the use of the llvm tools on cygwin. The test
    suite had 64 test failures (55 + additional 9 fixed by these patches).
    The test suite now runs clean.

  0003-pre-process-suppress-trailing-space-when-dumping-mac.patch
  0004-pre-process-print-macros-containing-and-correctly.patch
  0005-pre-process-don-t-put-spaces-in-macro-parameter-list.patch
  0006-pre-process-print-variable-argument-macros-correctly.patch
  0007-pre-process-add-the-dM-option-to-dump-macro-definiti.patch

    These patches implement '-dM' for sparse, just so that I could run:

      $ gcc -dM -E - </dev/null | sort >gcc-macs
      $ ./sparse -dM -E - </dev/null | sort >sp-macs
      $ meld gcc-macs sp-macs
      $ 

    (note you can add -m32, -mx32, -m64 to those gcc/sparse command lines).
    ... in order to help with ...

  0008-pre-processor-add-some-pre-defined-macros.patch

    ... this patch! This patch is not 'finished', but has enough to get
    started with (eg cygwin has a 16-bit wchar_t, etc). For example, on
    cygwin, sparse would spew approx. 1600 warnings on git, without using
    the SPARSE_FLAGS in the config.mak file to set the following:

      $ grep SPARSE_FLAGS config.mak
      #SPARSE_FLAGS += -D__INTPTR_TYPE__='long int'
      #SPARSE_FLAGS += -D__INT32_TYPE__=int
      #SPARSE_FLAGS += -D__INT32_MAX__=2147483647
      #SPARSE_FLAGS += -D__UINT32_TYPE__='unsigned int'
      #SPARSE_FLAGS += -D__UINT32_MAX__=4294967295U
      #SPARSE_FLAGS += -D__INT64_TYPE__='long int'
      #SPARSE_FLAGS += -D__INT64_MAX__=9223372036854775807L
      #SPARSE_FLAGS += -D__UINT64_TYPE__='long unsigned int'
      #SPARSE_FLAGS += -D__UINT64_MAX__=18446744073709551615UL
      #SPARSE_FLAGS += -D__INTMAX_TYPE__='long int'
      #SPARSE_FLAGS += -D__INTMAX_MAX__=9223372036854775807L
      #SPARSE_FLAGS += -D__UINTMAX_TYPE__='long unsigned int'
      #SPARSE_FLAGS += -D__UINTMAX_MAX__=18446744073709551615UL
      #SPARSE_FLAGS += -D__SIZE_TYPE__='long unsigned int'
      #SPARSE_FLAGS += -D__SIZE_MAX__=18446744073709551615UL
      $ 

    After this patch, as you can see, I can comment them out (and remove
    them once this patch lands). Also, the 'selfcheck' used to complain
    about being 'unable to determine type definition of intptr_t' and
    'int32_t'.

  0009-constant-add-Wconstant-size-warning.patch

    This is the RFC patch. The main (but not only) problem with this patch
    is the name of the warning 'constant-size'! ;-) Please take that as
    simply a placeholder for a more appropriate name (whatever that is!).


Ramsay Jones (9):
  sparsec: use a compatible exception model on cygwin
  sparsei: add the --[no-]jit options
  pre-process: suppress trailing space when dumping macros
  pre-process: print macros containing # and ## correctly
  pre-process: don't put spaces in macro parameter list
  pre-process: print variable argument macros correctly
  pre-process: add the -dM option to dump macro definitions
  pre-processor: add some pre-defined macros
  constant: add -Wconstant-size warning

 cgcc                                       |   2 +-
 expression.c                               |   2 +-
 lib.c                                      | 104 +++++++++++++++++++--
 lib.h                                      |   2 +
 pre-process.c                              |  22 ++++-
 sparse.1                                   |  10 ++
 sparsec                                    |  12 ++-
 sparsei                                    |  20 +++-
 validation/backend/sum.c                   |   2 +-
 validation/constant-size-32.c              |  15 +++
 validation/constant-size-64.c              |  15 +++
 validation/preprocessor/dump-macros-only.c |  36 +++++++
 validation/preprocessor/dump-macros.c      |  16 ++++
 13 files changed, 242 insertions(+), 16 deletions(-)
 create mode 100644 validation/constant-size-32.c
 create mode 100644 validation/constant-size-64.c
 create mode 100644 validation/preprocessor/dump-macros-only.c

Comments

Luc Van Oostenryck Nov. 19, 2018, 11:59 p.m. UTC | #1
On Mon, Nov 19, 2018 at 08:44:37PM +0000, Ramsay Jones wrote:
> 
> Hi Luc,
> 
> I noticed a couple of days ago, that the git.kernel.org sparse repo had
> suddenly 'fast-forwarded' to just two commits behind the master branch
> of your github sparse.git repo. As I mentioned before, I have been using
> that branch as a base for my own patches (so that I don't suffer the
> 'sysmacros' warnings on newer versions of Linux). Tonight, I noticed
> that it has 'fast-forwarded' again and is now at the same commit as the
> base for my patches. So, I thought I may as well send these along ...
> :-D

Ahh, great!
 
> Some brief notes about the patches:
> 
>   0001-sparsec-use-a-compatible-exception-model-on-cygwin.patch
>   0002-sparsei-add-the-no-jit-options.patch
> 
>     The first two patches fix the use of the llvm tools on cygwin. The test
>     suite had 64 test failures (55 + additional 9 fixed by these patches).
>     The test suite now runs clean.

I'm not sure to understand what's the difference between the 55 and
the 9 additional ones.

I quickly looked at these 2 patches and they looks good (they can't
regress on non-cygwin and obviosuly solve the problmes you had).

>   0003-pre-process-suppress-trailing-space-when-dumping-mac.patch
>   0004-pre-process-print-macros-containing-and-correctly.patch
>   0005-pre-process-don-t-put-spaces-in-macro-parameter-list.patch
>   0006-pre-process-print-variable-argument-macros-correctly.patch
>   0007-pre-process-add-the-dM-option-to-dump-macro-definiti.patch
> 
>     These patches implement '-dM' for sparse, just so that I could run:

It's nice to upport for -DM (I had a vague intention to add it but
it was very low priority). The small fixes/enhancements are much
welcome too.
 
>   0008-pre-processor-add-some-pre-defined-macros.patch
> 
>     ... this patch! This patch is not 'finished', but has enough to get
>     started with (eg cygwin has a 16-bit wchar_t, etc). For example, on
>     cygwin, sparse would spew approx. 1600 warnings on git, without using
>     the SPARSE_FLAGS in the config.mak file to set the following:
> 
>       $ grep SPARSE_FLAGS config.mak
>       #SPARSE_FLAGS += -D__INTPTR_TYPE__='long int'
>       #SPARSE_FLAGS += -D__INT32_TYPE__=int
>       #SPARSE_FLAGS += -D__INT32_MAX__=2147483647
>       #SPARSE_FLAGS += -D__UINT32_TYPE__='unsigned int'
>       #SPARSE_FLAGS += -D__UINT32_MAX__=4294967295U
>       #SPARSE_FLAGS += -D__INT64_TYPE__='long int'
>       #SPARSE_FLAGS += -D__INT64_MAX__=9223372036854775807L
>       #SPARSE_FLAGS += -D__UINT64_TYPE__='long unsigned int'
>       #SPARSE_FLAGS += -D__UINT64_MAX__=18446744073709551615UL
>       #SPARSE_FLAGS += -D__INTMAX_TYPE__='long int'
>       #SPARSE_FLAGS += -D__INTMAX_MAX__=9223372036854775807L
>       #SPARSE_FLAGS += -D__UINTMAX_TYPE__='long unsigned int'
>       #SPARSE_FLAGS += -D__UINTMAX_MAX__=18446744073709551615UL
>       #SPARSE_FLAGS += -D__SIZE_TYPE__='long unsigned int'
>       #SPARSE_FLAGS += -D__SIZE_MAX__=18446744073709551615UL
>       $ 

I see. That looks quite painful.
 
>     After this patch, as you can see, I can comment them out (and remove
>     them once this patch lands). Also, the 'selfcheck' used to complain
>     about being 'unable to determine type definition of intptr_t' and
>     'int32_t'.

Excellent!
 
>   0009-constant-add-Wconstant-size-warning.patch
> 
>     This is the RFC patch. The main (but not only) problem with this patch
>     is the name of the warning 'constant-size'! ;-) Please take that as
>     simply a placeholder for a more appropriate name (whatever that is!).

OK, we'll see this.

Thanks for these patches.

Kind regards,
-- Luc
Ramsay Jones Nov. 20, 2018, 12:36 a.m. UTC | #2
On 19/11/2018 23:59, Luc Van Oostenryck wrote:
> On Mon, Nov 19, 2018 at 08:44:37PM +0000, Ramsay Jones wrote:
>>
>> Some brief notes about the patches:
>>
>>   0001-sparsec-use-a-compatible-exception-model-on-cygwin.patch
>>   0002-sparsei-add-the-no-jit-options.patch
>>
>>     The first two patches fix the use of the llvm tools on cygwin. The test
>>     suite had 64 test failures (55 + additional 9 fixed by these patches).
>>     The test suite now runs clean.
> 
> I'm not sure to understand what's the difference between the 55 and
> the 9 additional ones.

When these patches were written, only 3 'additional test failures'
were caused by the problems addressed by these patches (backend tests).
Since then, many more backend tests have been written:

$ make check
Makefile:124: Your system does not have libxml, disabling c2xml
Makefile:146: Your system does not have gtk3/gtk2, disabling test-inspect
  TEST    __func__ (__func__.c)
  TEST    abi-integer (abi-integer.c)
...

  TEST    warn-unknown-attribute-yes (Wunknown-attribute-yes.c)
KO: out of 608 tests, 544 passed, 64 failed
	55 of them are known to fail
make: *** [Makefile:228: check] Error 1
$ 

So, the 55 are those marked 'known to fail' the 9 (64 - 55) other
test failures are fixed by these patches. A test suite run now
looks like:

$ make check
Makefile:124: Your system does not have libxml, disabling c2xml
Makefile:146: Your system does not have gtk3/gtk2, disabling test-inspect
  TEST    __func__ (__func__.c)
  TEST    abi-integer (abi-integer.c)
...
  TEST    warn-unknown-attribute-yes (Wunknown-attribute-yes.c)
OK: out of 611 tests, 556 passed, 55 failed
	55 of them are known to fail
$ 

ATB,
Ramsay Jones
Luc Van Oostenryck Nov. 20, 2018, 12:53 a.m. UTC | #3
On Tue, Nov 20, 2018 at 12:36:38AM +0000, Ramsay Jones wrote:
> 
> 
> On 19/11/2018 23:59, Luc Van Oostenryck wrote:
> > On Mon, Nov 19, 2018 at 08:44:37PM +0000, Ramsay Jones wrote:
> >>
> >> Some brief notes about the patches:
> >>
> >>   0001-sparsec-use-a-compatible-exception-model-on-cygwin.patch
> >>   0002-sparsei-add-the-no-jit-options.patch
> >>
> >>     The first two patches fix the use of the llvm tools on cygwin. The test
> >>     suite had 64 test failures (55 + additional 9 fixed by these patches).
> >>     The test suite now runs clean.
> > 
> > I'm not sure to understand what's the difference between the 55 and
> > the 9 additional ones.
> 
> When these patches were written, only 3 'additional test failures'
> were caused by the problems addressed by these patches (backend tests).
> Since then, many more backend tests have been written:
> 
> $ make check
> Makefile:124: Your system does not have libxml, disabling c2xml
> Makefile:146: Your system does not have gtk3/gtk2, disabling test-inspect
>   TEST    __func__ (__func__.c)
>   TEST    abi-integer (abi-integer.c)
> ...
> 
>   TEST    warn-unknown-attribute-yes (Wunknown-attribute-yes.c)
> KO: out of 608 tests, 544 passed, 64 failed
> 	55 of them are known to fail
> make: *** [Makefile:228: check] Error 1
> $ 
> 
> So, the 55 are those marked 'known to fail' the 9 (64 - 55) other
> test failures are fixed by these patches.

Ah yes, OK.

Thanks,
-- Luc
Luc Van Oostenryck Nov. 20, 2018, 1:04 a.m. UTC | #4
On Mon, Nov 19, 2018 at 08:44:37PM +0000, Ramsay Jones wrote:
> 
>   0009-constant-add-Wconstant-size-warning.patch
> 
>     This is the RFC patch. The main (but not only) problem with this patch
>     is the name of the warning 'constant-size'! ;-) Please take that as
>     simply a placeholder for a more appropriate name (whatever that is!).

It looks good to me.
Maybe '-Wstrict-constant-type' for the name? (I see the original
warning more as a type problem than as a size problem).
 
Best regards,
-- Luc