From patchwork Sun Apr 7 10:43:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 10888399 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 6168E139A for ; Sun, 7 Apr 2019 10:44:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4754828639 for ; Sun, 7 Apr 2019 10:44:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3735528706; Sun, 7 Apr 2019 10:44:29 +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 8E58A28639 for ; Sun, 7 Apr 2019 10:44:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726245AbfDGKoY (ORCPT ); Sun, 7 Apr 2019 06:44:24 -0400 Received: from conuserg-08.nifty.com ([210.131.2.75]:31486 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726199AbfDGKoX (ORCPT ); Sun, 7 Apr 2019 06:44:23 -0400 Received: from grover.tkatk1.zaq.ne.jp (zaqdadce369.zaq.ne.jp [218.220.227.105]) (authenticated) by conuserg-08.nifty.com with ESMTP id x37Ai14J006181; Sun, 7 Apr 2019 19:44:02 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com x37Ai14J006181 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1554633842; bh=NqfLefqeMtb7bISR8Nkb4quVom6OPYx9k0dm6zvdMLo=; h=From:To:Cc:Subject:Date:From; b=AUGrk78a8R7x2eTQzU5epZhlT+BqblHxmJPpTWvx6eUB+Oj6xGWIKsUC59/iyilAW kJLOyj4RE1yflrmYAe8rXAcyRblLecycOVLCfAiRxvUQnQuWpduM0cdZZ1J3bzHvRa 5d8Q/Yd48ar4sfbYQMUr1ua+ExMua8AcsN/vkfm00nqwGoLtXcVSTnCpMXCrdLrdj5 dms7EHcZm/VdQnUe4SHg5vi3fysFbHUX8WY+u2LBqGfuFhyikjSML+dE/hXX6sj50Y 7b/01YfFcJOzsm9qmh2nRU2RzmtKjZHGrUC6W17GoNOmS26Bgu5379uA2uGqr/PYh+ kFtbPGl1wUBAg== X-Nifty-SrcIP: [218.220.227.105] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH] kbuild: check arch/$(SRCARCH)/include/generated before out-of-tree build Date: Sun, 7 Apr 2019 19:43:51 +0900 Message-Id: <1554633831-10303-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 After cross-compiling the kernel, "make mrproper" should be executed with the proper ARCH= option. Otherwise, stale objects will remain under arch/$(SRCARCH)/. One bad scenario is like this: $ make ARCH=arm defconfig all # cross-compile the kernel for arm $ make mrproper # mrproper for host-arch (i.e. x86) $ make ARCH=arm O=build_dir defconfig all If you miss ARCH= for mrproper and cross-compile the kernel with O= and ARCH= options, Kbuild will happily start to build, but may fail due to stale objects in the srctree. If $(srctree)/arch/$(SRCARCH)/include/generated/ exists, let's stop the out-of-tree build. To detect this, mrproper should clean only arch/$(SRCARCH)/include/generated/. Signed-off-by: Masahiro Yamada --- Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 10643c3..17945ce 100644 --- a/Makefile +++ b/Makefile @@ -1091,7 +1091,9 @@ PHONY += prepare archprepare prepare1 prepare3 prepare3: include/config/kernel.release ifneq ($(srctree),.) @$(kecho) ' Using $(srctree) as source for kernel' - $(Q)if [ -f $(srctree)/.config -o -d $(srctree)/include/config ]; then \ + $(Q)if [ -f $(srctree)/.config -o \ + -d $(srctree)/include/config -o \ + -d $(srctree)/arch/$(SRCARCH)/include/generated ]; then \ echo >&2 " $(srctree) is not clean, please run 'make mrproper'"; \ echo >&2 " in the '$(srctree)' directory.";\ /bin/false; \ @@ -1350,7 +1352,7 @@ CLEAN_DIRS += $(MODVERDIR) include/ksym # Directories & files removed with 'make mrproper' MRPROPER_DIRS += include/config usr/include include/generated \ - arch/*/include/generated .tmp_objdiff + arch/$(SRCARCH)/include/generated .tmp_objdiff MRPROPER_FILES += .config .config.old .version \ Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \ signing_key.pem signing_key.priv signing_key.x509 \