Linux kbuild/kconfig development
 help / color / mirror / Atom feed
* [PATCH] um: let 'make clean' properly clean underlying SUBARCH as well
@ 2025-05-07  7:49 Masahiro Yamada
  2025-05-07 16:13 ` Johannes Berg
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Masahiro Yamada @ 2025-05-07  7:49 UTC (permalink / raw)
  To: linux-kbuild
  Cc: linux-kernel, Masahiro Yamada, Shuah Khan, Anton Ivanov,
	Johannes Berg, Richard Weinberger, linux-um

Building the kernel with O= is affected by stale in-tree build artifacts.

So, if the source tree is not clean, Kbuild displays the following:

  $ make ARCH=um O=build defconfig
  make[1]: Entering directory '/.../linux/build'
  ***
  *** The source tree is not clean, please run 'make ARCH=um mrproper'
  *** in /.../linux
  ***
  make[2]: *** [/.../linux/Makefile:673: outputmakefile] Error 1
  make[1]: *** [/.../linux/Makefile:248: __sub-make] Error 2
  make[1]: Leaving directory '/.../linux/build'
  make: *** [Makefile:248: __sub-make] Error 2

Usually, running 'make mrproper' is sufficient for cleaning the source
tree for out-of-tree builds.

However, building UML generates build artifacts not only in arch/um/,
but also in the SUBARCH directory (i.e., arch/x86/). If in-tree stale
files remain under arch/x86/, Kbuild will reuse them instead of creating
new ones under the specified build directory.

This commit makes 'make ARCH=um clean' recurse into the SUBARCH directory.

Reported-by: Shuah Khan <skhan@linuxfoundation.org>
Closes: https://lore.kernel.org/lkml/20250502172459.14175-1-skhan@linuxfoundation.org/
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 arch/um/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/um/Makefile b/arch/um/Makefile
index 1d36a613aad8..9ed792e565c9 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -154,5 +154,6 @@ MRPROPER_FILES += $(HOST_DIR)/include/generated
 archclean:
 	@find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \
 		-o -name '*.gcov' \) -type f -print | xargs rm -f
+	$(Q)$(MAKE) -f $(srctree)/Makefile ARCH=$(HEADER_ARCH) clean
 
 export HEADER_ARCH SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING DEV_NULL_PATH
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH] um: let 'make clean' properly clean underlying SUBARCH as well
  2025-05-07  7:49 [PATCH] um: let 'make clean' properly clean underlying SUBARCH as well Masahiro Yamada
@ 2025-05-07 16:13 ` Johannes Berg
  2025-05-07 21:38 ` Shuah Khan
  2025-05-08  6:12 ` David Gow
  2 siblings, 0 replies; 11+ messages in thread
From: Johannes Berg @ 2025-05-07 16:13 UTC (permalink / raw)
  To: Masahiro Yamada, linux-kbuild
  Cc: linux-kernel, Shuah Khan, Anton Ivanov, Richard Weinberger,
	linux-um

On Wed, 2025-05-07 at 16:49 +0900, Masahiro Yamada wrote:
> Building the kernel with O= is affected by stale in-tree build artifacts.
> 
> So, if the source tree is not clean, Kbuild displays the following:
> 
>   $ make ARCH=um O=build defconfig
>   make[1]: Entering directory '/.../linux/build'
>   ***
>   *** The source tree is not clean, please run 'make ARCH=um mrproper'
>   *** in /.../linux
>   ***
>   make[2]: *** [/.../linux/Makefile:673: outputmakefile] Error 1
>   make[1]: *** [/.../linux/Makefile:248: __sub-make] Error 2
>   make[1]: Leaving directory '/.../linux/build'
>   make: *** [Makefile:248: __sub-make] Error 2
> 
> Usually, running 'make mrproper' is sufficient for cleaning the source
> tree for out-of-tree builds.
> 
> However, building UML generates build artifacts not only in arch/um/,
> but also in the SUBARCH directory (i.e., arch/x86/). If in-tree stale
> files remain under arch/x86/, Kbuild will reuse them instead of creating
> new ones under the specified build directory.
> 
> This commit makes 'make ARCH=um clean' recurse into the SUBARCH directory.

Do you want to take that through your tree? I'm not sure we'd get it
into 6.15 at this point via uml, if you have some other material feel
free to take it:

Acked-by: Johannes Berg <johannes@sipsolutions.net>

Otherwise we can take it via uml tree for 6.16 too, let us know.

johannes

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] um: let 'make clean' properly clean underlying SUBARCH as well
  2025-05-07  7:49 [PATCH] um: let 'make clean' properly clean underlying SUBARCH as well Masahiro Yamada
  2025-05-07 16:13 ` Johannes Berg
@ 2025-05-07 21:38 ` Shuah Khan
  2025-05-07 23:49   ` Masahiro Yamada
  2025-05-08  5:29   ` Johannes Berg
  2025-05-08  6:12 ` David Gow
  2 siblings, 2 replies; 11+ messages in thread
From: Shuah Khan @ 2025-05-07 21:38 UTC (permalink / raw)
  To: Masahiro Yamada, linux-kbuild
  Cc: linux-kernel, Anton Ivanov, Johannes Berg, Richard Weinberger,
	linux-um, Shuah Khan, David Gow

On 5/7/25 01:49, Masahiro Yamada wrote:
> Building the kernel with O= is affected by stale in-tree build artifacts.
> 
> So, if the source tree is not clean, Kbuild displays the following:
> 
>    $ make ARCH=um O=build defconfig
>    make[1]: Entering directory '/.../linux/build'
>    ***
>    *** The source tree is not clean, please run 'make ARCH=um mrproper'
>    *** in /.../linux
>    ***
>    make[2]: *** [/.../linux/Makefile:673: outputmakefile] Error 1
>    make[1]: *** [/.../linux/Makefile:248: __sub-make] Error 2
>    make[1]: Leaving directory '/.../linux/build'
>    make: *** [Makefile:248: __sub-make] Error 2
> 
> Usually, running 'make mrproper' is sufficient for cleaning the source
> tree for out-of-tree builds.
> 
> However, building UML generates build artifacts not only in arch/um/,
> but also in the SUBARCH directory (i.e., arch/x86/). If in-tree stale
> files remain under arch/x86/, Kbuild will reuse them instead of creating
> new ones under the specified build directory.
> 
> This commit makes 'make ARCH=um clean' recurse into the SUBARCH directory.
> 
> Reported-by: Shuah Khan <skhan@linuxfoundation.org>
> Closes: https://lore.kernel.org/lkml/20250502172459.14175-1-skhan@linuxfoundation.org/
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

It doesn't solve the problem. I still see arch/x86/realmode/rm/pasyms.h
after running make ARCH=um mrproper

A subsequent kunit run on x86_64 fails. make ARCH=x86_64 mrproper
will remove the headers for x86_64 properly. The patch I proposed
prompts user run mrproper on the arch in compile.h - It works now
for the case where compile.h doesn't exist. I can send that out
unless you have other ideas on how to fix this.

My workflow:

- Build kernel on x86_64 with CONFIG_AMD_MEM_ENCRYPT enabled

- Check for arch/x86/realmode/rm/pasyms.h
   ls arch/x86/realmode/rm/pasyms.h
      arch/x86/realmode/rm/pasyms.h

- make ARCH=um O=/linux/build
   
   This patch cleans the source tree, but doesn't remove
   arch/x86/realmode/rm/pasyms.h

- ls arch/x86/realmode/rm/pasyms.h
      arch/x86/realmode/rm/pasyms.h

- ./tools/testing/kunit/kunit.py run --alltests --arch x86_64
[15:26:35] Configuring KUnit Kernel ...
Regenerating .config ...
Populating config with:
$ make ARCH=x86_64 O=.kunit olddefconfig
[15:26:37] Building KUnit Kernel ...
Populating config with:
$ make ARCH=x86_64 O=.kunit olddefconfig
Building with:
$ make all compile_commands.json scripts_gdb ARCH=x86_64 O=.kunit --jobs=16
ERROR:root:ld:arch/x86/realmode/rm/realmode.lds:236: undefined symbol `sev_es_trampoline_start' referenced in expression
make[6]: *** [../arch/x86/realmode/rm/Makefile:49: arch/x86/realmode/rm/realmode.elf] Error 1
make[5]: *** [../arch/x86/realmode/Makefile:22: arch/x86/realmode/rm/realmode.bin] Error 2
make[4]: *** [../scripts/Makefile.build:461: arch/x86/realmode] Error 2
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [../scripts/Makefile.build:461: arch/x86] Error 2
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [/linux/linux_kselftest/Makefile:2009: .] Error 2
make[1]: *** [/linux/linux_kselftest/Makefile:248: __sub-make] Error 2
make: *** [Makefile:248: __sub-make] Error 2

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] um: let 'make clean' properly clean underlying SUBARCH as well
  2025-05-07 21:38 ` Shuah Khan
@ 2025-05-07 23:49   ` Masahiro Yamada
  2025-05-08 22:14     ` Shuah Khan
  2025-05-08  5:29   ` Johannes Berg
  1 sibling, 1 reply; 11+ messages in thread
From: Masahiro Yamada @ 2025-05-07 23:49 UTC (permalink / raw)
  To: Shuah Khan
  Cc: linux-kbuild, linux-kernel, Anton Ivanov, Johannes Berg,
	Richard Weinberger, linux-um, David Gow

On Thu, May 8, 2025 at 6:38 AM Shuah Khan <skhan@linuxfoundation.org> wrote:
>
> On 5/7/25 01:49, Masahiro Yamada wrote:
> > Building the kernel with O= is affected by stale in-tree build artifacts.
> >
> > So, if the source tree is not clean, Kbuild displays the following:
> >
> >    $ make ARCH=um O=build defconfig
> >    make[1]: Entering directory '/.../linux/build'
> >    ***
> >    *** The source tree is not clean, please run 'make ARCH=um mrproper'
> >    *** in /.../linux
> >    ***
> >    make[2]: *** [/.../linux/Makefile:673: outputmakefile] Error 1
> >    make[1]: *** [/.../linux/Makefile:248: __sub-make] Error 2
> >    make[1]: Leaving directory '/.../linux/build'
> >    make: *** [Makefile:248: __sub-make] Error 2
> >
> > Usually, running 'make mrproper' is sufficient for cleaning the source
> > tree for out-of-tree builds.
> >
> > However, building UML generates build artifacts not only in arch/um/,
> > but also in the SUBARCH directory (i.e., arch/x86/). If in-tree stale
> > files remain under arch/x86/, Kbuild will reuse them instead of creating
> > new ones under the specified build directory.
> >
> > This commit makes 'make ARCH=um clean' recurse into the SUBARCH directory.
> >
> > Reported-by: Shuah Khan <skhan@linuxfoundation.org>
> > Closes: https://lore.kernel.org/lkml/20250502172459.14175-1-skhan@linuxfoundation.org/
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
>
> It doesn't solve the problem. I still see arch/x86/realmode/rm/pasyms.h
> after running make ARCH=um mrproper


Why not?

This patch allows 'make ARCH=um mrproper'
to clean up both arch/um and arch/x86/.

It is really simple to test the behavior.


[Without this patch]

masahiro@zoe:~/workspace/linux-kbuild(master)$ touch
arch/x86/realmode/rm/pasyms.h
masahiro@zoe:~/workspace/linux-kbuild(master)$ make ARCH=um mrproper
masahiro@zoe:~/workspace/linux-kbuild(master)$ ls arch/x86/realmode/rm/pasyms.h
arch/x86/realmode/rm/pasyms.h

[With this patch]

masahiro@zoe:~/workspace/linux-kbuild(kbuild)$ touch
arch/x86/realmode/rm/pasyms.h
masahiro@zoe:~/workspace/linux-kbuild(kbuild)$ make ARCH=um mrproper
  CLEAN   arch/x86/realmode/rm
masahiro@zoe:~/workspace/linux-kbuild(kbuild)$ ls arch/x86/realmode/rm/pasyms.h
ls: cannot access 'arch/x86/realmode/rm/pasyms.h': No such file or directory





> A subsequent kunit run on x86_64 fails. make ARCH=x86_64 mrproper
> will remove the headers for x86_64 properly. The patch I proposed
> prompts user run mrproper on the arch in compile.h - It works now
> for the case where compile.h doesn't exist. I can send that out
> unless you have other ideas on how to fix this.

No.

If you still see a problem, please explain the bad scenario,
please explain without kunit.









> My workflow:
>
> - Build kernel on x86_64 with CONFIG_AMD_MEM_ENCRYPT enabled
>
> - Check for arch/x86/realmode/rm/pasyms.h
>    ls arch/x86/realmode/rm/pasyms.h
>       arch/x86/realmode/rm/pasyms.h
>
> - make ARCH=um O=/linux/build
>
>    This patch cleans the source tree, but doesn't remove
>    arch/x86/realmode/rm/pasyms.h
>
> - ls arch/x86/realmode/rm/pasyms.h
>       arch/x86/realmode/rm/pasyms.h
>
> - ./tools/testing/kunit/kunit.py run --alltests --arch x86_64
> [15:26:35] Configuring KUnit Kernel ...
> Regenerating .config ...
> Populating config with:
> $ make ARCH=x86_64 O=.kunit olddefconfig
> [15:26:37] Building KUnit Kernel ...
> Populating config with:
> $ make ARCH=x86_64 O=.kunit olddefconfig
> Building with:
> $ make all compile_commands.json scripts_gdb ARCH=x86_64 O=.kunit --jobs=16
> ERROR:root:ld:arch/x86/realmode/rm/realmode.lds:236: undefined symbol `sev_es_trampoline_start' referenced in expression
> make[6]: *** [../arch/x86/realmode/rm/Makefile:49: arch/x86/realmode/rm/realmode.elf] Error 1
> make[5]: *** [../arch/x86/realmode/Makefile:22: arch/x86/realmode/rm/realmode.bin] Error 2
> make[4]: *** [../scripts/Makefile.build:461: arch/x86/realmode] Error 2
> make[4]: *** Waiting for unfinished jobs....
> make[3]: *** [../scripts/Makefile.build:461: arch/x86] Error 2
> make[3]: *** Waiting for unfinished jobs....
> make[2]: *** [/linux/linux_kselftest/Makefile:2009: .] Error 2
> make[1]: *** [/linux/linux_kselftest/Makefile:248: __sub-make] Error 2
> make: *** [Makefile:248: __sub-make] Error 2
>
> thanks,
> -- Shuah



--
Best Regards

Masahiro Yamada

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] um: let 'make clean' properly clean underlying SUBARCH as well
  2025-05-07 21:38 ` Shuah Khan
  2025-05-07 23:49   ` Masahiro Yamada
@ 2025-05-08  5:29   ` Johannes Berg
  2025-05-08  7:38     ` Geert Uytterhoeven
  1 sibling, 1 reply; 11+ messages in thread
From: Johannes Berg @ 2025-05-08  5:29 UTC (permalink / raw)
  To: Shuah Khan, Masahiro Yamada, linux-kbuild
  Cc: linux-kernel, Anton Ivanov, Richard Weinberger, linux-um,
	David Gow

On Wed, 2025-05-07 at 15:38 -0600, Shuah Khan wrote:
> My workflow:
> 
> - Build kernel on x86_64 with CONFIG_AMD_MEM_ENCRYPT enabled
> 
> - Check for arch/x86/realmode/rm/pasyms.h
>    ls arch/x86/realmode/rm/pasyms.h
>       arch/x86/realmode/rm/pasyms.h
> 
> - make ARCH=um O=/linux/build
>    
>    This patch cleans the source tree, but doesn't remove
>    arch/x86/realmode/rm/pasyms.h
> 
> - ls arch/x86/realmode/rm/pasyms.h
>       arch/x86/realmode/rm/pasyms.h

Is that even _expected_ to work? If you have x86 built first, I'd almost
expect you to have to do "make ARCH=x86 mrproper" before building
another ARCH. I don't see how ARCH=um would know how to do a full clean
up of ARCH=x86, unless this is somehow arch-independent?

Or maybe that's not an issue with other architectures because UML is
special in that it uses parts of x86?

Though I guess the patch here should make it do that, more or less, but
it can't, likely because you're also switching from in-tree build to O=
build?

johannes

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] um: let 'make clean' properly clean underlying SUBARCH as well
  2025-05-07  7:49 [PATCH] um: let 'make clean' properly clean underlying SUBARCH as well Masahiro Yamada
  2025-05-07 16:13 ` Johannes Berg
  2025-05-07 21:38 ` Shuah Khan
@ 2025-05-08  6:12 ` David Gow
  2 siblings, 0 replies; 11+ messages in thread
From: David Gow @ 2025-05-08  6:12 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, linux-kernel, Shuah Khan, Anton Ivanov,
	Johannes Berg, Richard Weinberger, linux-um

[-- Attachment #1: Type: text/plain, Size: 2381 bytes --]

On Wed, 7 May 2025 at 16:43, Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> Building the kernel with O= is affected by stale in-tree build artifacts.
>
> So, if the source tree is not clean, Kbuild displays the following:
>
>   $ make ARCH=um O=build defconfig
>   make[1]: Entering directory '/.../linux/build'
>   ***
>   *** The source tree is not clean, please run 'make ARCH=um mrproper'
>   *** in /.../linux
>   ***
>   make[2]: *** [/.../linux/Makefile:673: outputmakefile] Error 1
>   make[1]: *** [/.../linux/Makefile:248: __sub-make] Error 2
>   make[1]: Leaving directory '/.../linux/build'
>   make: *** [Makefile:248: __sub-make] Error 2
>
> Usually, running 'make mrproper' is sufficient for cleaning the source
> tree for out-of-tree builds.
>
> However, building UML generates build artifacts not only in arch/um/,
> but also in the SUBARCH directory (i.e., arch/x86/). If in-tree stale
> files remain under arch/x86/, Kbuild will reuse them instead of creating
> new ones under the specified build directory.
>
> This commit makes 'make ARCH=um clean' recurse into the SUBARCH directory.
>
> Reported-by: Shuah Khan <skhan@linuxfoundation.org>
> Closes: https://lore.kernel.org/lkml/20250502172459.14175-1-skhan@linuxfoundation.org/
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---

Thanks: thinking about it, I agree that this is the better solution,
as it handles some architecture-switching cases better.

I've tested it here, and it's definitely fixing my KUnit-based repro
case: the "The source tree is not clean, please run 'make ARCH=um
mrproper'" message appears as previously, but make ARCH=um mrproper
(from the source directory) does remove the pasyms.h file correctly.

So:

Reviewed-by: David Gow <davidgow@google.com>

Cheers,
-- David


>
>  arch/um/Makefile | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/arch/um/Makefile b/arch/um/Makefile
> index 1d36a613aad8..9ed792e565c9 100644
> --- a/arch/um/Makefile
> +++ b/arch/um/Makefile
> @@ -154,5 +154,6 @@ MRPROPER_FILES += $(HOST_DIR)/include/generated
>  archclean:
>         @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \
>                 -o -name '*.gcov' \) -type f -print | xargs rm -f
> +       $(Q)$(MAKE) -f $(srctree)/Makefile ARCH=$(HEADER_ARCH) clean
>
>  export HEADER_ARCH SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING DEV_NULL_PATH
> --
> 2.43.0
>
>

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 5281 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] um: let 'make clean' properly clean underlying SUBARCH as well
  2025-05-08  5:29   ` Johannes Berg
@ 2025-05-08  7:38     ` Geert Uytterhoeven
  2025-05-08  8:14       ` Masahiro Yamada
  0 siblings, 1 reply; 11+ messages in thread
From: Geert Uytterhoeven @ 2025-05-08  7:38 UTC (permalink / raw)
  To: Johannes Berg
  Cc: Shuah Khan, Masahiro Yamada, linux-kbuild, linux-kernel,
	Anton Ivanov, Richard Weinberger, linux-um, David Gow

Hi Johannes,

On Thu, 8 May 2025 at 07:29, Johannes Berg <johannes@sipsolutions.net> wrote:
> On Wed, 2025-05-07 at 15:38 -0600, Shuah Khan wrote:
> > My workflow:
> >
> > - Build kernel on x86_64 with CONFIG_AMD_MEM_ENCRYPT enabled
> >
> > - Check for arch/x86/realmode/rm/pasyms.h
> >    ls arch/x86/realmode/rm/pasyms.h
> >       arch/x86/realmode/rm/pasyms.h
> >
> > - make ARCH=um O=/linux/build
> >
> >    This patch cleans the source tree, but doesn't remove
> >    arch/x86/realmode/rm/pasyms.h
> >
> > - ls arch/x86/realmode/rm/pasyms.h
> >       arch/x86/realmode/rm/pasyms.h
>
> Is that even _expected_ to work? If you have x86 built first, I'd almost
> expect you to have to do "make ARCH=x86 mrproper" before building
> another ARCH. I don't see how ARCH=um would know how to do a full clean
> up of ARCH=x86, unless this is somehow arch-independent?
>
> Or maybe that's not an issue with other architectures because UML is
> special in that it uses parts of x86?

Probably.
I only use my linux-next source tree for fixing reported build issues on
various architectures, and I never use make clean/mrproper.  Works fine.

> Though I guess the patch here should make it do that, more or less, but
> it can't, likely because you're also switching from in-tree build to O=
> build?

Yeah, mixing in-tree and out-of-tree builds causes issues.
Never build in-tree in a source tree you use with O= (except for
e.g. "make tags").

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] um: let 'make clean' properly clean underlying SUBARCH as well
  2025-05-08  7:38     ` Geert Uytterhoeven
@ 2025-05-08  8:14       ` Masahiro Yamada
  2025-05-08  8:17         ` Geert Uytterhoeven
  0 siblings, 1 reply; 11+ messages in thread
From: Masahiro Yamada @ 2025-05-08  8:14 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Johannes Berg, Shuah Khan, linux-kbuild, linux-kernel,
	Anton Ivanov, Richard Weinberger, linux-um, David Gow

On Thu, May 8, 2025 at 4:38 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>
> Hi Johannes,
>
> On Thu, 8 May 2025 at 07:29, Johannes Berg <johannes@sipsolutions.net> wrote:
> > On Wed, 2025-05-07 at 15:38 -0600, Shuah Khan wrote:
> > > My workflow:
> > >
> > > - Build kernel on x86_64 with CONFIG_AMD_MEM_ENCRYPT enabled
> > >
> > > - Check for arch/x86/realmode/rm/pasyms.h
> > >    ls arch/x86/realmode/rm/pasyms.h
> > >       arch/x86/realmode/rm/pasyms.h
> > >
> > > - make ARCH=um O=/linux/build
> > >
> > >    This patch cleans the source tree, but doesn't remove
> > >    arch/x86/realmode/rm/pasyms.h
> > >
> > > - ls arch/x86/realmode/rm/pasyms.h
> > >       arch/x86/realmode/rm/pasyms.h
> >
> > Is that even _expected_ to work? If you have x86 built first, I'd almost
> > expect you to have to do "make ARCH=x86 mrproper" before building
> > another ARCH. I don't see how ARCH=um would know how to do a full clean
> > up of ARCH=x86, unless this is somehow arch-independent?
> >
> > Or maybe that's not an issue with other architectures because UML is
> > special in that it uses parts of x86?
>
> Probably.
> I only use my linux-next source tree for fixing reported build issues on
> various architectures, and I never use make clean/mrproper.  Works fine.
>
> > Though I guess the patch here should make it do that, more or less, but
> > it can't, likely because you're also switching from in-tree build to O=
> > build?
>
> Yeah, mixing in-tree and out-of-tree builds causes issues.
> Never build in-tree in a source tree you use with O= (except for
> e.g. "make tags").
>

I argue this.

You can start out-of-tree builds after running 'make mrproper'
for the architecture you want to build the kernel for.

Hence, Kbuild suggests to do so when it determines
the source tree is not clean enough.

Unfortunately, "make mrproper ARCH=um" did not clean the tree
deeply enough.   Hence, this patch.


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] um: let 'make clean' properly clean underlying SUBARCH as well
  2025-05-08  8:14       ` Masahiro Yamada
@ 2025-05-08  8:17         ` Geert Uytterhoeven
  0 siblings, 0 replies; 11+ messages in thread
From: Geert Uytterhoeven @ 2025-05-08  8:17 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Johannes Berg, Shuah Khan, linux-kbuild, linux-kernel,
	Anton Ivanov, Richard Weinberger, linux-um, David Gow

Hi Yamada-san,

On Thu, 8 May 2025 at 10:14, Masahiro Yamada <masahiroy@kernel.org> wrote:
> On Thu, May 8, 2025 at 4:38 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > On Thu, 8 May 2025 at 07:29, Johannes Berg <johannes@sipsolutions.net> wrote:
> > > On Wed, 2025-05-07 at 15:38 -0600, Shuah Khan wrote:
> > > > My workflow:
> > > >
> > > > - Build kernel on x86_64 with CONFIG_AMD_MEM_ENCRYPT enabled
> > > >
> > > > - Check for arch/x86/realmode/rm/pasyms.h
> > > >    ls arch/x86/realmode/rm/pasyms.h
> > > >       arch/x86/realmode/rm/pasyms.h
> > > >
> > > > - make ARCH=um O=/linux/build
> > > >
> > > >    This patch cleans the source tree, but doesn't remove
> > > >    arch/x86/realmode/rm/pasyms.h
> > > >
> > > > - ls arch/x86/realmode/rm/pasyms.h
> > > >       arch/x86/realmode/rm/pasyms.h
> > >
> > > Is that even _expected_ to work? If you have x86 built first, I'd almost
> > > expect you to have to do "make ARCH=x86 mrproper" before building
> > > another ARCH. I don't see how ARCH=um would know how to do a full clean
> > > up of ARCH=x86, unless this is somehow arch-independent?
> > >
> > > Or maybe that's not an issue with other architectures because UML is
> > > special in that it uses parts of x86?
> >
> > Probably.
> > I only use my linux-next source tree for fixing reported build issues on
> > various architectures, and I never use make clean/mrproper.  Works fine.
> >
> > > Though I guess the patch here should make it do that, more or less, but
> > > it can't, likely because you're also switching from in-tree build to O=
> > > build?
> >
> > Yeah, mixing in-tree and out-of-tree builds causes issues.
> > Never build in-tree in a source tree you use with O= (except for
> > e.g. "make tags").
>
> I argue this.
>
> You can start out-of-tree builds after running 'make mrproper'
> for the architecture you want to build the kernel for.
>
> Hence, Kbuild suggests to do so when it determines
> the source tree is not clean enough.

Sorry, I meant "without mrproper" (which wipes my tags file).

> Unfortunately, "make mrproper ARCH=um" did not clean the tree
> deeply enough.   Hence, this patch.

Thanks, fine!

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] um: let 'make clean' properly clean underlying SUBARCH as well
  2025-05-07 23:49   ` Masahiro Yamada
@ 2025-05-08 22:14     ` Shuah Khan
  2025-05-08 23:43       ` Masahiro Yamada
  0 siblings, 1 reply; 11+ messages in thread
From: Shuah Khan @ 2025-05-08 22:14 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, linux-kernel, Anton Ivanov, Johannes Berg,
	Richard Weinberger, linux-um, David Gow, Shuah Khan

On 5/7/25 17:49, Masahiro Yamada wrote:
> On Thu, May 8, 2025 at 6:38 AM Shuah Khan <skhan@linuxfoundation.org> wrote:
>>
>> On 5/7/25 01:49, Masahiro Yamada wrote:
>>> Building the kernel with O= is affected by stale in-tree build artifacts.
>>>
>>> So, if the source tree is not clean, Kbuild displays the following:
>>>
>>>     $ make ARCH=um O=build defconfig
>>>     make[1]: Entering directory '/.../linux/build'
>>>     ***
>>>     *** The source tree is not clean, please run 'make ARCH=um mrproper'
>>>     *** in /.../linux
>>>     ***
>>>     make[2]: *** [/.../linux/Makefile:673: outputmakefile] Error 1
>>>     make[1]: *** [/.../linux/Makefile:248: __sub-make] Error 2
>>>     make[1]: Leaving directory '/.../linux/build'
>>>     make: *** [Makefile:248: __sub-make] Error 2
>>>
>>> Usually, running 'make mrproper' is sufficient for cleaning the source
>>> tree for out-of-tree builds.
>>>
>>> However, building UML generates build artifacts not only in arch/um/,
>>> but also in the SUBARCH directory (i.e., arch/x86/). If in-tree stale
>>> files remain under arch/x86/, Kbuild will reuse them instead of creating
>>> new ones under the specified build directory.
>>>
>>> This commit makes 'make ARCH=um clean' recurse into the SUBARCH directory.
>>>
>>> Reported-by: Shuah Khan <skhan@linuxfoundation.org>
>>> Closes: https://lore.kernel.org/lkml/20250502172459.14175-1-skhan@linuxfoundation.org/
>>> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
>>
>> It doesn't solve the problem. I still see arch/x86/realmode/rm/pasyms.h
>> after running make ARCH=um mrproper
> 
> 
> Why not?
> 
> This patch allows 'make ARCH=um mrproper'
> to clean up both arch/um and arch/x86/.
> 
> It is really simple to test the behavior.
> 
> 
> [Without this patch]
> 
> masahiro@zoe:~/workspace/linux-kbuild(master)$ touch
> arch/x86/realmode/rm/pasyms.h
> masahiro@zoe:~/workspace/linux-kbuild(master)$ make ARCH=um mrproper
> masahiro@zoe:~/workspace/linux-kbuild(master)$ ls arch/x86/realmode/rm/pasyms.h
> arch/x86/realmode/rm/pasyms.h
> 
> [With this patch]
> 
> masahiro@zoe:~/workspace/linux-kbuild(kbuild)$ touch
> arch/x86/realmode/rm/pasyms.h
> masahiro@zoe:~/workspace/linux-kbuild(kbuild)$ make ARCH=um mrproper
>    CLEAN   arch/x86/realmode/rm
> masahiro@zoe:~/workspace/linux-kbuild(kbuild)$ ls arch/x86/realmode/rm/pasyms.h
> ls: cannot access 'arch/x86/realmode/rm/pasyms.h': No such file or directory
> 

I ran another controlled test starting from a totally clean repo
and the building - looks good to me.

Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>

thanks,
-- Shuah


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] um: let 'make clean' properly clean underlying SUBARCH as well
  2025-05-08 22:14     ` Shuah Khan
@ 2025-05-08 23:43       ` Masahiro Yamada
  0 siblings, 0 replies; 11+ messages in thread
From: Masahiro Yamada @ 2025-05-08 23:43 UTC (permalink / raw)
  To: Shuah Khan
  Cc: linux-kbuild, linux-kernel, Anton Ivanov, Johannes Berg,
	Richard Weinberger, linux-um, David Gow

On Fri, May 9, 2025 at 7:14 AM Shuah Khan <skhan@linuxfoundation.org> wrote:
>
> On 5/7/25 17:49, Masahiro Yamada wrote:
> > On Thu, May 8, 2025 at 6:38 AM Shuah Khan <skhan@linuxfoundation.org> wrote:
> >>
> >> On 5/7/25 01:49, Masahiro Yamada wrote:
> >>> Building the kernel with O= is affected by stale in-tree build artifacts.
> >>>
> >>> So, if the source tree is not clean, Kbuild displays the following:
> >>>
> >>>     $ make ARCH=um O=build defconfig
> >>>     make[1]: Entering directory '/.../linux/build'
> >>>     ***
> >>>     *** The source tree is not clean, please run 'make ARCH=um mrproper'
> >>>     *** in /.../linux
> >>>     ***
> >>>     make[2]: *** [/.../linux/Makefile:673: outputmakefile] Error 1
> >>>     make[1]: *** [/.../linux/Makefile:248: __sub-make] Error 2
> >>>     make[1]: Leaving directory '/.../linux/build'
> >>>     make: *** [Makefile:248: __sub-make] Error 2
> >>>
> >>> Usually, running 'make mrproper' is sufficient for cleaning the source
> >>> tree for out-of-tree builds.
> >>>
> >>> However, building UML generates build artifacts not only in arch/um/,
> >>> but also in the SUBARCH directory (i.e., arch/x86/). If in-tree stale
> >>> files remain under arch/x86/, Kbuild will reuse them instead of creating
> >>> new ones under the specified build directory.
> >>>
> >>> This commit makes 'make ARCH=um clean' recurse into the SUBARCH directory.
> >>>
> >>> Reported-by: Shuah Khan <skhan@linuxfoundation.org>
> >>> Closes: https://lore.kernel.org/lkml/20250502172459.14175-1-skhan@linuxfoundation.org/
> >>> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> >>
> >> It doesn't solve the problem. I still see arch/x86/realmode/rm/pasyms.h
> >> after running make ARCH=um mrproper
> >
> >
> > Why not?
> >
> > This patch allows 'make ARCH=um mrproper'
> > to clean up both arch/um and arch/x86/.
> >
> > It is really simple to test the behavior.
> >
> >
> > [Without this patch]
> >
> > masahiro@zoe:~/workspace/linux-kbuild(master)$ touch
> > arch/x86/realmode/rm/pasyms.h
> > masahiro@zoe:~/workspace/linux-kbuild(master)$ make ARCH=um mrproper
> > masahiro@zoe:~/workspace/linux-kbuild(master)$ ls arch/x86/realmode/rm/pasyms.h
> > arch/x86/realmode/rm/pasyms.h
> >
> > [With this patch]
> >
> > masahiro@zoe:~/workspace/linux-kbuild(kbuild)$ touch
> > arch/x86/realmode/rm/pasyms.h
> > masahiro@zoe:~/workspace/linux-kbuild(kbuild)$ make ARCH=um mrproper
> >    CLEAN   arch/x86/realmode/rm
> > masahiro@zoe:~/workspace/linux-kbuild(kbuild)$ ls arch/x86/realmode/rm/pasyms.h
> > ls: cannot access 'arch/x86/realmode/rm/pasyms.h': No such file or directory
> >
>
> I ran another controlled test starting from a totally clean repo
> and the building - looks good to me.
>
> Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
>
> thanks,
> -- Shuah
>

Applied to linux-kbuild.


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2025-05-08 23:44 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-07  7:49 [PATCH] um: let 'make clean' properly clean underlying SUBARCH as well Masahiro Yamada
2025-05-07 16:13 ` Johannes Berg
2025-05-07 21:38 ` Shuah Khan
2025-05-07 23:49   ` Masahiro Yamada
2025-05-08 22:14     ` Shuah Khan
2025-05-08 23:43       ` Masahiro Yamada
2025-05-08  5:29   ` Johannes Berg
2025-05-08  7:38     ` Geert Uytterhoeven
2025-05-08  8:14       ` Masahiro Yamada
2025-05-08  8:17         ` Geert Uytterhoeven
2025-05-08  6:12 ` David Gow

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox