All of lore.kernel.org
 help / color / mirror / Atom feed
From: kamensky@cisco.com (Victor Kamensky)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm64: makefile fix build of .i file in external module case
Date: Tue, 30 Oct 2018 16:37:10 -0700	[thread overview]
Message-ID: <20181030233710.5529-1-kamensky@cisco.com> (raw)

After 'a66649dab350 arm64: fix vdso-offsets.h dependency' if
one will try to build .i file in case of external kernel module,
build fails complaining that prepare0 target is missing. This
issue came up with SystemTap when it tries to build variety
of .i files for its own generated kernel modules trying to
figure given kernel features/capabilities.

The issue is that prepare0 is defined in top level Makefile
only if KBUILD_EXTMOD is not defined. .i file rule depends
on prepare and in case KBUILD_EXTMOD defined top level Makefile
contains empty rule for prepare. But after mentioned commit
arch/arm64/Makefile would introduce dependency on prepare0
through its own prepare target.

Fix it to put proper ifdef KBUILD_EXTMOD around code introduced
by mentioned commit. It matches what top level Makefile does.

Signed-off-by: Victor Kamensky <kamensky@cisco.com>
---
Test to reproduce the issue:

[kamensky at kamensky-w541 m]$ cat hello.c 
#include <linux/module.h>
#include <linux/printk.h>

int
init_module (void)
{
    printk(KERN_DEBUG "Hello, world\n");
    return 0;
}

void
cleanup_module(void)
{
    printk(KERN_ERR "Bye, got unloaded\n");
}

MODULE_LICENSE("GPL");
[kamensky at kamensky-w541 m]$ cat Makefile 
obj-m := hello.o
[kamensky at kamensky-w541 m]$ make -C /home/kamensky/linux M=`pwd`
make: Entering directory '/home/kamensky/linux'
  CC [M]  /home/kamensky/m/hello.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /home/kamensky/m/hello.mod.o
  LD [M]  /home/kamensky/m/hello.ko
make: Leaving directory '/home/kamensky/linux'
[kamensky at kamensky-w541 m]$ make -C /home/kamensky/linux M=`pwd` hello.i
make: Entering directory '/home/kamensky/linux'
make: *** No rule to make target 'prepare0', needed by 'vdso_prepare'.  Stop.
make: Leaving directory '/home/kamensky/linux'
[kamensky at kamensky-w541 m]$ 

After the fix:

[kamensky at kamensky-w541 m]$ make -C /home/kamensky/linux M=`pwd` hello.i
make: Entering directory '/home/kamensky/linux'
  CPP [M] /home/kamensky/m/hello.i
make: Leaving directory '/home/kamensky/linux'
[kamensky at kamensky-w541 m]

 arch/arm64/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index 106039d25e2f..3016ccb41468 100644
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -147,6 +147,7 @@ archclean:
 	$(Q)$(MAKE) $(clean)=$(boot)
 	$(Q)$(MAKE) $(clean)=$(boot)/dts
 
+ifeq ($(KBUILD_EXTMOD),)
 # We need to generate vdso-offsets.h before compiling certain files in kernel/.
 # In order to do that, we should use the archprepare target, but we can't since
 # asm-offsets.h is included in some files used to generate vdso-offsets.h, and
@@ -156,6 +157,7 @@ archclean:
 prepare: vdso_prepare
 vdso_prepare: prepare0
 	$(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso include/generated/vdso-offsets.h
+endif
 
 define archhelp
   echo  '* Image.gz      - Compressed kernel image (arch/$(ARCH)/boot/Image.gz)'
-- 
2.17.2

             reply	other threads:[~2018-10-30 23:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-30 23:37 Victor Kamensky [this message]
2018-11-01 18:29 ` [PATCH] arm64: makefile fix build of .i file in external module case Kevin Brodsky
2018-11-02 17:26 ` Catalin Marinas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181030233710.5529-1-kamensky@cisco.com \
    --to=kamensky@cisco.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.