Skip to contentSkip to conversation

configure: do CC check before verifying host CPU

PATCH Superseded Daniel Henrique Barboza 3 participants 7 messages Nov 1, 2017 – Nov 2, 2017

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 configure: do CC check before verifying host CPU

When executing 'configure' in a fresh QEMU clone, in a fresh OS install running in a ppc64le host, this is the error shown:

-----

../configure --enable-trace-backend=simple --enable-debug

    --target-list=ppc64-softmmu

ERROR: Unsupported CPU = ppc64le, try --enable-tcg-interpreter

-----

This isn't true, ppc64le host CPU is supported. This happens because, in a fresh install, we don't have a C compiler to autodetect the $cpu variable to "ppc64".

Since we need a C compiler to properly get the value of $cpu in this and other cases, this patch changes the location of the C compiler check right after setting the preferred CC.

---
 configure | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)
configure +17 -17
index 285d123dbf..a641bf18b6 100755
@@ -467,6 +467,23 @@ else
   cc="${CC-${cross_prefix}gcc}"
 fi
 
+write_c_skeleton() {
+    cat > $TMPC <<EOF
+int main(void) { return 0; }
+EOF
+}
+
+# check that the C compiler works.
+write_c_skeleton;
+if compile_object ; then
+  : C compiler works ok
+else
+    error_exit "\"$cc\" either does not exist or does not work"
+fi
+if ! compile_prog ; then
+    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
+fi
+
 if test -z "${CXX}${cross_prefix}"; then
   cxx="c++"
 else
@@ -537,12 +554,6 @@ EOF
   compile_object
 }
 
-write_c_skeleton() {
-    cat > $TMPC <<EOF
-int main(void) { return 0; }
-EOF
-}
-
 if check_define __linux__ ; then
   targetos="Linux"
 elif check_define _WIN32 ; then
@@ -1593,17 +1604,6 @@ if test -z "$werror" ; then
     fi
 fi
 
-# check that the C compiler works.
-write_c_skeleton;
-if compile_object ; then
-  : C compiler works ok
-else
-    error_exit "\"$cc\" either does not exist or does not work"
-fi
-if ! compile_prog ; then
-    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
-fi
-
 if test "$bogus_os" = "yes"; then
     # Now that we know that we're not printing the help and that
     # the compiler works (so the results of the check_defines we used
Signature · 1 line
2.13.6
Reviewed-by on v4 1/1
#1 lore raw

Maybe "configure: check $CC available before verifying host CPU" ?

Quoted 17 lines · Daniel Henrique Barboza

When executing 'configure' in a fresh QEMU clone, in a fresh OS install running in a ppc64le host, this is the error shown:

-----

../configure --enable-trace-backend=simple --enable-debug

    --target-list=ppc64-softmmu

ERROR: Unsupported CPU = ppc64le, try --enable-tcg-interpreter

-----

This isn't true, ppc64le host CPU is supported. This happens because, in a fresh install, we don't have a C compiler to autodetect the $cpu variable to "ppc64".

Quoted 5 lines

Since we need a C compiler to properly get the value of $cpu in this and other cases, this patch changes the location of the C compiler check right after setting the preferred CC.

Quoted 64 lines
---
 configure | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)
configure +17 -17
index 285d123dbf..a641bf18b6 100755
@@ -467,6 +467,23 @@ else
   cc="${CC-${cross_prefix}gcc}"
 fi
 
+write_c_skeleton() {
+    cat > $TMPC <<EOF
+int main(void) { return 0; }
+EOF
+}
+
+# check that the C compiler works.
+write_c_skeleton;
+if compile_object ; then
+  : C compiler works ok
+else
+    error_exit "\"$cc\" either does not exist or does not work"
+fi
+if ! compile_prog ; then
+    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
+fi
+
 if test -z "${CXX}${cross_prefix}"; then
   cxx="c++"
 else
@@ -537,12 +554,6 @@ EOF
   compile_object
 }
 
-write_c_skeleton() {
-    cat > $TMPC <<EOF
-int main(void) { return 0; }
-EOF
-}
-
 if check_define __linux__ ; then
   targetos="Linux"
 elif check_define _WIN32 ; then
@@ -1593,17 +1604,6 @@ if test -z "$werror" ; then
     fi
 fi
 
-# check that the C compiler works.
-write_c_skeleton;
-if compile_object ; then
-  : C compiler works ok
-else
-    error_exit "\"$cc\" either does not exist or does not work"
-fi
-if ! compile_prog ; then
-    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
-fi
-
 if test "$bogus_os" = "yes"; then
     # Now that we know that we're not printing the help and that
     # the compiler works (so the results of the check_defines we used
#2 lore raw
Quoted 1 line · Philippe Mathieu-Daudé

Maybe "configure: check $CC available before verifying host CPU" ?

If the maintainer is willing to amend the patch before pushing, works for me!

Daniel

Quoted 90 lines · Daniel Henrique Barboza
Quoted 17 lines

When executing 'configure' in a fresh QEMU clone, in a fresh OS install running in a ppc64le host, this is the error shown:

-----

../configure --enable-trace-backend=simple --enable-debug

     --target-list=ppc64-softmmu

ERROR: Unsupported CPU = ppc64le, try --enable-tcg-interpreter

-----

This isn't true, ppc64le host CPU is supported. This happens because, in a fresh install, we don't have a C compiler to autodetect the $cpu variable to "ppc64".

Quoted 5 lines

Since we need a C compiler to properly get the value of $cpu in this and other cases, this patch changes the location of the C compiler check right after setting the preferred CC.

Quoted 64 lines
---
  configure | 34 +++++++++++++++++-----------------
  1 file changed, 17 insertions(+), 17 deletions(-)
configure +17 -17
index 285d123dbf..a641bf18b6 100755
@@ -467,6 +467,23 @@ else
    cc="${CC-${cross_prefix}gcc}"
  fi
 
+write_c_skeleton() {
+    cat > $TMPC <<EOF
+int main(void) { return 0; }
+EOF
+}
+
+# check that the C compiler works.
+write_c_skeleton;
+if compile_object ; then
+  : C compiler works ok
+else
+    error_exit "\"$cc\" either does not exist or does not work"
+fi
+if ! compile_prog ; then
+    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
+fi
+
  if test -z "${CXX}${cross_prefix}"; then
    cxx="c++"
  else
@@ -537,12 +554,6 @@ EOF
    compile_object
  }
 
-write_c_skeleton() {
-    cat > $TMPC <<EOF
-int main(void) { return 0; }
-EOF
-}
-
  if check_define __linux__ ; then
    targetos="Linux"
  elif check_define _WIN32 ; then
@@ -1593,17 +1604,6 @@ if test -z "$werror" ; then
      fi
  fi
 
-# check that the C compiler works.
-write_c_skeleton;
-if compile_object ; then
-  : C compiler works ok
-else
-    error_exit "\"$cc\" either does not exist or does not work"
-fi
-if ! compile_prog ; then
-    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
-fi
-
  if test "$bogus_os" = "yes"; then
      # Now that we know that we're not printing the help and that
      # the compiler works (so the results of the check_defines we used
#3 lore raw
In reply to Daniel Henrique Barboza
Quoted 41 lines · Daniel Henrique Barboza

When executing 'configure' in a fresh QEMU clone, in a fresh OS install running in a ppc64le host, this is the error shown:

-----

../configure --enable-trace-backend=simple --enable-debug

    --target-list=ppc64-softmmu

ERROR: Unsupported CPU = ppc64le, try --enable-tcg-interpreter

-----

This isn't true, ppc64le host CPU is supported. This happens because, in a fresh install, we don't have a C compiler to autodetect the $cpu variable to "ppc64".

Since we need a C compiler to properly get the value of $cpu in this and other cases, this patch changes the location of the C compiler check right after setting the preferred CC.

---
 configure | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)
configure +7 -0
index 285d123dbf..a641bf18b6 100755
@@ -467,6 +467,23 @@ else
   cc="${CC-${cross_prefix}gcc}"
 fi
 
+write_c_skeleton() {
+    cat > $TMPC <<EOF
+int main(void) { return 0; }
+EOF
+}
+
+# check that the C compiler works.

configure else · line 486

Quoted 10 lines
configure +10 -0
+write_c_skeleton;
+if compile_object ; then
+  : C compiler works ok
+else
+    error_exit "\"$cc\" either does not exist or does not work"
+fi
+if ! compile_prog ; then
+    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
+fi
+

I think that currently we try to make "--help" work even if you don't have a working C compiler. Does this break that?

thanks
-- PMM

#4 lore raw
Quoted 48 lines · Peter Maydell
Quoted 46 lines · Daniel Henrique Barboza

When executing 'configure' in a fresh QEMU clone, in a fresh OS install running in a ppc64le host, this is the error shown:

-----

../configure --enable-trace-backend=simple --enable-debug

     --target-list=ppc64-softmmu

ERROR: Unsupported CPU = ppc64le, try --enable-tcg-interpreter

-----

This isn't true, ppc64le host CPU is supported. This happens because, in a fresh install, we don't have a C compiler to autodetect the $cpu variable to "ppc64".

Since we need a C compiler to properly get the value of $cpu in this and other cases, this patch changes the location of the C compiler check right after setting the preferred CC.

---
  configure | 34 +++++++++++++++++-----------------
  1 file changed, 17 insertions(+), 17 deletions(-)
configure +12 -0
index 285d123dbf..a641bf18b6 100755
@@ -467,6 +467,23 @@ else
    cc="${CC-${cross_prefix}gcc}"
  fi
 
+write_c_skeleton() {
+    cat > $TMPC <<EOF
+int main(void) { return 0; }
+EOF
+}
+
+# check that the C compiler works.
+write_c_skeleton;
+if compile_object ; then
+  : C compiler works ok
+else
+    error_exit "\"$cc\" either does not exist or does not work"
Quoted 8 lines

configure else · line 486

Quoted 5 lines
configure +5 -0
+fi
+if ! compile_prog ; then
+    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
+fi
+

I think that currently we try to make "--help" work even if you don't have a working C compiler. Does this break that?

Just checked, configure --help isn't broken with this change:

$ ../configure --help

Usage: configure [options]
Options: [defaults in brackets after descriptions]

Standard options:
  --help                   print this message
(...)

Thanks,

Daniel

Quoted 4 lines

thanks
-- PMM

#5 lore raw
Quoted 6 lines · Daniel Henrique Barboza
Quoted 3 lines · Peter Maydell

I think that currently we try to make "--help" work even if you don't have a working C compiler. Does this break that?

Just checked, configure --help isn't broken with this change:

Did you test with gcc uninstalled again? It's hard to see how it could work -- if the compile test fails we'll call error_exit, which (as the name suggests) exits. Your patch moves the compiler check from after we handle --help to before it...

thanks
-- PMM

#6 lore raw
Quoted 11 lines
Quoted 5 lines
Quoted 3 lines

I think that currently we try to make "--help" work even if you don't have a working C compiler. Does this break that?

Just checked, configure --help isn't broken with this change:

Did you test with gcc uninstalled again? It's hard to see how it could work -- if the compile test fails we'll call error_exit, which (as the name suggests) exits. Your patch moves the compiler check from after we handle --help to before it...

$ CC=asdf ./configure --help

ERROR: "asdf" either does not exist or does not work

Oops.