01.07.2020 12:12, Christophe de Dinechin wrote: .. >>> # Build libraries >>> >>> +libqemuutil.a-libs += $(call extract-libs, $(util-obj-y) $(trace-obj-y) >>> $(stub-obj-y)) >>> +libvhost-user.a-libs += $(call extract-libs, $(libvhost-user-obj-y) >>> $(util-obj-y) $(stub-obj-y)) .. >> Another thing I wonder about: the purpose of the .a files is to compile >> all object files and only link those .o files needed by the program >> (i.e. a subset of the .a file). > > I believe that what you are saying is that by passing the required libraries > automatically, the binaries that use libqemuutil.a will inherit undesired > ldd dependencies. Indeed, a quick experiment shows that if you pass a -l > option, the library dependency is recorded even if no symbol in that library > is used. I saw no obvious linker option to address that.
There's --as-needed and --no-as-needed ld flag (used with cc as -Wl,--as-needed), which is designed for this very case. JFYI. /mjt