linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christopher Li <sparse@chrisli.org>
To: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
	Junio C Hamano <gitster@pobox.com>, Andreas Ericsson <ae@op5.se>,
	Sparse Mailing-list <linux-sparse@vger.kernel.org>
Subject: Re: Multiple translation unit regression
Date: Mon, 6 Jul 2009 02:32:47 -0700	[thread overview]
Message-ID: <70318cbf0907060232j7067f7fcra857b71ebdf62348@mail.gmail.com> (raw)
In-Reply-To: <4A5131F4.7070007@ramsay1.demon.co.uk>

On Sun, Jul 5, 2009 at 4:06 PM, Ramsay Jones<ramsay@ramsay1.demon.co.uk> wrote:
>
> pre-process.c:609 in function expand():
>        struct arg args[nargs];

That is a known limit of sparse. It does not handle dynamic sized array.
In kernel that is not a good thing because kernel stack is very limited.

> sparse:
>        cgcc -no-compile $(ALL_CFLAGS) $(SPARSE_FLAGS) $(SRC_C)

I think libgit2 should make sparse to compile the file one by one.
Do them all at once might overflow your memory.

>
> this results in the follwing warnings (on cygwin):
>
> .../byteorder.h:39:1: warning: multiple definitions for function '__ntohl'
> .../byteorder.h:39:1:  the previous one is here
> .../byteorder.h:56:1: warning: multiple definitions for function '__ntohs'
> .../byteorder.h:56:1:  the previous one is here

GNU C has special treatment for "extern inline". It does not generate
the stand alone copy of the function. Sparse does not handle that very
well yet. I think the easiest way to fix is just run those source file
in sparse one by one.


>
> The third hunk of the diff to parse.c actually triggers the problem,
> but is not the real cause of the regression.

I think that is the right thing to do. The problem is that sparse currently
does not have way to mark a function as inline only without the standalone
copy.


>
> I think the problem is mainly caused by bind_symbol() binding the
> global_scope to some symbols. Indeed, the global_scope/file_scope
> seems to be a bit confused and confusing. Note that the global_scope

Global scope is for store global visible symbols.
File scopes is use for file local symbols like static functions.

> is not changed at all once intialised. In particular, each translation
> unit keeps adding to the, one and only, global_scope; which is
> effectively the same as the builtin_scope!

What is wrong with only one global scope?

Chris

> Hmm, the following diff shows a quick fix:
>
> --->8---
> diff --git a/scope.c b/scope.c
> index 27e38bc..fb4c039 100644
> --- a/scope.c
> +++ b/scope.c
> @@ -49,6 +49,7 @@ void start_file_scope(void)
>        /* top-level stuff defaults to file scope, "extern" etc will choose global scope */
>        function_scope = scope;
>        block_scope = scope;
> +       start_scope(&global_scope);
>  }
>
>  void start_symbol_scope(void)
> @@ -87,6 +88,7 @@ static void end_scope(struct scope **s)
>  void end_file_scope(void)
>  {
>        end_scope(&file_scope);
> +       end_scope(&global_scope);
>  }
>
>  void new_file_scope(void)
> --->8---
>
> But this is not the correct fix. In fact it may have broken c2xml
> and ctags. I haven't checked, but look at the main() code in c2xml.c
> and ctags.c; again the semantics of global_scope vs. file_scope
> seems confused and confusing. At least to me. ;-)

As you said, that is not the right fix. Ctags needs to use global scope
to look for symbol has been define but does not used in the file.

Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2009-07-06  9:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-05 23:06 Multiple translation unit regression Ramsay Jones
2009-07-06  9:32 ` Christopher Li [this message]
2009-07-07  6:27   ` Christopher Li
2009-07-08 19:32     ` Ramsay Jones
2009-07-08 20:15       ` Christopher Li
2009-07-10 20:53         ` Ramsay Jones
2009-07-10 23:27           ` Christopher Li
2009-07-13 17:43             ` Ramsay Jones
2009-07-18 20:26               ` Ramsay Jones
2009-07-18 21:53                 ` Christopher Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=70318cbf0907060232j7067f7fcra857b71ebdf62348@mail.gmail.com \
    --to=sparse@chrisli.org \
    --cc=ae@op5.se \
    --cc=gitster@pobox.com \
    --cc=linux-sparse@vger.kernel.org \
    --cc=ramsay@ramsay1.demon.co.uk \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).