From patchwork Wed Feb 21 01:03:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Emilio Cota X-Patchwork-Id: 10231131 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3C374602A7 for ; Wed, 21 Feb 2018 01:04:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2DD9828A00 for ; Wed, 21 Feb 2018 01:04:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 21E9328A04; Wed, 21 Feb 2018 01:04:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EF37A28A00 for ; Wed, 21 Feb 2018 01:04:13 +0000 (UTC) Received: from localhost ([::1]:58558 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoIpO-0001cL-Op for patchwork-qemu-devel@patchwork.kernel.org; Tue, 20 Feb 2018 20:04:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51533) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoIoe-0001GD-4K for qemu-devel@nongnu.org; Tue, 20 Feb 2018 20:03:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eoIoY-0008K8-Ty for qemu-devel@nongnu.org; Tue, 20 Feb 2018 20:03:24 -0500 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:50791) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eoIoY-0008JP-MI for qemu-devel@nongnu.org; Tue, 20 Feb 2018 20:03:18 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 0E83A20D04; Tue, 20 Feb 2018 20:03:16 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute4.internal (MEProxy); Tue, 20 Feb 2018 20:03:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h=cc :content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= mesmtp; bh=7JSAxZtEjgdnPUOiB259cQgzhVzwBPs0GDC4cnti3wM=; b=w/C4o hCzAyKzv7D4IAdjK9I+ZTm0GGlb9hp7oT+rTGMJek/OWwBELQatwH4/PokBj5ylm TeFIRPx272Zq/lgMy+5hJyMskoPoyZ85+xJHEFuTQhG7WZGxr3mvScam1RyhpgQ5 rO8CZAjWeGqb0H7xiiQU4MIinkYWUoLXx6+bQ0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=7JSAxZtEjgdnPUOiB259cQgzhVzwB Ps0GDC4cnti3wM=; b=Je64qkERMptlW3kwT10QsZ4ma75r12a7GisCN5+Pp2tDk D83DEaWNVJrhP/soReAFipb3ou075jEsjqtYw1p/a4YZE2cCh6JS9BOTau2dwUVx dJUJqMziNHJDFy1q/USXYBow7TZrPQuUITBjetsVy29KPKe/R1mvCWN6fNx68dQd ih9Y/pzfmcCokXGMjutHdD6d9tZpDpR/kTaX8OBAyWdeOVWltDAUrHLhtzGyWd+h 00GCHhc172beVrAdzmXXVMFFcFphED4SWv7zAkb2yYkj1WhlfRCFsJ5pubBX0v5o jMjDQSovPZ+GVWrXIkvx4HV3zf0v9GxQx60ynPh+w== X-ME-Sender: Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id BD65624434; Tue, 20 Feb 2018 20:03:15 -0500 (EST) From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Tue, 20 Feb 2018 20:03:15 -0500 Message-Id: <1519174995-1039-1-git-send-email-cota@braap.org> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.111.4.26 Subject: [Qemu-devel] [PATCH] configure: fix sanitizers' test program to mend ASan detection X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Commit 218bb57 ("build-sys: check static linking of UBSAN", 2018-02-13) adds a small test program to check whether ubsan works even when configuring with --static. This added program is used to detect all sanitizers, which breaks ASan's detection since the compilation fails with -fsanitize=address, at least with gcc 5.4.0 and 7.2.0: qemu-conf.c: In function ‘main’: qemu-conf.c:3:20: error: integer overflow in expression [-Werror=overflow] return INT32_MIN / -1; ^ cc1: all warnings being treated as errors Fix it by: - Changing the test program to one that incurs undefined behaviour that isn't detected at compile-time, even with -fsanitize=address. - To be extra safe (since compilers might evolve and eventually figure out the UB at compile-time), use this newly-added test only when checking for UBSan; use the skeleton otherwise. Signed-off-by: Emilio G. Cota --- configure | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/configure b/configure index 913e148..56f647f 100755 --- a/configure +++ b/configure @@ -5306,13 +5306,13 @@ fi ########################################## # checks for sanitizers -# we could use a simple skeleton for flags checks, but this also -# detect the static linking issue of ubsan, see also: +# Use this program to detect the static linking issue of ubsan; see # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285 cat > $TMPC << EOF -#include -int main(void) { - return INT32_MIN / -1; +int main(int argc, char **argv) { + int k = 0x7fffffff; + k += argc; + return 0; } EOF @@ -5322,12 +5322,16 @@ have_asan_iface_h=no have_asan_iface_fiber=no if test "$sanitizers" = "yes" ; then + if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then + have_ubsan=yes + fi + + # Use the skeleton for all other sanitizer checks + write_c_skeleton + if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then have_asan=yes fi - if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then - have_ubsan=yes - fi if check_include "sanitizer/asan_interface.h" ; then have_asan_iface_h=yes