[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: configure --extra-cflags and --extra-ldflags values not propagating
From: |
Paolo Bonzini |
Subject: |
Re: configure --extra-cflags and --extra-ldflags values not propagating to meson? |
Date: |
Mon, 25 Oct 2021 19:26:28 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 |
On 25/10/21 15:10, Thomas Huth wrote:
I see a similar behavior with netmap now - I've got the corresponding
header file in a non-standard directory, and up to commit
837b84b1c078bf3e909 it used to work fine to do:
.../configure --enable-netmap \
--extra-cflags=-I/path/to/netmap/sys
but since the conversion to meson, this does not seem to work anymore.
Paolo, any ideas?
Meson (intentionally) does not add QEMU_CFLAGS to cc.compiles/cc.links
tests, as they are supposed to be independent. This however is not
true of CFLAGS.
The fix should be to add --extra-cflags/--extra-ldflags to the c_args
and c_link_args of config-meson.cross, instead of adding them to
QEMU_CFLAGS/QEMU_LDFLAGS:
diff --git a/configure b/configure
index 99051f3254..94224b9931 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".
@@ -285,6 +285,9 @@ for opt do
esac
done
+EXTRA_CFLAGS=""
+EXTRA_LDFLAGS=""
+
xen_ctrl_version="$default_feature"
xfs="$default_feature"
membarrier="$default_feature"
@@ -357,13 +360,11 @@ 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=*) 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"
;;
@@ -3508,10 +3509,10 @@ if test "$skip_meson" = no; then
test -z "$cxx" && echo "link_language = 'c'" >> $cross
echo "[built-in options]" >> $cross
- echo "c_args = [${CFLAGS:+$(meson_quote $CFLAGS)}]" >> $cross
- echo "cpp_args = [${CXXFLAGS:+$(meson_quote $CXXFLAGS)}]" >> $cross
- echo "c_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS)}]" >> $cross
- echo "cpp_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS)}]" >> $cross
+ echo "c_args = [${CFLAGS:+$(meson_quote $CFLAGS $EXTRA_CFLAGS)}]" >> $cross
+ echo "cpp_args = [${CXXFLAGS:+$(meson_quote $CXXFLAGS $EXTRA_CFLAGS)}]" >>
$cross
+ echo "c_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS $EXTRA_LDFLAGS)}]" >>
$cross
+ echo "cpp_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS $EXTRA_LDFLAGS)}]"
>> $cross
echo "[binaries]" >> $cross
echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross
test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross
except that I haven't figured out the exact (current) behavior of
--extra-cxxflags. Also, it would require a re-configure of any tree that
includes --extra-cflags or --extra-ldflags.
Thanks,
Paolo