diff mbox

scripts/kconfig/Makefile: Fix KBUILD_DEFCONFIG check when building with O=

Message ID 1444889150-23609-1-git-send-email-mpe@ellerman.id.au (mailing list archive)
State Accepted
Headers show

Commit Message

Michael Ellerman Oct. 15, 2015, 6:05 a.m. UTC
My recent commit d2036f30cfe1 ("scripts/kconfig/Makefile: Allow
KBUILD_DEFCONFIG to be a target"), contained a bug in that when it
checks if KBUILD_DEFCONFIG is a file it forgets to prepend $(srctree) to
the path.

This causes the build to fail when building out of tree (with O=), and
when the value of KBUILD_DEFCONFIG is 'defconfig'. In that case we will
fail to find the 'defconfig' file, because we look in the build
directory not $(srctree), and so we will call Make again with
'defconfig' as the target. From there we loop infinitely calling 'make
defconfig' again and again.

The fix is simple, we need to look for the file under $(srctree).

Fixes: d2036f30cfe1 ("scripts/kconfig/Makefile: Allow KBUILD_DEFCONFIG to be a target")
Reported-by: Olof Johansson <olof@lixom.net>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 scripts/kconfig/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


This works for me and is a minimal fix. I'll merge this into the powerpc#next
branch unless anyone yells.

Comments

Michal Marek Oct. 15, 2015, 7:27 a.m. UTC | #1
Dne 15.10.2015 v 08:05 Michael Ellerman napsal(a):
> My recent commit d2036f30cfe1 ("scripts/kconfig/Makefile: Allow
> KBUILD_DEFCONFIG to be a target"), contained a bug in that when it
> checks if KBUILD_DEFCONFIG is a file it forgets to prepend $(srctree) to
> the path.
> 
> This causes the build to fail when building out of tree (with O=), and
> when the value of KBUILD_DEFCONFIG is 'defconfig'. In that case we will
> fail to find the 'defconfig' file, because we look in the build
> directory not $(srctree), and so we will call Make again with
> 'defconfig' as the target. From there we loop infinitely calling 'make
> defconfig' again and again.
> 
> The fix is simple, we need to look for the file under $(srctree).
> 
> Fixes: d2036f30cfe1 ("scripts/kconfig/Makefile: Allow KBUILD_DEFCONFIG to be a target")
> Reported-by: Olof Johansson <olof@lixom.net>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

Acked-by: Michal Marek <mmarek@suse.com>

I could have spotted it myself :-/.

Michal
Michael Ellerman Oct. 15, 2015, 9:38 a.m. UTC | #2
On Thu, 2015-10-15 at 09:27 +0200, Michal Marek wrote:
> Dne 15.10.2015 v 08:05 Michael Ellerman napsal(a):
> > My recent commit d2036f30cfe1 ("scripts/kconfig/Makefile: Allow
> > KBUILD_DEFCONFIG to be a target"), contained a bug in that when it
> > checks if KBUILD_DEFCONFIG is a file it forgets to prepend $(srctree) to
> > the path.
> > 
> > This causes the build to fail when building out of tree (with O=), and
> > when the value of KBUILD_DEFCONFIG is 'defconfig'. In that case we will
> > fail to find the 'defconfig' file, because we look in the build
> > directory not $(srctree), and so we will call Make again with
> > 'defconfig' as the target. From there we loop infinitely calling 'make
> > defconfig' again and again.
> > 
> > The fix is simple, we need to look for the file under $(srctree).
> > 
> > Fixes: d2036f30cfe1 ("scripts/kconfig/Makefile: Allow KBUILD_DEFCONFIG to be a target")
> > Reported-by: Olof Johansson <olof@lixom.net>
> > Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> 
> Acked-by: Michal Marek <mmarek@suse.com>
> 
> I could have spotted it myself :-/.

It was pretty easy to miss in the diff, especially as the kconfig invocation
doesn't use $(srctree).

I should have noticed it in my testing, but it didn't actually break powerpc,
so the only clue was that the message says "based on target". Anyway fixed now
hopefully.

cheers
diff mbox

Patch

diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index b2b9c87cec50..3043d6b0b51d 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -96,7 +96,7 @@  savedefconfig: $(obj)/conf
 defconfig: $(obj)/conf
 ifeq ($(KBUILD_DEFCONFIG),)
 	$< $(silent) --defconfig $(Kconfig)
-else ifneq ($(wildcard arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)),)
+else ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)),)
 	@$(kecho) "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
 	$(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
 else