diff mbox

[5/5] sparse: Add end-to-end compiler shell script

Message ID 1314021451-24808-5-git-send-email-penberg@kernel.org (mailing list archive)
State Rejected, archived
Headers show

Commit Message

Pekka Enberg Aug. 22, 2011, 1:57 p.m. UTC
This patch adds a 'kcc' shell script that combines the sparse's i386 backend
with GCC and GNU assembler to make it easier for people to find bugs in sparse.
You can, for example, attempt to build sparse with itself and see it crash and
burn:

  make && find . -name "*.o" | xargs rm
  make CC=./kcc
       CC       test-lexing.o
  FIXME! no value for symbol preprocess_only.  creating pseudo 1 (stack offset 4)
  {standard input}: Assembler messages:
  {standard input}:79: Error: operand type mismatch for `mov'
  make: *** [test-lexing.o] Error 1

Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
---
 kcc |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)
 create mode 100755 kcc

Comments

Jeff Garzik Aug. 22, 2011, 2:51 p.m. UTC | #1
On 08/22/2011 09:57 AM, Pekka Enberg wrote:
> This patch adds a 'kcc' shell script that combines the sparse's i386 backend
> with GCC and GNU assembler to make it easier for people to find bugs in sparse.
> You can, for example, attempt to build sparse with itself and see it crash and
> burn:
>
>    make&&  find . -name "*.o" | xargs rm
>    make CC=./kcc
>         CC       test-lexing.o
>    FIXME! no value for symbol preprocess_only.  creating pseudo 1 (stack offset 4)
>    {standard input}: Assembler messages:
>    {standard input}:79: Error: operand type mismatch for `mov'
>    make: *** [test-lexing.o] Error 1
>
> Cc: Christopher Li<sparse@chrisli.org>
> Cc: Jeff Garzik<jgarzik@redhat.com>
> Cc: Linus Torvalds<torvalds@linux-foundation.org>
> Signed-off-by: Pekka Enberg<penberg@kernel.org>

For the record, the i386 backend is quite incomplete and awful.

Ideally, an sparse compiler would work from linearized output, not from 
walking the tree as compile-i386 does.

	Jeff




--
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
Pekka Enberg Aug. 25, 2011, 10:28 a.m. UTC | #2
On 8/22/11 5:51 PM, Jeff Garzik wrote:
> On 08/22/2011 09:57 AM, Pekka Enberg wrote:
>> This patch adds a 'kcc' shell script that combines the sparse's i386 
>> backend
>> with GCC and GNU assembler to make it easier for people to find bugs 
>> in sparse.
>> You can, for example, attempt to build sparse with itself and see it 
>> crash and
>> burn:
>>
>>    make&&  find . -name "*.o" | xargs rm
>>    make CC=./kcc
>>         CC       test-lexing.o
>>    FIXME! no value for symbol preprocess_only.  creating pseudo 1 
>> (stack offset 4)
>>    {standard input}: Assembler messages:
>>    {standard input}:79: Error: operand type mismatch for `mov'
>>    make: *** [test-lexing.o] Error 1
>>
>> Cc: Christopher Li<sparse@chrisli.org>
>> Cc: Jeff Garzik<jgarzik@redhat.com>
>> Cc: Linus Torvalds<torvalds@linux-foundation.org>
>> Signed-off-by: Pekka Enberg<penberg@kernel.org>
>
> For the record, the i386 backend is quite incomplete and awful.
>
> Ideally, an sparse compiler would work from linearized output, not 
> from walking the tree as compile-i386 does.

Christopher, please drop this patch. I'm not planning to continue
hacking on compile-i386.c.

                                     Pekka
--
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
diff mbox

Patch

diff --git a/kcc b/kcc
new file mode 100755
index 0000000..7f275a9
--- /dev/null
+++ b/kcc
@@ -0,0 +1,31 @@ 
+#!/bin/sh
+#
+# GCC compatible C compiler based on Sparse
+
+SPARSEOPTS=""
+ASOPTS=""
+DIRNAME=`dirname $0`
+
+use_gcc=1
+
+while [ $# -gt 0 ]; do
+	case $1 in
+	'-o')
+		ASOPTS=$ASOPTS"-o "$2" "
+		shift
+		;;
+	'-c')
+		use_gcc=0
+		;;
+	*)
+		SPARSEOPTS="$SPARSEOPTS $1 " ;;
+	esac
+	shift
+done
+
+if [ $use_gcc -eq 1 ]; then
+	gcc $ASOPTS $SPARSEOPTS
+
+else
+	$DIRNAME/compile $SPARSEOPTS | as $ASOPTS
+fi