From a038ffd88ecb8d994f5f51961529cf82945d61ba Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Wed, 7 Oct 2020 13:58:57 -0400 Subject: gdb: put user-supplied CFLAGS at the end GDB currently doesn't build cleanly with clang (a -Wdeprecated-copy-dtor error). I configured my clang-based GDB build with CXXFLAGS="-Wno-error=deprecated-copy-dtor", so I can use it despite that problem. However, I found that it had no effect. This is because my -Wno-error=Wdeprecated-copy-dtor switch is followed by -Werror in the command line, which switches back all warnings to be errors. If we want the user-supplied C(XX)FLAGS to be able to override flags added by our configure script, the user-supplied C(XX)FLAGS should appear after the configure-supplied flags. This patch moves the user-supplied CXXFLAGS at the very end of the compilation command line, which fixes the problem described above. This means moving it out of INTERNAL_CFLAGS and inlining it in the users of INTERNAL_CFLAGS. I observed the problem when building GDB, but the same problem could happen with GDBserver, so the change is done there too. In GDBserver, INTERNAL_CFLAGS is passed when linking gdb/ChangeLog: * Makefile.in (COMPILE): Add CXXFLAGS. (INTERNAL_CFLAGS_BASE): Remove CXXFLAGS. (check-headers): Add CXXFLAGS. gdbserver/ChangeLog: * Makefile.in (COMPILE): Add CXXFLAGS. (INTERNAL_CFLAGS_BASE): Remove CXXFLAGS. (gdbserver$(EXEEXT)): Add CXXFLAGS. (gdbreplay$(EXEEXT)): Add CXXFLAGS. ($(IPA_LIB)): Add CXXFLAGS. (IPAGENT_COMPILE): Add CXXFLAGS. Change-Id: I00e054506695e0e9536095c6d14827e48abd8f69 --- gdb/Makefile.in | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'gdb/Makefile.in') diff --git a/gdb/Makefile.in b/gdb/Makefile.in index afce262..e14d41c 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -118,9 +118,13 @@ include $(srcdir)/silent-rules.mk # GNU make is used. The overrides implement dependency tracking. COMPILE.pre = $(CXX) -x c++ $(CXX_DIALECT) COMPILE.post = -c -o $@ -COMPILE = $(ECHO_CXX) $(COMPILE.pre) $(INTERNAL_CFLAGS) $(COMPILE.post) POSTCOMPILE = @true +# CXXFLAGS is at the very end on purpose, so that user-supplied flags can +# override internal flags. +COMPILE = $(ECHO_CXX) $(COMPILE.pre) $(INTERNAL_CFLAGS) $(CXXFLAGS) \ + $(COMPILE.post) + YACC = @YACC@ # This is used to rebuild ada-lex.c from ada-lex.l. If the program is @@ -598,7 +602,7 @@ INTERNAL_CPPFLAGS = $(CPPFLAGS) @GUILE_CPPFLAGS@ @PYTHON_CPPFLAGS@ \ # INTERNAL_CFLAGS is the aggregate of all other *CFLAGS macros. INTERNAL_CFLAGS_BASE = \ - $(CXXFLAGS) $(GLOBAL_CFLAGS) $(PROFILE_CFLAGS) \ + $(GLOBAL_CFLAGS) $(PROFILE_CFLAGS) \ $(GDB_CFLAGS) $(OPCODES_CFLAGS) $(READLINE_CFLAGS) $(ZLIBINC) \ $(BFD_CFLAGS) $(INCLUDE_CFLAGS) $(LIBDECNUMBER_CFLAGS) \ $(INTL_CFLAGS) $(INCGNU) $(INCSUPPORT) $(ENABLE_CFLAGS) \ @@ -1712,7 +1716,7 @@ check-headers: @echo Checking headers. for i in $(CHECK_HEADERS) ; do \ $(CXX) $(CXX_DIALECT) -x c++-header -c -fsyntax-only \ - $(INTERNAL_CFLAGS) -include defs.h $(srcdir)/$$i ; \ + $(INTERNAL_CFLAGS) $(CXXFLAGS) -include defs.h $(srcdir)/$$i ; \ done .PHONY: check-headers -- cgit v1.1