From patchwork Mon Jun 11 03:45:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 138195 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp3560683lji; Sun, 10 Jun 2018 20:46:47 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJVrT9+MrEu0Kj4XhWfOa51btfmoMtYTKuxstJJJxQeXqhUVw/nXju/iHoneqlAwW1pNbRt X-Received: by 2002:a63:6fce:: with SMTP id k197-v6mr13408854pgc.307.1528688807665; Sun, 10 Jun 2018 20:46:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528688807; cv=none; d=google.com; s=arc-20160816; b=ZJNCopie9nuRQYe3FzdJ45sgsrj1XxYuUxBa8qck+t2CEpAVUN00DL4URAJNaSCn9Q kV3iwuGaAV1xhqB8ZUragW6O7H6QqVovzP7weYE+SL+kEc9rNriV55pzvg5j2q3WNdI/ aqhU+ONWAl95ZhYv2Eu1Mbg6NI9V7VoxC+8q0DSSAeRACnRofMJpy39r0eACzvPqRI3a DBAqFbbOtLAftNLKrhQhXamGHwigWa6FgGNoAXCUNR8YTUZyPup/xNFJuZR0FRwlnOHd ctsGEodPeMQERMOhe2vTY/Zj95mXdM9n2VW3uUbV+cM7p5rNlre53XAFAUWRCzmGtiPG i97Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter:arc-authentication-results; bh=m97PBOSOnWxXAULMiYWVvcCnl8Mo0pxtAYU/Z6qnyG4=; b=px1gX1yKUKgbN/PcQtNfefr3h/sy21ZWBFED2ErQRtUjVXC2GEmrKn3A2CXOOIjAeJ XcLVPTxmny49NGXA+/PERt4zX0wlmWeqc5QbcrxLabwOexZgKjWTP7Pgkyv+SIXt2SOt p51NrLPxX7LJFipi+z7/PP7u86f/jr5k7UZKIqw9j0Rs4a88LKLSkQ1S+Uh2IW2x13NM o+5hAnIc+SutQW2JWUqGp75Trn75kDAO5hszVbO+xiA+9SERqHtksMul3kjOPIPkb6u9 wyARzZ9xBfyIjmTAr5c/6Kp+ROmTizuO9Y9hl9ca5ndQbJuoIt7OKAdJ41WubTzAg4LL /o0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=jJxStz3h; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g4-v6si16337254pgs.322.2018.06.10.20.46.46; Sun, 10 Jun 2018 20:46:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=jJxStz3h; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753910AbeFKDqm (ORCPT + 30 others); Sun, 10 Jun 2018 23:46:42 -0400 Received: from conuserg-12.nifty.com ([210.131.2.79]:38120 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753793AbeFKDqk (ORCPT ); Sun, 10 Jun 2018 23:46:40 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-12.nifty.com with ESMTP id w5B3jXZH020626; Mon, 11 Jun 2018 12:45:33 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com w5B3jXZH020626 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1528688734; bh=m97PBOSOnWxXAULMiYWVvcCnl8Mo0pxtAYU/Z6qnyG4=; h=From:To:Cc:Subject:Date:From; b=jJxStz3hXzwshgz4/9y/zIbAsJEOn5iEjamHDp2+b0knLOJaFR9U38k+/v08Oolvh jAryA3wXQQX5e4S3VbTUcQOUxzsZBslF98Y0wTe9DO4Tb6SNzTKwQ2RIWwNdPWspLX 9unFjQMWya39j+lo5mZS3hiH6TKR4Xhc/AGgkR449KHCP6hm+eKBQcox2V3Vx0B7HJ Gz6KZJs31BpPEleZr7Kpw8zUriejL9W/+CuOrRSXtfIkBe6G/covWEj5ku64eRsh02 iv5V4n6Fho/Nxr2zI/2wIy5NP2Gj21df0tOZ06OVv2PcDya57pp1FiQjbE8q3JPomX ZK8QNcdVKtMzw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Sam Ravnborg , Linus Torvalds , Arnd Bergmann , Kees Cook , Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [RFC PATCH] kbuild: clean-up passing KCOV compiler flags Date: Mon, 11 Jun 2018 12:45:17 +0900 Message-Id: <1528688717-8500-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that the compiler support for KCOV is computed in the Kconfig phase, expensive $(call cc-option,...) calls no longer exist in scripts/Makefile.kcov . It shouldn't hurt to include scripts/Makefile.kcov everytime Kbuild descends into a sub-directory. Also, move ugly stuff from Makefile.lib to Makefile.kcov . Signed-off-by: Masahiro Yamada --- My hope is to do likewise for gcov, kasan, ubsan. gcov, kcov, kasan, ubsan need per-file (or per-directory) flag addition or removal. Currently, scripts/Makefile.lib is cluttered to handle this. If this clean-up is achieved, scripts/Makefile.lib will look like this: ---------------------->8------------------------------ include-$(CONFIG_GCOV_KERNEL) += scripts/Makefile.gcov include-$(CONFIG_KCOV) += scripts/Makefile.kcov include-$(CONFIG_KASAN) += scripts/Makefile.kasan include-$(CONFIG_UBSAN) += scripts/Makefile.ubsan include $(include-y) ---------------------->8------------------------------ I will not apply this until some more cleanups are done (hence, RFC). At least, scripts/Makefile.kasan is so complicated for now. Makefile | 1 - scripts/Makefile.kcov | 8 +++----- scripts/Makefile.lib | 8 +++----- 3 files changed, 6 insertions(+), 11 deletions(-) -- 2.7.4 diff --git a/Makefile b/Makefile index 73f0bb2..c99ca82 100644 --- a/Makefile +++ b/Makefile @@ -669,7 +669,6 @@ KBUILD_CFLAGS += $(call cc-ifversion, -lt, 0409, \ # Tell gcc to never replace conditional load with a non-conditional one KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0) -include scripts/Makefile.kcov include scripts/Makefile.gcc-plugins ifdef CONFIG_READABLE_ASM diff --git a/scripts/Makefile.kcov b/scripts/Makefile.kcov index 3d61c4b..408b776 100644 --- a/scripts/Makefile.kcov +++ b/scripts/Makefile.kcov @@ -1,9 +1,7 @@ -ifdef CONFIG_KCOV - kcov-flags-$(CONFIG_CC_HAS_SANCOV_TRACE_PC) += -fsanitize-coverage=trace-pc kcov-flags-$(CONFIG_KCOV_ENABLE_COMPARISONS) += -fsanitize-coverage=trace-cmp kcov-flags-$(CONFIG_GCC_PLUGIN_SANCOV) += -fplugin=$(objtree)/scripts/gcc-plugins/sancov_plugin.so -export CFLAGS_KCOV := $(kcov-flags-y) - -endif +_c_flags += $(if $(patsubst n%,, \ + $(KCOV_INSTRUMENT_$(basetarget).o)$(KCOV_INSTRUMENT)$(CONFIG_KCOV_INSTRUMENT_ALL)), \ + $(kcov-flags-y)) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 5af34a2b..f5bd1d3 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -126,11 +126,9 @@ _c_flags += $(if $(patsubst n%,, \ $(CFLAGS_UBSAN)) endif -ifeq ($(CONFIG_KCOV),y) -_c_flags += $(if $(patsubst n%,, \ - $(KCOV_INSTRUMENT_$(basetarget).o)$(KCOV_INSTRUMENT)$(CONFIG_KCOV_INSTRUMENT_ALL)), \ - $(CFLAGS_KCOV)) -endif +include-$(CONFIG_KCOV) += scripts/Makefile.kcov + +include $(include-y) # If building the kernel in a separate objtree expand all occurrences # of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/').