Support SPARSE in Makefile, better SPARSE_FLAGS
PATCH 1/1 Support SPARSE in Makefile, better SPARSE_FLAGS
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.
Makefile +4 -3
@@ -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
Signature · 2 lines
Regards, Pavel Roskin
Makefile INSTALL = install · line 71
Quoted 3 lines · Pavel Roskin
Makefile +3
-0+# 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?
Quoted 9 lines · Junio C Hamano
Makefile INSTALL = install · line 71
Quoted 3 lines · Pavel Roskin
Makefile +3
-0+# 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.
Quoted 9 lines
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.
Signature · 2 lines
Regards, Pavel Roskin
Quoted 5 lines · Pavel Roskin
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
Quoted 11 lines · H. Peter Anvin
Quoted 5 lines · Pavel Roskin
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-obuiltin.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).
Signature · 2 lines
Regards, Pavel Roskin
Quoted 6 lines · Pavel Roskin
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
Makefileis 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
Quoting "H. Peter Anvin" <[email protected]>:
Quoted 10 lines
Quoted 6 lines · Pavel Roskin
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
Makefileis 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.
Quoted 3 lines
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