[PATCH] configure: fix parameter expansion of --cross-cc-cflags options

matheus.ferst@eldorado.org.br posted 1 patch 2 years, 3 months ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20220120173142.2755077-1-matheus.ferst@eldorado.org.br
configure | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] configure: fix parameter expansion of --cross-cc-cflags options
Posted by matheus.ferst@eldorado.org.br 2 years, 3 months ago
From: Matheus Ferst <matheus.ferst@eldorado.org.br>

Without this fix, any use of --cross-cc-cflags-* causes a message like:
$ ../configure --cross-cc-ppc64le=clang --cross-cc-cflags-ppc64le="-target powerpc64le-unknown-linux-gnu -sysroot ..."
../configure: 1: eval: cross_cc_cflags_--cross-cc-cflags-ppc64le=-target: not found
../configure: 3816: export: cross_cc_cflags_--cross-cc-cflags-ppc64le: bad variable name

Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index e1a31fb332..4735c1bffc 100755
--- a/configure
+++ b/configure
@@ -402,7 +402,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}"
   ;;
-- 
2.25.1


Re: [PATCH] configure: fix parameter expansion of --cross-cc-cflags options
Posted by Philippe Mathieu-Daudé via 2 years, 3 months ago
On 20/1/22 18:31, matheus.ferst@eldorado.org.br wrote:
> From: Matheus Ferst <matheus.ferst@eldorado.org.br>
> 
> Without this fix, any use of --cross-cc-cflags-* causes a message like:
> $ ../configure --cross-cc-ppc64le=clang --cross-cc-cflags-ppc64le="-target powerpc64le-unknown-linux-gnu -sysroot ..."
> ../configure: 1: eval: cross_cc_cflags_--cross-cc-cflags-ppc64le=-target: not found
> ../configure: 3816: export: cross_cc_cflags_--cross-cc-cflags-ppc64le: bad variable name
> 
> Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
> ---
>   configure | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/configure b/configure
> index e1a31fb332..4735c1bffc 100755
> --- a/configure
> +++ b/configure
> @@ -402,7 +402,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}"
>     ;;

Commit d422b2bc23 subject is "configure: allow user to specify
--cross-cc-cflags-foo=" but then documented "--cross-cc-flags":

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

$  git grep cross.*flag
configure:409:  --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-flags-}; 
cc_arch=${cc_arch%%=*}
configure:410:                      eval 
"cross_cc_cflags_${cc_arch}=\$optarg"
configure:411:                      cross_cc_vars="$cross_cc_vars 
cross_cc_cflags_${cc_arch}"
configure:1338:  --cross-cc-flags-ARCH=   use compiler flags when 
building ARCH guest tests
docs/devel/testing.rst:1327:There is also a ``--cross-cc-flags-ARCH`` 
flag in case additional
tests/tcg/configure.sh:48:: ${cross_cc_cflags_aarch64_be="-mbig-endian"}
tests/tcg/configure.sh:51:: ${cross_cc_cflags_armeb="-mbig-endian"}
tests/tcg/configure.sh:53:: ${cross_cc_cflags_hexagon="-mv67 -O2 -static"}
tests/tcg/configure.sh:56:: ${cross_cc_cflags_i386="-m32"}
tests/tcg/configure.sh:65:: ${cross_cc_cflags_ppc="-m32"}
tests/tcg/configure.sh:67:: ${cross_cc_cflags_ppc64="-m64 -mbig"}
tests/tcg/configure.sh:69:: ${cross_cc_cflags_ppc64le="-m64 -mlittle"}
tests/tcg/configure.sh:73:: ${cross_cc_cflags_sparc="-m32 -mv8plus 
-mcpu=ultrasparc"}
tests/tcg/configure.sh:75:: ${cross_cc_cflags_sparc64="-m64 
-mcpu=ultrasparc"}
tests/tcg/configure.sh:77:: ${cross_cc_cflags_x86_64="-m64"}
tests/tcg/configure.sh:244:  eval 
"target_compiler_cflags=\${cross_cc_cflags_$arch}"

OK, 'cflags' wins over 'flags'.

I agree this requires cleanup, but all occurrences need to be updated.

Please Cc Alex in v2, and add:
Fixes: d422b2bc23 ("configure: allow user to specify 
--cross-cc-cflags-foo=")

Thanks,

Phil.

Re: [PATCH] configure: fix parameter expansion of --cross-cc-cflags options
Posted by Paolo Bonzini 2 years, 3 months ago
On 1/20/22 18:31, matheus.ferst@eldorado.org.br wrote:
> From: Matheus Ferst <matheus.ferst@eldorado.org.br>
> 
> Without this fix, any use of --cross-cc-cflags-* causes a message like:
> $ ../configure --cross-cc-ppc64le=clang --cross-cc-cflags-ppc64le="-target powerpc64le-unknown-linux-gnu -sysroot ..."
> ../configure: 1: eval: cross_cc_cflags_--cross-cc-cflags-ppc64le=-target: not found
> ../configure: 3816: export: cross_cc_cflags_--cross-cc-cflags-ppc64le: bad variable name
> 
> Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
> ---
>   configure | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/configure b/configure
> index e1a31fb332..4735c1bffc 100755
> --- a/configure
> +++ b/configure
> @@ -402,7 +402,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}"
>     ;;

Queued, thanks.

Paolo