* [PATCH] Support SPARSE in Makefile, better SPARSE_FLAGS
@ 2005-09-29 20:46 Pavel Roskin
2005-09-30 5:46 ` Junio C Hamano
0 siblings, 1 reply; 7+ messages in thread
From: Pavel Roskin @ 2005-09-29 20:46 UTC (permalink / raw)
To: git
Support SPARSE in Makefile, better SPARSE_FLAGS
This patch makes it possible to use some other program instead of sparse
(e.g. a wrapper around sparse). It also provides a better default for
SPARSE_FLAGS. __BIG_ENDIAN__ should not be needed.
Signed-off-by: Pavel Roskin <proski@gnu.org>
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -66,8 +66,9 @@ INSTALL = install
RPMBUILD = rpmbuild
# sparse is architecture-neutral, which means that we need to tell it
-# explicitly what architecture to check for. Fix this up for yours..
-SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
+# explicitly what architecture to check for.
+SPARSE = sparse
+SPARSE_FLAGS = -D__$(shell uname -i)__
@@ -335,7 +336,7 @@ test-delta: test-delta.c diff-delta.o pa
$(CC) $(ALL_CFLAGS) -o $@ $^
check:
- for i in *.c; do sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i; done
+ for i in *.c; do $(SPARSE) $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i; done
--
Regards,
Pavel Roskin
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Support SPARSE in Makefile, better SPARSE_FLAGS
2005-09-29 20:46 [PATCH] Support SPARSE in Makefile, better SPARSE_FLAGS Pavel Roskin
@ 2005-09-30 5:46 ` Junio C Hamano
2005-09-30 13:41 ` Pavel Roskin
0 siblings, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2005-09-30 5:46 UTC (permalink / raw)
To: Pavel Roskin; +Cc: git
Pavel Roskin <proski@gnu.org> writes:
> +# explicitly what architecture to check for.
> +SPARSE = sparse
> +SPARSE_FLAGS = -D__$(shell uname -i)__
: siamese; uname --version
uname (coreutils) 5.2.1
Written by David MacKenzie.
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
: siamese; uname -i
Try `uname --help' for more information.
Better alternatives?
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] Support SPARSE in Makefile, better SPARSE_FLAGS
2005-09-30 5:46 ` Junio C Hamano
@ 2005-09-30 13:41 ` Pavel Roskin
2005-09-30 19:19 ` H. Peter Anvin
0 siblings, 1 reply; 7+ messages in thread
From: Pavel Roskin @ 2005-09-30 13:41 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
On Thu, 2005-09-29 at 22:46 -0700, Junio C Hamano wrote:
> Pavel Roskin <proski@gnu.org> writes:
>
> > +# explicitly what architecture to check for.
> > +SPARSE = sparse
> > +SPARSE_FLAGS = -D__$(shell uname -i)__
>
> : siamese; uname --version
> uname (coreutils) 5.2.1
> Written by David MacKenzie.
Apparently my uname 5.2.1 was heavily patched by Fedora. Note that
"uname -m" is not good enough, as it would give us i686 when i386 is
really needed.
> Copyright (C) 2004 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.
> There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A
> PARTICULAR PURPOSE.
> : siamese; uname -i
> Try `uname --help' for more information.
>
> Better alternatives?
I hate to say that, but a better alternative is to fix sparse to act
like the native compiler by default (possibly with options to imitate
other architectures or to be fully arch-neutral).
I have some hacks in mind, but I don't really like them:
Not good for i686 with unpatched uname:
SPARSE_FLAGS = __$(shell uname -i 2>/dev/null || uname -m)__
gcc specific:
SPARSE_FLAGS = __$(shell $CC -dumpmachine | sed 's/-.*//')__
bash specific:
SPARSE_FLAGS = __$(shell echo $$HOSTTYPE)__
In any case, having SPARSE variable would be convenient.
--
Regards,
Pavel Roskin
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Support SPARSE in Makefile, better SPARSE_FLAGS
2005-09-30 13:41 ` Pavel Roskin
@ 2005-09-30 19:19 ` H. Peter Anvin
2005-09-30 22:14 ` Pavel Roskin
0 siblings, 1 reply; 7+ messages in thread
From: H. Peter Anvin @ 2005-09-30 19:19 UTC (permalink / raw)
To: Pavel Roskin; +Cc: Junio C Hamano, git
Pavel Roskin wrote:
>
> I hate to say that, but a better alternative is to fix sparse to act
> like the native compiler by default (possibly with options to imitate
> other architectures or to be fully arch-neutral).
>
$(CC) $(CFLAGS) -E -dM -x c /dev/null -o builtin.h
... will output a file containing all the buildin macros that you can
feed to sparse with -include.
Replacing -x c with, say, -x c++ gives you the builtins for C++;
including $(CFLAGS) gives the appropriate set of macros for any
particular combination of options (which can affect the builtin macro set.)
-hpa
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Support SPARSE in Makefile, better SPARSE_FLAGS
2005-09-30 19:19 ` H. Peter Anvin
@ 2005-09-30 22:14 ` Pavel Roskin
2005-09-30 22:16 ` H. Peter Anvin
0 siblings, 1 reply; 7+ messages in thread
From: Pavel Roskin @ 2005-09-30 22:14 UTC (permalink / raw)
To: H. Peter Anvin; +Cc: Junio C Hamano, git
On Fri, 2005-09-30 at 12:19 -0700, H. Peter Anvin wrote:
> Pavel Roskin wrote:
> >
> > I hate to say that, but a better alternative is to fix sparse to act
> > like the native compiler by default (possibly with options to imitate
> > other architectures or to be fully arch-neutral).
> >
>
> $(CC) $(CFLAGS) -E -dM -x c /dev/null -o builtin.h
>
> ... will output a file containing all the buildin macros that you can
> feed to sparse with -include.
I know. That's what I'm using in the wrapper (plus -m64 and some
warnings). But it should be the default. Until then, hassle-free
sparse support in the Makefile is only possible for the projects that
already know the architecture (e.g. the Linux kernel).
--
Regards,
Pavel Roskin
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Support SPARSE in Makefile, better SPARSE_FLAGS
2005-09-30 22:14 ` Pavel Roskin
@ 2005-09-30 22:16 ` H. Peter Anvin
2005-10-01 4:13 ` Pavel Roskin
0 siblings, 1 reply; 7+ messages in thread
From: H. Peter Anvin @ 2005-09-30 22:16 UTC (permalink / raw)
To: Pavel Roskin; +Cc: Junio C Hamano, git
Pavel Roskin wrote:
>
> I know. That's what I'm using in the wrapper (plus -m64 and some
> warnings). But it should be the default. Until then, hassle-free
> sparse support in the Makefile is only possible for the projects that
> already know the architecture (e.g. the Linux kernel).
>
I think that's debatable. It introduces main-compiler dependencies into
sparse which is undesirable.
A much simpler option would be to write a "sparsegcc" script which would
be invoked just like gcc, extract the appropriate macro information
based on options, and then invoke sparse.
-hpa
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Support SPARSE in Makefile, better SPARSE_FLAGS
2005-09-30 22:16 ` H. Peter Anvin
@ 2005-10-01 4:13 ` Pavel Roskin
0 siblings, 0 replies; 7+ messages in thread
From: Pavel Roskin @ 2005-10-01 4:13 UTC (permalink / raw)
To: H. Peter Anvin; +Cc: Junio C Hamano, git
Quoting "H. Peter Anvin" <hpa@zytor.com>:
> Pavel Roskin wrote:
> >
> > I know. That's what I'm using in the wrapper (plus -m64 and some
> > warnings). But it should be the default. Until then, hassle-free
> > sparse support in the Makefile is only possible for the projects that
> > already know the architecture (e.g. the Linux kernel).
> >
>
> I think that's debatable. It introduces main-compiler dependencies into
> sparse which is undesirable.
I see sparse is already moving in this direction. Right now, it's somewhere in
the middle, which is quite inconvenient. It hardcodes gcc version numbers but
not the architecture.
> A much simpler option would be to write a "sparsegcc" script which would
> be invoked just like gcc, extract the appropriate macro information
> based on options, and then invoke sparse.
I guess that's what cgcc is trying to be. Since it also runs the compiler, no
special support for cgcc should be needed in Makefile other than using $(CC).
--
Regards,
Pavel Roskin
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2005-10-01 4:14 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-29 20:46 [PATCH] Support SPARSE in Makefile, better SPARSE_FLAGS Pavel Roskin
2005-09-30 5:46 ` Junio C Hamano
2005-09-30 13:41 ` Pavel Roskin
2005-09-30 19:19 ` H. Peter Anvin
2005-09-30 22:14 ` Pavel Roskin
2005-09-30 22:16 ` H. Peter Anvin
2005-10-01 4:13 ` Pavel Roskin
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).