All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] configure: Fixes for --cross-cc-FOO
@ 2021-07-23 14:45 Greg Kurz
  2021-07-23 14:46 ` [PATCH 1/2] configure: Fix trivial typo in --cross-cc-cflags-FOO Greg Kurz
  2021-07-23 14:46 ` [PATCH 2/2] configure: Fix excessive error detection when handling --cross-cc-FOO Greg Kurz
  0 siblings, 2 replies; 3+ messages in thread
From: Greg Kurz @ 2021-07-23 14:45 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Michael Tokarev, Laurent Vivier, Greg Kurz

This series fixes some issues I've hit while trying to compile
TCG checks with a cross-compiler, as an alternative to using
docker.

This isn't a regression in QEMU 6.1: the issues have been around
since they got merged in QEMU 3.0. Hence clearly QEMU 6.2 material.

Greg Kurz (2):
  configure: Fix trivial typo in --cross-cc-cflags-FOO
  configure: Fix excessive error detection when handling --cross-cc-FOO

 configure              | 29 ++++++++++++++++++-----------
 docs/devel/testing.rst |  2 +-
 2 files changed, 19 insertions(+), 12 deletions(-)

-- 
2.31.1




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

* [PATCH 1/2] configure: Fix trivial typo in --cross-cc-cflags-FOO
  2021-07-23 14:45 [PATCH 0/2] configure: Fixes for --cross-cc-FOO Greg Kurz
@ 2021-07-23 14:46 ` Greg Kurz
  2021-07-23 14:46 ` [PATCH 2/2] configure: Fix excessive error detection when handling --cross-cc-FOO Greg Kurz
  1 sibling, 0 replies; 3+ messages in thread
From: Greg Kurz @ 2021-07-23 14:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, alex.bennee, Michael Tokarev, Laurent Vivier, Greg Kurz

The 'flags' wording is used in several places instead of 'cflags'.

$ git grep cross-cc-flags
configure:  --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-flags-}; cc_arch=${cc_arch%%=*}
configure:  --cross-cc-flags-ARCH=   use compiler flags when building ARCH guest tests
docs/devel/testing.rst:There is also a ``--cross-cc-flags-ARCH`` flag in case additional

Fix this treewide.

Fixes: d422b2bc23bf ("configure: allow user to specify --cross-cc-cflags-foo=")
Fixes: f8ed349e6d14 ("docs/devel: add "check-tcg" to testing.rst")
Cc: alex.bennee@linaro.org
Signed-off-by: Greg Kurz <groug@kaod.org>
---
 configure              | 4 ++--
 docs/devel/testing.rst | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index b5965b159f2f..3a926ff8fc23 100755
--- a/configure
+++ b/configure
@@ -474,7 +474,7 @@ for opt do
   ;;
   --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
   ;;
-  --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-flags-}; cc_arch=${cc_arch%%=*}
+  --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-cflags-}; cc_arch=${cc_arch%%=*}
                       eval "cross_cc_cflags_${cc_arch}=\$optarg"
                       cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}"
   ;;
@@ -1764,7 +1764,7 @@ Advanced options (experts only):
   --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
   --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
   --cross-cc-ARCH=CC       use compiler when building ARCH guest test cases
-  --cross-cc-flags-ARCH=   use compiler flags when building ARCH guest tests
+  --cross-cc-cflags-ARCH=CFLAGS use compiler flags when building ARCH guest tests
   --make=MAKE              use specified make [$make]
   --python=PYTHON          use specified python [$python]
   --sphinx-build=SPHINX    use specified sphinx-build [$sphinx_build]
diff --git a/docs/devel/testing.rst b/docs/devel/testing.rst
index 8f572255d320..a8c8aa365cf8 100644
--- a/docs/devel/testing.rst
+++ b/docs/devel/testing.rst
@@ -1142,7 +1142,7 @@ for the architecture in question, for example::
 
   $(configure) --cross-cc-aarch64=aarch64-cc
 
-There is also a ``--cross-cc-flags-ARCH`` flag in case additional
+There is also a ``--cross-cc-cflags-ARCH`` flag in case additional
 compiler flags are needed to build for a given target.
 
 If you have the ability to run containers as the user the build system
-- 
2.31.1



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

* [PATCH 2/2] configure: Fix excessive error detection when handling --cross-cc-FOO
  2021-07-23 14:45 [PATCH 0/2] configure: Fixes for --cross-cc-FOO Greg Kurz
  2021-07-23 14:46 ` [PATCH 1/2] configure: Fix trivial typo in --cross-cc-cflags-FOO Greg Kurz
@ 2021-07-23 14:46 ` Greg Kurz
  1 sibling, 0 replies; 3+ messages in thread
From: Greg Kurz @ 2021-07-23 14:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, alex.bennee, Michael Tokarev, Laurent Vivier, Greg Kurz

Passing a --cross-cc-cflags-* option with a value that contains a '='
causes configure to exit:

$ ./configure --cross-cc-cflags-arm='-DFOO=bar'

ERROR: Passed bad --cross-cc-FOO option

This is an annoying limitation since '=' is frequently found
in CFLAGS.

This is caused by this line in the CC options parsing loop:

  --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"

The '[!a-zA-Z0-9_-]' pattern matches the first '=' in the
option and the '=' pattern matches the other one. The '*'
patterns then match the rest.

The intent seems to be that we only want characters from the
range [a-zA-Z0-9_-] in the option name. Shell pattern matching
isn't powerful enough to do that with a single expression.

First, isolate the option name, i.e. before the first '=' character,
with a regular expression. Only error out if there's at least one
unwanted character in the name.

Fixes: d75402b5ee29 ("configure: add support for --cross-cc-FOO")
Cc: alex.bennee@linaro.org
Signed-off-by: Greg Kurz <groug@kaod.org>
---
 configure | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/configure b/configure
index 3a926ff8fc23..61a415e4dc61 100755
--- a/configure
+++ b/configure
@@ -472,16 +472,23 @@ for opt do
   ;;
   --disable-debug-info) debug_info="no"
   ;;
-  --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
-  ;;
-  --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-cflags-}; cc_arch=${cc_arch%%=*}
-                      eval "cross_cc_cflags_${cc_arch}=\$optarg"
-                      cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}"
-  ;;
-  --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
-                cc_archs="$cc_archs $cc_arch"
-                eval "cross_cc_${cc_arch}=\$optarg"
-                cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}"
+  --cross-cc-*=*)
+    optname=$(expr "x$opt" : 'x\([^=]*\)=.*')
+    case "$optname" in
+    *[!a-zA-Z0-9_-]*) error_exit "Passed bad $optname option"
+    ;;
+    esac
+    case "$opt" in
+    --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-cflags-}; cc_arch=${cc_arch%%=*}
+                         eval "cross_cc_cflags_${cc_arch}=\$optarg"
+                         cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}"
+    ;;
+    --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
+                  cc_archs="$cc_archs $cc_arch"
+                  eval "cross_cc_${cc_arch}=\$optarg"
+                  cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}"
+    ;;
+    esac
   ;;
   esac
 done
-- 
2.31.1



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

end of thread, other threads:[~2021-07-23 14:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-23 14:45 [PATCH 0/2] configure: Fixes for --cross-cc-FOO Greg Kurz
2021-07-23 14:46 ` [PATCH 1/2] configure: Fix trivial typo in --cross-cc-cflags-FOO Greg Kurz
2021-07-23 14:46 ` [PATCH 2/2] configure: Fix excessive error detection when handling --cross-cc-FOO Greg Kurz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.