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: 10572973 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A7C30139B for ; Wed, 22 Aug 2018 13:51:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 97A8A2B56C for ; Wed, 22 Aug 2018 13:51:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8BA832B56E; Wed, 22 Aug 2018 13:51:54 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 33DDA2B56F for ; Wed, 22 Aug 2018 13:51:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728567AbeHVRQx (ORCPT ); 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-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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,