{"thread":{"id":"1977","subject":"[PATCH] Support SPARSE in Makefile, better SPARSE_FLAGS","startedAt":"2005-09-29T20:46:05Z","lastAt":"2005-10-01T04:13:58Z","messageCount":7,"participants":["Pavel Roskin","Junio C Hamano","H. Peter Anvin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"9498","messageId":"1128026765.24397.46.camel@dv","threadId":"1977","inReplyTo":null,"subject":"[PATCH] Support SPARSE in Makefile, better SPARSE_FLAGS","fromName":"Pavel Roskin","fromEmail":"proski@gnu.org","sentAt":"2005-09-29T20:46:05Z","receivedAt":"2005-09-29T20:46:05Z","isPatch":true,"sender":{"key":"proski@gnu.org","avatar":null},"body":"Support SPARSE in Makefile, better SPARSE_FLAGS\n\nThis patch makes it possible to use some other program instead of sparse\n(e.g. a wrapper around sparse).  It also provides a better default for\nSPARSE_FLAGS.  __BIG_ENDIAN__ should not be needed.\n\nSigned-off-by: Pavel Roskin <proski@gnu.org>\n\ndiff --git a/Makefile b/Makefile\n--- a/Makefile\n+++ b/Makefile\n@@ -66,8 +66,9 @@ INSTALL = install\n RPMBUILD = rpmbuild\n \n # sparse is architecture-neutral, which means that we need to tell it\n-# explicitly what architecture to check for. Fix this up for yours..\n-SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__\n+# explicitly what architecture to check for.\n+SPARSE = sparse\n+SPARSE_FLAGS = -D__$(shell uname -i)__\n \n \n \n@@ -335,7 +336,7 @@ test-delta: test-delta.c diff-delta.o pa\n \t$(CC) $(ALL_CFLAGS) -o $@ $^\n \n check:\n-\tfor i in *.c; do sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i; done\n+\tfor i in *.c; do $(SPARSE) $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i; done\n \n \n \n\n\n-- \nRegards,\nPavel Roskin\n"},{"id":"9529","messageId":"7vek779kg0.fsf@assigned-by-dhcp.cox.net","threadId":"1977","inReplyTo":"1128026765.24397.46.camel@dv","subject":"Re: [PATCH] Support SPARSE in Makefile, better SPARSE_FLAGS","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-09-30T05:46:39Z","receivedAt":"2005-09-30T05:46:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pavel Roskin <proski@gnu.org> writes:\n\n> +# explicitly what architecture to check for.\n> +SPARSE = sparse\n> +SPARSE_FLAGS = -D__$(shell uname -i)__\n\n        : siamese; uname --version\n        uname (coreutils) 5.2.1\n        Written by David MacKenzie.\n\n        Copyright (C) 2004 Free Software Foundation, Inc.\n        This is free software; see the source for copying conditions.\n        There is NO\n        warranty; not even for MERCHANTABILITY or FITNESS FOR A\n        PARTICULAR PURPOSE.\n        : siamese; uname -i\n        Try `uname --help' for more information.\n\nBetter alternatives?\n"},{"id":"9552","messageId":"1128087662.14543.14.camel@dv","threadId":"1977","inReplyTo":"7vek779kg0.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Support SPARSE in Makefile, better SPARSE_FLAGS","fromName":"Pavel Roskin","fromEmail":"proski@gnu.org","sentAt":"2005-09-30T13:41:02Z","receivedAt":"2005-09-30T13:41:02Z","isPatch":true,"sender":{"key":"proski@gnu.org","avatar":null},"body":"On Thu, 2005-09-29 at 22:46 -0700, Junio C Hamano wrote:\n> Pavel Roskin <proski@gnu.org> writes:\n> \n> > +# explicitly what architecture to check for.\n> > +SPARSE = sparse\n> > +SPARSE_FLAGS = -D__$(shell uname -i)__\n> \n>         : siamese; uname --version\n>         uname (coreutils) 5.2.1\n>         Written by David MacKenzie.\n\nApparently my uname 5.2.1 was heavily patched by Fedora.  Note that\n\"uname -m\" is not good enough, as it would give us i686 when i386 is\nreally needed.\n\n>         Copyright (C) 2004 Free Software Foundation, Inc.\n>         This is free software; see the source for copying conditions.\n>         There is NO\n>         warranty; not even for MERCHANTABILITY or FITNESS FOR A\n>         PARTICULAR PURPOSE.\n>         : siamese; uname -i\n>         Try `uname --help' for more information.\n> \n> Better alternatives?\n\nI hate to say that, but a better alternative is to fix sparse to act\nlike the native compiler by default (possibly with options to imitate\nother architectures or to be fully arch-neutral).\n\nI have some hacks in mind, but I don't really like them:\n\nNot good for i686 with unpatched uname:\nSPARSE_FLAGS = __$(shell uname -i 2>/dev/null || uname -m)__\n\ngcc specific:\nSPARSE_FLAGS = __$(shell $CC -dumpmachine | sed 's/-.*//')__\n\nbash specific:\nSPARSE_FLAGS = __$(shell echo $$HOSTTYPE)__\n\nIn any case, having SPARSE variable would be convenient.\n\n-- \nRegards,\nPavel Roskin\n"},{"id":"9566","messageId":"433D8FA6.2080808@zytor.com","threadId":"1977","inReplyTo":"1128087662.14543.14.camel@dv","subject":"Re: [PATCH] Support SPARSE in Makefile, better SPARSE_FLAGS","fromName":"H. Peter Anvin","fromEmail":"hpa@zytor.com","sentAt":"2005-09-30T19:19:02Z","receivedAt":"2005-09-30T19:19:02Z","isPatch":true,"sender":{"key":"hpa@zytor.com","avatar":null},"body":"Pavel Roskin wrote:\n> \n> I hate to say that, but a better alternative is to fix sparse to act\n> like the native compiler by default (possibly with options to imitate\n> other architectures or to be fully arch-neutral).\n> \n\n$(CC) $(CFLAGS) -E -dM -x c /dev/null -o builtin.h\n\n... will output a file containing all the buildin macros that you can \nfeed to sparse with -include.\n\nReplacing -x c with, say, -x c++ gives you the builtins for C++; \nincluding $(CFLAGS) gives the appropriate set of macros for any \nparticular combination of options (which can affect the builtin macro set.)\n\n\t-hpa\n"},{"id":"9567","messageId":"1128118469.7352.15.camel@dv","threadId":"1977","inReplyTo":"433D8FA6.2080808@zytor.com","subject":"Re: [PATCH] Support SPARSE in Makefile, better SPARSE_FLAGS","fromName":"Pavel Roskin","fromEmail":"proski@gnu.org","sentAt":"2005-09-30T22:14:29Z","receivedAt":"2005-09-30T22:14:29Z","isPatch":true,"sender":{"key":"proski@gnu.org","avatar":null},"body":"On Fri, 2005-09-30 at 12:19 -0700, H. Peter Anvin wrote:\n> Pavel Roskin wrote:\n> > \n> > I hate to say that, but a better alternative is to fix sparse to act\n> > like the native compiler by default (possibly with options to imitate\n> > other architectures or to be fully arch-neutral).\n> > \n> \n> $(CC) $(CFLAGS) -E -dM -x c /dev/null -o builtin.h\n> \n> ... will output a file containing all the buildin macros that you can \n> feed to sparse with -include.\n\nI know.  That's what I'm using in the wrapper (plus -m64 and some\nwarnings).  But it should be the default.  Until then, hassle-free\nsparse support in the Makefile is only possible for the projects that\nalready know the architecture (e.g. the Linux kernel).\n\n-- \nRegards,\nPavel Roskin\n"},{"id":"9568","messageId":"433DB950.3010909@zytor.com","threadId":"1977","inReplyTo":"1128118469.7352.15.camel@dv","subject":"Re: [PATCH] Support SPARSE in Makefile, better SPARSE_FLAGS","fromName":"H. Peter Anvin","fromEmail":"hpa@zytor.com","sentAt":"2005-09-30T22:16:48Z","receivedAt":"2005-09-30T22:16:48Z","isPatch":true,"sender":{"key":"hpa@zytor.com","avatar":null},"body":"Pavel Roskin wrote:\n> \n> I know.  That's what I'm using in the wrapper (plus -m64 and some\n> warnings).  But it should be the default.  Until then, hassle-free\n> sparse support in the Makefile is only possible for the projects that\n> already know the architecture (e.g. the Linux kernel).\n> \n\nI think that's debatable.  It introduces main-compiler dependencies into \nsparse which is undesirable.\n\nA much simpler option would be to write a \"sparsegcc\" script which would \nbe invoked just like gcc, extract the appropriate macro information \nbased on options, and then invoke sparse.\n\n\t-hpa\n"},{"id":"9576","messageId":"20051001001358.n59rjyg48400c0kw@webmail.spamcop.net","threadId":"1977","inReplyTo":"433DB950.3010909@zytor.com","subject":"Re: [PATCH] Support SPARSE in Makefile, better SPARSE_FLAGS","fromName":"Pavel Roskin","fromEmail":"proski@gnu.org","sentAt":"2005-10-01T04:13:58Z","receivedAt":"2005-10-01T04:13:58Z","isPatch":true,"sender":{"key":"proski@gnu.org","avatar":null},"body":"Quoting \"H. Peter Anvin\" <hpa@zytor.com>:\n\n> Pavel Roskin wrote:\n> >\n> > I know.  That's what I'm using in the wrapper (plus -m64 and some\n> > warnings).  But it should be the default.  Until then, hassle-free\n> > sparse support in the Makefile is only possible for the projects that\n> > already know the architecture (e.g. the Linux kernel).\n> >\n>\n> I think that's debatable.  It introduces main-compiler dependencies into\n> sparse which is undesirable.\n\nI see sparse is already moving in this direction.  Right now, it's somewhere in\nthe middle, which is quite inconvenient.  It hardcodes gcc version numbers but\nnot the architecture.\n\n> A much simpler option would be to write a \"sparsegcc\" script which would\n> be invoked just like gcc, extract the appropriate macro information\n> based on options, and then invoke sparse.\n\nI guess that's what cgcc is trying to be.  Since it also runs the compiler, no\nspecial support for cgcc should be needed in Makefile other than using $(CC).\n\n--\nRegards,\nPavel Roskin\n"}]}