diff mbox series

[4/4] configure: ignore preexisting QEMU_*FLAGS envvars

Message ID 20211108084323.541961-5-pbonzini@redhat.com (mailing list archive)
State New, archived
Headers show
Series configure: propagate --extra-cflags and --extra-ldflags to meson compile tests | expand

Commit Message

Paolo Bonzini Nov. 8, 2021, 8:43 a.m. UTC
User flags should be passed via CFLAGS/CXXFLAGS/LDFLAGS,
or --extra-cflags/extra-cxxflags/--extra-ldflags on the
command line.

QEMU_CFLAGS, QEMU_CXXFLAGS and QEMU_LDFLAGS are reserved
for flags detected by configure, so do not add to them
and clear them at the beginning of the script.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 configure | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Thomas Huth Nov. 8, 2021, 9:17 a.m. UTC | #1
On 08/11/2021 09.43, Paolo Bonzini wrote:
> User flags should be passed via CFLAGS/CXXFLAGS/LDFLAGS,
> or --extra-cflags/extra-cxxflags/--extra-ldflags on the
> command line.
> 
> QEMU_CFLAGS, QEMU_CXXFLAGS and QEMU_LDFLAGS are reserved
> for flags detected by configure, so do not add to them
> and clear them at the beginning of the script.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>   configure | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/configure b/configure
> index 1ea26c67e5..2048a52b20 100755
> --- a/configure
> +++ b/configure
> @@ -158,7 +158,7 @@ update_cxxflags() {
>       # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
>       # options which some versions of GCC's C++ compiler complain about
>       # because they only make sense for C programs.
> -    QEMU_CXXFLAGS="$QEMU_CXXFLAGS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS"
> +    QEMU_CXXFLAGS="-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS"
>       CONFIGURE_CXXFLAGS=$(echo "$CONFIGURE_CFLAGS" | sed s/-std=gnu11/-std=gnu++11/)
>       for arg in $QEMU_CFLAGS; do
>           case $arg in
> @@ -465,11 +465,13 @@ sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
>   # left shift of signed integers is well defined and has the expected
>   # 2s-complement style results. (Both clang and gcc agree that it
>   # provides these semantics.)
> -QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
> +QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv"
>   QEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
>   QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
>   QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
>   
> +QEMU_LDFLAGS=
> +
>   # Flags that are needed during configure but later taken care of by Meson
>   CONFIGURE_CFLAGS="-std=gnu11 -Wall"
>   CONFIGURE_LDFLAGS=
> 

Reviewed-by: Thomas Huth <thuth@redhat.com>
Philippe Mathieu-Daudé Nov. 8, 2021, 9:17 a.m. UTC | #2
On 11/8/21 09:43, Paolo Bonzini wrote:
> User flags should be passed via CFLAGS/CXXFLAGS/LDFLAGS,
> or --extra-cflags/extra-cxxflags/--extra-ldflags on the
> command line.
> 
> QEMU_CFLAGS, QEMU_CXXFLAGS and QEMU_LDFLAGS are reserved
> for flags detected by configure, so do not add to them
> and clear them at the beginning of the script.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  configure | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/configure b/configure
> index 1ea26c67e5..2048a52b20 100755
> --- a/configure
> +++ b/configure
> @@ -158,7 +158,7 @@ update_cxxflags() {
>      # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
>      # options which some versions of GCC's C++ compiler complain about
>      # because they only make sense for C programs.
> -    QEMU_CXXFLAGS="$QEMU_CXXFLAGS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS"
> +    QEMU_CXXFLAGS="-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS"
>      CONFIGURE_CXXFLAGS=$(echo "$CONFIGURE_CFLAGS" | sed s/-std=gnu11/-std=gnu++11/)
>      for arg in $QEMU_CFLAGS; do
>          case $arg in

update_cxxflags() should keep previous QEMU_CXXFLAGS. But since
we call it only once, we don't use it to update. IMHO we should
inline this code where it is called, then overwriting QEMU_CXXFLAGS
makes sense.
Paolo Bonzini Nov. 8, 2021, 10:45 a.m. UTC | #3
On 11/8/21 10:17, Philippe Mathieu-Daudé wrote:
>> -    QEMU_CXXFLAGS="$QEMU_CXXFLAGS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS"
>> +    QEMU_CXXFLAGS="-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS"
>>       CONFIGURE_CXXFLAGS=$(echo "$CONFIGURE_CFLAGS" | sed s/-std=gnu11/-std=gnu++11/)
>>       for arg in $QEMU_CFLAGS; do
>>           case $arg in
> update_cxxflags() should keep previous QEMU_CXXFLAGS. But since
> we call it only once, we don't use it to update. IMHO we should
> inline this code where it is called, then overwriting QEMU_CXXFLAGS
> makes sense.

With Meson 0.60 it's possible to link-test a C source with a C++ 
compiler and then all this stuff (including the link_language detection) 
can be moved to the proper place.

Paolo
diff mbox series

Patch

diff --git a/configure b/configure
index 1ea26c67e5..2048a52b20 100755
--- a/configure
+++ b/configure
@@ -158,7 +158,7 @@  update_cxxflags() {
     # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
     # options which some versions of GCC's C++ compiler complain about
     # because they only make sense for C programs.
-    QEMU_CXXFLAGS="$QEMU_CXXFLAGS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS"
+    QEMU_CXXFLAGS="-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS"
     CONFIGURE_CXXFLAGS=$(echo "$CONFIGURE_CFLAGS" | sed s/-std=gnu11/-std=gnu++11/)
     for arg in $QEMU_CFLAGS; do
         case $arg in
@@ -465,11 +465,13 @@  sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
 # left shift of signed integers is well defined and has the expected
 # 2s-complement style results. (Both clang and gcc agree that it
 # provides these semantics.)
-QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
+QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv"
 QEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
 
+QEMU_LDFLAGS=
+
 # Flags that are needed during configure but later taken care of by Meson
 CONFIGURE_CFLAGS="-std=gnu11 -Wall"
 CONFIGURE_LDFLAGS=