From patchwork Fri Oct 2 17:46:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Boichat X-Patchwork-Id: 7318021 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CE5ABBEEA4 for ; Fri, 2 Oct 2015 17:46:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B8AB7205CA for ; Fri, 2 Oct 2015 17:46:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9635B2058E for ; Fri, 2 Oct 2015 17:46:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753022AbbJBRqP (ORCPT ); Fri, 2 Oct 2015 13:46:15 -0400 Received: from mail-pa0-f49.google.com ([209.85.220.49]:35730 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752810AbbJBRqN (ORCPT ); Fri, 2 Oct 2015 13:46:13 -0400 Received: by pacfv12 with SMTP id fv12so114452164pac.2 for ; Fri, 02 Oct 2015 10:46:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=YCnj9dpkXNNCVHBaw9VFDIzHNK1njvYWCJzMG6z/d4M=; b=I+IUEHdyEC66dbBQRItPv7QhHfXD0qvwuc3P8t8oN1DovaWWC8UTLWTw2q2UqkzatK M8YpgbzfPAD0VP8rRReMACXP03lyupEKMSIUysshgr5TBk4aEJcfw5kzbALI821QR2Q9 6I3Vjz2pHyhasqCIJa1r75I8hrH/TLhB3xsLw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=YCnj9dpkXNNCVHBaw9VFDIzHNK1njvYWCJzMG6z/d4M=; b=RlVYsq/pVthi2bnVdVaURVvyfZLpKZg11d1PJDXMRD5naaXpRw/EdfTTcGXgF8TAoW DC9dlEDfOwFopRQpLCLPpnXSfoOPXEBdJlLYFO7G/hTl1xLQfD5US2P7Mr/xnRU1h/Zc DAeuGdBIbfDBHpeHvyhTwrFiu24UikPlryx5ovq13xYn3/i3e6DT89eMGYqX6arlCzco FGqYVHWAVPQmKM4NVTEztdDEFKIaCE53zoT70EUIcu8rHWcbVvsm+DEu+Pgv28OkfSy8 4hZCYfDaCroxKxczILLUzKigWuL/6dgzK/Cih4pVAOfwy7zX4T8SHdM7hsVZpojpsv2X 1Zhg== X-Gm-Message-State: ALoCoQlYyExP/7QBqp/VJHjPayFX991IKyJNP9o6IoTcTVLKtMwwJhjwIWeNH1Pa3+JAP1YfErvQ X-Received: by 10.66.144.165 with SMTP id sn5mr22064270pab.122.1443807973024; Fri, 02 Oct 2015 10:46:13 -0700 (PDT) Received: from drinkcat.tpe.corp.google.com ([172.30.210.53]) by smtp.gmail.com with ESMTPSA id gv1sm13069627pbc.38.2015.10.02.10.46.09 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 02 Oct 2015 10:46:12 -0700 (PDT) From: Nicolas Boichat To: linux-kbuild@vger.kernel.org Cc: Michal Marek , "Paul E . McKenney" , Andrew Morton , Ingo Molnar , Pranith Kumar , Peter Zijlstra , Vladimir Murzin , Davidlohr Bueso , Joonsoo Kim , John Stultz , Jan Kiszka , Rusty Russell , Quentin Casasnovas , Paul Gortmaker , Chris Metcalf , Takashi Iwai , Nicolas Boichat , Kyle McMartin , linux-kernel@vger.kernel.org, Jonathan Kliegman , olofj@chromium.org, Sam Ravnborg Subject: [PATCH v2] modpost: Add flag -E for making section mismatches fatal Date: Sat, 3 Oct 2015 01:46:03 +0800 Message-Id: <1443807963-36364-1-git-send-email-drinkcat@chromium.org> X-Mailer: git-send-email 2.6.0.rc2.230.g3dd15c0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The section mismatch warning can be easy to miss during the kernel build process. Allow it to be marked as fatal to be easily caught and prevent bugs from slipping in. Setting CONFIG_SECTION_MISMATCH_WARN_ONLY=y causes these warnings to be non-fatal, since there are a number of section mismatches when using allmodconfig on some architectures, and we do not want to break these builds by default. Signed-off-by: Nicolas Boichat Change-Id: Ic346706e3297c9f0d790e3552aa94e5cff9897a6 --- v2 (Rusty Russell feedback): - Renamed flag from -f to -E (-f means force, so we pick -E for error) - Renamed config option from SECTION_MISMATCH_WARNING to SECTION_MISMATCH_WARN_ONLY v1: I'm trying to revive this old patch. When it was first submitted [1], Jonathan got the following feedback: - The logic of the option should be inverted (i.e. SECTION_MISMATCH_WARNING), so that is not not enabled in allmodconfig for some architectures that do have section mismatches. I've seen some failures (namely, on arm64), so I did that. - CONFIG_DEBUG_SECTION_MISMATCH should be removed and warnings should always be shown verbosely. This option does 3 things: 1. Enable -fno-inline-functions-called-onc 2. Run the section mismatch analysis for each module/built-in.o 3. Enable verbose reporting from modpost We definitely do not want 1 by default, so I think we should keep the option. If we enable 2 & 3 by default, which I think would be reasonable, then the option name does not make much sense anymore, and I'm not sure what to do with the documentation that is currently provided in the Kconfig description. Tested on x86-64 allmodconfig, setting the option to =n, and creating a section mismatch by running: sed -i -e 's/\(ssize_t soc_codec_reg_show\)/__init \1/' sound/soc/soc-core.c Applies on linux-next/20151002 [1] http://thread.gmane.org/gmane.linux.kbuild.devel/9044 lib/Kconfig.debug | 9 +++++++++ scripts/Makefile.modpost | 1 + scripts/mod/modpost.c | 24 +++++++++++++++++------- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index d190d44..e3b43ab 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -311,6 +311,15 @@ config DEBUG_SECTION_MISMATCH - Enable verbose reporting from modpost in order to help resolve the section mismatches that are reported. +config SECTION_MISMATCH_WARN_ONLY + bool "Make section mismatch errors non-fatal" + default y + help + If you say N here, the build process will fail if there are any + section mismatch, instead of just throwing warnings. + + If unsure, say Y. + # # Select this config option from the architecture Kconfig, if it # is preferred to always offer frame pointers as a config diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 9c40dae..a5b42fb 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -77,6 +77,7 @@ modpost = scripts/mod/modpost \ $(if $(KBUILD_EXTRA_SYMBOLS), $(patsubst %, -e %,$(KBUILD_EXTRA_SYMBOLS))) \ $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ $(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S) \ + $(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \ $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w) \ $(if $(CONFIG_LTO),-w) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index d583c98..b2ae8af 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -38,6 +38,7 @@ static int warn_unresolved = 0; /* How a symbol is exported */ static int sec_mismatch_count = 0; static int sec_mismatch_verbose = 1; +static int sec_mismatch_fatal = 0; /* ignore missing files */ static int ignore_missing_files; @@ -2385,7 +2386,7 @@ int main(int argc, char **argv) struct ext_sym_list *extsym_iter; struct ext_sym_list *extsym_start = NULL; - while ((opt = getopt(argc, argv, "i:I:e:mnsST:o:awM:K:")) != -1) { + while ((opt = getopt(argc, argv, "i:I:e:mnsST:o:awM:K:E")) != -1) { switch (opt) { case 'i': kernel_read = optarg; @@ -2426,6 +2427,9 @@ int main(int argc, char **argv) case 'w': warn_unresolved = 1; break; + case 'E': + sec_mismatch_fatal = 1; + break; default: exit(1); } @@ -2475,14 +2479,20 @@ int main(int argc, char **argv) sprintf(fname, "%s.mod.c", mod->name); write_if_changed(&buf, fname); } - if (dump_write) write_dump(dump_write); - if (sec_mismatch_count && !sec_mismatch_verbose) - warn("modpost: Found %d section mismatch(es).\n" - "To see full details build your kernel with:\n" - "'make CONFIG_DEBUG_SECTION_MISMATCH=y'\n", - sec_mismatch_count); + if (sec_mismatch_count) { + if (!sec_mismatch_verbose) { + warn("modpost: Found %d section mismatch(es).\n" + "To see full details build your kernel with:\n" + "'make CONFIG_DEBUG_SECTION_MISMATCH=y'\n", + sec_mismatch_count); + } + if (sec_mismatch_fatal) { + fatal("modpost: Section mismatches detected.\n" + "Set CONFIG_SECTION_MISMATCH_WARN_ONLY=y to allow them.\n"); + } + } return err; }