qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [PATCH 3/4] configure: propagate --extra-cflags and --extra-ldflags to meson compile tests
Date: Mon, 8 Nov 2021 10:11:33 +0100	[thread overview]
Message-ID: <cad11e05-9a0a-fca4-08aa-a0ad31e13496@redhat.com> (raw)
In-Reply-To: <20211108084323.541961-4-pbonzini@redhat.com>

On 08/11/2021 09.43, Paolo Bonzini wrote:
> Meson (intentionally) does not add QEMU_CFLAGS to cc.compiles/cc.links
> tests, as they are supposed to be independent of the specific sets of
> compilation flags used to build the programs.  However, the user can
> still use CFLAGS or the toolchain file's LANG_args/LANG_link_args option
> to specify -I or -L options that apply to cc.compiles/cc.links as well.
> 
> This is also the intended use of configure's --extra-cflags,
> --extra-cxxflags and --extra-ldflags options.  For example, if
> one has netmap's header in a nonstandard directory, up to commit
> 837b84b1c078bf3e909 it used to work fine to do:
> 
> .../configure --enable-netmap \
>       --extra-cflags=-I/path/to/netmap/sys
> 
> but since the test was converted to meson, this does not work anymore.
> 
> Pass these options to meson via the toolchain file instead of via
> config-host.mak, since the toolchain file's variables have the
> same purpose as configure's --extra-*flags arguments.
> 
> Reported-by: Owen LaGarde
> Reported-by: Thomas Huth <thuth@redhat.com>
> Fixes: 47b30835e4 ("configure: consistently pass CFLAGS/CXXFLAGS/LDFLAGS to meson", 2020-10-06)
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>   configure | 36 ++++++++++++++++++++----------------
>   1 file changed, 20 insertions(+), 16 deletions(-)
> 
> diff --git a/configure b/configure
> index d268f59246..1ea26c67e5 100755
> --- a/configure
> +++ b/configure
> @@ -174,14 +174,14 @@ update_cxxflags() {
>   
>   compile_object() {
>     local_cflags="$1"
> -  do_cc $CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
> +  do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
>   }
>   
>   compile_prog() {
>     local_cflags="$1"
>     local_ldflags="$2"
> -  do_cc $CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC \
> -      $LDFLAGS $CONFIGURE_LDFLAGS $QEMU_LDFLAGS $local_ldflags
> +  do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC \
> +      $LDFLAGS $EXTRA_LDFLAGS $CONFIGURE_LDFLAGS $QEMU_LDFLAGS $local_ldflags
>   }
>   
>   # symbolically link $1 to $2.  Portable version of "ln -sf".
> @@ -286,6 +286,10 @@ for opt do
>     esac
>   done
>   
> +EXTRA_CFLAGS=""
> +EXTRA_CXXFLAGS=""
> +EXTRA_LDFLAGS=""
> +
>   xen_ctrl_version="$default_feature"
>   xfs="$default_feature"
>   membarrier="$default_feature"
> @@ -394,13 +398,13 @@ for opt do
>     ;;
>     --cpu=*) cpu="$optarg"
>     ;;
> -  --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
> -                    QEMU_LDFLAGS="$QEMU_LDFLAGS $optarg"
> +  --extra-cflags=*)
> +    EXTRA_CFLAGS="$EXTRA_CFLAGS $optarg"
> +    EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg"

I'd rather drop that EXTRA_CXXFLAGS line here - I think that calls for 
trouble otherwise if a user is trying to add a C compiler option that is not 
supported in C++ mode.
If the users have some options that need to be passed to both, C and C++, 
they should simply use --extra-cxxflags in addition instead.

  Thomas

> +    ;;
> +  --extra-cxxflags=*) EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg"
>     ;;
> -  --extra-cxxflags=*) QEMU_CXXFLAGS="$QEMU_CXXFLAGS $optarg"
> -  ;;
> -  --extra-ldflags=*) QEMU_LDFLAGS="$QEMU_LDFLAGS $optarg"
> -                     EXTRA_LDFLAGS="$optarg"
> +  --extra-ldflags=*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS $optarg"
>     ;;
>     --enable-debug-info) debug_info="yes"
>     ;;



  reply	other threads:[~2021-11-08  9:15 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-08  8:43 [PATCH 0/4] configure: propagate --extra-cflags and --extra-ldflags to meson compile tests Paolo Bonzini
2021-11-08  8:43 ` [PATCH 1/4] configure: simplify calls to meson_quote Paolo Bonzini
2021-11-08  9:02   ` Thomas Huth
2021-11-08  8:43 ` [PATCH 2/4] configure: preserve CFLAGS, CXXFLAGS and LDFLAGS in config.status Paolo Bonzini
2021-11-08  9:04   ` Thomas Huth
2021-11-08  8:43 ` [PATCH 3/4] configure: propagate --extra-cflags and --extra-ldflags to meson compile tests Paolo Bonzini
2021-11-08  9:11   ` Thomas Huth [this message]
2021-11-08 11:07     ` Paolo Bonzini
2021-11-08  8:43 ` [PATCH 4/4] configure: ignore preexisting QEMU_*FLAGS envvars Paolo Bonzini
2021-11-08  9:17   ` Thomas Huth
2021-11-08  9:17   ` Philippe Mathieu-Daudé
2021-11-08 10:45     ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cad11e05-9a0a-fca4-08aa-a0ad31e13496@redhat.com \
    --to=thuth@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).