From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by sourceware.org (Postfix) with ESMTP id 67BA73870911 for ; Fri, 19 Jun 2020 13:49:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 67BA73870911 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-377-4vstaM4WOy20YdLXe_ffJg-1; Fri, 19 Jun 2020 09:49:52 -0400 X-MC-Unique: 4vstaM4WOy20YdLXe_ffJg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8E4308015CB for ; Fri, 19 Jun 2020 13:49:51 +0000 (UTC) Received: from blade.nx (ovpn-115-39.ams2.redhat.com [10.36.115.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B14B7166A; Fri, 19 Jun 2020 13:49:50 +0000 (UTC) Received: by blade.nx (Postfix, from userid 1000) id 9F610816CCA9; Fri, 19 Jun 2020 14:49:46 +0100 (BST) Date: Fri, 19 Jun 2020 14:49:46 +0100 From: Gary Benson To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [OB PATCH] Fix build errors in with clang in gdb.compile/compile-cplus.c Message-ID: <20200619134946.GA31823@blade.nx> References: <1590770634-26360-1-git-send-email-gbenson@redhat.com> <7b5505a6-68ac-fc94-a747-ffec3c7bf086@redhat.com> MIME-Version: 1.0 In-Reply-To: <7b5505a6-68ac-fc94-a747-ffec3c7bf086@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-15.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, 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: Fri, 19 Jun 2020 13:49:56 -0000 Pedro Alves wrote: > On 5/29/20 5:43 PM, Gary Benson via Gdb-patches wrote: > > Clang fails to compile the file, with the following error: > > fatal error: 'iostream' file not found > > > > This prevents the following testcase from executing: > > gdb.compile/compile-cplus.exp > > > > The testcase sets additional_flags when building with GCC, which > > this commit causes to also be set when building with clang. This > > makes the testcase fail to build with a different error: > > warning: treating 'c' input as 'c++' when in C++ mode, this behavior > > is deprecated [-Wdeprecated] > > so this commit adds -Wno-deprecated in two places to sidestep this. > > Note that, while allowing the testcase to build, this commit reveals > > failures when the testsuite is built using clang. > > > > gdb/testsuite/ChangeLog: > > > > * gdb.compile/compile-cplus.exp (additional_flags): Also > > set when building with clang. > > (additional_flags, srcfilesoptions): Pass -Wno-deprecated > > when building with clang. > > --- > > gdb/testsuite/ChangeLog | 7 +++++++ > > gdb/testsuite/gdb.compile/compile-cplus.exp | 15 +++++++++++++-- > > 2 files changed, 20 insertions(+), 2 deletions(-) > > > > diff --git a/gdb/testsuite/gdb.compile/compile-cplus.exp b/gdb/testsuite/gdb.compile/compile-cplus.exp > > index cca5b20..85b2f20 100644 > > --- a/gdb/testsuite/gdb.compile/compile-cplus.exp > > +++ b/gdb/testsuite/gdb.compile/compile-cplus.exp > > @@ -19,11 +19,16 @@ standard_testfile .c compile-shlib.c compile-constvar.S compile-nodebug.c > > > > get_compiler_info > > set options {} > > -if [test_compiler_info gcc*] { > > +if { [test_compiler_info gcc*] || [test_compiler_info clang*] } { > > lappend options additional_flags=-g3 > > lappend options additional_flags=-std=gnu++11 > > lappend options c++ > > } > > +if [test_compiler_info clang*] { > > + # Treating C input as C++ is deprecated in Clang, so > > + # the build will fail without disabling -Wdeprecated. > > + lappend options additional_flags=-Wno-deprecated > > +} > > I think > > lappend options "additional_flags=-x c++" > > in the previous "if" would be better. [i'm replying to this out-of-order] > Even better would be to tweak gdb_compile or thereabouts to make the > "c++" option automatically add "-x c++" to the compiler options with > clang. That would handle everywhere this could be an issue all at > once. WDYT? I disagree with adding global support for this, for these reasons: 1) It only affects this testcase. 2) This testcase is one big hack, afaict. It's a copy of (one/some of?) the original C-language testcases, with some stuff at the start to force the C sources through the C++ compiler, and to force GDB to recognise the result as C++. Force force force. 3) Clang is warning that compiling C as C++ is deprecated. Deprecated, as in, the support is there now, but don't count on it being there forever. We should not add global support for testcases to do deprecated things. In terms of fixing this locally: > I think > > lappend options "additional_flags=-x c++" > > in the previous "if" would be better. It doesn't work, one of the sources is assembler. I tried adding it to the other sources individually, but I couldn't make that work either, a) There's some quoting issue, I had to do: lappend options "additional_flags=-x" lappend options "additional_flags=c++" (I'm assuming there's a better way, but I don't know it) b) There's $srcfile3, $srcfile4, but I couldn't figure out how to apply the additional flags to the first srcfile. > BTW, it looks like a bug that appending the "c++" option is inside > the if, rather than outside. Maybe. I don't know. I doubt it's ever been run other than with GCC as the testcase compiler, the testcase is testing GDB using GCC to compile code for injection after all. Let me know what to do with this testcase. How important is it to not have -Wno-deprecated in there? I've probably spent close to three hours on this issue now fwiw :( Cheers, Gary -- Gary Benson - he / him / his Principal Software Engineer, Red Hat