From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id D04F13857C74 for ; Wed, 7 Oct 2020 15:27:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D04F13857C74 X-ASG-Debug-ID: 1602084427-0c856e1c4514e160001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id sFPSUP4NSVxNuDSS (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 07 Oct 2020 11:27:08 -0400 (EDT) X-Barracuda-Envelope-From: simon.marchi@efficios.com X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from smarchi-efficios.internal.efficios.com (192-222-181-218.qc.cable.ebox.net [192.222.181.218]) by smtp.ebox.ca (Postfix) with ESMTP id C05D7441D65; Wed, 7 Oct 2020 11:27:07 -0400 (EDT) From: Simon Marchi X-Barracuda-RBL-IP: 192.222.181.218 X-Barracuda-Effective-Source-IP: 192-222-181-218.qc.cable.ebox.net[192.222.181.218] X-Barracuda-Apparent-Source-IP: 192.222.181.218 To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH v2] gdb: put user-supplied CFLAGS at the end Date: Wed, 7 Oct 2020 11:27:07 -0400 X-ASG-Orig-Subj: [PATCH v2] gdb: put user-supplied CFLAGS at the end Message-Id: <20201007152707.78244-1-simon.marchi@efficios.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1602084427 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 6145 X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.85132 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Spam-Status: No, score=-21.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Oct 2020 15:27:23 -0000 New in v2: * Put $(CXXFLAGS) in the top-level COMPILE command instead of keeping it buried in INTERNAL_CFLAGS. * Do the same change in gdbserver. ---8<--- 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 +++++++--- gdbserver/Makefile.in | 14 +++++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/gdb/Makefile.in b/gdb/Makefile.in index afce26276ecd..e14d41cef915 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 diff --git a/gdbserver/Makefile.in b/gdbserver/Makefile.in index 8b80acebdf1e..903c4a855516 100644 --- a/gdbserver/Makefile.in +++ b/gdbserver/Makefile.in @@ -83,9 +83,12 @@ include $(srcdir)/../gdb/silent-rules.mk # GNU make is used. The overrides implement dependency tracking. COMPILE.pre = $(CXX) $(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) + # It is also possible that you will need to add -I/usr/include/sys to the # CFLAGS section if your system doesn't have fcntl.h in /usr/include (which # is where it should be according to Posix). @@ -158,7 +161,7 @@ PTHREAD_LIBS = @PTHREAD_LIBS@ WIN32APILIBS = @WIN32APILIBS@ # INTERNAL_CFLAGS is the aggregate of all other *CFLAGS macros. -INTERNAL_CFLAGS_BASE = ${CXXFLAGS} ${GLOBAL_CFLAGS} \ +INTERNAL_CFLAGS_BASE = ${GLOBAL_CFLAGS} \ ${PROFILE_CFLAGS} ${INCLUDE_CFLAGS} ${CPPFLAGS} $(PTHREAD_CFLAGS) INTERNAL_WARN_CFLAGS = ${INTERNAL_CFLAGS_BASE} $(WARN_CFLAGS) INTERNAL_CFLAGS = ${INTERNAL_WARN_CFLAGS} $(WERROR_CFLAGS) -DGDBSERVER @@ -352,6 +355,7 @@ gdbserver$(EXEEXT): $(sort $(OBS)) ${CDEPS} $(LIBGNU) $(LIBIBERTY) \ $(INTL_DEPS) $(GDBSUPPORT) $(SILENCE) rm -f gdbserver$(EXEEXT) $(ECHO_CXXLD) $(CC_LD) $(INTERNAL_CFLAGS) $(INTERNAL_LDFLAGS) \ + $(CXXFLAGS) \ -o gdbserver$(EXEEXT) $(OBS) $(GDBSUPPORT) $(LIBGNU) \ $(LIBIBERTY) $(INTL) $(GDBSERVER_LIBS) $(XM_CLIBS) \ $(WIN32APILIBS) @@ -360,6 +364,7 @@ gdbreplay$(EXEEXT): $(sort $(GDBREPLAY_OBS)) $(LIBGNU) $(LIBIBERTY) \ $(INTL_DEPS) $(GDBSUPPORT) $(SILENCE) rm -f gdbreplay$(EXEEXT) $(ECHO_CXXLD) $(CC_LD) $(INTERNAL_CFLAGS) $(INTERNAL_LDFLAGS) \ + $(CXXFLAGS) \ -o gdbreplay$(EXEEXT) $(GDBREPLAY_OBS) $(XM_CLIBS) \ $(GDBSUPPORT) $(LIBGNU) $(LIBIBERTY) $(INTL) \ $(WIN32APILIBS) @@ -387,6 +392,7 @@ $(IPA_LIB): $(sort $(IPA_OBJS)) ${CDEPS} $(SILENCE) rm -f $(IPA_LIB) $(ECHO_CXXLD) $(CC_LD) -shared -fPIC -Wl,--soname=$(IPA_LIB) \ -Wl,--no-undefined $(INTERNAL_CFLAGS) $(INTERNAL_LDFLAGS) \ + $(CXXFLAGS) \ -o $(IPA_LIB) ${IPA_OBJS} -ldl -pthread # Put the proper machine-specific files first, so M-. on a machine @@ -482,7 +488,9 @@ IPAGENT_CFLAGS = $(INTERNAL_CFLAGS) $(UST_CFLAGS) \ -fPIC -DIN_PROCESS_AGENT \ -fvisibility=hidden -IPAGENT_COMPILE = $(ECHO_CXX) $(COMPILE.pre) $(IPAGENT_CFLAGS) $(COMPILE.post) +# CXXFLAGS is at the very end on purpose, so that user-supplied flags can +# override internal flags. +IPAGENT_COMPILE = $(ECHO_CXX) $(COMPILE.pre) $(IPAGENT_CFLAGS) $(CXXFLAGS) $(COMPILE.post) # Rules for special cases. -- 2.26.2