Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1737485ybt; Sat, 27 Jun 2020 18:54:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPBtIFFMm4ycx/K9tD2BZ0rPa7X6+3PHglhlT0dnDBhgV31iAY2YTdOmHAzwAAC7PnWLby X-Received: by 2002:a17:906:7d86:: with SMTP id v6mr8402091ejo.542.1593309282913; Sat, 27 Jun 2020 18:54:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593309282; cv=none; d=google.com; s=arc-20160816; b=U2m5hpuv91ZNiSWsiNeSrCJcFfDdkvkqcYuE+czWhm1nR5866dUFEnt/VIkbCQXyy0 /6G0rAGaf6P/1hxg2q+cQ4MWqyl2hfUzId+IPU4fOJ4+c85fRsJgzbk7Tdy3x3anEm5w J795UmilKAT9HUYmPPMDJbbKIcmfN13aWdDkQGPtsUt26Oo2S7//v251KXNU1e4l80LP 1gJ9RawWMUi7z/3ttHqi4g1GFdDJVb6NOO45Fg0Ag2lUNTl8PoOiwNkT0ZsVwBoZ9QSj f4Up+sa6yyQQ+ZL/VpNBrEQ/cPM2/NVoBXobdkMX4jkb68TDjGOEp+Tj5D5fx7erJ/1B 2CgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=hkY77VUGXSYac7YbrIkUecBgq7WORaGieZmySJIL5UA=; b=gCsLgL8zdvtUowozXY94NHM0+Aa62r24a2WPji+AnQoLrJBXKunmDbhjU71AxWlOCO 7hvwDurRiY2yYIpxFjQGaYGk8rjoNUbANx/lVXrE34GRjRFwPZa4KXwye55+H5CJ/Nki eY4+7bYM6kHFNKq6eqvQPM72/zSmRqVRLfRCvuDroHUQathLScIPoJXcm1iqq1fbtvSE TFITTfhrbVJCwwz61GcZZHFZbUD44J5IpIm0blsniyyvqEBeIXjwuvoBORr4yn5maInw fJ03jjp34lhvDnP+gSSZf3hO4hZ901WZp0T4znFjSSySSg5i+6zOYMY5PAHBVkwoIaM9 TPIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=ahJ3uto2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dp8si25701653ejc.281.2020.06.27.18.54.20; Sat, 27 Jun 2020 18:54:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=ahJ3uto2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726789AbgF1ByQ (ORCPT + 99 others); Sat, 27 Jun 2020 21:54:16 -0400 Received: from conuserg-09.nifty.com ([210.131.2.76]:50055 "EHLO conuserg-09.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726530AbgF1ByQ (ORCPT ); Sat, 27 Jun 2020 21:54:16 -0400 Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-09.nifty.com with ESMTP id 05S1oixP004742; Sun, 28 Jun 2020 10:50:44 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com 05S1oixP004742 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1593309045; bh=hkY77VUGXSYac7YbrIkUecBgq7WORaGieZmySJIL5UA=; h=From:To:Cc:Subject:Date:From; b=ahJ3uto2fhcnzsnIdLNU74S4vUyrlAQ4RsoPaFq9zt9MQ9rNbQLVQSS7jxeu5Q8si hZ34tVZRnliSC5lwB2mp+XhuUvw+20+ogpJbv2SrSVGwLunHSwliobc980NNYxgtNV 7KoTg5pXNDlDue+Qw95dB65tKTenO+yJoYpKMjA+pouECDFfbNgi/Gl3GphBAEx2jt JIId1nbEsdrcgnMp1nLu2y0LwNlkZ7F/kd88h+53l3Wy2U7beVZi9x+0lCqdPuAiyn xq4P1+iR/S7vXT/ZdlGa6TQaScQErK5xw4F96tYA3UgjBxvfSj1llEDfgf/+ZBEQh9 WQo1lz/K7CrLw== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada , Sami Tolvanen , Benjamin Herrenschmidt , Ingo Molnar , Michael Ellerman , Michal Marek , Paul Mackerras , Rich Felker , Russell King , Steven Rostedt , Yoshinori Sato , linux-arm-kernel@lists.infradead.org, linux-sh@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH] kbuild: introduce ccflags-remove-y and asflags-remove-y Date: Sun, 28 Jun 2020 10:50:41 +0900 Message-Id: <20200628015041.1000002-1-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org CFLAGS_REMOVE_.o works per object, that is, there is no convenient way to filter out flags for every object in a directory. Add ccflags-remove-y and asflags-remove-y to make it easily. Use ccflags-remove-y to clean up some Makefiles. Suggested-by: Sami Tolvanen Signed-off-by: Masahiro Yamada --- arch/arm/boot/compressed/Makefile | 6 +----- arch/powerpc/xmon/Makefile | 3 +-- arch/sh/boot/compressed/Makefile | 5 +---- kernel/trace/Makefile | 4 ++-- lib/Makefile | 5 +---- scripts/Makefile.lib | 4 ++-- 6 files changed, 8 insertions(+), 19 deletions(-) diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile index 00602a6fba04..3d5691b23951 100644 --- a/arch/arm/boot/compressed/Makefile +++ b/arch/arm/boot/compressed/Makefile @@ -103,13 +103,9 @@ clean-files += piggy_data lib1funcs.S ashldi3.S bswapsdi2.S hyp-stub.S KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING -ifeq ($(CONFIG_FUNCTION_TRACER),y) -ORIG_CFLAGS := $(KBUILD_CFLAGS) -KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS)) -endif - ccflags-y := -fpic $(call cc-option,-mno-single-pic-base,) -fno-builtin \ -I$(obj) $(DISABLE_ARM_SSP_PER_TASK_PLUGIN) +ccflags-remove-$(CONFIG_FUNCTION_TRACER) += -pg asflags-y := -DZIMAGE # Supply kernel BSS size to the decompressor via a linker symbol. diff --git a/arch/powerpc/xmon/Makefile b/arch/powerpc/xmon/Makefile index 89c76ca35640..55cbcdd88ac0 100644 --- a/arch/powerpc/xmon/Makefile +++ b/arch/powerpc/xmon/Makefile @@ -7,8 +7,7 @@ UBSAN_SANITIZE := n KASAN_SANITIZE := n # Disable ftrace for the entire directory -ORIG_CFLAGS := $(KBUILD_CFLAGS) -KBUILD_CFLAGS = $(subst $(CC_FLAGS_FTRACE),,$(ORIG_CFLAGS)) +ccflags-remove-y += $(CC_FLAGS_FTRACE) ifdef CONFIG_CC_IS_CLANG # clang stores addresses on the stack causing the frame size to blow diff --git a/arch/sh/boot/compressed/Makefile b/arch/sh/boot/compressed/Makefile index ad0e2403e56f..589d2d8a573d 100644 --- a/arch/sh/boot/compressed/Makefile +++ b/arch/sh/boot/compressed/Makefile @@ -28,10 +28,7 @@ IMAGE_OFFSET := $(shell /bin/bash -c 'printf "0x%08x" \ $(CONFIG_BOOT_LINK_OFFSET)]') endif -ifeq ($(CONFIG_MCOUNT),y) -ORIG_CFLAGS := $(KBUILD_CFLAGS) -KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS)) -endif +ccflags-remove-$(CONFIG_MCOUNT) += -pg LDFLAGS_vmlinux := --oformat $(ld-bfd) -Ttext $(IMAGE_OFFSET) -e startup \ -T $(obj)/../../kernel/vmlinux.lds diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile index 6575bb0a0434..7492844a8b1b 100644 --- a/kernel/trace/Makefile +++ b/kernel/trace/Makefile @@ -2,9 +2,9 @@ # Do not instrument the tracer itself: +ccflags-remove-$(CONFIG_FUNCTION_TRACER) += $(CC_FLAGS_FTRACE) + ifdef CONFIG_FUNCTION_TRACER -ORIG_CFLAGS := $(KBUILD_CFLAGS) -KBUILD_CFLAGS = $(subst $(CC_FLAGS_FTRACE),,$(ORIG_CFLAGS)) # Avoid recursion due to instrumentation. KCSAN_SANITIZE := n diff --git a/lib/Makefile b/lib/Makefile index b1c42c10073b..b2ed4beddd68 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -3,10 +3,7 @@ # Makefile for some libs needed in the kernel. # -ifdef CONFIG_FUNCTION_TRACER -ORIG_CFLAGS := $(KBUILD_CFLAGS) -KBUILD_CFLAGS = $(subst $(CC_FLAGS_FTRACE),,$(ORIG_CFLAGS)) -endif +ccflags-remove-$(CONFIG_FUNCTION_TRACER) += $(CC_FLAGS_FTRACE) # These files are disabled because they produce lots of non-interesting and/or # flaky coverage that is not a function of syscall inputs. For example, diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 99ac59c59826..5da420f13f9b 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -113,10 +113,10 @@ modfile_flags = -DKBUILD_MODFILE=$(call stringify,$(modfile)) orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \ $(ccflags-y) $(CFLAGS_$(target-stem).o) -_c_flags = $(filter-out $(CFLAGS_REMOVE_$(target-stem).o), $(orig_c_flags)) +_c_flags = $(filter-out $(ccflags-remove-y) $(CFLAGS_REMOVE_$(target-stem).o), $(orig_c_flags)) orig_a_flags = $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) \ $(asflags-y) $(AFLAGS_$(target-stem).o) -_a_flags = $(filter-out $(AFLAGS_REMOVE_$(target-stem).o), $(orig_a_flags)) +_a_flags = $(filter-out $(asflags-remove-y) $(AFLAGS_REMOVE_$(target-stem).o), $(orig_a_flags)) _cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(target-stem).lds) # -- 2.25.1