From patchwork Wed Aug 22 13:51:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 144833 Delivered-To: patch@linaro.org Received: by 2002:a2e:164a:0:0:0:0:0 with SMTP id 10-v6csp74043ljw; Wed, 22 Aug 2018 06:51:55 -0700 (PDT) X-Google-Smtp-Source: AA+uWPy9xwea6v5te/28z5k+Fp+zD9K5B9vxjt7xegb2Zt0GN2Ho0lQU2pvZVcrQ9b/mOqcI1/iN X-Received: by 2002:a17:902:a58c:: with SMTP id az12-v6mr25239742plb.339.1534945915420; Wed, 22 Aug 2018 06:51:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534945915; cv=none; d=google.com; s=arc-20160816; b=Gj6eCw70LrWPcT3W1VLgfxugRrnkY5oqXjzwi7tM/t0rNfxx9nCxYvlXW0wsNtd/5N h/sNDBt0bsV99REm0l/IV6G73Su+FUTbLJlR5wzoSHt/QF/lVxLJ1iYiCGwR+/xrXZs6 jSeV6vYc9qJ6S2g81aW7yXOCdgVqf6SHVu0X/E9HDB4BJJW1uky/++UM1uTTvnVNGMmP X6lZjkSr6SE3BtIOUCeZX3J+Nw5xS6/WyGfQ8JgUodnn4z/eLVKpBs+/Lh0iukZe5vxQ TOSSJX+j+qMe1HQYupC+3iKWorWtTrw/6WkMmfRh6XijsCHPAYI9xgdCWPdiaSa7JW6E II8g== 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=71T7VEr8TWf5H7TaCdI/1IrR0dzQDsooywK1qEO+Fv4=; b=pHyWKFbmQ0g+N5DF0VWEzZoSaL6I8vc72qXfnOPYKXykRMDgsuGnwpxEZ3hmfYfKwT p8nbhp0aLIGoUWSctSeMWpdDpq/Dmh9uBgvXET0pQRbBzR1r20hL75D/L/1SBfyfS3q5 59u2ZYdF1Xr4x1yXYUHhsqM/IwSIYXj7XdaXqTSNTgFw1VF9N6O3mm6LTTztw1IHJCZw ro1bjNyV8XgENtcWJrmbhYryD9DqX4AUH0ghYdRO1504g6zFBPB8g2G6wqYltIAc1YnL b/g82kMWgURDZ83xbfPsVq8QN8WNpUzW+LhzPxh9tm5M/l+gw0p6O+pfxppc1ocpkl03 u4XQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=GN5tIjY9; 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 d7-v6si1662919pll.162.2018.08.22.06.51.55; Wed, 22 Aug 2018 06:51:55 -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=GN5tIjY9; 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 S1729142AbeHVRQx (ORCPT + 32 others); Wed, 22 Aug 2018 13:16:53 -0400 Received: from conuserg-12.nifty.com ([210.131.2.79]:40546 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728534AbeHVRQx (ORCPT ); Wed, 22 Aug 2018 13:16:53 -0400 Received: from grover.tkatk1.zaq.ne.jp (zaqdadce369.zaq.ne.jp [218.220.227.105]) (authenticated) by conuserg-12.nifty.com with ESMTP id w7MDpROF020754; Wed, 22 Aug 2018 22:51:28 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com w7MDpROF020754 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1534945888; bh=71T7VEr8TWf5H7TaCdI/1IrR0dzQDsooywK1qEO+Fv4=; h=From:To:Cc:Subject:Date:From; b=GN5tIjY9dyVnznvHNOH4GjvEjX8SFcTrKN0Sm6BaTjLxOOvtZZGG8KxIfBo1G0PwQ NkFZlCfET5iA/EDG8xVrxfWjQ6UbgIW5vm1sN71avVG9GJjo59z5CRyEuAWakm24eF YNbpECGUfT2ELIZHZCUjqMjEg7tqkRw7iOdmFOKOyTCVQ4PEJpG7Hxdgbdm5XHX255 gIhxYvXeMb9olB0Zd6qeM+S32z1sguzGFRJsDj/wHBiDyohpr7Fbmjv8FgzmrUBRbf jA/nl0dWKmqYASN9l1vN9oX7ZECYExqea98cyS1g2ExHyCprF1k/I5U2OR4lPIXECh xlr4os71mDEBQ== X-Nifty-SrcIP: [218.220.227.105] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Nicholas Piggin , Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH] kbuild: test dead code/data elimination support in Kconfig Date: Wed, 22 Aug 2018 22:51:09 +0900 Message-Id: <1534945869-17117-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 This config option should be enabled only when both the compiler and the linker support necessary flags. Add proper dependencies to Kconfig. Signed-off-by: Masahiro Yamada --- Makefile | 8 ++------ init/Kconfig | 2 ++ 2 files changed, 4 insertions(+), 6 deletions(-) -- 2.7.4 diff --git a/Makefile b/Makefile index 1289a01..2e2b009 100644 --- a/Makefile +++ b/Makefile @@ -790,8 +790,8 @@ KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions-called-once) endif ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION -KBUILD_CFLAGS_KERNEL += $(call cc-option,-ffunction-sections,) -KBUILD_CFLAGS_KERNEL += $(call cc-option,-fdata-sections,) +KBUILD_CFLAGS_KERNEL += -ffunction-sections -fdata-sections +LDFLAGS_vmlinux += --gc-sections endif # arch Makefile may override CC so keep this after arch Makefile is included @@ -857,10 +857,6 @@ LDFLAGS_BUILD_ID := $(call ld-option, --build-id) KBUILD_LDFLAGS_MODULE += $(LDFLAGS_BUILD_ID) LDFLAGS_vmlinux += $(LDFLAGS_BUILD_ID) -ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION -LDFLAGS_vmlinux += $(call ld-option, --gc-sections,) -endif - ifeq ($(CONFIG_STRIP_ASM_SYMS),y) LDFLAGS_vmlinux += $(call ld-option, -X,) endif diff --git a/init/Kconfig b/init/Kconfig index 9bd50ba..21b8559 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1085,6 +1085,8 @@ config LD_DEAD_CODE_DATA_ELIMINATION bool "Dead code and data elimination (EXPERIMENTAL)" depends on HAVE_LD_DEAD_CODE_DATA_ELIMINATION depends on EXPERT + depends on $(cc-option,-ffunction-sections -fdata-sections) + depends on $(ld-option,--gc-sections) help Enable this if you want to do dead code and data elimination with the linker by compiling with -ffunction-sections -fdata-sections,