Bug 209093 - KERNELRELESE may be empty when building kernel by multi-threads
Summary: KERNELRELESE may be empty when building kernel by multi-threads
Status: NEW
Alias: None
Product: Other
Classification: Unclassified
Component: Modules (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: other_modules
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-08-31 17:40 UTC by Larry
Modified: 2020-08-31 17:40 UTC (History)
1 user (show)

See Also:
Kernel Version: 4.14.y
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Larry 2020-08-31 17:40:12 UTC
I need to create a new module named my_driver, which could be built both in and  out  of kernel source tree, so I use the KERNELRELEASE to share the Makefile, and write the module Makefile like this:

ifeq ($(KERNELRELEASE),)
	KDIR=/xxx/linux-4.14.y
	all:
		$(MAKE) -C $(KDIR) M=$$PWD
else
	obj-$(BUILD_TYPE) = xxx.o
	xxx-y = x.o y.o
endif

I put my_driver out of the kernel source tree and make a soft link to my_driver in the drivers directory, like this:

drivers/my_driver -> ../../my_driver/

When I build the kernel with 'make ARCH=arm64 CROSS_COMPILE=aarch64-hi100-linux- BUILD_TYPE=y -j ',  it may fail sometimes and I found that KERNELRELEASE may be empty sometimes.

So I add some info to check the problem, like this:

$(info KERNELRELEASE=$(KERNELRELEASE))

ifeq ($(KERNELRELEASE),)
$(error It's not right!)
...
else
$(info We should be here!)
...
endif

And then I get the error again when building the kernel, like this:

xxx:~/build/xxx/linux-4.14.y> make ARCH=arm64 CROSS_COMPILE=aarch64-hi100-linux- BUILD_TYPE=y -j
scripts/kconfig/conf  --silentoldconfig Kconfig
  CHK     include/config/kernel.release
  WRAP    arch/arm64/include/generated/uapi/asm/errno.h
  WRAP    arch/arm64/include/generated/uapi/asm/ioctl.h
  WRAP    arch/arm64/include/generated/uapi/asm/kvm_para.h
  WRAP    arch/arm64/include/generated/uapi/asm/ipcbuf.h
  WRAP    arch/arm64/include/generated/uapi/asm/mman.h
  WRAP    arch/arm64/include/generated/uapi/asm/poll.h
  WRAP    arch/arm64/include/generated/uapi/asm/ioctls.h
  WRAP    arch/arm64/include/generated/uapi/asm/msgbuf.h
  WRAP    arch/arm64/include/generated/uapi/asm/resource.h
  WRAP    arch/arm64/include/generated/uapi/asm/sembuf.h
  WRAP    arch/arm64/include/generated/uapi/asm/socket.h
  WRAP    arch/arm64/include/generated/uapi/asm/shmbuf.h
  WRAP    arch/arm64/include/generated/uapi/asm/swab.h
  WRAP    arch/arm64/include/generated/uapi/asm/sockios.h
  WRAP    arch/arm64/include/generated/uapi/asm/termbits.h
  CHK     include/generated/uapi/linux/version.h
  UPD     include/generated/uapi/linux/version.h
  WRAP    arch/arm64/include/generated/uapi/asm/termios.h
  WRAP    arch/arm64/include/generated/uapi/asm/types.h
KERNELRELEASE=
drivers/my_driver/Makefile:5: *** It's not right!.  Stop.
scripts/Makefile.modbuiltin:55: recipe for target 'drivers/my_driver' failed
make[1]: *** [drivers/my_driver] Error 2
make[1]: *** Waiting for unfinished jobs....
Makefile:1360: recipe for target 'drivers/modules.builtin' failed
make: *** [drivers/modules.builtin] Error 2
make: *** Waiting for unfinished jobs....
  UPD     include/config/kernel.release
make: *** wait: No child processes.  Stop.

 #### make target "ARCH=arm64 CROSS_COMPILE=aarch64-hi100-linux- -j" failed !!!(01:03 (mm:ss)) ####


Please check if this issue is a bug! Thanks!

Note You need to log in before you can comment on or make changes to this bug.