Bug 15161

Summary: kernel can't support SUBDIR
Product: buildroot Reporter: luffy.jiang
Component: OtherAssignee: unassigned
Status: RESOLVED INVALID    
Severity: major CC: buildroot, yann.morin.1998
Priority: P1    
Version: 2022.08.2   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:

Description luffy.jiang 2022-11-30 04:32:15 UTC
My kernel path is top/kernel/linux-x.y.z
I must keep to relative path because of some special reason

the local.mk like this
LINUX_OVERRIDE_SRCDIR = ../kernel
LINUX_SUBDIR = linux-x.y.z

After run make, I found the build directory follow my idea, the top/kernel/linux-x.y.z be copied as output/build/linux-custom/linux-x.y.z/

but make oldconfig failed, because it use LINUX_DIR, I hope it use LINUX_SRCDIR
in package/pkg-kconfig.mk, I saw this code:
$$($(2)_DIR)/$$($(2)_KCONFIG_STAMP_DOTCONFIG): $$($(2)_KCONFIG_FILE) $$($(2)_KCONFIG_FRAGMENT_FILES)
        $$(call prepare-per-package-directory,$$($(2)_KCONFIG_DEPENDENCIES))
        $$(call kconfig-package-merge-config,$(2),$$(@D)/$$($(2)_KCONFIG_DOTCONFIG),\
                $$($(2)_KCONFIG_FRAGMENT_FILES))
        $$(Q)touch $$(@D)/$$($(2)_KCONFIG_STAMP_DOTCONFIG)




build log:

lujiang@cn028lnx02:~/work/mt_sdk/symphony/Lznux/linux/buildroot $ make V=1
/usr/bin/install -m 0644 -D ../kernel/linux-x.y.z/arch/arm64/configs/symphony6_fpga_dbg_defconfig /home/lujiang/work/mt_sdk/symphony/Lznux/linux/buildroot/output/build/linux-custom/.config
support/kconfig/merge_config.sh -m -O /home/lujiang/work/mt_sdk/symphony/Lznux/linux/buildroot/output/build/linux-custom/ /home/lujiang/work/mt_sdk/symphony/Lznux/linux/buildroot/output/build/linux-custom/.config
Using /home/lujiang/work/mt_sdk/symphony/Lznux/linux/buildroot/output/build/linux-custom/.config as base
#
# merged configuration written to /home/lujiang/work/mt_sdk/symphony/Lznux/linux/buildroot/output/build/linux-custom/.config (needs make)
#
(yes "" | PATH="/home/lujiang/work/mt_sdk/symphony/Lznux/linux/buildroot/output/host/bin:/home/lujiang/work/mt_sdk/symphony/Lznux/linux/buildroot/output/host/sbin:/home/lujiang/work/mt_sdk/symphony/Lznux/linux/build/script/mt-pkg-config-dir:/home/lujiang/bin:/home/lujiang/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/lujiang/crosstool-ng/crosstool-ng-1.24.0/bin:/home/lujiang/bin:/usr/local/crosstool-ng/gcc-9.3-glibc-2.28-mipsel-linux-gnu-rm2.0/bin:/usr/local/linaro/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin:/usr/local/linaro/gcc-arm-10.2-2020.11-x86_64-aarch64-none-linux-gnu/bin" PKG_CONFIG="/home/lujiang/work/mt_sdk/symphony/Lznux/linux/buildroot/output/host/bin/pkg-config" PKG_CONFIG_SYSROOT_DIR="/" PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 PKG_CONFIG_LIBDIR="/home/lujiang/work/mt_sdk/symphony/Lznux/linux/buildroot/output/host/lib/pkgconfig:/home/lujiang/work/mt_sdk/symphony/Lznux/linux/buildroot/output/host/share/pkgconfig" BR_BINARIES_DIR=/home/lujiang/work/mt_sdk/symphony/Lznux/linux/buildroot/output/images KCFLAGS=-Wno-attribute-alias /usr/bin/make -j33 -C /home/lujiang/work/mt_sdk/symphony/Lznux/linux/buildroot/output/build/linux-custom HOSTCC="/usr/bin/gcc" HOSTCC="/usr/bin/gcc -O2 -I/home/lujiang/work/mt_sdk/symphony/Lznux/linux/buildroot/output/host/include -L/home/lujiang/work/mt_sdk/symphony/Lznux/linux/buildroot/output/host/lib -Wl,-rpath,/home/lujiang/work/mt_sdk/symphony/Lznux/linux/buildroot/output/host/lib" ARCH=arm64 INSTALL_MOD_PATH=/home/lujiang/work/mt_sdk/symphony/Lznux/linux/buildroot/output/target CROSS_COMPILE="/home/lujiang/work/mt_sdk/symphony/Lznux/linux/buildroot/output/host/bin/aarch64-none-linux-gnu-" WERROR=0 DEPMOD=/home/lujiang/work/mt_sdk/symphony/Lznux/linux/buildroot/output/host/sbin/depmod INSTALL_MOD_STRIP=1 HOSTCC="/usr/bin/gcc" oldconfig)
make[1]: Entering directory '/home/lujiang/work/mt_sdk/symphony/Lznux/linux/buildroot/output/build/linux-custom'
make[1]: *** No rule to make target 'oldconfig'.  Stop.
make[1]: Leaving directory '/home/lujiang/work/mt_sdk/symphony/Lznux/linux/buildroot/output/build/linux-custom'
linux/linux.mk:617: recipe for target '/home/lujiang/work/mt_sdk/symphony/Lznux/linux/buildroot/output/build/linux-custom/.stamp_dotconfig' failed
make: *** [/home/lujiang/work/mt_sdk/symphony/Lznux/linux/buildroot/output/build/linux-custom/.stamp_dotconfig] Error 2




you can see, the kernel config file be copied as output/build/linux-custom/.config, but I want it be copied as output/build/linux-custom/linux-x.y.z/.config

and make oldconfig in output/build/linux-custom/.config,
but I want to i run in output/build/linux-custom/linux-x.y.z





I print the var LINUX_SRCDIR and LINUX_DIR
$ make show-vars VARS=LINUX_SRCDIR
the value is "/home/lujiang/work/mt_sdk/symphony/Lznux/linux/buildroot/output/build/linux-custom/linux-x.y.z"
$ make show-vars VARS=LINUX_DIR
the value is "/home/lujiang/work/mt_sdk/symphony/Lznux/linux/buildroot/output/build/linux-custom"
Comment 1 Thomas Petazzoni 2022-12-01 11:09:29 UTC
I don't understand why you're not doing:

LINUX_OVERRIDE_SRCDIR = ../kernel/linux-x.y.z

and stop using _SUBDIR ?

In your case, I don't understand why you would be using _SUBDIR.
Comment 2 luffy.jiang 2022-12-01 11:49:40 UTC
some kernel space code is not in kernel/linux-x.y.z
my directory tree like this:

top/kernel/msp/drv
top/kernel/linux-x.y.z
top/kernel/linux-x.y.z/drivers

there is a soft link in kernel/linux-x.y.z/drivers
kernel/linux-x.y.z/drivers/msp point to top/kernel/msp/drv
the content of soft link is: ../../msp/drv

I hope set LINUX_OVERRIDE_SRCDIR at kernel level, then rsync can copy all kernel directory, then the relative path can be fixed
Comment 3 Yann E. MORIN 2022-12-10 08:58:19 UTC
Luffy, All,

When you provide overrides of standard pacjages, you have to provide
them with the same layout as the upstream version of those programs.

We can't support arbitrary overrides.

You should fix your kernel tree and your out-of-tree driver, either:
  - move the driver in-tree rather than rely on a symlink, or
  - ensure the driver is a proper out-of-tree driver and can compile
    standalone, and create a buildroot package for it (see kernel-module
    in the manual and existing packages for examples).

Regards,
Yann E. MORIN.