From patchwork Fri Apr 13 05:06:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 133318 Delivered-To: patch@linaro.org Received: by 10.46.84.18 with SMTP id i18csp344996ljb; Thu, 12 Apr 2018 22:09:31 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/WcQTbmSDqT+zPsiN9AzXJPoXag5LzsDpqicOgbBGsnM5ypMLhL+Es2ajZec5kCj6z0i0U X-Received: by 10.101.88.11 with SMTP id g11mr2942153pgr.201.1523596170938; Thu, 12 Apr 2018 22:09:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523596170; cv=none; d=google.com; s=arc-20160816; b=CvymFQeoh0FdepZo67h1IGbr5ervx1xOZpy/9gV0QQkBLqpfWv4kffq/fq+B+Ep6bV giFRcvpdC9doTdsZ+UaHr7RA0O1gYvxGtZhxtem4Czd1ZAHRZQs7cl8m5IEd5uKiR4ww hSvrQhcFjfHjw+zGogDss4am73BLaVzASr54lNFXeF9VXsfPMdXw95xgDbvAFYTODPoA 6dieMkasJhZ5uNVN5D1E7NESop0xfQ8SvAG6IrS9vQlyLb5Pcq657LsCGdKBma4QDb0H h9uvBmFnTGmfZ25A567twE/9vy1LgrMCuuGKho7R3MltmXQLIgDTChg3ppq+hNUa+pI1 ojvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=4M6pCC9EPgYj0SwcHSwqfnESE7wdZuu3VHrr/fdPj9Y=; b=MMlvhP/IucQJVErDODpVxdbbOAQAWonTnzlEBwL9pFBWxoYGe7ddIpdoX2Nd03VWGT boSoHSN3kG1B4KLKnVjpBRAiARU5k9dofYQGIzZE3QuXynfg2SAF6vZQRCohNVfVN2qT Aa9pc8fH9peNucIxcAaeU9dw+oI7jpWLnqjxeYce6tZtu9XUUW0gmZPMC4cd4sP/nysn fbylua+ZPiFsPu/Ijj09As936SiVqXf3H+KnUqoWtuXrjGlq6FsMoZUQH5iERqKjf+YD voGD+r4UOFizs23tcxYNcDQcEnCDzXVUS3PGVpLGQBoHn9+ltP3YQ6z4IClapahhe+q6 PhKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=u8cP+SA4; 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 e6si3441833pfg.305.2018.04.12.22.09.30; Thu, 12 Apr 2018 22:09:30 -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=u8cP+SA4; 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 S1753588AbeDMFJ1 (ORCPT + 29 others); Fri, 13 Apr 2018 01:09:27 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:56558 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753296AbeDMFJY (ORCPT ); Fri, 13 Apr 2018 01:09:24 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id w3D56lgO029209; Fri, 13 Apr 2018 14:07:14 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w3D56lgO029209 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1523596035; bh=4M6pCC9EPgYj0SwcHSwqfnESE7wdZuu3VHrr/fdPj9Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u8cP+SA4BEqnRMXp4k5kXgv5tiiE/2uB8iKGUCbmjo67ysFKyKJZ4niNCisd/ZyGC ZXqe3IFqhIRXUzRtMf6SUdo11nECoJDAbZ6Qw1LaN2nD4PYAqshiXix47MY9mtciUw j9zfOlFpFCYqJ66bSTWsmlzbjaQBdHfR0XESZhTCPJC0B66Op7X4em1eZg+SvFZIVH N9mX69dg8fNj/DKphAz9UdF2t28gG0XTREwPYw4AweKvtKpaDk8WjnFrF5MNTzgBtd N6mVsBDFeLVTSHp0vBeIHFxqslVoy1ymG0nHakit08FUKklXAJvFBHboof3QSP5nEs C/MZCd8ulmttA== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Linus Torvalds , Sam Ravnborg , Ulf Magnusson , Nicholas Piggin , Kees Cook , Emese Revfy , x86@kernel.org, Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 30/30] kbuild: test dead code/data elimination support in Kconfig Date: Fri, 13 Apr 2018 14:06:39 +0900 Message-Id: <1523595999-27433-31-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523595999-27433-1-git-send-email-yamada.masahiro@socionext.com> References: <1523595999-27433-1-git-send-email-yamada.masahiro@socionext.com> 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. Unlike 'select', 'imply' is modest enough to observe those dependencies. I suggested this in the help message. Signed-off-by: Masahiro Yamada --- Changes in v3: None Changes in v2: None Makefile | 8 ++------ arch/Kconfig | 4 +++- 2 files changed, 5 insertions(+), 7 deletions(-) -- 2.7.4 diff --git a/Makefile b/Makefile index 88733b7..92db767 100644 --- a/Makefile +++ b/Makefile @@ -754,8 +754,8 @@ KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions-called-once) endif ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION -KBUILD_CFLAGS += $(call cc-option,-ffunction-sections,) -KBUILD_CFLAGS += $(call cc-option,-fdata-sections,) +KBUILD_CFLAGS += -ffunction-sections -fdata-sections +LDFLAGS_vmlinux += --gc-sections endif # arch Makefile may override CC so keep this after arch Makefile is included @@ -819,10 +819,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/arch/Kconfig b/arch/Kconfig index 95b9b2e..e88f1ba 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -597,8 +597,10 @@ config CC_STACKPROTECTOR_STRONG config LD_DEAD_CODE_DATA_ELIMINATION bool + depends on $(cc-option -ffunction-sections -fdata-sections) + depends on $(ld-option --gc-sections) help - Select this if the architecture wants to do dead code and + Imply this if the architecture wants to do dead code and data elimination with the linker by compiling with -ffunction-sections -fdata-sections and linking with --gc-sections.