From patchwork Mon Oct 2 10:50:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Gorski X-Patchwork-Id: 9980691 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F2F2E60365 for ; Mon, 2 Oct 2017 10:50:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E61EF2896A for ; Mon, 2 Oct 2017 10:50:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB16C2897A; Mon, 2 Oct 2017 10:50:31 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable 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 888482896A for ; Mon, 2 Oct 2017 10:50:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751296AbdJBKuY (ORCPT ); Mon, 2 Oct 2017 06:50:24 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:36179 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750957AbdJBKuW (ORCPT ); Mon, 2 Oct 2017 06:50:22 -0400 Received: by mail-wm0-f65.google.com with SMTP id 63so2096820wmn.3; Mon, 02 Oct 2017 03:50:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=WtZwKMJu0/WnQmQ2ALLTwcjjDCOcbq91RorcLc0AiqU=; b=YOqmpXEM13abA+nXECJyLtDWLImi44Dtzp7VlnbkLMHRMsTl33lsHyJuntDcu3Jagi RqMqpsJvzYxyI9FWX4lcwOEFt1peI8lLtkBkRyY5QgC686jfgr4SQ0AK+VF8NrpFWfoY 1MpPntWNt6B7nA8aS6HV9cXvyjnyJSXMbBBWX7YzKCO5XXKvO4+/c0db8T6HQCoY0goq +tWeSblwkmDyXb1corMcyhr/3ku2aGMWxg2Dbrc+O7AlH9lbFJ3aUll2/f+VY8cEdQsc r14yRTMQ6RhBxydGiorjy3+XcjESlua4/DsSNk45/MB86u7wDZAzS13b9PpV8EkgoaRP 7nVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=WtZwKMJu0/WnQmQ2ALLTwcjjDCOcbq91RorcLc0AiqU=; b=twe/ZX7TK+rEesNLBE6pSIc+K1iv4abcmJspgUQMGfRRB6CZXh78WQ0O82pYS/RVff zHsotfY4y2//i4XRtfTcDURYrSy9A5dVOTNC3o12PA6epmm2VteZ3ajGR20xYc/7kkPP cmcwaOcyxVliyjPVnBzc9EOAgZL2OCnV62En03Uct4K17KF4cGVZEkSjBJXC5cm4LJsb w1WAvJ0z4Mx5YEY9I45FWUFKpPek+Gah2GwqPpt4hmeTe2V9H11eGbc3M/qXpSCL34KN 8C8s0AaI//5mz1XBupIMSqEzBT5wZ+om6gjf6ZTn1gdkJukubDBut1BY8Bypix89//V/ W9Eg== X-Gm-Message-State: AHPjjUif0Ryc3LBr4zHOUXrTgberzKy0bnvgVs8H4zBIacuqYOsOOMmP CGzj1qaOk1IHOPVXQkjmQrcnjQ== X-Google-Smtp-Source: AOwi7QAf/qCX5ZixqYSrczcGrCHmo4RpS0nMMz98LX0cgyiM7bkjSRGsksNcOMaQF9sQQ9hzqCwbkQ== X-Received: by 10.80.146.243 with SMTP id l48mr20424045eda.232.1506941420441; Mon, 02 Oct 2017 03:50:20 -0700 (PDT) Received: from localhost.localdomain ([2001:470:9e39::48e]) by smtp.gmail.com with ESMTPSA id r8sm1726334edd.96.2017.10.02.03.50.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Oct 2017 03:50:19 -0700 (PDT) From: Jonas Gorski To: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Masahiro Yamada , Michal Marek Subject: [PATCH] kbuild: allow making undefined symbols fatal for external modules Date: Mon, 2 Oct 2017 12:50:04 +0200 Message-Id: <20171002105004.32426-1-jonas.gorski@gmail.com> X-Mailer: git-send-email 2.13.2 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 By passing appropriate values in KBUILD_EXTRA_SYMBOLS it is possible to make modpost be able to resolve all symbols for external modules, even between to other external modules. Because of this, it might be desirable to make unresolved symbols an error on external module builds as well, to catch missing exports there as well. So add a new flag KBUILD_MODPOST_ERROR which can be set to enable this behaviour. It has no effect on non external module builds. Signed-off-by: Jonas Gorski --- The main target is to allow distributions (like LEDE) that make use of kernel backports and other out of tree drivers to be able to catch errors like missing EXPORT_SYMBOLs in the kernel early. scripts/Makefile.modpost | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 16923ba4b5b1..29f787bf8c3a 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -34,6 +34,8 @@ # KBUILD_MODPOST_WARN can be set to avoid error out in case of undefined # symbols in the final module linking stage +# KBUILD_MODPOST_ERROR can be set to error out in case of undefined +# symbols in the final module linking stage for external modules # KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules. # This is solely useful to speed up test compiles PHONY := _modpost @@ -49,6 +51,8 @@ ifneq ($(KBUILD_EXTMOD),) obj := $(KBUILD_EXTMOD) src := $(obj) +KBUILD_MODPOST_WARN = $(if $(KBUILD_MODPOST_ERROR),,1) + # Include the module's Makefile to find KBUILD_EXTRA_SYMBOLS include $(if $(wildcard $(KBUILD_EXTMOD)/Kbuild), \ $(KBUILD_EXTMOD)/Kbuild, $(KBUILD_EXTMOD)/Makefile) @@ -78,7 +82,7 @@ modpost = scripts/mod/modpost \ $(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 $(KBUILD_MODPOST_WARN),-w) MODPOST_OPT=$(subst -i,-n,$(filter -i,$(MAKEFLAGS)))