qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] -cc checking wrong
@ 2006-05-01  7:41 Pavel Janík
  2006-05-07 22:46 ` Pavel Janík
  0 siblings, 1 reply; 10+ messages in thread
From: Pavel Janík @ 2006-05-01  7:41 UTC (permalink / raw)
  To: qemu-devel


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.
-- 
Pavel Janík

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] -cc checking wrong
  2006-05-01  7:41 [Qemu-devel] -cc checking wrong Pavel Janík
@ 2006-05-07 22:46 ` Pavel Janík
  2006-05-08  0:18   ` Jim C. Brown
  0 siblings, 1 reply; 10+ messages in thread
From: Pavel Janík @ 2006-05-07 22:46 UTC (permalink / raw)
  To: qemu-devel

   From: Pavel@Janik.cz (Pavel Janík)
   Date: Mon, 01 May 2006 09:41:14 +0200

   > 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.
-- 
Pavel Janík

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] -cc checking wrong
  2006-05-07 22:46 ` Pavel Janík
@ 2006-05-08  0:18   ` Jim C. Brown
  2006-05-08  0:34     ` Jim C. Brown
  2006-05-08  0:53     ` Paul Brook
  0 siblings, 2 replies; 10+ messages in thread
From: Jim C. Brown @ 2006-05-08  0:18 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 546 bytes --]

On Mon, May 08, 2006 at 12:46:24AM +0200, Pavel Jan?k wrote:
> 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.

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

I find that quote very ironic ... ;)

-- 
Infinite complexity begets infinite beauty.
Infinite precision begets infinite perfection.

[-- Attachment #2: configure.patch --]
[-- Type: text/plain, Size: 450 bytes --]

--- configure.orig	Sun May  7 20:14:23 2006
+++ configure	Sun May  7 20:16:58 2006
@@ -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
 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] -cc checking wrong
  2006-05-08  0:18   ` Jim C. Brown
@ 2006-05-08  0:34     ` Jim C. Brown
  2006-05-08  7:52       ` Pavel Janík
  2006-05-08  0:53     ` Paul Brook
  1 sibling, 1 reply; 10+ messages in thread
From: Jim C. Brown @ 2006-05-08  0:34 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1023 bytes --]

On Sun, May 07, 2006 at 08:18:55PM -0400, Jim C. Brown wrote:
> On Mon, May 08, 2006 at 12:46:24AM +0200, Pavel Jan?k wrote:
> > 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.

> 
> > Two wrongs do not make a right.
> >                   -- Linus Torvalds in linux-kernel
> 
> I find that quote very ironic ... ;)
> 
> -- 
> Infinite complexity begets infinite beauty.
> Infinite precision begets infinite perfection.

-- 
Infinite complexity begets infinite beauty.
Infinite precision begets infinite perfection.

[-- Attachment #2: configure.patch --]
[-- Type: text/plain, Size: 719 bytes --]

--- configure.orig	Sun May  7 20:14:23 2006
+++ configure	Sun May  7 20:33:49 2006
@@ -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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] -cc checking wrong
  2006-05-08  0:18   ` Jim C. Brown
  2006-05-08  0:34     ` Jim C. Brown
@ 2006-05-08  0:53     ` Paul Brook
  2006-05-08  1:13       ` Jim C. Brown
  1 sibling, 1 reply; 10+ messages in thread
From: Paul Brook @ 2006-05-08  0:53 UTC (permalink / raw)
  To: qemu-devel

On Monday 08 May 2006 01:18, Jim C. Brown wrote:
> On Mon, May 08, 2006 at 12:46:24AM +0200, Pavel Jan?k wrote:
> > 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.

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

Paul

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] -cc checking wrong
  2006-05-08  0:53     ` Paul Brook
@ 2006-05-08  1:13       ` Jim C. Brown
  0 siblings, 0 replies; 10+ messages in thread
From: Jim C. Brown @ 2006-05-08  1:13 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 372 bytes --]

On Mon, May 08, 2006 at 01:53:03AM +0100, Paul Brook wrote:
> 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.

-- 
Infinite complexity begets infinite beauty.
Infinite precision begets infinite perfection.

[-- Attachment #2: configure.patch --]
[-- Type: text/plain, Size: 452 bytes --]

--- configure.orig	Sun May  7 20:14:23 2006
+++ configure	Sun May  7 20:16:58 2006
@@ -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
 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] -cc checking wrong
  2006-05-08  0:34     ` Jim C. Brown
@ 2006-05-08  7:52       ` Pavel Janík
  2006-05-08 15:12         ` Jim C. Brown
  0 siblings, 1 reply; 10+ messages in thread
From: Pavel Janík @ 2006-05-08  7:52 UTC (permalink / raw)
  To: qemu-devel

   From: "Jim C. Brown" <jma5@umd.edu>
   Date: Sun, 7 May 2006 20:34:11 -0400

   > 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...
-- 
Pavel Janík

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] -cc checking wrong
  2006-05-08  7:52       ` Pavel Janík
@ 2006-05-08 15:12         ` Jim C. Brown
  2006-05-08 18:53           ` Pavel Janík
  0 siblings, 1 reply; 10+ messages in thread
From: Jim C. Brown @ 2006-05-08 15:12 UTC (permalink / raw)
  To: qemu-devel

On Mon, May 08, 2006 at 09:52:12AM +0200, Pavel Jan?k wrote:
>    From: "Jim C. Brown" <jma5@umd.edu>
>    Date: Sun, 7 May 2006 20:34:11 -0400
> 
>    > 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.

> -- 
> Pavel Jan?k
> 
> Sounds like a "bug waiting to be implemented" ;)
>                   -- Rik van Riel in linux-kernel
> 
> 
> _______________________________________________
> Qemu-devel mailing list
> Qemu-devel@nongnu.org
> http://lists.nongnu.org/mailman/listinfo/qemu-devel
> 

-- 
Infinite complexity begets infinite beauty.
Infinite precision begets infinite perfection.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] -cc checking wrong
  2006-05-08 15:12         ` Jim C. Brown
@ 2006-05-08 18:53           ` Pavel Janík
  2006-05-08 19:08             ` Jim C. Brown
  0 siblings, 1 reply; 10+ messages in thread
From: Pavel Janík @ 2006-05-08 18:53 UTC (permalink / raw)
  To: qemu-devel

   From: "Jim C. Brown" <jma5@umd.edu>
   Date: Mon, 8 May 2006 11:12:54 -0400

   > 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.

   > 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.
-- 
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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] -cc checking wrong
  2006-05-08 18:53           ` Pavel Janík
@ 2006-05-08 19:08             ` Jim C. Brown
  0 siblings, 0 replies; 10+ messages in thread
From: Jim C. Brown @ 2006-05-08 19:08 UTC (permalink / raw)
  To: qemu-devel

On Mon, May 08, 2006 at 08:53:29PM +0200, Pavel Jan?k wrote:
> 
>    > 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.

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.

> -- 
> 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
> Qemu-devel@nongnu.org
> http://lists.nongnu.org/mailman/listinfo/qemu-devel
> 

-- 
Infinite complexity begets infinite beauty.
Infinite precision begets infinite perfection.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2006-05-08 19:08 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-01  7:41 [Qemu-devel] -cc checking wrong Pavel Janík
2006-05-07 22:46 ` Pavel Janík
2006-05-08  0:18   ` Jim C. Brown
2006-05-08  0:34     ` Jim C. Brown
2006-05-08  7:52       ` Pavel Janík
2006-05-08 15:12         ` Jim C. Brown
2006-05-08 18:53           ` Pavel Janík
2006-05-08 19:08             ` Jim C. Brown
2006-05-08  0:53     ` Paul Brook
2006-05-08  1:13       ` Jim C. Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).