@@ -107,15 +107,12 @@ 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/)
for arg in $QEMU_CFLAGS; do
case $arg in
-Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
-Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
;;
- -std=gnu99)
- QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }"-std=gnu++98"
- ;;
*)
QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
;;
@@ -125,13 +122,13 @@ update_cxxflags() {
compile_object() {
local_cflags="$1"
- do_cc $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
+ do_cc $CFLAGS $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
}
compile_prog() {
local_cflags="$1"
local_ldflags="$2"
- do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $QEMU_LDFLAGS $local_ldflags
+ do_cc $CFLAGS $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $QEMU_LDFLAGS $local_ldflags
}
# symbolically link $1 to $2. Portable version of "ln -sf".
@@ -597,15 +594,14 @@ ARFLAGS="${ARFLAGS-rv}"
# 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 -std=gnu99 $QEMU_CFLAGS"
-QEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
+QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
+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_INCLUDES="-iquote . -iquote ${source_path} -iquote ${source_path}/accel/tcg -iquote ${source_path}/include"
QEMU_INCLUDES="$QEMU_INCLUDES -iquote ${source_path}/disas/libvixl"
-if test "$debug_info" = "yes"; then
- CFLAGS="-g $CFLAGS"
-fi
+CFLAGS="-std=gnu99 -Wall"
+
# running configure in the source tree?
# we know that's the case if configure is there.
@@ -886,7 +882,6 @@ SunOS)
QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
# needed for TIOCWIN* defines in termios.h
QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
- QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
solarisnetlibs="-lsocket -lnsl -lresolv"
LIBS="$solarisnetlibs $LIBS"
libs_qga="$solarisnetlibs $libs_qga"
@@ -2109,7 +2104,7 @@ EOF
for flag in $gcc_flags; do
# We need to check both a compile and a link, since some compiler
# setups fail only on a .c->.o compile and some only at link time
- if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
+ if compile_object "-Werror $flag" &&
compile_prog "-Werror $flag" ""; then
QEMU_CFLAGS="$QEMU_CFLAGS $flag"
QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
@@ -2184,7 +2179,7 @@ fi
if test "$static" = "yes"; then
if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then
- QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
+ CFLAGS="-fPIE -DPIE $CFLAGS"
QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS"
pie="yes"
elif test "$pie" = "yes"; then
@@ -2194,11 +2189,11 @@ if test "$static" = "yes"; then
pie="no"
fi
elif test "$pie" = "no"; then
- QEMU_CFLAGS="$CFLAGS_NOPIE $QEMU_CFLAGS"
- QEMU_LDFLAGS="$LDFLAGS_NOPIE $QEMU_LDFLAGS"
+ CFLAGS="$CFLAGS_NOPIE $CFLAGS"
+ LDFLAGS="$LDFLAGS_NOPIE $LDFLAGS"
elif compile_prog "-Werror -fPIE -DPIE" "-pie"; then
- QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
- QEMU_LDFLAGS="-pie $QEMU_LDFLAGS"
+ CFLAGS="-fPIE -DPIE $CFLAGS"
+ LDFLAGS="-pie $LDFLAGS"
pie="yes"
elif test "$pie" = "yes"; then
error_exit "PIE not available due to missing toolchain support"
@@ -3981,7 +3976,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"
+ QEMU_CFLAGS="-Wno-unknown-attributes $CFLAGS"
fi
fi
@@ -6506,10 +6501,16 @@ if test "$gcov" = "yes" ; then
QEMU_CFLAGS="-fprofile-arcs -ftest-coverage -g $QEMU_CFLAGS"
QEMU_LDFLAGS="-fprofile-arcs -ftest-coverage $QEMU_LDFLAGS"
elif test "$fortify_source" = "yes" ; then
- CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
-elif test "$debug" = "no"; then
+ QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
+ debug=no
+fi
+if test "$debug" = "no"; then
CFLAGS="-O2 $CFLAGS"
fi
+if test "$debug_info" = "yes"; then
+ CFLAGS="-g $CFLAGS"
+ LDFLAGS="-g $LDFLAGS"
+fi
if test "$have_asan" = "yes"; then
QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS"
@@ -7874,7 +7875,7 @@ if test "$fuzzing" = "yes" ; then
if test "$have_fuzzer" = "yes"; then
FUZZ_LDFLAGS=" -fsanitize=fuzzer"
FUZZ_CFLAGS=" -fsanitize=fuzzer"
- CFLAGS="$CFLAGS -fsanitize=fuzzer-no-link"
+ QEMU_CFLAGS="$QEMU_CFLAGS -fsanitize=fuzzer-no-link"
else
error_exit "Your compiler doesn't support -fsanitize=fuzzer"
exit 1
@@ -7961,6 +7962,7 @@ echo "NM=$nm" >> $config_host_mak
echo "PKG_CONFIG=$pkg_config_exe" >> $config_host_mak
echo "WINDRES=$windres" >> $config_host_mak
echo "CFLAGS=$CFLAGS" >> $config_host_mak
+echo "CXXFLAGS=$CXXFLAGS" >> $config_host_mak
echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
echo "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
@@ -88,12 +88,12 @@ LINK = $(call quiet-command, $(LINKPROG) $(CFLAGS) $(QEMU_LDFLAGS) -o $@ \
%.o: %.cc
$(call quiet-command,$(CXX) $(QEMU_LOCAL_INCLUDES) $(QEMU_INCLUDES) \
- $(QEMU_CXXFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) $($@-cflags) \
+ $(QEMU_CXXFLAGS) $(QEMU_DGFLAGS) $(CXXFLAGS) $($@-cflags) \
-c -o $@ $<,"CXX","$(TARGET_DIR)$@")
%.o: %.cpp
$(call quiet-command,$(CXX) $(QEMU_LOCAL_INCLUDES) $(QEMU_INCLUDES) \
- $(QEMU_CXXFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) $($@-cflags) \
+ $(QEMU_CXXFLAGS) $(QEMU_DGFLAGS) $(CXXFLAGS) $($@-cflags) \
-c -o $@ $<,"CXX","$(TARGET_DIR)$@")
%.o: %.m
Split between CFLAGS/QEMU_CFLAGS and CXXFLAGS/QEMU_CXXFLAGS so that we will use CFLAGS and CXXFLAGS for flags that we do not want to pass to add_project_arguments. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> --- configure | 46 ++++++++++++++++++++++++---------------------- rules.mak | 4 ++-- 2 files changed, 26 insertions(+), 24 deletions(-)