From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by sourceware.org (Postfix) with ESMTP id 9D2D8388B03A for ; Fri, 29 May 2020 21:12:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9D2D8388B03A Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-315-45rBi_u7PNuBU3BDojFjqA-1; Fri, 29 May 2020 17:12:21 -0400 X-MC-Unique: 45rBi_u7PNuBU3BDojFjqA-1 Received: by mail-wr1-f69.google.com with SMTP id y7so1500040wrd.12 for ; Fri, 29 May 2020 14:12:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=gnb8qoiirg6Jaza68RRpHbrvV+OMxPnttWh+xgGHa9Y=; b=EakeboTofnqj1Zqqs0AJnGw53vvrLqPJuiv4FAvhnCMd62OK9q6oyFQT+5D7HzBu5F 1i6fSj35PZ0OzmIQkDI0ChKSLW0zdXOuaLmfkNAi2Yy4qih0G8uCQUMyLsT0jmwPvtfz frRFAFzsTMoGtl3IF9KjGFYaaBsl6viiTo5WDfSZO63xl4pgfT/Y5a47E4wvFyuVttlV 4tbzQEvNUqS2W3yZR7coKuSKqeI45SLSpjzc1ttnliUDEzdDrZ89VVViWGiRk30SPiLB gcNc56EstApKmRn36nCpzaSuVP/Lr8KTKQ2K/aDz0NfeYWG30TA3IXsnhagM1ddMu4S0 uRcg== X-Gm-Message-State: AOAM531aCus2XWIPSehsP8Lt1xRjJPYpstdOuPiI7ggouqZplR9FUPdS plYER3/K3fCgvElhnxDHWE4/rj3kDpGGLc/GtYHK8kciWs+31qywyAAkBjlYzp8l/QBxQCNx5iD cqXPqbh5pqtfgD8oaMZCFRg== X-Received: by 2002:adf:f988:: with SMTP id f8mr11199082wrr.81.1590786740151; Fri, 29 May 2020 14:12:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzv/IQ6ADluXwhSWnvVLXFDIJYlngwcLwzAvqfpRer4jvpJSNLqtV06t+V1bWwTbhUOl5qS9A== X-Received: by 2002:adf:f988:: with SMTP id f8mr11199064wrr.81.1590786739899; Fri, 29 May 2020 14:12:19 -0700 (PDT) Received: from ?IPv6:2001:8a0:f909:7b00:56ee:75ff:fe8d:232b? ([2001:8a0:f909:7b00:56ee:75ff:fe8d:232b]) by smtp.gmail.com with ESMTPSA id p10sm11773072wra.78.2020.05.29.14.12.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 May 2020 14:12:19 -0700 (PDT) Subject: Re: [OB PATCH] Fix build errors in with clang in gdb.compile/compile-cplus.c To: Gary Benson , gdb-patches@sourceware.org References: <1590770634-26360-1-git-send-email-gbenson@redhat.com> From: Pedro Alves Message-ID: <7b5505a6-68ac-fc94-a747-ffec3c7bf086@redhat.com> Date: Fri, 29 May 2020 22:12:18 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <1590770634-26360-1-git-send-email-gbenson@redhat.com> Content-Language: en-US X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.2 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, 29 May 2020 21:12:25 -0000 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. 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? BTW, it looks like a bug that appending the "c++" option is inside the if, rather than outside. Thanks, Pedro Alves > > if { ![istarget x86_64-*-* ] || ![is_lp64_target] } { > verbose "Skipping x86_64 LOC_CONST test." > @@ -34,7 +39,13 @@ set srcfilesoptions [list ${srcfile} ${options}] > if { $srcfile3 != "" } { > lappend srcfilesoptions $srcfile3 ${options} > } > -lappend srcfilesoptions $srcfile4 "nodebug c++" > +set srcfile4options "nodebug c++" > +if [test_compiler_info clang*] { > + # Treating C input as C++ is deprecated in Clang, so > + # the build will fail without disabling -Wdeprecated. > + set srcfile4options "$srcfile4options additional_flags=-Wno-deprecated" > +} > +lappend srcfilesoptions $srcfile4 $srcfile4options > if { [eval build_executable_from_specs ${testfile}.exp $testfile {$options} ${srcfilesoptions}] } { > return -1 > } >