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 1BAFC3851C19 for ; Wed, 24 Jun 2020 22:26:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1BAFC3851C19 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-257-c5itiVo0PgKH7sizpr4HMQ-1; Wed, 24 Jun 2020 18:26:33 -0400 X-MC-Unique: c5itiVo0PgKH7sizpr4HMQ-1 Received: by mail-wm1-f71.google.com with SMTP id b13so2474752wme.9 for ; Wed, 24 Jun 2020 15:26:33 -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:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=zK7nyoh0uA0s9ojwWZiXIc31wPhdILtphSboayi/pUo=; b=dunYmVgwVqSgJW0qFhZNcnTgx/EWmAEf7UqvnwBMaIqeeVnuKcQoVp0bIMWBfKL7Ke ltzmxJyl2mbwXiEvN1Ho+fWb27GA4J1JI+rJ4u1PujS0jAZci+kADuNTcDfYaUFph/mR 5qPMiaFFMxNMa25aTGhn5NASCPnIZaVFs/6GRKmKW1vSQ/cA5yxJJDAZiwkkBk81Vbf2 KSbi2/IrU+d8E352/HAFmMu0MQvh2Ke67DZhl317DX2wgTHpurTweA0S4NU7+c3bElJH KNWPn38SFenrJOlPmltoTggOu6jBDFyJvd28s5yC6dtMCk7cWlJQkYgEZH/PfV82kbA0 QlXg== X-Gm-Message-State: AOAM532acWTjd3JAeVVcEM4nHElwl0UeBcaiwtdzQIjQmvuEJk9ZDc25 PbpjVLzUGIVXOrcz1UAda/f5BMcylrS8b2+cMOr/WJts5pn6R7JDB7wyT26uVqcGok/pcHPOfAP oBVsD63ZjMDQPvSE44GAWTg== X-Received: by 2002:a5d:52c6:: with SMTP id r6mr32415027wrv.74.1593037592709; Wed, 24 Jun 2020 15:26:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzN1d6/BSWZMsjI/nTWCHV9cEhTgKFJu/WKkdjwwNp4NbREjnkvBnrACtKRJigU7wwVhi29AQ== X-Received: by 2002:a5d:52c6:: with SMTP id r6mr32415005wrv.74.1593037592416; Wed, 24 Jun 2020 15:26:32 -0700 (PDT) Received: from ?IPv6:2001:8a0:f922:c400:56ee:75ff:fe8d:232b? ([2001:8a0:f922:c400:56ee:75ff:fe8d:232b]) by smtp.gmail.com with ESMTPSA id j24sm27528546wrd.43.2020.06.24.15.26.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 24 Jun 2020 15:26:31 -0700 (PDT) Subject: Re: [PATCH] W/ Clang, compile C/C++ testcases with -Wno-unknown-warning-option To: Gary Benson References: <1590757423-18004-1-git-send-email-gbenson@redhat.com> <87mu5qaa2b.fsf@tromey.com> <68fd1b3e-10ae-8f1d-b96d-f35ce7ae3037@redhat.com> <20200616124212.GB30305@blade.nx> <5b75188a-0c0e-528a-1bbd-213f5fa52bd4@redhat.com> <20200617172913.GA5386@blade.nx> <4a87b8c6-a71c-cb54-8e23-7388c7128c2e@redhat.com> <20200618161829.GB1032@blade.nx> Cc: Tom Tromey , gdb-patches@sourceware.org From: Pedro Alves Message-ID: <4cba48fd-47d8-1a1c-59a0-c1b7ed85aba0@redhat.com> Date: Wed, 24 Jun 2020 23:26:30 +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: <20200618161829.GB1032@blade.nx> 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=-8.7 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_H3, 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: Wed, 24 Jun 2020 22:26:37 -0000 On 6/18/20 5:18 PM, Gary Benson via Gdb-patches wrote: > Pedro Alves wrote: >> From 79f1cfddeea957a778c856c879a386901a96609b Mon Sep 17 00:00:00 2001 >> From: Pedro Alves >> Date: Wed, 17 Jun 2020 19:29:37 +0100 >> Subject: [PATCH] W/ Clang, compile C/C++ testcases with >> -Wno-unknown-warning-option >> >> Some C/C++ testcases unconditionally pass -Wno-foo as additional >> options to disable some warning. That is OK with GCC, because GCC >> accepts -Wno-foo silently even if it doesn't support -Wfoo. This is a >> feature which allows disabling warnings with newer compilers without >> breaking builds with older compilers. Clang however warns about >> unknown -Wno-foo by default, unless you pass >> -Wno-unknown-warning-option as well: >> >> $ gcc -Wno-foo test.c >> * nothing, compiles successfuly * >> >> $ clang -Wno-foo test.c >> warning: unknown warning option '-Wno-foo [-Wunknown-warning-option] >> >> This commit adds -Wunknown-warning-option centrally in gdb_compile, so >> that individual testcases don't have to worry about breaking older >> Clangs. >> >> IOW, this avoids this problematic scenario: >> >> #1 - A testcase compiles successfully with Clang version X. >> #2 - Clang version "X + 1" adds a new warning, enabled by default, >> which breaks the test. >> #3 - We add -Wno-newwarning to the testcase, fixing the testcase with >> clang "X + 1". >> #4 - Now building the test with Clang version X no longer works, due >> to "unknown warning option". >> >> gdb/testsuite/ChangeLog: >> yyyy-mm-dd Pedro Alves >> >> * lib/gdb.exp (gdb_compile): Update intro comment. If C/C++ with >> Clang, add "-Wno-unknown-warning-option" to the options. >> --- >> gdb/testsuite/lib/gdb.exp | 19 ++++++++++++++++++- >> 1 file changed, 18 insertions(+), 1 deletion(-) >> >> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp >> index f502eb157d8..bbc940a4512 100644 >> --- a/gdb/testsuite/lib/gdb.exp >> +++ b/gdb/testsuite/lib/gdb.exp >> @@ -3826,7 +3826,8 @@ set gdb_saved_set_unbuffered_mode_obj "" >> # - ldflags=flag: Add FLAG to the linker flags. >> # - incdir=path: Add PATH to the searched include directories. >> # - libdir=path: Add PATH to the linker searched directories. >> -# - ada, c++, f77: Compile the file as Ada, C++ or Fortran. >> +# - ada, c++, f77, f90, rust: Compile the file as Ada, C++, >> +# Fortran 77, Fortran 90 or Rust. >> # - debug: Build with debug information. >> # - optimize: Build with optimization. >> >> @@ -3850,6 +3851,22 @@ proc gdb_compile {source dest type options} { >> set new_options [universal_compile_options] >> } >> >> + # Some C/C++ testcases unconditionally pass -Wno-foo as additional >> + # options to disable some warning. That is OK with GCC, because >> + # by design, GCC accepts any -Wno-foo option, even if it doesn't >> + # support -Wfoo. Clang however warns about unknown -Wno-foo by >> + # default, unless you pass -Wno-unknown-warning-option as well. >> + # We do that here, so that individual testcases don't have to >> + # worry about it. >> + if {[lsearch -exact $options getting_compiler_info] == -1 >> + && [lsearch -exact $options rust] == -1 >> + && [lsearch -exact $options ada] == -1 >> + && [lsearch -exact $options f77] == -1 >> + && [lsearch -exact $options f90] == -1 >> + && [test_compiler_info "clang-*"]} { >> + lappend new_options "additional_flags=-Wno-unknown-warning-option" >> + } >> + >> # Place (and look for) Fortran `.mod` files in the output >> # directory for this specific test. >> if {[lsearch -exact $options f77] != -1 \ >> >> base-commit: 669203174311c5be76744a879563c697cd479853 >> -- >> 2.14.5 > > Oh, thanks, that looks great. Could you commit it please? I've pushed this now, with just a tweak to also list "go". >From 331733cd4e2f2fe76c0b7b6fdd81e54724572354 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Wed, 24 Jun 2020 23:18:19 +0100 Subject: [PATCH] W/ Clang, compile C/C++ testcases with -Wno-unknown-warning-option Some C/C++ testcases unconditionally pass -Wno-foo as additional options to disable some warning. That is OK with GCC, because GCC accepts -Wno-foo silently even if it doesn't support -Wfoo. This is a feature which allows disabling warnings with newer compilers without breaking builds with older compilers. Clang however warns about unknown -Wno-foo by default, unless you pass -Wno-unknown-warning-option as well: $ gcc -Wno-foo test.c * nothing, compiles successfuly * $ clang -Wno-foo test.c warning: unknown warning option '-Wno-foo [-Wunknown-warning-option] This commit adds -Wunknown-warning-option centrally in gdb_compile, so that individual testcases don't have to worry about breaking older Clangs. IOW, this avoids this problematic scenario: #1 - A testcase compiles successfully with Clang version X. #2 - Clang version "X + 1" adds a new warning, enabled by default, which breaks the test. #3 - We add -Wno-newwarning to the testcase, fixing the testcase with clang "X + 1". #4 - Now building the test with Clang version X no longer works, due to "unknown warning option". gdb/testsuite/ChangeLog: 2020-06-24 Pedro Alves * lib/gdb.exp (gdb_compile): Update intro comment. If C/C++ with Clang, add "-Wno-unknown-warning-option" to the options. --- gdb/testsuite/ChangeLog | 5 +++++ gdb/testsuite/lib/gdb.exp | 20 +++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 26284dabb25..6f4d99d3902 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-06-24 Pedro Alves + + * lib/gdb.exp (gdb_compile): Update intro comment. If C/C++ with + Clang, add "-Wno-unknown-warning-option" to the options. + 2020-06-23 Andrew Burgess * gdb.xml/tdesc-reload.c: New file. diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 7b243f5fff3..6b4f71be588 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -3826,7 +3826,8 @@ set gdb_saved_set_unbuffered_mode_obj "" # - ldflags=flag: Add FLAG to the linker flags. # - incdir=path: Add PATH to the searched include directories. # - libdir=path: Add PATH to the linker searched directories. -# - ada, c++, f77: Compile the file as Ada, C++ or Fortran. +# - ada, c++, f77, f90, go, rust: Compile the file as Ada, C++, +# Fortran 77, Fortran 90, Go or Rust. # - debug: Build with debug information. # - optimize: Build with optimization. @@ -3850,6 +3851,23 @@ proc gdb_compile {source dest type options} { set new_options [universal_compile_options] } + # Some C/C++ testcases unconditionally pass -Wno-foo as additional + # options to disable some warning. That is OK with GCC, because + # by design, GCC accepts any -Wno-foo option, even if it doesn't + # support -Wfoo. Clang however warns about unknown -Wno-foo by + # default, unless you pass -Wno-unknown-warning-option as well. + # We do that here, so that individual testcases don't have to + # worry about it. + if {[lsearch -exact $options getting_compiler_info] == -1 + && [lsearch -exact $options rust] == -1 + && [lsearch -exact $options ada] == -1 + && [lsearch -exact $options f77] == -1 + && [lsearch -exact $options f90] == -1 + && [lsearch -exact $options go] == -1 + && [test_compiler_info "clang-*"]} { + lappend new_options "additional_flags=-Wno-unknown-warning-option" + } + # Place (and look for) Fortran `.mod` files in the output # directory for this specific test. if {[lsearch -exact $options f77] != -1 \ base-commit: a8654e7d784980cb4596f685964200fcc1164c78 -- 2.14.5