bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] maint.mk: add a syntax-check rule to ensure tightly-scoped s


From: Jim Meyering
Subject: Re: [PATCH] maint.mk: add a syntax-check rule to ensure tightly-scoped symbols
Date: Tue, 17 May 2011 16:08:22 +0200

Pádraig Brady wrote:
> On 09/05/11 11:44, Jim Meyering wrote:
>> I've been using a precursor of this rule in coreutils for many years,
>
>> so finally have made it general enough so that the same
>
> The above change is giving a false positive on my 32 linux laptop,
> where it flags  __i686.get_pc_thunk.bx from src/libstdbuf_so-libstdbuf.o
> The following fix auto excludes any symbols starting with an underscore.
> Maybe I should do this only for double underscores?
>
> pb-laptop:~/git/coreutils$ diff gnulib/top/maint.mk maint.mk
> --- gnulib/top/maint.mk 2011-05-14 09:30:58.000000000 +0000
> +++ maint.mk    2011-05-17 12:45:56.000000000 +0000
> @@ -1397,7 +1397,7 @@
>           perl -lne '$(_gl_TS_function_match)'                          \
>                   -e 'and print $$1' $$hdr;                             \
>         ) | sort -u | sed 's/^/^/;s/$$/$$/' > $$t;                      \
> -       nm -e *.$(OBJEXT) | sed -n 's/.* T //p' | grep -Ev -f $$t       \
> +       nm -e *.$(OBJEXT) | sed -n 's/.* T \([^_]\)/\1/p' | grep -Ev -f $$t \
>           && { echo the above functions should have static scope >&2;   \
>                exit 1; } || : ;                                         \
>         ( printf '^%s$$\n' $(_gl_TS_unmarked_extern_vars);              \

Hi Pádraig,
I did hesitate as I removed the filter that ignored
any name with a leading underscore.  But since I didn't
see any such symbol actually being removed in testing
I chose to omit the filter.

I'm reluctant to ignore all of them... what if someone accidentally
declares e.g., int _foo () { ... }
(omitting the "static")?  I wouldn't want to fail to warn about that,
just because their function name starts with "_".

Two alternatives:

  - rather than hard-coding *.$(OBJEXT), use something like this:
      _gl_TS_function_objects ?= *.$(OBJEXT)
    and override it in coreutils to $(filter-out ...) that one
    offending .o file.

  - in coreutils, add __i686.get_pc_thunk.bx or maybe just '^__i686.*$$'
    to the list of _gl_TS_unmarked_extern_functions



reply via email to

[Prev in Thread] Current Thread [Next in Thread]