Skip to contentSkip to conversation

-cc checking wrong

Qemu-devel Pavel Janík 3 participants 10 messages May 1, 2006 – May 8, 2006

lore
Share & tools
lore
#0 lore raw

pavel@paveljanik:/tmp/QEMU/qemu-cvs> ./configure --cc="ccache gcc" Compiler ccache gcc could not be found pavel@paveljanik:/tmp/QEMU/qemu-cvs>

Would be nice to accept environment setting of CC as well.

Signature · 4 lines
Pavel Janík

panic("Aarggh: attempting to free lock with active wait queue - shoot Andy");
                  -- 2.0.38 fs/locks.c
#1 lore raw

From: [email protected] (Pavel Janík)
Date: Mon, 01 May 2006 09:41:14 +0200

Quoted 3 lines

pavel@paveljanik:/tmp/QEMU/qemu-cvs> ./configure --cc="ccache gcc" Compiler ccache gcc could not be found pavel@paveljanik:/tmp/QEMU/qemu-cvs>

This comes from

revision 1.93
date: 2006-04-23 16:35:23 +0200; author: bellard; state: Exp; lines: +5 -0 check if specified compiler exists

configure contains:

if [ ! -x "which $cc" ] ; then
echo "Compiler $cc could not be found"
exit
fi

You should check if the command compiles, not if it exists and is executable.

Signature · 4 lines
Pavel Janík

Two wrongs do not make a right.
                  -- Linus Torvalds in linux-kernel
#2 lore raw
Quoted 8 lines · Pavel Jan?k

configure contains:

if [ ! -x "which $cc" ] ; then
echo "Compiler $cc could not be found"
exit
fi

You should check if the command compiles, not if it exists and is executable.

Patch attached. Simply tries to compile a dummy program.

Quoted 2 lines

Two wrongs do not make a right.
-- Linus Torvalds in linux-kernel

I find that quote very ironic ... ;)

Signature · 2 lines
Infinite complexity begets infinite beauty.
Infinite precision begets infinite perfection.
configure renamed from configure.orig +8 -2
@@ -293,8 +293,14 @@
 ar="${cross_prefix}${ar}"
 strip="${cross_prefix}${strip}"
 
-if [ ! -x "`which $cc`" ] ; then
-    echo "Compiler $cc could not be found"
+# check that gcc is able to compile
+cat > $TMPC <<EOF
+int main(void) {
+}
+EOF
+
+if $cc -o $TMPE $TMPC 2>/dev/null ; then
+    echo "Compiler $cc either does not exist or does not work"
     exit
 fi
 
#3 lore raw
Quoted 11 lines · Jim C. Brown
Quoted 8 lines · Pavel Jan?k

configure contains:

if [ ! -x "which $cc" ] ; then
echo "Compiler $cc could not be found"
exit
fi

You should check if the command compiles, not if it exists and is executable.

Patch attached. Simply tries to compile a dummy program.

Slightly different patch.

The right thing to do might be to check if the first arg is ccache, and if so check for both ccache and the 2nd compiler. Especially if ccache is the only compiler that requires arguments be passed to it in --cc or CC=

This patch assumes the above.

Quoted 9 lines
Quoted 3 lines

Two wrongs do not make a right.
-- Linus Torvalds in linux-kernel

I find that quote very ironic ... ;)

Signature · 2 lines
Infinite complexity begets infinite beauty.
Infinite precision begets infinite perfection.
Signature · 2 lines
Infinite complexity begets infinite beauty.
Infinite precision begets infinite perfection.
configure renamed from configure.orig +21 -1
@@ -293,9 +293,29 @@
 ar="${cross_prefix}${ar}"
 strip="${cross_prefix}${strip}"
 
-if [ ! -x "`which $cc`" ] ; then
+# cc_head=`echo $cc | xargs printf 2> /dev/null`
+cc_head=`echo $cc | awk '{ printf $1 }'`
+cc_tail=`echo $cc | awk '{ printf $2 }'`
+
+if [ "$cc_head" = "ccache" ]; then
+
+if [ ! -x "`which $cc_head`" ] ; then
+    echo "ccache could not be found"
+    exit
+fi
+
+if [ ! -x "`which $cc_tail`" ] ; then
+    echo "Compiler $cc_tail could not be found"
+    exit
+fi
+
+else
+
+if [ ! -x "`which $cc_head`" ] ; then
     echo "Compiler $cc could not be found"
     exit
+fi
+
 fi
 
 if test "$mingw32" = "yes" ; then
#4 lore raw

From: "Jim C. Brown" <[email protected]>
Date: Sun, 7 May 2006 20:34:11 -0400

Quoted 4 lines

The right thing to do might be to check if the first arg is ccache, and if so check for both ccache and the 2nd compiler. Especially if ccache is the only compiler that requires arguments be passed to it in --cc or CC=

This is also wrong - you can use "distcc ccache gcc" as your compiler...

Signature · 4 lines
Pavel Janík

Sounds like a "bug waiting to be implemented" ;)
                  -- Rik van Riel in linux-kernel
#5 lore raw
Quoted 9 lines · Pavel Jan?k

From: "Jim C. Brown" <[email protected]>
Date: Sun, 7 May 2006 20:34:11 -0400

Quoted 4 lines

The right thing to do might be to check if the first arg is ccache, and if so check for both ccache and the 2nd compiler. Especially if ccache is the only compiler that requires arguments be passed to it in --cc or CC=

This is also wrong - you can use "distcc ccache gcc" as your compiler...

Hmm.

Maybe make the check into a function, and if the first arg is distcc or ccache, check that the first arg is -x and then call the function recursively with the remaining args. Else just check if the compiler exists.

Quoted 12 lines
Signature · 10 lines
Pavel Jan?k

Sounds like a "bug waiting to be implemented" ;)
                  -- Rik van Riel in linux-kernel


_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel
Signature · 2 lines
Infinite complexity begets infinite beauty.
Infinite precision begets infinite perfection.
#6 lore raw

From: "Jim C. Brown" <[email protected]>
Date: Mon, 8 May 2006 11:12:54 -0400

Quoted 1 line

Maybe make the check into a function, and if the first arg is distcc or ccache,

Do you know icecast or compilercache? Sorry, this is incorrect way by definition.

Quoted 1 line

check that the first arg is -x

This is also incorrect.

pavel@paveljanik:/tmp> alias compiler=gcc pavel@paveljanik:/tmp> compiler -v
Reading specs from /usr/lib/gcc-lib/i586-suse-linux/3.3.5/specs [...]
pavel@paveljanik:/tmp> [ -x compiler ] || echo ERROR ERROR
pavel@paveljanik:/tmp>

The only correct way is to *execute* simple test.

Signature · 5 lines
Pavel Janík

"With some developers it is not needed to run the code through
obfuscator... I have inherited code which only the compiler could
understand."      -- someone in LKML
#7 lore raw
Quoted 13 lines · Pavel Jan?k
Quoted 2 lines

check that the first arg is -x

This is also incorrect.

pavel@paveljanik:/tmp> alias compiler=gcc pavel@paveljanik:/tmp> compiler -v
Reading specs from /usr/lib/gcc-lib/i586-suse-linux/3.3.5/specs [...]
pavel@paveljanik:/tmp> [ -x compiler ] || echo ERROR ERROR
pavel@paveljanik:/tmp>

Quoted 1 line

The only correct way is to *execute* simple test.

Incidently, this is not correct either way.

$ alias compiler=gcc
$ compiler -v
Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.5-20050130/specs
[...]
$ ./configure --cc=compiler
ERROR: "compiler" either does not exist or does not work

Thats with the fixed CVS that uses my other patch.

Aliases aren't suppose to pass through to shell scripts.

Quoted 13 lines
Signature · 11 lines
Pavel Jan?k

"With some developers it is not needed to run the code through
obfuscator... I have inherited code which only the compiler could
understand."      -- someone in LKML


_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel
Signature · 2 lines
Infinite complexity begets infinite beauty.
Infinite precision begets infinite perfection.
#8 lore raw
In reply to Jim C. Brown
Quoted 8 lines · Jim C. Brown
Quoted 7 lines · Pavel Jan?k

configure contains:

if [ ! -x "which $cc" ] ; then
echo "Compiler $cc could not be found"
exit
fi

Quoted 4 lines
Quoted 2 lines

You should check if the command compiles, not if it exists and is executable.

Patch attached. Simply tries to compile a dummy program.

You really should test your patches. The patch you attached generates an error if the compiler works.

Paul

#9 lore raw
Quoted 5 lines · Paul Brook

You really should test your patches. The patch you attached generates an error if the compiler works.

Paul

Whoops, sorry about that. I only tested the --cc="ccache gcc" case.

Here's the correct patch.

Signature · 2 lines
Infinite complexity begets infinite beauty.
Infinite precision begets infinite perfection.
configure renamed from configure.orig +8 -2
@@ -293,8 +293,14 @@
 ar="${cross_prefix}${ar}"
 strip="${cross_prefix}${strip}"
 
-if [ ! -x "`which $cc`" ] ; then
-    echo "Compiler $cc could not be found"
+# check that gcc is able to compile
+cat > $TMPC <<EOF
+int main(void) {
+}
+EOF
+
+if ! $cc -o $TMPE $TMPC 2>/dev/null ; then
+    echo "Compiler $cc either does not exist or does not work"
     exit
 fi