Re: [PATCH v2 7/8] kbuild: use obj-y instead extra-y for objects placed at the head

From: Guenter Roeck
Date: Mon Sep 19 2022 - 18:51:04 EST


Hi,

On Tue, Sep 06, 2022 at 03:13:12PM +0900, Masahiro Yamada wrote:
> The objects placed at the head of vmlinux need special treatments:
>
> - arch/$(SRCARCH)/Makefile adds them to head-y in order to place
> them before other archives in the linker command line.
>
> - arch/$(SRCARCH)/kernel/Makefile adds them to extra-y instead of
> obj-y to avoid them going into built-in.a.
>
> This commit gets rid of the latter.
>
> Create vmlinux.a to collect all the objects that are unconditionally
> linked to vmlinux. The objects listed in head-y are moved to the head
> of vmlinux.a by using 'ar m'.
>
> With this, arch/$(SRCARCH)/kernel/Makefile can consistently use obj-y
> for builtin objects.
>
> There is no *.o that is directly linked to vmlinux. Drop unneeded code
> in scripts/clang-tools/gen_compile_commands.py.
>
> Signed-off-by: Masahiro Yamada <masahiroy@xxxxxxxxxx>
> Reviewed-by: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>

The following build failure is seen when building m68k:defconfig in
next-20220919.

m68k-linux-ld: arch/m68k/kernel/setup.o: in function `setup_arch':
setup.c:(.init.text+0x2dc): undefined reference to `availmem'
m68k-linux-ld: arch/m68k/kernel/early_printk.o: in function `debug_cons_write':
early_printk.c:(.ref.text+0x28): undefined reference to `debug_cons_nputs'
m68k-linux-ld: arch/m68k/mm/init.o: in function `mem_init':
init.c:(.init.text+0x6e): undefined reference to `kernel_pg_dir'
m68k-linux-ld: init.c:(.init.text+0x10): undefined reference to `kernel_pg_dir'
m68k-linux-ld: init.c:(.init.text+0x1e): undefined reference to `kernel_pg_dir'
m68k-linux-ld: arch/m68k/mm/motorola.o: in function `cache_page':
motorola.c:(.text+0xfc): undefined reference to `m68k_supervisor_cachemode'
m68k-linux-ld: arch/m68k/mm/motorola.o: in function `mmu_page_ctor':
motorola.c:(.text+0x162): undefined reference to `m68k_pgtable_cachemode'
m68k-linux-ld: arch/m68k/mm/motorola.o: in function `paging_init':
motorola.c:(.init.text+0x3d2): undefined reference to `kernel_pg_dir'
m68k-linux-ld: motorola.c:(.init.text+0x1d8): undefined reference to `availmem'
m68k-linux-ld: motorola.c:(.init.text+0x32e): undefined reference to `m68k_supervisor_cachemode'
m68k-linux-ld: motorola.c:(.init.text+0x3a8): undefined reference to `kernel_pg_dir'
m68k-linux-ld: arch/m68k/q40/config.o: in function `q40_mem_console_write':
config.c:(.text+0x25c): undefined reference to `q40_mem_cptr'
m68k-linux-ld: config.c:(.text+0x254): undefined reference to `q40_mem_cptr'
m68k-linux-ld: arch/m68k/q40/config.o: in function `q40_debug_setup':
config.c:(.init.text+0x28): undefined reference to `q40_mem_cptr'
m68k-linux-ld: arch/m68k/mvme16x/config.o: in function `mvme16x_abort_int':
config.c:(.text+0x4): undefined reference to `mvme_bdid'
m68k-linux-ld: arch/m68k/mvme16x/config.o: in function `mvme16x_get_model':
config.c:(.text+0xc8): undefined reference to `mvme_bdid'
m68k-linux-ld: config.c:(.text+0xce): undefined reference to `mvme_bdid'
m68k-linux-ld: config.c:(.text+0xea): undefined reference to `mvme_bdid'
m68k-linux-ld: arch/m68k/mvme16x/config.o: in function `mvme16x_get_hardware_list':
config.c:(.text+0x148): undefined reference to `mvme_bdid'
m68k-linux-ld: arch/m68k/mvme16x/config.o:config.c:(.text+0x1d0): more undefined references to `mvme_bdid' follow
m68k-linux-ld: kernel/extable.o: in function `core_kernel_text':
extable.c:(.text+0x52): undefined reference to `_stext'
m68k-linux-ld: kernel/kallsyms.o: in function `is_ksym_addr':
kallsyms.c:(.text+0x31c): undefined reference to `_stext'
m68k-linux-ld: kernel/crash_core.o: in function `crash_save_vmcoreinfo_init':
crash_core.c:(.init.text+0x4d4): undefined reference to `_stext'
m68k-linux-ld: crash_core.c:(.init.text+0x4bc): undefined reference to `kernel_pg_dir'
m68k-linux-ld: mm/page_alloc.o: in function `mem_init_print_info':
page_alloc.c:(.init.text+0xff8): undefined reference to `_stext'
m68k-linux-ld: page_alloc.c:(.init.text+0x1050): undefined reference to `_stext'
m68k-linux-ld: mm/init-mm.o:(.data+0x18): undefined reference to `kernel_pg_dir'
m68k-linux-ld: mm/usercopy.o: in function `__check_object_size':
usercopy.c:(.text+0x15a): undefined reference to `_stext'

Bisect points to this patch (or its equivalent in next-20220919).

Guenter

---
# bad: [4c9ca5b1597e3222177ba2a94658f78fa5ef4f58] Add linux-next specific files for 20220919
# good: [521a547ced6477c54b4b0cc206000406c221b4d6] Linux 6.0-rc6
git bisect start 'HEAD' 'v6.0-rc6'
# bad: [8b4141305a585c4cb1147dcc164059dc3b5489e2] Merge branch 'drm-next' of git://git.freedesktop.org/git/drm/drm.git
git bisect bad 8b4141305a585c4cb1147dcc164059dc3b5489e2
# bad: [03e33baab7f2c3459bd268639af383cafe0c0a4b] Merge branch 'docs-next' of git://git.lwn.net/linux.git
git bisect bad 03e33baab7f2c3459bd268639af383cafe0c0a4b
# bad: [c1a464c761e4098899873c472b3756f557a3b73c] Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap.git
git bisect bad c1a464c761e4098899873c472b3756f557a3b73c
# bad: [59d922adf1c023a84bd4dd4fad0442221fd6347f] Merge branch 'for-next/core' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
git bisect bad 59d922adf1c023a84bd4dd4fad0442221fd6347f
# good: [166f57a723e13d816b09b2f27433f2c8ba2f06fe] Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git
git bisect good 166f57a723e13d816b09b2f27433f2c8ba2f06fe
# bad: [aaa38e8ca1345b2369051a6213f706d5107a20ba] Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic.git
git bisect bad aaa38e8ca1345b2369051a6213f706d5107a20ba
# good: [1081fb0f6d6e68186e1088db33396b11770a0710] perf vendor events arm64: Move REMOTE_ACCESS to "memory" category
git bisect good 1081fb0f6d6e68186e1088db33396b11770a0710
# bad: [4aaa1766cf8d19becdade98bff3960c6583b8d09] Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git
git bisect bad 4aaa1766cf8d19becdade98bff3960c6583b8d09
# good: [a521c97e2a63490c238865763fc86942dce8d6bb] kbuild: rewrite check-local-export in sh/awk
git bisect good a521c97e2a63490c238865763fc86942dce8d6bb
# bad: [6676e2cdd7c339dc40331faccbaac1112d2c1d78] kbuild: use obj-y instead extra-y for objects placed at the head
git bisect bad 6676e2cdd7c339dc40331faccbaac1112d2c1d78
# good: [10d1d4b75525f3172c6930fb20445f669762ea95] kbuild: move core-y and drivers-y to ./Kbuild
git bisect good 10d1d4b75525f3172c6930fb20445f669762ea95
# good: [b8d366ae69fe633e697776b839ac52d3eecf07d3] kbuild: move vmlinux.o rule to the top Makefile
git bisect good b8d366ae69fe633e697776b839ac52d3eecf07d3
# good: [165b718fdd8c5a9165b4485019729c0cd8728120] kbuild: unify two modpost invocations
git bisect good 165b718fdd8c5a9165b4485019729c0cd8728120
# first bad commit: [6676e2cdd7c339dc40331faccbaac1112d2c1d78] kbuild: use obj-y instead extra-y for objects placed at the head