From: Junio C Hamano <hidden> Date: 2016-06-15 22:42:07
Pavel Roskin [off-list ref] 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?
From: Pavel Roskin <hidden> Date: 2016-06-15 22:42:07
On Thu, 2005-09-29 at 22:46 -0700, Junio C Hamano wrote:
Pavel Roskin [off-list ref] writes:
quoted
+# 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
From: "H. Peter Anvin" <hpa@zytor.com> Date: 2016-06-15 22:42:07
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
From: Pavel Roskin <hidden> Date: 2016-06-15 22:42:07
On Fri, 2005-09-30 at 12:19 -0700, H. Peter Anvin wrote:
Pavel Roskin wrote:
quoted
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
From: "H. Peter Anvin" <hpa@zytor.com> Date: 2016-06-15 22:42:07
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
From: Pavel Roskin <hidden> Date: 2016-06-15 22:42:07
Quoting "H. Peter Anvin" [off-list ref]:
Pavel Roskin wrote:
quoted
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