[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 61/92] configure: do not clobber environment CFLAGS/CXXFLAGS/LDFLA
From: |
Paolo Bonzini |
Subject: |
[PULL 61/92] configure: do not clobber environment CFLAGS/CXXFLAGS/LDFLAGS |
Date: |
Thu, 24 Sep 2020 05:22:43 -0400 |
If the CFLAGS, CXXFLAGS or LDFLAGS variables are present in the environment,
any modification made within the configure script is passed down to Meson.
This is particularly undesirable for the "-pie" option, since it overrides
"-shared" and thus messes up the linker flags for shared modules.
Using a separate variable therefore fixes the bug, while clarifying that
the scope of these CFLAGS is just the configure script.
Reported-by: Frederic Bezies
Analyzed-by: Toolybird
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
configure | 30 +++++++++++++++++-------------
1 file changed, 17 insertions(+), 13 deletions(-)
diff --git a/configure b/configure
index 9b7232f9d2..a0575f1db1 100755
--- a/configure
+++ b/configure
@@ -155,7 +155,7 @@ update_cxxflags() {
# 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"
- CXXFLAGS=$(echo "$CFLAGS" | sed s/-std=gnu99/-std=gnu++11/)
+ CONFIGURE_CXXFLAGS=$(echo "$CONFIGURE_CFLAGS" | sed
s/-std=gnu99/-std=gnu++11/)
for arg in $QEMU_CFLAGS; do
case $arg in
-Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
@@ -170,13 +170,14 @@ update_cxxflags() {
compile_object() {
local_cflags="$1"
- do_cc $CFLAGS $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
+ do_cc $CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
}
compile_prog() {
local_cflags="$1"
local_ldflags="$2"
- do_cc $CFLAGS $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS
$QEMU_LDFLAGS $local_ldflags
+ do_cc $CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC \
+ $LDFLAGS $CONFIGURE_LDFLAGS $QEMU_LDFLAGS $local_ldflags
}
# symbolically link $1 to $2. Portable version of "ln -sf".
@@ -639,7 +640,10 @@ QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls
$QEMU_CFLAGS"
QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
$QEMU_CFLAGS"
QEMU_INCLUDES="-iquote . -iquote ${source_path} -iquote
${source_path}/accel/tcg -iquote ${source_path}/include"
QEMU_INCLUDES="$QEMU_INCLUDES -iquote ${source_path}/disas/libvixl"
-CFLAGS="-std=gnu99 -Wall"
+
+# Flags that are needed during configure but later taken care of by Meson
+CONFIGURE_CFLAGS="-std=gnu99 -Wall"
+CONFIGURE_LDFLAGS=
check_define() {
@@ -967,7 +971,7 @@ if test "$mingw32" = "yes" ; then
EXESUF=".exe"
HOST_DSOSUF=".dll"
# MinGW needs -mthreads for TLS and macro _MT.
- CFLAGS="-mthreads $CFLAGS"
+ CONFIGURE_CFLAGS="-mthreads $CONFIGURE_CFLAGS"
write_c_skeleton;
prefix="/qemu"
qemu_suffix=""
@@ -2234,7 +2238,7 @@ fi
if test "$static" = "yes"; then
if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie";
then
- CFLAGS="-fPIE -DPIE $CFLAGS"
+ CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS"
pie="yes"
elif test "$pie" = "yes"; then
@@ -2244,11 +2248,11 @@ if test "$static" = "yes"; then
pie="no"
fi
elif test "$pie" = "no"; then
- CFLAGS="$CFLAGS_NOPIE $CFLAGS"
- LDFLAGS="$LDFLAGS_NOPIE $LDFLAGS"
+ CONFIGURE_CFLAGS="$CFLAGS_NOPIE $CONFIGURE_CFLAGS"
+ CONFIGURE_LDFLAGS="$LDFLAGS_NOPIE $CONFIGURE_LDFLAGS"
elif compile_prog "-Werror -fPIE -DPIE" "-pie"; then
- CFLAGS="-fPIE -DPIE $CFLAGS"
- LDFLAGS="-pie $LDFLAGS"
+ CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
+ CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS"
pie="yes"
elif test "$pie" = "yes"; then
error_exit "PIE not available due to missing toolchain support"
@@ -3812,7 +3816,7 @@ EOF
if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
if cc_has_warning_flag "-Wno-unknown-attributes"; then
glib_cflags="-Wno-unknown-attributes $glib_cflags"
- CFLAGS="-Wno-unknown-attributes $CFLAGS"
+ CONFIGURE_CFLAGS="-Wno-unknown-attributes $CONFIGURE_CFLAGS"
fi
fi
@@ -3832,7 +3836,7 @@ EOF
if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
if cc_has_warning_flag "-Wno-unused-function"; then
glib_cflags="$glib_cflags -Wno-unused-function"
- CFLAGS="$CFLAGS -Wno-unused-function"
+ CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Wno-unused-function"
fi
fi
@@ -6370,7 +6374,7 @@ EOF
update_cxxflags
- if do_cxx $CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS;
then
+ if do_cxx $CXXFLAGS $CONFIGURE_CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX
$TMPO $QEMU_LDFLAGS; then
# C++ compiler $cxx works ok with C compiler $cc
:
else
--
2.26.2
- [PULL 45/92] net: relocate paths to helpers and scripts, (continued)
- [PULL 45/92] net: relocate paths to helpers and scripts, Paolo Bonzini, 2020/09/24
- [PULL 53/92] exec: Remove MemoryRegion::global_locking field, Paolo Bonzini, 2020/09/24
- [PULL 49/92] qga: relocate path to default configuration and hook, Paolo Bonzini, 2020/09/24
- [PULL 55/92] meson: fix installation of keymaps, Paolo Bonzini, 2020/09/24
- [PULL 54/92] checkpatch: avoid error on cover letter files, Paolo Bonzini, 2020/09/24
- [PULL 58/92] tests/tcg: reinstate or replace desired parts of rules.mak, Paolo Bonzini, 2020/09/24
- [PULL 57/92] oss-fuzz: move linker arg to fix coverage-build, Paolo Bonzini, 2020/09/24
- [PULL 56/92] configure: fix performance regression due to PIC objects, Paolo Bonzini, 2020/09/24
- [PULL 63/92] smp: drop support for deprecated (invalid topologies), Paolo Bonzini, 2020/09/24
- [PULL 59/92] configure: cleanup invocation of submodule Make, Paolo Bonzini, 2020/09/24
- [PULL 61/92] configure: do not clobber environment CFLAGS/CXXFLAGS/LDFLAGS,
Paolo Bonzini <=
- [PULL 62/92] configure: consistently pass CFLAGS/CXXFLAGS/LDFLAGS to meson, Paolo Bonzini, 2020/09/24
- [PULL 60/92] configure: cleanup CFLAGS and LDFLAGS for submodules, Paolo Bonzini, 2020/09/24
- [PULL 64/92] cphp: remove deprecated cpu-add command(s), Paolo Bonzini, 2020/09/24
- [PULL 65/92] char: fix logging when chardev write fails, Paolo Bonzini, 2020/09/24
- [PULL 66/92] qom: Document all function parameters in doc comments, Paolo Bonzini, 2020/09/24
- [PULL 67/92] qom: Use kernel-doc private/public tags in structs, Paolo Bonzini, 2020/09/24
- [PULL 68/92] qom: Use ``code`` Sphinx syntax where appropriate, Paolo Bonzini, 2020/09/24
- [PULL 69/92] qom: Add kernel-doc markup to introduction doc comment, Paolo Bonzini, 2020/09/24
- [PULL 70/92] qom: Reformat section titles using Sphinx syntax, Paolo Bonzini, 2020/09/24
- [PULL 71/92] qom: Indent existing code examples, Paolo Bonzini, 2020/09/24