* configure --extra-cflags and --extra-ldflags values not propagating to meson?
@ 2021-10-22 11:20 Owen LaGarde
2021-10-25 13:10 ` Thomas Huth
0 siblings, 1 reply; 3+ messages in thread
From: Owen LaGarde @ 2021-10-22 11:20 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 2519 bytes --]
Am I using --extra-cflags and --extra-ldflags wrong in the configure call?
I'd like to source build several pre-reqs specific to supporting the qemu
source
build. I'd specifically not like to install neither the qemu or re-req
builds
at the system level. Normally I'd expect the --extra-cflags and
--extra-ldflags
configure options to do this but they do not appear to propagate to meson.
There
was an approved meson patch back in 2018 for extra-cflags / extra-ldflags
and qemu
is currently using meson >5.8(?) but it doesn't look like configure is
adding the
args anywhere in the build tree. There are a number of ways to do this,
what's
appropriate / future-proof wrt building qemu from source? And why is
configure
supporting --extra-[c,ld]args but not doing anything with the values?
---------
As an example assume I've installed lzfse from source with a homedir
prefix, no
other copies elsewhere, no ldconfig reference, no associated env vars, and
force
the qemu build to require it. Yeah, but this is just an dumb example.
$ ls -l ~/include/* ~/lib/*
/home/olagarde/include/lzfse.h
/home/olagarde/lib/liblzfse.so
$ env |grep -i flags
$ set |grep -i flags
local flags_color="$c_lblue";
s="$flags_color$s";
$ git clone https://gitlab.com/qemu-project/qemu.git
<...snipsnip...>
$ mkdir qemu/build && cd qemu/build
$ ../configure --prefix=/home/olagarde \
--extra-cflags="-I /home/olagarde/include" \
--extra-ldflags="-L /home/olagarde/lib" \
--enable-lzfse
<...snipsnip...>
../meson.build:898:2: ERROR: C header 'lzfse.h' not found
A full log can be found at {a_really_long_path}meson-log.txt
ERROR: meson setup failed
Per the meson logs the command was
cc -m64 -mcx16 {a_really_long_path}testfile.c -E -P \
-D_FILE_OFFSET_BITS=64 -P -O0 -std=gnu11
and the testfile.c was
#ifdef __has_include
#if !__has_include("lzfse.h")
#error "Header 'lzfse.h' could not be found"
#endif
#else
#include <lzfse.h>
#endif
which obviously should fail exactly as it did, but should and does succeed
if the --extra-cflags value is added to the cc call.
All four args arrays in the config-meson.cross are empty so configure
didn't pass the cli extra-args in? Also 'find' doesn't report any files
in the tree containing /home/olagarde/include or /home/olagarde/lib, so
the option values passed to configure never made it into mesa (or anything
else)?
[-- Attachment #2: Type: text/html, Size: 3065 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: configure --extra-cflags and --extra-ldflags values not propagating to meson?
2021-10-22 11:20 configure --extra-cflags and --extra-ldflags values not propagating to meson? Owen LaGarde
@ 2021-10-25 13:10 ` Thomas Huth
2021-10-25 17:26 ` Paolo Bonzini
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Huth @ 2021-10-25 13:10 UTC (permalink / raw)
To: Owen LaGarde, qemu-devel; +Cc: Paolo Bonzini
On 22/10/2021 13.20, Owen LaGarde wrote:
> Am I using --extra-cflags and --extra-ldflags wrong in the configure call?
>
> I'd like to source build several pre-reqs specific to supporting the qemu source
> build. I'd specifically not like to install neither the qemu or re-req builds
> at the system level. Normally I'd expect the --extra-cflags and --extra-ldflags
> configure options to do this but they do not appear to propagate to meson.
> There
> was an approved meson patch back in 2018 for extra-cflags / extra-ldflags
> and qemu
> is currently using meson >5.8(?) but it doesn't look like configure is
> adding the
> args anywhere in the build tree. There are a number of ways to do this, what's
> appropriate / future-proof wrt building qemu from source? And why is configure
> supporting --extra-[c,ld]args but not doing anything with the values?
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?
Thomas
PS: As a work-around, it seems to be fine to pass the flags via the CFLAGS
environment variable instead:
CFLAGS=-I/path/to/netmap/sys .../configure --enable-netmap
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: configure --extra-cflags and --extra-ldflags values not propagating to meson?
2021-10-25 13:10 ` Thomas Huth
@ 2021-10-25 17:26 ` Paolo Bonzini
0 siblings, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2021-10-25 17:26 UTC (permalink / raw)
To: Thomas Huth, Owen LaGarde, qemu-devel
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-10-25 17:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-22 11:20 configure --extra-cflags and --extra-ldflags values not propagating to meson? Owen LaGarde
2021-10-25 13:10 ` Thomas Huth
2021-10-25 17:26 ` Paolo Bonzini
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).