Bug 12803 - [Yocto-2.6_M1.RC1] Building a kernel module on target image fails
Summary: [Yocto-2.6_M1.RC1] Building a kernel module on target image fails
Status: RESOLVED NOTABUG
Alias: None
Product: Meta-yocto
Classification: Build System, Metadata & Runtime
Component: meta-yocto (show other bugs)
Version: 2.6
Hardware: x86 Multiple
: Medium+ normal
Target Milestone: 2.6 M2
Assignee: Apoorv
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2018-06-20 10:19 UTC by pankaj yadav
Modified: 2018-06-22 11:58 UTC (History)
4 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description pankaj yadav 2018-06-20 10:19:47 UTC
Test Case ID : https://bugzilla.yoctoproject.org/tr_show_case.cgi?case_id=316
poky commit ddbd7b0cd6580ee26e11aa87e426fb294b372d64

Please find the logs for the same : 
root@qemux86-64:/usr/src/kernel# cd /home/root/
root@qemux86-64:~# make
make -C /usr/src/kernel M=/home/root modules
make[1]: Entering directory '/usr/src/kernel'
make[2]: *** No rule to make target 'tools/objtool/objtool', needed by '/home/root/hello.o'. Stop.
make[1]: *** [Makefile:1522: _module_/home/root] Error 2
make[1]: Leaving directory '/usr/src/kernel'
make: *** [Makefile:6: all] Error 2

Steps to reproduce : 
1.Create a QEMU(x86 or x86-64) core-image-sato-sdk image. 
2.Run 'make scripts' in /usr/src/kernel
3. cd /home/root and create hello.c with the following content:
#undef _KERNEL_
#define _KERNEL_
#undef MODULE
#define MODULE
#include <linux/module.h>	
#include <linux/kernel.h>	
#include <linux/init.h>	
static int __init hello_init(void)

{ printk(KERN_INFO "Hello world!\n"); return 0;	}
static void __exit hello_cleanup(void)

{ printk(KERN_INFO "Cleaning up module.\n"); }
module_init(hello_init);
module_exit(hello_cleanup);
4. Create a Makefile with the following content and run 'make'
obj-m := hello.o
KDIR := /usr/src/kernel
PWD := $(shell pwd)
all:
$(MAKE) -C $(KDIR) M=$(PWD) modules
clean:
$(MAKE) -C $(KDIR) M=$(PWD) clean
Comment 1 pankaj yadav 2018-06-21 08:19:00 UTC
While Regression, I unable to see this issue with below mentioned cofiguration :
Branch: master
Build name: yocto-2.5_M1.rc1
poky commit: b73e96e7f3f5d1ba3a221d99792a7a3c7ef42c21  
Architecture : x86-64
Comment 2 Richard Purdie 2018-06-21 09:11:49 UTC
As far as I can tell this is an automated test case:

http://git.yoctoproject.org/cgit.cgi/poky/tree/meta/lib/oeqa/runtime/cases/kernelmodule.py

a) Why are QA running this manually?
b) If it really does need to be run manually, the steps need updating, as already done in the above code:

http://git.yoctoproject.org/cgit.cgi/poky/commit/meta/lib/oeqa/runtime/cases/kernelmodule.py?id=0f85563eacf5138d98b826343cdfc3833d1c5c8e

i.e. "make scripts prepare" instead of "make scripts"

I still wonder why this is being run manually though?
Comment 3 Richard Purdie 2018-06-21 09:12:43 UTC
Also, one part of the bug says yocto-2.5_M1.rc1 the other says yocto-2.6_M1.rc1, I'll assume the latter is correct...
Comment 4 Richard Purdie 2018-06-21 15:00:44 UTC
(In reply to comment #3)
> Also, one part of the bug says yocto-2.5_M1.rc1 the other says
> yocto-2.6_M1.rc1, I'll assume the latter is correct...

I realise now you're highlighting this is a regression, thanks.
Comment 5 pankaj yadav 2018-06-22 07:41:12 UTC
Issue has gone with "make scripts prepare" instead of "make scripts".
Hence please help to close this issue.

Configuration :
Architecture : x86-64
Release : 2.6_M1.RC1

Logs are given below for the same :

root@qemux86-64:/usr/src/kernel# make scripts prepare
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/basic/bin2c
  CC      scripts/mod/empty.o
  HOSTCC  scripts/mod/mk_elfconfig
  MKELF   scripts/mod/elfconfig.h
  HOSTCC  scripts/mod/modpost.o
  CC      scripts/mod/devicetable-offsets.s
  CHK     scripts/mod/devicetable-offsets.h
  UPD     scripts/mod/devicetable-offsets.h
  HOSTCC  scripts/mod/file2alias.o
  HOSTCC  scripts/mod/sumversion.o
  HOSTLD  scripts/mod/modpost
  HOSTCC  scripts/kallsyms
  HOSTCC  scripts/conmakehash
  HOSTCC  scripts/recordmcount
  HOSTCC  scripts/sortextable
  HOSTCC  arch/x86/tools/relocs_32.o
  HOSTCC  arch/x86/tools/relocs_64.o
  HOSTCC  arch/x86/tools/relocs_common.o
  HOSTLD  arch/x86/tools/relocs
  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CC      kernel/bounds.s
  CHK     include/generated/bounds.h
  CHK     include/generated/timeconst.h
  CC      arch/x86/kernel/asm-offsets.s
  CHK     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
  DESCEND  objtool
  HOSTCC   /usr/src/kernel/tools/objtool/fixdep.o
  HOSTLD   /usr/src/kernel/tools/objtool/fixdep-in.o
  LINK     /usr/src/kernel/tools/objtool/fixdep
  CC       /usr/src/kernel/tools/objtool/exec-cmd.o
  CC       /usr/src/kernel/tools/objtool/help.o
  CC       /usr/src/kernel/tools/objtool/pager.o
  CC       /usr/src/kernel/tools/objtool/parse-options.o
  CC       /usr/src/kernel/tools/objtool/run-command.o
  CC       /usr/src/kernel/tools/objtool/sigchain.o
  CC       /usr/src/kernel/tools/objtool/subcmd-config.o
  LD       /usr/src/kernel/tools/objtool/libsubcmd-in.o
  AR       /usr/src/kernel/tools/objtool/libsubcmd.a
  CC       /usr/src/kernel/tools/objtool/arch/x86/decode.o
  LD       /usr/src/kernel/tools/objtool/arch/x86/objtool-in.o
  CC       /usr/src/kernel/tools/objtool/builtin-check.o
  CC       /usr/src/kernel/tools/objtool/builtin-orc.o
  CC       /usr/src/kernel/tools/objtool/check.o
  CC       /usr/src/kernel/tools/objtool/orc_gen.o
  CC       /usr/src/kernel/tools/objtool/orc_dump.o
  CC       /usr/src/kernel/tools/objtool/elf.o
  CC       /usr/src/kernel/tools/objtool/special.o
  CC       /usr/src/kernel/tools/objtool/objtool.o
  CC       /usr/src/kernel/tools/objtool/libstring.o
  CC       /usr/src/kernel/tools/objtool/str_error_r.o
  LD       /usr/src/kernel/tools/objtool/objtool-in.o
Warning: synced file at 'tools/objtool/arch/x86/tools/gen-insn-attr-x86.awk' differs from latest kernel version at 'arch/x86/tools/gen-insn-attr-x86.awk'
  LINK     /usr/src/kernel/tools/objtool/objtool
root@qemux86-64:/usr/src/kernel# cd

root@qemux86-64:~# make
make -C /usr/src/kernel M=/home/root modules
make[1]: Entering directory '/usr/src/kernel'
  CC [M]  /home/root/hello.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /home/root/hello.mod.o
  LD [M]  /home/root/hello.ko
make[1]: Leaving directory '/usr/src/kernel'

root@qemux86-64:~# insmod hello.ko
root@qemux86-64:~# lsmod
Module                  Size  Used by
hello                  16384  0
nfsd                  258048  11
bnep                   20480  2
uvesafb                28672  1 

root@qemux86-64:~#  dmesg | grep -i hello
[  856.655544] hello: loading out-of-tree module taints kernel.
[  856.657533] hello: module license 'unspecified' taints kernel.
[  856.688530] Hello world!
root@qemux86-64:~#
Comment 6 Manish Das 2018-06-22 11:58:05 UTC
Re running the test case with "make scripts prepare" instead of "make scripts" as suggested by Richard, resolved the issue.

Since this test case is already automated, this test care will be removed from the manual execution test suite.