From patchwork Tue Jun 13 23:08:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Kaehlcke X-Patchwork-Id: 9784929 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 58D6C60244 for ; Tue, 13 Jun 2017 23:10:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B7542858D for ; Tue, 13 Jun 2017 23:10:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4034928595; Tue, 13 Jun 2017 23:10:58 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA9E42858D for ; Tue, 13 Jun 2017 23:10:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754058AbdFMXK5 (ORCPT ); Tue, 13 Jun 2017 19:10:57 -0400 Received: from mail-pg0-f47.google.com ([74.125.83.47]:35090 "EHLO mail-pg0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753217AbdFMXJ6 (ORCPT ); Tue, 13 Jun 2017 19:09:58 -0400 Received: by mail-pg0-f47.google.com with SMTP id k71so66715487pgd.2 for ; Tue, 13 Jun 2017 16:09:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VTcIO0+pgjucDJVttO4IHP9cdGJhWj55PTnhmO//FKo=; b=ieJvGl7Yre+DJuI/pNhegSffnQRpl9lln5eQFCdeDEPF2zq/wJdbD2lkYXCzf4I53A NsAt17hgNJR9re6I4LrwdFitQLPV+l4UTCdxwayOGxHlSvu5+eA0NBuYZx0fzTcgidf3 lAvHO0XTnqR4E2S+njeENyNAViV8H0n9eDXiKx4gVmtv+84IIgCoEShi8TTtXiiQxIo9 WttVCEiV+fLdFpgp2fA/rW5lqRxby4Oa3vPAKkVGcWuF1VTRR9+KgyO5zUA8FFHzQNIL SJcehhq8kcaRkPZhQXCDP4bB1Nrp63V1Dhg/uGlsqkMc12rxG0Dg+Ro+axb4TwuLiS0t lTKw== X-Gm-Message-State: AKS2vOxUnVrhny+z6nQYM6Jp3Im98kaQwpkFTAH9HlzTbIu2vlAr6ixu AjfR0ZE4K/Rl7777 X-Received: by 10.84.130.33 with SMTP id 30mr1825363plc.240.1497395397227; Tue, 13 Jun 2017 16:09:57 -0700 (PDT) Received: from mka.mtv.corp.google.com ([172.22.64.162]) by smtp.gmail.com with ESMTPSA id e18sm29179939pfk.118.2017.06.13.16.09.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Jun 2017 16:09:56 -0700 (PDT) From: Matthias Kaehlcke To: Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , "H . J . Lu" , David Woodhouse , Masahiro Yamada , Michal Marek Cc: x86@kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Davidson , Greg Hackmann , Nick Desaulniers , Stephen Hines , Kees Cook , Arnd Bergmann , Bernhard.Rosenkranzer@linaro.org, Peter Foley , Behan Webster , Douglas Anderson , Matthias Kaehlcke Subject: [PATCH v2 1/4] kbuild: Add cc-option-raw macro Date: Tue, 13 Jun 2017 16:08:51 -0700 Message-Id: <20170613230854.112282-2-mka@chromium.org> X-Mailer: git-send-email 2.13.1.518.g3df882009-goog In-Reply-To: <20170613230854.112282-1-mka@chromium.org> References: <20170613230854.112282-1-mka@chromium.org> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP cc-option uses KBUILD_CFLAGS and KBUILD_CPPFLAGS when it determines whether an option is supported or not. This is fine for options used to build the kernel itself, however some components like the x86 boot code use a different set of flags. Add the new macro cc-option-raw which serves the same purpose as cc-option but has additional parameters. One parameter is the compiler with which the check should be performed, the other the compiler options to be used instead KBUILD_C*FLAGS. The compiler parameter allows other macros like hostcc-option to be implemented on top of cc-option-raw. Also rework cc-option to make use of cc-option-raw. Suggested-by: Arnd Bergmann Suggested-by: Masahiro Yamada Signed-off-by: Matthias Kaehlcke Acked-by: Masahiro Yamada Acked-by: Arnd Bergmann Acked-by: Michal Marek --- Changes in v2: - Changed macro name from Add cc-option-no-kbuild to cc-option-raw - Added compiler as parameter to the macro - Reworked cc-option to make use of cc-option-raw - Updated commit message scripts/Kbuild.include | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 61f87a99bf0a..6dd0d1a921d6 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -108,6 +108,11 @@ as-option = $(call try-run,\ as-instr = $(call try-run,\ printf "%b\n" "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3)) +# cc-option-raw +# Usage: MY_CFLAGS += $(call cc-option-raw,$(CC),$(MY_CFLAGS),-march=winchip-c6,-march=i586) +cc-option-raw = $(call try-run,\ + $(1) -Werror $(2) $(3) -c -x c /dev/null -o "$$TMP",$(3),$(4)) + # Do not attempt to build with gcc plugins during cc-option tests. # (And this uses delayed resolution so the flags will be up to date.) CC_OPTION_CFLAGS = $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS)) @@ -115,8 +120,8 @@ CC_OPTION_CFLAGS = $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS)) # cc-option # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586) -cc-option = $(call try-run,\ - $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2)) +cc-option = $(call cc-option-raw, $(CC), $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS),\ + $(1), $(2)) # cc-option-yn # Usage: flag := $(call cc-option-yn,-march=winchip-c6)