From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04D51C73C41 for ; Tue, 9 Jul 2019 12:59:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BEB7320861 for ; Tue, 9 Jul 2019 12:59:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nifty.com header.i=@nifty.com header.b="Bnnge/N9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726831AbfGIM71 (ORCPT ); Tue, 9 Jul 2019 08:59:27 -0400 Received: from conssluserg-01.nifty.com ([210.131.2.80]:64113 "EHLO conssluserg-01.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725947AbfGIM71 (ORCPT ); Tue, 9 Jul 2019 08:59:27 -0400 Received: from mail-ua1-f47.google.com (mail-ua1-f47.google.com [209.85.222.47]) (authenticated) by conssluserg-01.nifty.com with ESMTP id x69CxDHx028630; Tue, 9 Jul 2019 21:59:14 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-01.nifty.com x69CxDHx028630 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1562677154; bh=7A2N7Ho/Fdv5L4vwp1BQNOK65hN86LtcgZIzAIW+wEE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Bnnge/N9Fv4luUIPhbG9LIXeqmI8ZHLkUm8+3sS0i2BVdOYLpsWFFX7YPnyVvUQuo TkhkfQI9hkTgtHGmwKMwr5vYLx98x05YPz+KwsvEDLe8ZfHkem7IQpVXBQKh6h0GAi 2UTu7RxOXYDEIvklae1TwrgMRTJbbhDzGfN8BCbJACTnJM3ScMbgPLljSvyxPWiqNM iusJZG3BvXIYkscM9/wi//NnMpLwYUhuUsVQFab1fPxXCHi7XxYmodNmPueOOaFA7n OYXbeZq5Oa4dRmjj4OlPeq0SKiDyBaSONgZdoCP+jgRCXzXSCBBEh6czauupOsjKzw 75ZguVXbLyVRg== X-Nifty-SrcIP: [209.85.222.47] Received: by mail-ua1-f47.google.com with SMTP id v18so6352289uad.12; Tue, 09 Jul 2019 05:59:14 -0700 (PDT) X-Gm-Message-State: APjAAAV4u/ZaWkK6G9qzUHOPFpMnJqyhF2FqCPqRO8O8gnzAxkbitZHd FcQQ2xYiHvuZS2mhhxgG9ab0Jj3rNNSwZU/8JIk= X-Google-Smtp-Source: APXvYqwtKIB0v3EDyCZQeUN86YmMG6zvyxmpJC2IQaVOnT3ACLkK6Z3rtEjhPGYgzoXMUsz9eqTldUU5Op9Q8n79YPk= X-Received: by 2002:ab0:70d9:: with SMTP id r25mr12877071ual.109.1562677153044; Tue, 09 Jul 2019 05:59:13 -0700 (PDT) MIME-Version: 1.0 References: <1554633831-10303-1-git-send-email-yamada.masahiro@socionext.com> In-Reply-To: From: Masahiro Yamada Date: Tue, 9 Jul 2019 21:58:37 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] kbuild: check arch/$(SRCARCH)/include/generated before out-of-tree build To: Geert Uytterhoeven Cc: linux-kbuild , Michal Marek , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Geert, On Tue, Jul 9, 2019 at 9:45 PM Geert Uytterhoeven wrote: > > Hi Yamada-san, > > On Tue, Jul 9, 2019 at 2:22 PM Masahiro Yamada > wrote: > > On Tue, Jul 9, 2019 at 5:31 PM Geert Uytterhoeven wrote: > > > On Sun, Apr 7, 2019 at 12:45 PM Masahiro Yamada > > > wrote: > > > > 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.";\ > > > > > > This took me a bit to find out what was wrong... > > > > > > Usually I don't run "make mrproper", as it removes files I may want to > > > keep (e.g. tags). Hence I ran "git ls-files -o | grep m68k | xargs rm" > > > (I usually build in separate output directories), confirmed with "git > > > ls-files -o" there were no remaining build artefacts, and was surprised > > > to discover I still got the error message above?!? > > > > > > Apparently arch/m68k/include/generated was still present, but as "git > > > ls-files -o" only shows files, not directories, it was not listed. > > > Perhaps the directory checks above can be changed to directory exists > > > _and_ is not empty? > > > > No. > > > > Since you did not run mrproper, > > Kbuild _correctly_ showed error. > > This is the expected and correct behavior. :) > > > > The upstream kernel is not a place > > to be customized for your workflow. Sorry. > > > > > > Every developer has a set of handy custom commands. > > > > Since you are already running a long command, > > why don't you add one more line, and put in ~/.bash_aliases or somewhere? > > > > my_mrproper() > > { > > git ls-files -o | grep m68k | xargs rm > > rm -rf arch/m68k/include/generated > > } > > Please note this was not part of my standard workflow, so I don't have a > script for it. I just happened to had done a quick test build in my > kernel source tree repository before, and had forgotten about that. > > So IMHO this is more of a usability issue: it is difficult to find out > what is wrong, and how to solve it, as "git ls-files -o" doesn't give a > clue. And running "make mrproper" doesn't help. > > Perhaps the message should be changed to > > $(srctree) is not clean, please run 'make ARCH=$(SRCARCH) mrproper'" Fair enough, but 'make ARCH=$(ARCH) mrproper' please. Will you send a patch? -- Best Regards Masahiro Yamada