From nobody Sun Feb 8 17:21:55 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579188558; cv=none; d=zohomail.com; s=zohoarc; b=S3vOAL2tgYraY7kJLUe6J7E2/mpO398Ic+UfDaxZjof3nD01n3c/HOHOeHxsjp1zHUWa8VOUUXGO4e2+UMtXVMx1q1lW3wDDLF5m/eOkd57uPXgDSFbfx6fa0Dju41EBU9/wXDMHzM/tZRocb8KsIK066KqkR3zY0+PfgEwysOg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579188558; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BY3v87UuvEL+QXDoFOO70mv2qGp/t9b3qzeLh17Urlo=; b=bQLQbO9/fETWJdmwrWhALPA7rRVPLjrd/es6cNg2kyO9nX5dR1svlXDrRMSbqdqzeIYfOlrQDxPKD1BxFH8KMfQUS0jQ2amZC2dbziUJL5F5VgydONLbbgmgCuG84CMhtvyIIl9S1tp0KndwgwMmGTeKRXEjfvEICmvvsaKT2WQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1579188558047468.1576196456907; Thu, 16 Jan 2020 07:29:18 -0800 (PST) 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-356-tXNx5ktWOsKl5yUCqPCW7w-1; Thu, 16 Jan 2020 10:29:13 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D299A18FE86C; Thu, 16 Jan 2020 15:29:05 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A66DB5D9C9; Thu, 16 Jan 2020 15:29:05 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 58133845FD; Thu, 16 Jan 2020 15:29:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00GFRZDn026058 for ; Thu, 16 Jan 2020 10:27:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2851581206; Thu, 16 Jan 2020 15:27:35 +0000 (UTC) Received: from catbus.gsslab.fab.redhat.com (mustard.gsslab.fab.redhat.com [10.33.8.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id 68F7C81201; Thu, 16 Jan 2020 15:27:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579188556; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=BY3v87UuvEL+QXDoFOO70mv2qGp/t9b3qzeLh17Urlo=; b=ASTn52w+d/r+VdnVwT9VKs0OIkLc/2zK8weYWORyADNqlH8WKz6Zouv+zf6ZxK50glpM1m +bxSOXxpumfToWCO15ZFYlHxajbDw63Hip4Qy9N201xI0IEyZ+hiEpGvQccpqfl00FNdri C2xU5hcG3+UXmBuPu6+P5z7O+1EB+dQ= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 13/13] bootstrap: remove 25 more gnulib modules Date: Thu, 16 Jan 2020 15:24:48 +0000 Message-Id: <20200116152448.592267-14-berrange@redhat.com> In-Reply-To: <20200116152448.592267-1-berrange@redhat.com> References: <20200116152448.592267-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Pavel Hrdina X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: tXNx5ktWOsKl5yUCqPCW7w-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" * send, recv: we use write & read for sockets so don't need these portability wrappers * ioctl, fcntl, fcntl-h: any usage of these is conditionally compiled and excludes Windows * ttyname_r: this exists in all supported platforms that we require now * environ: the tests explicitly declare this global variable * intprops: the code has been converted / simplified * openpty: custom checks in configure.ac cope with portability * accept, bind, connect, getpeername, getsockname, listen, setsockopt, socket: code needing Windows portability uses our wrapper functions * close: avoids abort when passed invalid FD on Windows. Our VIR_FORCE_CLOSE wrapper avoids calling close(-1) and it is reasonable to abort in other scenarios in the RPC client * physmem: the gnulib code has been partially imported * warnings, manywarnings: copy the files directly into our local m4 dir * verify: replaced by G_STATIC_ASSERT * pthread_sigmask: none of the fixed portability problems affect libvirt's usage on current supported platforms * termios: the header is now conditionally included only when needed * time_r: replaced with GDateTime APIs Reviewed-by: Pavel Hrdina Signed-off-by: Daniel P. Berrang=C3=A9 --- bootstrap.conf | 50 ------ m4/virt-manywarnings.m4 | 339 ++++++++++++++++++++++++++++++++++++++++ m4/virt-warnings.m4 | 115 ++++++++++++++ 3 files changed, 454 insertions(+), 50 deletions(-) create mode 100644 m4/virt-manywarnings.m4 create mode 100644 m4/virt-warnings.m4 diff --git a/bootstrap.conf b/bootstrap.conf index ae9ecb4039..7e550a379c 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -24,44 +24,18 @@ # turning it into a FD, since closing an FD also closes # the original HANDLE. =20 -# -> GSocket -gnulib_modules=3D"$gnulib_modules accept" -# -> GSocket -gnulib_modules=3D"$gnulib_modules bind" # -> conditional build to avoid Win32 gnulib_modules=3D"$gnulib_modules chown" -# -> GSocket -gnulib_modules=3D"$gnulib_modules close" -# -> GSocket -gnulib_modules=3D"$gnulib_modules connect" # -> Meson gnulib_modules=3D"$gnulib_modules configmake" -# -> eliminate usage in some manner -gnulib_modules=3D"$gnulib_modules environ" -# -> GSocket -gnulib_modules=3D"$gnulib_modules fcntl" -# -> conditional build avoid win32 -gnulib_modules=3D"$gnulib_modules fcntl-h" # -> GSocket gnulib_modules=3D"$gnulib_modules getaddrinfo" # -> copy gnuliub win32 impl gnulib_modules=3D"$gnulib_modules getpass" -# -> GSocket -gnulib_modules=3D"$gnulib_modules getpeername" -# -> GSocket -gnulib_modules=3D"$gnulib_modules getsockname" -# -> copy gnulib STRBUFLEN macro -gnulib_modules=3D"$gnulib_modules intprops" -# -> GSocket -gnulib_modules=3D"$gnulib_modules ioctl" # -> Meson gnulib_modules=3D"$gnulib_modules largefile" -# -> GSocket -gnulib_modules=3D"$gnulib_modules listen" # -> custom configure check gnulib_modules=3D"$gnulib_modules localeconv" -# -> Meson -gnulib_modules=3D"$gnulib_modules manywarnings" # -> painful copy gnulib gnulib_modules=3D"$gnulib_modules mgetgroups" # -> GSocket @@ -70,12 +44,8 @@ gnulib_modules=3D"$gnulib_modules net_if" gnulib_modules=3D"$gnulib_modules netdb" # -> GSocket gnulib_modules=3D"$gnulib_modules nonblocking" -# -> Just add -lutil to cli -gnulib_modules=3D"$gnulib_modules openpty" # -> GSocket gnulib_modules=3D"$gnulib_modules passfd" -# -> open code / copy gnulib code -gnulib_modules=3D"$gnulib_modules physmem" # -> open code / conditional comp gnulib_modules=3D"$gnulib_modules pipe-posix" # -> open code / conditional comp @@ -85,19 +55,9 @@ gnulib_modules=3D"$gnulib_modules poll" # -> Meson gnulib_modules=3D"$gnulib_modules posix-shell" # -> open code conditional logic -gnulib_modules=3D"$gnulib_modules pthread_sigmask" -# -> GSocket -gnulib_modules=3D"$gnulib_modules recv" -# -> GSocket -gnulib_modules=3D"$gnulib_modules send" -# -> GSocket -gnulib_modules=3D"$gnulib_modules setsockopt" -# -> open code conditional logic gnulib_modules=3D"$gnulib_modules sigaction" # -> open code conditional logic gnulib_modules=3D"$gnulib_modules sigpipe" -# -> GSocket -gnulib_modules=3D"$gnulib_modules socket" # -> open code conditional or use GIO GFileInfo gnulib_modules=3D"$gnulib_modules stat-time" # -> remove use or open-code it. possibly add to glib @@ -108,20 +68,10 @@ gnulib_modules=3D"$gnulib_modules strtok_r" gnulib_modules=3D"$gnulib_modules sys_stat" # -> remove sys/wait.h include from any win32 code paths gnulib_modules=3D"$gnulib_modules sys_wait" -# -> remove from any win32 code paths -gnulib_modules=3D"$gnulib_modules termios" -# -> GDateTime ? -gnulib_modules=3D"$gnulib_modules time_r" -# -> obsolete - exists on Linux, MacOS >=3D ?? & FreeBSD >=3D 6 -gnulib_modules=3D"$gnulib_modules ttyname_r" # -> g_get_os_info in GLib 2.64 but can't use that yet gnulib_modules=3D"$gnulib_modules uname" -# -> G_STATIC_ASSERT -gnulib_modules=3D"$gnulib_modules verify" # -> remove from Win32 code paths gnulib_modules=3D"$gnulib_modules waitpid" -# -> Meson -gnulib_modules=3D"$gnulib_modules warnings" # -> open code impl gnulib_modules=3D"$gnulib_modules wcwidth" =20 diff --git a/m4/virt-manywarnings.m4 b/m4/virt-manywarnings.m4 new file mode 100644 index 0000000000..783620da3a --- /dev/null +++ b/m4/virt-manywarnings.m4 @@ -0,0 +1,339 @@ +# manywarnings.m4 serial 18 +dnl Copyright (C) 2008-2020 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Simon Josefsson + +# gl_MANYWARN_COMPLEMENT(OUTVAR, LISTVAR, REMOVEVAR) +# -------------------------------------------------- +# Copy LISTVAR to OUTVAR except for the entries in REMOVEVAR. +# Elements separated by whitespace. In set logic terms, the function +# does OUTVAR =3D LISTVAR \ REMOVEVAR. +AC_DEFUN([gl_MANYWARN_COMPLEMENT], +[ + gl_warn_set=3D + set x $2; shift + for gl_warn_item + do + case " $3 " in + *" $gl_warn_item "*) + ;; + *) + gl_warn_set=3D"$gl_warn_set $gl_warn_item" + ;; + esac + done + $1=3D$gl_warn_set +]) + +# gl_MANYWARN_ALL_GCC(VARIABLE) +# ----------------------------- +# Add all documented GCC warning parameters to variable VARIABLE. +# Note that you need to test them using gl_WARN_ADD if you want to +# make sure your gcc understands it. +# +# The effects of this macro depend on the current language (_AC_LANG). +AC_DEFUN([gl_MANYWARN_ALL_GCC], +[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)]) + +# Specialization for _AC_LANG =3D C. +# Use of m4_defun rather than AC_DEFUN works around a bug in autoconf < 2.= 63b. +m4_defun([gl_MANYWARN_ALL_GCC(C)], +[ + AC_LANG_PUSH([C]) + + dnl First, check for some issues that only occur when combining multiple + dnl gcc warning categories. + AC_REQUIRE([AC_PROG_CC]) + if test -n "$GCC"; then + + dnl Check if -W -Werror -Wno-missing-field-initializers is supported + dnl with the current $CC $CFLAGS $CPPFLAGS. + AC_CACHE_CHECK([whether -Wno-missing-field-initializers is supported], + [gl_cv_cc_nomfi_supported], + [gl_save_CFLAGS=3D"$CFLAGS" + CFLAGS=3D"$CFLAGS -W -Werror -Wno-missing-field-initializers" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[]], [[]])], + [gl_cv_cc_nomfi_supported=3Dyes], + [gl_cv_cc_nomfi_supported=3Dno]) + CFLAGS=3D"$gl_save_CFLAGS" + ]) + + if test "$gl_cv_cc_nomfi_supported" =3D yes; then + dnl Now check whether -Wno-missing-field-initializers is needed + dnl for the { 0, } construct. + AC_CACHE_CHECK([whether -Wno-missing-field-initializers is needed], + [gl_cv_cc_nomfi_needed], + [gl_save_CFLAGS=3D"$CFLAGS" + CFLAGS=3D"$CFLAGS -W -Werror" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[int f (void) + { + typedef struct { int a; int b; } s_t; + s_t s1 =3D { 0, }; + return s1.b; + } + ]], + [[]])], + [gl_cv_cc_nomfi_needed=3Dno], + [gl_cv_cc_nomfi_needed=3Dyes]) + CFLAGS=3D"$gl_save_CFLAGS" + ]) + fi + + dnl Next, check if -Werror -Wuninitialized is useful with the + dnl user's choice of $CFLAGS; some versions of gcc warn that it + dnl has no effect if -O is not also used + AC_CACHE_CHECK([whether -Wuninitialized is supported], + [gl_cv_cc_uninitialized_supported], + [gl_save_CFLAGS=3D"$CFLAGS" + CFLAGS=3D"$CFLAGS -Werror -Wuninitialized" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[]], [[]])], + [gl_cv_cc_uninitialized_supported=3Dyes], + [gl_cv_cc_uninitialized_supported=3Dno]) + CFLAGS=3D"$gl_save_CFLAGS" + ]) + + fi + + # List all gcc warning categories. + # To compare this list to your installed GCC's, run this Bash command: + # + # comm -3 \ + # <((sed -n 's/^ *\(-[^ 0-9][^ ]*\) .*/\1/p' manywarnings.m4; \ + # awk '/^[^#]/ {print $1}' ../build-aux/gcc-warning.spec) | sort) \ + # <(LC_ALL=3DC gcc --help=3Dwarnings | sed -n 's/^ \(-[^ ]*\) .*/\1/p'= | sort) + + gl_manywarn_set=3D + for gl_manywarn_item in -fno-common \ + -W \ + -Wabsolute-value \ + -Waddress \ + -Waddress-of-packed-member \ + -Waggressive-loop-optimizations \ + -Wall \ + -Wattribute-warning \ + -Wattributes \ + -Wbad-function-cast \ + -Wbool-compare \ + -Wbool-operation \ + -Wbuiltin-declaration-mismatch \ + -Wbuiltin-macro-redefined \ + -Wcannot-profile \ + -Wcast-align \ + -Wcast-align=3Dstrict \ + -Wcast-function-type \ + -Wchar-subscripts \ + -Wclobbered \ + -Wcomment \ + -Wcomments \ + -Wcoverage-mismatch \ + -Wcpp \ + -Wdangling-else \ + -Wdate-time \ + -Wdeprecated \ + -Wdeprecated-declarations \ + -Wdesignated-init \ + -Wdisabled-optimization \ + -Wdiscarded-array-qualifiers \ + -Wdiscarded-qualifiers \ + -Wdiv-by-zero \ + -Wdouble-promotion \ + -Wduplicated-branches \ + -Wduplicated-cond \ + -Wduplicate-decl-specifier \ + -Wempty-body \ + -Wendif-labels \ + -Wenum-compare \ + -Wexpansion-to-defined \ + -Wextra \ + -Wformat-contains-nul \ + -Wformat-extra-args \ + -Wformat-nonliteral \ + -Wformat-security \ + -Wformat-signedness \ + -Wformat-y2k \ + -Wformat-zero-length \ + -Wframe-address \ + -Wfree-nonheap-object \ + -Whsa \ + -Wif-not-aligned \ + -Wignored-attributes \ + -Wignored-qualifiers \ + -Wimplicit \ + -Wimplicit-function-declaration \ + -Wimplicit-int \ + -Wincompatible-pointer-types \ + -Winit-self \ + -Winline \ + -Wint-conversion \ + -Wint-in-bool-context \ + -Wint-to-pointer-cast \ + -Winvalid-memory-model \ + -Winvalid-pch \ + -Wlogical-not-parentheses \ + -Wlogical-op \ + -Wmain \ + -Wmaybe-uninitialized \ + -Wmemset-elt-size \ + -Wmemset-transposed-args \ + -Wmisleading-indentation \ + -Wmissing-attributes \ + -Wmissing-braces \ + -Wmissing-declarations \ + -Wmissing-field-initializers \ + -Wmissing-include-dirs \ + -Wmissing-parameter-type \ + -Wmissing-profile \ + -Wmissing-prototypes \ + -Wmultichar \ + -Wmultistatement-macros \ + -Wnarrowing \ + -Wnested-externs \ + -Wnonnull \ + -Wnonnull-compare \ + -Wnull-dereference \ + -Wodr \ + -Wold-style-declaration \ + -Wold-style-definition \ + -Wopenmp-simd \ + -Woverflow \ + -Woverlength-strings \ + -Woverride-init \ + -Wpacked \ + -Wpacked-bitfield-compat \ + -Wpacked-not-aligned \ + -Wparentheses \ + -Wpointer-arith \ + -Wpointer-compare \ + -Wpointer-sign \ + -Wpointer-to-int-cast \ + -Wpragmas \ + -Wpsabi \ + -Wrestrict \ + -Wreturn-local-addr \ + -Wreturn-type \ + -Wscalar-storage-order \ + -Wsequence-point \ + -Wshadow \ + -Wshift-count-negative \ + -Wshift-count-overflow \ + -Wshift-negative-value \ + -Wsizeof-array-argument \ + -Wsizeof-pointer-div \ + -Wsizeof-pointer-memaccess \ + -Wstack-protector \ + -Wstrict-aliasing \ + -Wstrict-overflow \ + -Wstrict-prototypes \ + -Wstringop-truncation \ + -Wsuggest-attribute=3Dcold \ + -Wsuggest-attribute=3Dconst \ + -Wsuggest-attribute=3Dformat \ + -Wsuggest-attribute=3Dmalloc \ + -Wsuggest-attribute=3Dnoreturn \ + -Wsuggest-attribute=3Dpure \ + -Wsuggest-final-methods \ + -Wsuggest-final-types \ + -Wswitch \ + -Wswitch-bool \ + -Wswitch-unreachable \ + -Wsync-nand \ + -Wsystem-headers \ + -Wtautological-compare \ + -Wtrampolines \ + -Wtrigraphs \ + -Wtype-limits \ + -Wuninitialized \ + -Wunknown-pragmas \ + -Wunsafe-loop-optimizations \ + -Wunused \ + -Wunused-but-set-parameter \ + -Wunused-but-set-variable \ + -Wunused-function \ + -Wunused-label \ + -Wunused-local-typedefs \ + -Wunused-macros \ + -Wunused-parameter \ + -Wunused-result \ + -Wunused-value \ + -Wunused-variable \ + -Wvarargs \ + -Wvariadic-macros \ + -Wvector-operation-performance \ + -Wvla \ + -Wvolatile-register-var \ + -Wwrite-strings \ + \ + ; do + gl_manywarn_set=3D"$gl_manywarn_set $gl_manywarn_item" + done + + # gcc --help=3Dwarnings outputs an unusual form for these options; list + # them here so that the above 'comm' command doesn't report a false matc= h. + # Would prefer "min (PTRDIFF_MAX, SIZE_MAX)", but it must be a literal. + # Also, AC_COMPUTE_INT requires it to fit in a long; it is 2**63 on + # the only platforms where it does not fit in a long, so make that + # a special case. + AC_MSG_CHECKING([max safe object size]) + AC_COMPUTE_INT([gl_alloc_max], + [LONG_MAX < (PTRDIFF_MAX < (size_t) -1 ? PTRDIFF_MAX : (size_t) -1) + ? -1 + : PTRDIFF_MAX < (size_t) -1 ? (long) PTRDIFF_MAX : (long) (size_t) -1= ], + [[#include + #include + #include + ]], + [gl_alloc_max=3D2147483647]) + case $gl_alloc_max in + -1) gl_alloc_max=3D9223372036854775807;; + esac + AC_MSG_RESULT([$gl_alloc_max]) + gl_manywarn_set=3D"$gl_manywarn_set -Walloc-size-larger-than=3D$gl_alloc= _max" + gl_manywarn_set=3D"$gl_manywarn_set -Warray-bounds=3D2" + gl_manywarn_set=3D"$gl_manywarn_set -Wattribute-alias=3D2" + gl_manywarn_set=3D"$gl_manywarn_set -Wformat-overflow=3D2" + gl_manywarn_set=3D"$gl_manywarn_set -Wformat-truncation=3D2" + gl_manywarn_set=3D"$gl_manywarn_set -Wimplicit-fallthrough=3D5" + gl_manywarn_set=3D"$gl_manywarn_set -Wnormalized=3Dnfc" + gl_manywarn_set=3D"$gl_manywarn_set -Wshift-overflow=3D2" + gl_manywarn_set=3D"$gl_manywarn_set -Wstringop-overflow=3D2" + gl_manywarn_set=3D"$gl_manywarn_set -Wunused-const-variable=3D2" + gl_manywarn_set=3D"$gl_manywarn_set -Wvla-larger-than=3D4031" + + # These are needed for older GCC versions. + if test -n "$GCC"; then + case `($CC --version) 2>/dev/null` in + 'gcc (GCC) '[[0-3]].* | \ + 'gcc (GCC) '4.[[0-7]].*) + gl_manywarn_set=3D"$gl_manywarn_set -fdiagnostics-show-option" + gl_manywarn_set=3D"$gl_manywarn_set -funit-at-a-time" + ;; + esac + fi + + # Disable specific options as needed. + if test "$gl_cv_cc_nomfi_needed" =3D yes; then + gl_manywarn_set=3D"$gl_manywarn_set -Wno-missing-field-initializers" + fi + + if test "$gl_cv_cc_uninitialized_supported" =3D no; then + gl_manywarn_set=3D"$gl_manywarn_set -Wno-uninitialized" + fi + + $1=3D$gl_manywarn_set + + AC_LANG_POP([C]) +]) + +# Specialization for _AC_LANG =3D C++. +# Use of m4_defun rather than AC_DEFUN works around a bug in autoconf < 2.= 63b. +m4_defun([gl_MANYWARN_ALL_GCC(C++)], +[ + gl_MANYWARN_ALL_GCC_CXX_IMPL([$1]) +]) diff --git a/m4/virt-warnings.m4 b/m4/virt-warnings.m4 new file mode 100644 index 0000000000..d272365f0a --- /dev/null +++ b/m4/virt-warnings.m4 @@ -0,0 +1,115 @@ +# warnings.m4 serial 14 +dnl Copyright (C) 2008-2020 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Simon Josefsson + +# gl_AS_VAR_APPEND(VAR, VALUE) +# ---------------------------- +# Provide the functionality of AS_VAR_APPEND if Autoconf does not have it. +m4_ifdef([AS_VAR_APPEND], +[m4_copy([AS_VAR_APPEND], [gl_AS_VAR_APPEND])], +[m4_define([gl_AS_VAR_APPEND], +[AS_VAR_SET([$1], [AS_VAR_GET([$1])$2])])]) + + +# gl_COMPILER_OPTION_IF(OPTION, [IF-SUPPORTED], [IF-NOT-SUPPORTED], +# [PROGRAM =3D AC_LANG_PROGRAM()]) +# ----------------------------------------------------------------- +# Check if the compiler supports OPTION when compiling PROGRAM. +# +# The effects of this macro depend on the current language (_AC_LANG). +AC_DEFUN([gl_COMPILER_OPTION_IF], +[ +dnl FIXME: gl_Warn must be used unquoted until we can assume Autoconf +dnl 2.64 or newer. +AS_VAR_PUSHDEF([gl_Warn], [gl_cv_warn_[]_AC_LANG_ABBREV[]_$1])dnl +AS_VAR_PUSHDEF([gl_Flags], [_AC_LANG_PREFIX[]FLAGS])dnl +AS_LITERAL_IF([$1], + [m4_pushdef([gl_Positive], m4_bpatsubst([$1], [^-Wno-], [-W]))], + [gl_positive=3D"$1" +case $gl_positive in + -Wno-*) gl_positive=3D-W`expr "X$gl_positive" : 'X-Wno-\(.*\)'` ;; +esac +m4_pushdef([gl_Positive], [$gl_positive])])dnl +AC_CACHE_CHECK([whether _AC_LANG compiler handles $1], m4_defn([gl_Warn]),= [ + gl_save_compiler_FLAGS=3D"$gl_Flags" + gl_AS_VAR_APPEND(m4_defn([gl_Flags]), + [" $gl_unknown_warnings_are_errors ]m4_defn([gl_Positive])["]) + AC_LINK_IFELSE([m4_default([$4], [AC_LANG_PROGRAM([])])], + [AS_VAR_SET(gl_Warn, [yes])], + [AS_VAR_SET(gl_Warn, [no])]) + gl_Flags=3D"$gl_save_compiler_FLAGS" +]) +AS_VAR_IF(gl_Warn, [yes], [$2], [$3]) +m4_popdef([gl_Positive])dnl +AS_VAR_POPDEF([gl_Flags])dnl +AS_VAR_POPDEF([gl_Warn])dnl +]) + +# gl_UNKNOWN_WARNINGS_ARE_ERRORS +# ------------------------------ +# Clang doesn't complain about unknown warning options unless one also +# specifies -Wunknown-warning-option -Werror. Detect this. +# +# The effects of this macro depend on the current language (_AC_LANG). +AC_DEFUN([gl_UNKNOWN_WARNINGS_ARE_ERRORS], +[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)]) + +# Specialization for _AC_LANG =3D C. This macro can be AC_REQUIREd. +# Use of m4_defun rather than AC_DEFUN works around a bug in autoconf < 2.= 63b. +m4_defun([gl_UNKNOWN_WARNINGS_ARE_ERRORS(C)], +[ + AC_LANG_PUSH([C]) + gl_UNKNOWN_WARNINGS_ARE_ERRORS_IMPL + AC_LANG_POP([C]) +]) + +# Specialization for _AC_LANG =3D C++. This macro can be AC_REQUIREd. +# Use of m4_defun rather than AC_DEFUN works around a bug in autoconf < 2.= 63b. +m4_defun([gl_UNKNOWN_WARNINGS_ARE_ERRORS(C++)], +[ + AC_LANG_PUSH([C++]) + gl_UNKNOWN_WARNINGS_ARE_ERRORS_IMPL + AC_LANG_POP([C++]) +]) + +# Specialization for _AC_LANG =3D Objective C. This macro can be AC_REQUIR= Ed. +# Use of m4_defun rather than AC_DEFUN works around a bug in autoconf < 2.= 63b. +m4_defun([gl_UNKNOWN_WARNINGS_ARE_ERRORS(Objective C)], +[ + AC_LANG_PUSH([Objective C]) + gl_UNKNOWN_WARNINGS_ARE_ERRORS_IMPL + AC_LANG_POP([Objective C]) +]) + +AC_DEFUN([gl_UNKNOWN_WARNINGS_ARE_ERRORS_IMPL], +[gl_COMPILER_OPTION_IF([-Werror -Wunknown-warning-option], + [gl_unknown_warnings_are_errors=3D'-Wunknown-warning-option -Werror'], + [gl_unknown_warnings_are_errors=3D])]) + +# gl_WARN_ADD(OPTION, [VARIABLE =3D WARN_CFLAGS/WARN_CXXFLAGS], +# [PROGRAM =3D AC_LANG_PROGRAM()]) +# ----------------------------------------------------------- +# Adds parameter to WARN_CFLAGS/WARN_CXXFLAGS if the compiler supports it +# when compiling PROGRAM. For example, gl_WARN_ADD([-Wparentheses]). +# +# If VARIABLE is a variable name, AC_SUBST it. +# +# The effects of this macro depend on the current language (_AC_LANG). +AC_DEFUN([gl_WARN_ADD], +[AC_REQUIRE([gl_UNKNOWN_WARNINGS_ARE_ERRORS(]_AC_LANG[)]) +gl_COMPILER_OPTION_IF([$1], + [gl_AS_VAR_APPEND(m4_if([$2], [], [[WARN_]_AC_LANG_PREFIX[FLAGS]], [[$2]= ]), [" $1"])], + [], + [$3]) +m4_ifval([$2], + [AS_LITERAL_IF([$2], [AC_SUBST([$2])])], + [AC_SUBST([WARN_]_AC_LANG_PREFIX[FLAGS])])dnl +]) + +# Local Variables: +# mode: autoconf +# End: --=20 2.24.1