Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp6702772ybh; Thu, 8 Aug 2019 04:23:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqynEUd8bjDTnS2yN8rOlVI4SI5ERHCqWvZo+OSn3oi7SbgTM6zGX07GY/ZethrZBxac6JDR X-Received: by 2002:a62:1d11:: with SMTP id d17mr15073039pfd.249.1565263392468; Thu, 08 Aug 2019 04:23:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565263392; cv=none; d=google.com; s=arc-20160816; b=0j6vvVJbc+1DPk1Ks4IrCiNnxtfGVD5D5Judq7IboxsoCgtQMfZ2A2nzYErtjaTC7g 4rVmTZm1B2UhXyhe6x0nbk2ypi0a6uZhILVqqvSvkeLLHbEJruUJSucgGvh2mjMvOYsr 55kH646HyiCUY5+PipmcoOdTxN4ppUT7Yecn9UeEk4I9sEpBGgb/te9AmfODOZ7+f+Sf yT25JyH1hPbD3nw0mf6IeErOIqU0zzIjk4hTXpC+PrNAlHAufSJ260GZNoJGErpkTG4B dsrZ9U9sf3f8Q9ej2teM+uh9+bI+WnYsbZ6LF5TlyidHs3c8vUxoJgZAmybokjmFFdcG nJeg== 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; bh=Y3joUPUMYoBzCVDWCYCkXvHGxBHe0Rsmx3YuHH4+91M=; b=aZsEMDUjcEIu6tNmeVPPayIsVNUZP0o691+cDGoGWClmyrV3lkex5PE4AKU34tG08B Cv6moj7I0S1JeaRCv8ADc/dU3poVTzWiTsrLuUOZYoTCAasmAMF8Em5EGI7+gpe6lkwO O3rJUHs6ZwEbWXkw4VpPr98UG4vOuNgzAAgbmQzpB1ZMmKZoduzx/pobrNVAw32NFEKx 3kweuh8b06BKNStjsp4gSmxonCj0gsdlOUnMOMg87DNIjP27Uks6VWp8Uwyf2Eki6wrB oh8xMouXewwSnOraQxPglBefrL8LGBiHDwcaTqaxIqeXQ6/i5N2lz9EqO3NvtlPGHzoY P0eA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=iCGTFksi; 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 bh4si48486470plb.198.2019.08.08.04.22.56; Thu, 08 Aug 2019 04:23:12 -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=iCGTFksi; 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 S1732178AbfHHLVv (ORCPT + 99 others); Thu, 8 Aug 2019 07:21:51 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:37726 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730747AbfHHLVv (ORCPT ); Thu, 8 Aug 2019 07:21:51 -0400 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id x78BLEkO027157; Thu, 8 Aug 2019 20:21:15 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com x78BLEkO027157 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1565263275; bh=Y3joUPUMYoBzCVDWCYCkXvHGxBHe0Rsmx3YuHH4+91M=; h=From:To:Cc:Subject:Date:From; b=iCGTFksi3llJddT4lN0m7yPIlNGjS7AghbijE+hez0ISz3b3PLhEoWhe8ZzA0AQD1 tmuGow482ok/3d9oy/0PYpn+1SAfMT+duWTPJQBgh55L34l4wnb740DftNfP72p4bK aVKdwDsT6xKeiIXY6if/cQyMi6kDX7o+z1dasan/d74TyZq2vmZdgJeo71cIXEwTro iqtvX0k17GTKR4xWb7K4k/D8ZMkBB3hhnVx+hj9cJtujetuLZmPO8IkT27p6dP6HMb uwYk3S0pCSmHXXn7Ttt/VrmKEz0l3WNU0cenS5Khc2kLclUhn33SlMDoN2Vlg58Ik9 oGL/0vdUIw4fg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Jan Kiszka , Tom Stonecypher , linux-kernel@vger.kernel.org, Masahiro Yamada , Michal Marek Subject: [PATCH v2] kbuild: show hint if subdir-y/m is used to visit module Makefile Date: Thu, 8 Aug 2019 20:21:11 +0900 Message-Id: <20190808112111.16159-1-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since commit ff9b45c55b26 ("kbuild: modpost: read modules.order instead of $(MODVERDIR)/*.mod"), a module is no longer built in the following pattern: [Makefile] subdir-y := some-module [some-module/Makefile] obj-m := some-module.o You cannot write Makefile this way in upstream because modules.order is not correctly generated. subdir-y is used to descend to a sub-directory that builds tools, device trees, etc. For external modules, the modules order does not matter. So, the Makefile above was known to work. I believe the Makefile should be re-written as follows: [Makefile] obj-m := some-module/ [some-module/Makefile] obj-m := some-module.o However, people will have no idea if their Makefile suddenly stops working. In fact, I received questions from multiple people. Show a warning if obj-m is specified in a Makefile visited by subdir-y or subdir-m. I touched the %/ rule to avoid false-positive warnings for the single target. Cc: Jan Kiszka Cc: Tom Stonecypher Signed-off-by: Masahiro Yamada --- Changes in v2: - fix false-positive warnings for single targets Makefile | 2 +- scripts/Makefile.build | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0e37ad2f77bf..fac25e279da6 100644 --- a/Makefile +++ b/Makefile @@ -1783,7 +1783,7 @@ PHONY += / /: ./ %/: prepare FORCE - $(Q)$(MAKE) KBUILD_MODULES=1 $(build)=$(build-dir) + $(Q)$(MAKE) KBUILD_MODULES=1 $(build)=$(build-dir) need-modorder=1 # FIXME Should go into a make.lib or something # =========================================================================== diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 37a1d2cd49d4..2f66ed388d1c 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -52,6 +52,13 @@ ifndef obj $(warning kbuild: Makefile.build is included improperly) endif +ifeq ($(MAKECMDGOALS)$(need-modorder),) +ifneq ($(obj-m),) +$(warning $(patsubst %.o,'%.ko',$(obj-m)) will not be built even though obj-m is specified.) +$(warning You cannot use subdir-y/m to visit a module Makefile. Use obj-y/m instead.) +endif +endif + # =========================================================================== ifneq ($(strip $(lib-y) $(lib-m) $(lib-)),) -- 2.17.1