From patchwork Thu Nov 7 01:08:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Wendling X-Patchwork-Id: 11231475 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CF82E1599 for ; Thu, 7 Nov 2019 01:09:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A9E0F21848 for ; Thu, 7 Nov 2019 01:09:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="I+1tX8Kl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728366AbfKGBJC (ORCPT ); Wed, 6 Nov 2019 20:09:02 -0500 Received: from mail-pg1-f202.google.com ([209.85.215.202]:32996 "EHLO mail-pg1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728265AbfKGBJB (ORCPT ); Wed, 6 Nov 2019 20:09:01 -0500 Received: by mail-pg1-f202.google.com with SMTP id y22so445107pgc.0 for ; Wed, 06 Nov 2019 17:08:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=iswOSk/cZ98lnJ7BbrIe/h5JrJo81nLP88Lj3jwN4P0=; b=I+1tX8Kl7CXMH+Hz830Y99VMAsMZ/b0El9mFJo3kNwnTRCRKWTpejQKLJz20nv/OFe aY/7fDUshnB/CXOrTmjqlJJqueTT6+ZQmqi5CsZu4JlI2rFwqnDSRTiQGTRX6j3WQIQK d+BR6uV3C9YPNk1NrZ2wKNkvfQDdwKnBWaCtusdaUgBFiFOpdjgQCT1TGxEm9M+pgaIS GM9Z3lWasxEWBCg/YvWkip79fADKf4C+LlXqw+6ZqD/NXfu0vCmMKJkjL9zfaKc1Zjl/ uTdG7WNYvP3umgQGATBdMPUgQv3p7SYEZHJ6O3HCXYc50K97nd1O1PDB5VT9O38GquQK WMSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=iswOSk/cZ98lnJ7BbrIe/h5JrJo81nLP88Lj3jwN4P0=; b=m5gmn709sN45028aH/oRVZnxUYMDm1m4E8Wx78YomH//KbfMWsWPfinLKRmDfxIld+ 9UxK2Noaqzflr9dY3Ph4XEQDssrgx7N3IiEIxbfxjHRNKY4NE5/zo4NxpXHyX2ee6QhQ aQm0Zq3vuGESzXaA986XqDBe44xXVCaLp06zBKdkPjtHv9uaqMVJ8slpCKaf9Eec8Rl1 UY3laZpuVBn1aD03VzFn14SMxWEbfdNyNkACxcnX1Fu+AGSdalUFSzdXBlFpR0+2wuAO fdj1wDJOyWZ4ev6eFO6uLPPQAQ7doQPqKqmOVqG9WSO8uJK+/E1e1fn1ETIrf2aj/ohq Zx5Q== X-Gm-Message-State: APjAAAVuLqIySOU6l34gdddiDI+1xsgwDpA7FkS0FQPA59cXnAZiVJhM cJDDi3T4EuB+j/o1MifLpakwPHUZNd93Z9ZvDBssEPLluAZIsirn4YXJG8DVxEBf8V+UP2bsMJs lG742J0xLG7Ft5YYxd41JrS1PqIWDkB3A79ssl46tYIx2AAhlkmCwdw== X-Google-Smtp-Source: APXvYqy3gJ0/ynp+CqtY1t9JZ1HQVt0j6B0OPz6rLFZltcjSIj+bbBu1JCmx2qwRT0x92C4m93R1Yf342w== X-Received: by 2002:a63:1323:: with SMTP id i35mr1039144pgl.450.1573088939030; Wed, 06 Nov 2019 17:08:59 -0800 (PST) Date: Wed, 6 Nov 2019 17:08:43 -0800 In-Reply-To: <20191107010844.101059-1-morbo@google.com> Message-Id: <20191107010844.101059-2-morbo@google.com> Mime-Version: 1.0 References: <20191107010844.101059-1-morbo@google.com> X-Mailer: git-send-email 2.24.0.rc1.363.gb1bccd3e3d-goog Subject: [kvm-unit-tests PATCH 1/2] Makefile: use "-Werror" in cc-option From: Bill Wendling To: kvm@vger.kernel.org, pbonzini@redhat.com Cc: jmattson@google.com, Bill Wendling Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The "cc-option" macro should use "-Werror" to determine if a flag is supported. Otherwise the test may not return a nonzero result. Also conditionalize some of the warning flags which aren't supported by clang. Signed-off-by: Bill Wendling Reviewed-by: Thomas Huth --- Makefile | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 32414dc..4c716da 100644 --- a/Makefile +++ b/Makefile @@ -46,13 +46,13 @@ include $(SRCDIR)/$(TEST_DIR)/Makefile # cc-option # Usage: OP_CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0) -cc-option = $(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null \ +cc-option = $(shell if $(CC) -Werror $(1) -S -o /dev/null -xc /dev/null \ > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;) COMMON_CFLAGS += -g $(autodepend-flags) -COMMON_CFLAGS += -Wall -Wwrite-strings -Wclobbered -Wempty-body -Wuninitialized -COMMON_CFLAGS += -Wignored-qualifiers -Wunused-but-set-parameter -COMMON_CFLAGS += -Werror +COMMON_CFLAGS += -Wall -Wwrite-strings -Wempty-body -Wuninitialized +COMMON_CFLAGS += -Wignored-qualifiers -Werror + frame-pointer-flag=-f$(if $(KEEP_FRAME_POINTER),no-,)omit-frame-pointer fomit_frame_pointer := $(call cc-option, $(frame-pointer-flag), "") fnostack_protector := $(call cc-option, -fno-stack-protector, "") @@ -60,16 +60,24 @@ fnostack_protector_all := $(call cc-option, -fno-stack-protector-all, "") wno_frame_address := $(call cc-option, -Wno-frame-address, "") fno_pic := $(call cc-option, -fno-pic, "") no_pie := $(call cc-option, -no-pie, "") +wclobbered := $(call cc-option, -Wclobbered, "") +wunused_but_set_parameter := $(call cc-option, -Wunused-but-set-parameter, "") +wmissing_parameter_type := $(call cc-option, -Wmissing-parameter-type, "") +wold_style_declaration := $(call cc-option, -Wold-style-declaration, "") + COMMON_CFLAGS += $(fomit_frame_pointer) COMMON_CFLAGS += $(fno_stack_protector) COMMON_CFLAGS += $(fno_stack_protector_all) COMMON_CFLAGS += $(wno_frame_address) COMMON_CFLAGS += $(if $(U32_LONG_FMT),-D__U32_LONG_FMT__,) COMMON_CFLAGS += $(fno_pic) $(no_pie) +COMMON_CFLAGS += $(wclobbered) +COMMON_CFLAGS += $(wunused_but_set_parameter) CFLAGS += $(COMMON_CFLAGS) -CFLAGS += -Wmissing-parameter-type -Wold-style-declaration -Woverride-init -CFLAGS += -Wmissing-prototypes -Wstrict-prototypes +CFLAGS += $(wmissing_parameter_type) +CFLAGS += $(wold_style_declaration) +CFLAGS += -Woverride-init -Wmissing-prototypes -Wstrict-prototypes CXXFLAGS += $(COMMON_CFLAGS) From patchwork Thu Nov 7 01:08:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Wendling X-Patchwork-Id: 11231477 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9878D1599 for ; Thu, 7 Nov 2019 01:09:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 73EC221848 for ; Thu, 7 Nov 2019 01:09:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="gvLdfGSI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732689AbfKGBJE (ORCPT ); Wed, 6 Nov 2019 20:09:04 -0500 Received: from mail-pg1-f202.google.com ([209.85.215.202]:57338 "EHLO mail-pg1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725989AbfKGBJD (ORCPT ); Wed, 6 Nov 2019 20:09:03 -0500 Received: by mail-pg1-f202.google.com with SMTP id 11so395655pgm.23 for ; Wed, 06 Nov 2019 17:09:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=wCVCgwDANVIGIxCeEGctye8R+7lP7DshFbaab6MvEoc=; b=gvLdfGSIe6tXg1Q1iHltg/tBMaN6XZVeV87ue4/qdDx6HZVtKG20VlJM6KBTo3BVdb Z+veG92zi4nm00dVgR3/ksVbSaEjXkvecDAxb1ZRBW+0SOLH/YYdi1+PJnkxIJxCCiO/ zIEiYwRzigtZnmtRmd5O+dat+zAXONYQU0tdUa3nQh/X93/n3bvMf8EBnhSeZR+5qqrg eeRtoq1pUVl493iu5kuevmI2PYv2VbkLtbByDbk0V5d1btC1WRVmCX8wUolTBUoWBm9O zZCtJHtDWnMc5uGnICPrNc6gRae7X873hwVfTAcUrNRw/+izMxXY99o7aYoH8Ccf6iLd QKhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=wCVCgwDANVIGIxCeEGctye8R+7lP7DshFbaab6MvEoc=; b=mcBB1YSj8GTUNb9qzpdYOzYsXyYhX6NRX0SgqeXYqquhyB/NKt37WkO8/2Rr9He07F k6bwFyPzU49Nlu1rCKKK3VAETKcrcThhNPgMkRBNfi6jRLwG7CSfnPuNVz2On9vMZxQh VSSPYj1T+VaYgCJtI7J1M+pGeFo8LBWOWj3RfGngGxQBfqb10OErIosAyDe1MVmKV6eU 9iAyRs9Yv2Qh/0R/C+AMByrYozDS86m5HkSyyGOMYmDTu+tiJS+Q8MTfCASlYmuZee7W mSiN09augfU66m5ccynmjgDrpKwFUwhiFmO8QwlYbvG8f2YBBMRi0twJZIG0wT7TKDVD RPxQ== X-Gm-Message-State: APjAAAXI5mKsZJSwglWb1blQ8lyHbvI88uxDn209cQY/aieG/98xriQg CdnNYydwaR9Otwouqq021EZO16zXo4Hlvtz3dSKbqYEhs2R7IbXjwMinPTG4ffDpA9w+9vPjZIa oBlxE0PMJu6dLuJoSSxATpzNuTociul4KMMOBkTZ+DI84tSxWpfiAZQ== X-Google-Smtp-Source: APXvYqwGU38QKUG5yK6xcv4PG0DKHW1Kiqm7mt0rMEn8GMIMQRuA4/NDa1bW/CjueqS/vfvAu/ZuKcaVVg== X-Received: by 2002:a65:5303:: with SMTP id m3mr970458pgq.400.1573088941471; Wed, 06 Nov 2019 17:09:01 -0800 (PST) Date: Wed, 6 Nov 2019 17:08:44 -0800 In-Reply-To: <20191107010844.101059-1-morbo@google.com> Message-Id: <20191107010844.101059-3-morbo@google.com> Mime-Version: 1.0 References: <20191107010844.101059-1-morbo@google.com> X-Mailer: git-send-email 2.24.0.rc1.363.gb1bccd3e3d-goog Subject: [kvm-unit-tests PATCH 2/2] Makefile: add "cxx-option" for C++ builds From: Bill Wendling To: kvm@vger.kernel.org, pbonzini@redhat.com Cc: jmattson@google.com, Bill Wendling Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The C++ compiler may not support all of the same flags as the C compiler. Add a separate test for these flags. Signed-off-by: Bill Wendling --- Makefile | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 4c716da..9cb47e6 100644 --- a/Makefile +++ b/Makefile @@ -48,6 +48,8 @@ include $(SRCDIR)/$(TEST_DIR)/Makefile cc-option = $(shell if $(CC) -Werror $(1) -S -o /dev/null -xc /dev/null \ > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;) +cxx-option = $(shell if $(CXX) -Werror $(1) -S -o /dev/null -xc++ /dev/null \ + > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;) COMMON_CFLAGS += -g $(autodepend-flags) COMMON_CFLAGS += -Wall -Wwrite-strings -Wempty-body -Wuninitialized @@ -62,8 +64,6 @@ fno_pic := $(call cc-option, -fno-pic, "") no_pie := $(call cc-option, -no-pie, "") wclobbered := $(call cc-option, -Wclobbered, "") wunused_but_set_parameter := $(call cc-option, -Wunused-but-set-parameter, "") -wmissing_parameter_type := $(call cc-option, -Wmissing-parameter-type, "") -wold_style_declaration := $(call cc-option, -Wold-style-declaration, "") COMMON_CFLAGS += $(fomit_frame_pointer) COMMON_CFLAGS += $(fno_stack_protector) @@ -75,11 +75,19 @@ COMMON_CFLAGS += $(wclobbered) COMMON_CFLAGS += $(wunused_but_set_parameter) CFLAGS += $(COMMON_CFLAGS) +CXXFLAGS += $(COMMON_CFLAGS) + +wmissing_parameter_type := $(call cc-option, -Wmissing-parameter-type, "") +wold_style_declaration := $(call cc-option, -Wold-style-declaration, "") CFLAGS += $(wmissing_parameter_type) CFLAGS += $(wold_style_declaration) CFLAGS += -Woverride-init -Wmissing-prototypes -Wstrict-prototypes -CXXFLAGS += $(COMMON_CFLAGS) +# Clang's C++ compiler doesn't support some of the flags its C compiler does. +wmissing_parameter_type := $(call cxx-option, -Wmissing-parameter-type, "") +wold_style_declaration := $(call cxx-option, -Wold-style-declaration, "") +CXXFLAGS += $(wmissing_parameter_type) +CXXFLAGS += $(wold_style_declaration) autodepend-flags = -MMD -MF $(dir $*).$(notdir $*).d