# git rev-parse -q --verify 58bb4f7d4970e92c2400208a1b48aae3b2853e5c^{commit} 58bb4f7d4970e92c2400208a1b48aae3b2853e5c already have revision, skipping fetch # git checkout -q -f -B kisskb 58bb4f7d4970e92c2400208a1b48aae3b2853e5c # git clean -qxdf # < git log -1 # commit 58bb4f7d4970e92c2400208a1b48aae3b2853e5c # Author: Masahiro Yamada # Date: Thu Mar 12 07:37:25 2020 +0900 # # kbuild: link lib-y objects to vmlinux forcibly when CONFIG_MODULES=y # # Kbuild supports not only obj-y but also lib-y to list objects linked to # vmlinux. # # The difference between them is that all the objects from obj-y are # forcibly linked to vmlinux, whereas the objects from lib-y are linked # as needed; if there is no user of a lib-y object, it is not linked. # # lib-y is intended to list utility functions that may be called from all # over the place (and may be unused at all), but it is a problem for # EXPORT_SYMBOL(). Even if there is no call-site in the vmlinux, we need # to keep exported symbols for the use from loadable modules. # # Commit 7f2084fa55e6 ("[kbuild] handle exports in lib-y objects reliably") # worked around it by linking a dummy object, lib-ksyms.o, which contains # references to all the symbols exported from lib.a in that directory. # It uses the linker script command, EXTERN. Unfortunately, the meaning of # EXTERN of ld.lld is different from that of ld.bfd. Therefore, this does # not work with LD=ld.lld (CBL issue #515). # # Anyway, the build rule of lib-ksyms.o is somewhat tricky. So, I want to # get rid of it. # # At first, I was thinking of accumulating lib-y objects into obj-y # (or even replacing lib-y with obj-y entirely), but the lib-y syntax # is used beyond the ordinary use in lib/ and arch/*/lib/. # # Examples: # # - drivers/firmware/efi/libstub/Makefile builds lib.a, which is linked # into vmlinux in the own way (arm64), or linked to the decompressor # (arm, x86). # # - arch/alpha/lib/Makefile builds lib.a which is linked not only to # vmlinux, but also to bootloaders in arch/alpha/boot/Makefile. # # - arch/xtensa/boot/lib/Makefile builds lib.a for use from # arch/xtensa/boot/boot-redboot/Makefile. # # One more thing, adding everything to obj-y would increase the vmlinux # size of allnoconfig (or tinyconfig). # # For less impact, I tweaked the destination of lib.a at the top Makefile; # when CONFIG_MODULES=y, lib.a goes to KBUILD_VMLINUX_OBJS, which is # forcibly linked to vmlinux, otherwise lib.a goes to KBUILD_VMLINUX_LIBS # as before. # # The size impact for normal usecases is quite small since at lease one # symbol in every lib-y object is eventually called by someone. In case # you are intrested, here are the figures. # # x86_64_defconfig: # # text data bss dec hex filename # 19566602 5422072 1589328 26578002 1958c52 vmlinux.before # 19566932 5422104 1589328 26578364 1958dbc vmlinux.after # # The case with the biggest impact is allnoconfig + CONFIG_MODULES=y. # # ARCH=x86 allnoconfig + CONFIG_MODULES=y: # # text data bss dec hex filename # 1175162 254740 1220608 2650510 28718e vmlinux.before # 1177974 254836 1220608 2653418 287cea vmlinux.after # # Hopefully this is still not a big deal. The per-file trimming with the # static library is not so effective after all. # # If fine-grained optimization is desired, some architectures support # CONFIG_LD_DEAD_CODE_DATA_ELIMINATION, which trims dead code per-symbol # basis. When LTO is supported in mainline, even better optimization will # be possible. # # Link: https://github.com/ClangBuiltLinux/linux/issues/515 # Signed-off-by: Masahiro Yamada # Reported-by: kbuild test robot # Reviewed-by: Nick Desaulniers # < /opt/cross/kisskb/korg/gcc-4.9.4-nolibc/ia64-linux/bin/ia64-linux-gcc --version # < /opt/cross/kisskb/korg/gcc-4.9.4-nolibc/ia64-linux/bin/ia64-linux-ld --version # < git log --format=%s --max-count=1 58bb4f7d4970e92c2400208a1b48aae3b2853e5c # < make -s -j 80 ARCH=ia64 O=/kisskb/build/kbuild_ia64-defconfig_ia64-gcc4.9 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-4.9.4-nolibc/ia64-linux/bin/ia64-linux- defconfig # < make -s -j 80 ARCH=ia64 O=/kisskb/build/kbuild_ia64-defconfig_ia64-gcc4.9 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-4.9.4-nolibc/ia64-linux/bin/ia64-linux- help # make -s -j 80 ARCH=ia64 O=/kisskb/build/kbuild_ia64-defconfig_ia64-gcc4.9 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-4.9.4-nolibc/ia64-linux/bin/ia64-linux- olddefconfig # make -s -j 80 ARCH=ia64 O=/kisskb/build/kbuild_ia64-defconfig_ia64-gcc4.9 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-4.9.4-nolibc/ia64-linux/bin/ia64-linux- :1511:2: warning: #warning syscall clone3 not implemented [-Wcpp] In file included from /kisskb/src/arch/ia64/include/uapi/asm/intrinsics.h:22:0, from /kisskb/src/arch/ia64/include/asm/intrinsics.h:11, from /kisskb/src/arch/ia64/include/asm/bitops.h:19, from /kisskb/src/include/linux/bitops.h:29, from /kisskb/src/include/linux/kernel.h:12, from /kisskb/src/include/linux/list.h:9, from /kisskb/src/include/linux/preempt.h:11, from /kisskb/src/include/linux/spinlock.h:51, from /kisskb/src/include/linux/seqlock.h:36, from /kisskb/src/include/linux/time.h:6, from /kisskb/src/fs/nfs/read.c:11: /kisskb/src/fs/nfs/read.c: In function 'nfs_read_completion': /kisskb/src/arch/ia64/include/uapi/asm/cmpxchg.h:57:2: warning: value computed is not used [-Wunused-value] ((__typeof__(*(ptr))) __xchg((unsigned long) (x), (ptr), sizeof(*(ptr)))) ^ /kisskb/src/fs/nfs/read.c:196:5: note: in expansion of macro 'xchg' xchg(&nfs_req_openctx(req)->error, error); ^ /kisskb/src/fs/nfs/read.c: In function 'nfs_readpage': /kisskb/src/arch/ia64/include/uapi/asm/cmpxchg.h:57:2: warning: value computed is not used [-Wunused-value] ((__typeof__(*(ptr))) __xchg((unsigned long) (x), (ptr), sizeof(*(ptr)))) ^ /kisskb/src/fs/nfs/read.c:353:2: note: in expansion of macro 'xchg' xchg(&ctx->error, 0); ^ /kisskb/src/kernel/futex.c: In function 'do_futex': /kisskb/src/kernel/futex.c:1676:17: warning: 'oldval' may be used uninitialized in this function [-Wmaybe-uninitialized] return oldval == cmparg; ^ /kisskb/src/kernel/futex.c:1652:6: note: 'oldval' was declared here int oldval, ret; ^ /kisskb/src/drivers/gpu/drm/drm_dp_mst_topology.c: In function 'drm_dp_mst_dsc_aux_for_port': /kisskb/src/drivers/gpu/drm/drm_dp_mst_topology.c:5497:9: warning: missing braces around initializer [-Wmissing-braces] struct drm_dp_desc desc = { 0 }; ^ /kisskb/src/drivers/gpu/drm/drm_dp_mst_topology.c:5497:9: warning: (near initialization for 'desc.ident') [-Wmissing-braces] No errors detected in 22154 functions. Completed OK # rm -rf /kisskb/build/kbuild_ia64-defconfig_ia64-gcc4.9 # Build took: 0:02:15.505182