Hey Masahiro, On Wed, Dec 22, 2021 at 3:36 PM Jason A. Donenfeld <Jason@xxxxxxxxx> wrote: > Hi Masahiro, > > This is a commit I'm working on as part of a change to the RNG, which > got broken out into something standalone because it wound up being a bit > more involved than originally conceived. With Ard's help, this is using > weak symbols with the generic code in lib-y, but the only way we figured > to actually include the lib.a file was via this unseemly > KBUILD_VMLINUX_LIBS line below, which doesn't seem very okay. I tried > adding `libs-y += lib/crypto/` to lib/Makefile, but it seemed like the > build system ignored it. I figure there's probably a right way to do > this, so thought I should send you this RFC to look at first. > Alternatively, if the KBUILD_VMLINUX_LIBS trick is somehow okay, that'd > be useful to know too. > > Thanks, > Jason I found something else that works. Here's the original (bad) idea: > diff --git a/Makefile b/Makefile > index d85f1ff79f5c..4b4a2bec020c 100644 > --- a/Makefile > +++ b/Makefile > @@ -1120,6 +1120,7 @@ else > KBUILD_VMLINUX_LIBS := $(patsubst %/,%/lib.a, $(libs-y)) > endif > KBUILD_VMLINUX_OBJS += $(patsubst %/,%/built-in.a, $(drivers-y)) > +KBUILD_VMLINUX_LIBS += lib/crypto/lib.a > > export KBUILD_VMLINUX_OBJS KBUILD_VMLINUX_LIBS > export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds Here's a new idea: diff --git a/Makefile b/Makefile index d85f1ff79f5c..235a3b712d7b 100644 --- a/Makefile +++ b/Makefile @@ -700,6 +700,7 @@ export RETPOLINE_CFLAGS export RETPOLINE_VDSO_CFLAGS include $(srctree)/arch/$(SRCARCH)/Makefile +libs-y += lib/crypto/ ifdef need-config ifdef may-sync-config diff --git a/lib/Makefile b/lib/Makefile index 364c23f15578..bb57b2e466fa 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -139,7 +139,7 @@ endif obj-$(CONFIG_DEBUG_INFO_REDUCED) += debug_info.o CFLAGS_debug_info.o += $(call cc-option, -femit-struct-debug-detailed=any) -obj-y += math/ crypto/ +obj-y += math/ obj-$(CONFIG_GENERIC_IOMAP) += iomap.o obj-$(CONFIG_GENERIC_PCI_IOMAP) += pci_iomap.o Perhaps there's yet a third way that you see. Thanks, Jason