From patchwork Wed Dec 6 06:12:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 81475 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C95C0384DED1 for ; Wed, 6 Dec 2023 06:13:11 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) by sourceware.org (Postfix) with ESMTP id 448CC3858CDA for ; Wed, 6 Dec 2023 06:12:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 448CC3858CDA Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 448CC3858CDA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=140.211.166.183 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701843180; cv=none; b=mPGytX/VGcgSMwELHZn2D+9xTuU1MGQMr+yEhkrCIhznUJWNbbwykrvSHqFdYct+wg9vjDdhIM2KE5CNPBnVuLA8SrlxpvJkLYJvs3+NpSLIJBOi3i2N4uRGzr6kmWU/xy+AwOg9wc6W+yPxE++LoXbetiEJqu0Amz3j9HP4LBQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701843180; c=relaxed/simple; bh=HgpPTtt1k38t+pEOAqoS++1ED/xmR/RTj/LLwg9s418=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=AP6YERlxhMsGuSiGgjK5UtsfsDZKcBa6CGjgXz/IjZfAuqzffZlnX0o7D9GKgaKVp1wvXvbw4LUETgT8+4xZdPL0J+Z4WqaZuvxMn5ETUparNW0M5jb8rZpp+4qxgvb9fu5Kp4vSGS36Z59jhKZoRSnRHaswXHnageWAolxpXFg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by smtp.gentoo.org (Postfix, from userid 559) id AA67933BE19; Wed, 6 Dec 2023 06:12:57 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH/committed] sim: warnings: sync some build logic from gdbsupport Date: Tue, 5 Dec 2023 23:12:56 -0700 Message-ID: <20231206061256.6528-1-vapier@gentoo.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org This fixes testing of -Wno flags, and adds some more portable ones. --- sim/configure | 39 ++++++++++++++++++++++++------ sim/m4/sim_ac_option_warnings.m4 | 41 +++++++++++++++++++++++++------- 2 files changed, 65 insertions(+), 15 deletions(-) diff --git a/sim/configure b/sim/configure index 32cd8fb051fc..73a638f0798e 100755 --- a/sim/configure +++ b/sim/configure @@ -15802,7 +15802,6 @@ _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: result: $sim_trace" >&5 $as_echo "$sim_trace" >&6; } - # Check whether --enable-werror was given. if test "${enable_werror+set}" = set; then : enableval=$enable_werror; case "${enableval}" in @@ -15834,11 +15833,21 @@ build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith -Wold-style-declaration -Wold-style-definition " -# Enable -Wno-format by default when using gcc on mingw since many -# GCC versions complain about %I64. case "${host}" in - *-*-mingw32*) build_warnings="$build_warnings -Wno-format" ;; - *) build_warnings="$build_warnings -Wformat-nonliteral" ;; + *-*-mingw32*) + # Enable -Wno-format by default when using gcc on mingw since many + # GCC versions complain about %I64. + build_warnings="$build_warnings -Wno-format" ;; + *-*-solaris*) + # Solaris 11.4 uses #pragma no_inline that GCC + # doesn't understand. + build_warnings="$build_warnings -Wno-unknown-pragmas" + # Solaris 11 marks vfork deprecated. + build_warnings="$build_warnings -Wno-deprecated-declarations" ;; + *) + # Note that gcc requires -Wformat for -Wformat-nonliteral to work, + # but there's a special case for this below. + build_warnings="$build_warnings -Wformat-nonliteral" ;; esac # Check whether --enable-build-warnings was given. @@ -15879,11 +15888,27 @@ $as_echo_n "checking compiler warning flags... " >&6; } # Separate out the -Werror flag as some files just cannot be # compiled with it enabled. for w in ${build_warnings}; do + # GCC does not complain about -Wno-unknown-warning. Invert + # and test -Wunknown-warning instead. + case $w in + -Wno-*) + wtest=`echo $w | sed 's/-Wno-/-W/g'` ;; + -Wformat-nonliteral) + # gcc requires -Wformat before -Wformat-nonliteral + # will work, so stick them together. + w="-Wformat $w" + wtest="$w" + ;; + *) + wtest=$w ;; + esac + case $w in -Werr*) WERROR_CFLAGS=-Werror ;; - *) # Check that GCC accepts it + *) + # Check whether GCC accepts it. saved_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -Werror $w" + CFLAGS="$CFLAGS -Werror $wtest" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ diff --git a/sim/m4/sim_ac_option_warnings.m4 b/sim/m4/sim_ac_option_warnings.m4 index 16d358b0bbaa..b66e0ec3b5c3 100644 --- a/sim/m4/sim_ac_option_warnings.m4 +++ b/sim/m4/sim_ac_option_warnings.m4 @@ -15,8 +15,7 @@ dnl along with this program. If not, see . dnl dnl --enable-build-warnings is for developers of the simulator. dnl it enables extra GCC specific warnings. -AC_DEFUN([SIM_AC_OPTION_WARNINGS], -[ +AC_DEFUN([SIM_AC_OPTION_WARNINGS], [dnl AC_ARG_ENABLE(werror, AS_HELP_STRING([--enable-werror], [treat compile warnings as errors]), [case "${enableval}" in @@ -49,11 +48,21 @@ build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith -Wold-style-declaration -Wold-style-definition " -# Enable -Wno-format by default when using gcc on mingw since many -# GCC versions complain about %I64. case "${host}" in - *-*-mingw32*) build_warnings="$build_warnings -Wno-format" ;; - *) build_warnings="$build_warnings -Wformat-nonliteral" ;; + *-*-mingw32*) + # Enable -Wno-format by default when using gcc on mingw since many + # GCC versions complain about %I64. + build_warnings="$build_warnings -Wno-format" ;; + *-*-solaris*) + # Solaris 11.4 uses #pragma no_inline that GCC + # doesn't understand. + build_warnings="$build_warnings -Wno-unknown-pragmas" + # Solaris 11 marks vfork deprecated. + build_warnings="$build_warnings -Wno-deprecated-declarations" ;; + *) + # Note that gcc requires -Wformat for -Wformat-nonliteral to work, + # but there's a special case for this below. + build_warnings="$build_warnings -Wformat-nonliteral" ;; esac AC_ARG_ENABLE(build-warnings, @@ -91,11 +100,27 @@ then # Separate out the -Werror flag as some files just cannot be # compiled with it enabled. for w in ${build_warnings}; do + # GCC does not complain about -Wno-unknown-warning. Invert + # and test -Wunknown-warning instead. + case $w in + -Wno-*) + wtest=`echo $w | sed 's/-Wno-/-W/g'` ;; + -Wformat-nonliteral) + # gcc requires -Wformat before -Wformat-nonliteral + # will work, so stick them together. + w="-Wformat $w" + wtest="$w" + ;; + *) + wtest=$w ;; + esac + case $w in -Werr*) WERROR_CFLAGS=-Werror ;; - *) # Check that GCC accepts it + *) + # Check whether GCC accepts it. saved_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -Werror $w" + CFLAGS="$CFLAGS -Werror $wtest" AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",) CFLAGS="$saved_CFLAGS" esac