On 26/03/2019 10:00, Paolo Bonzini wrote: > On 21/03/19 13:46, Laurent Vivier wrote: >> + >> +ifneq ($(CONFIG_USER_ONLY),y) >> ####################################################################### >> # authz-obj-y is code used by both qemu system emulation and qemu-img >> >> @@ -21,21 +27,11 @@ block-obj-$(CONFIG_REPLICATION) += replication.o >> >> block-obj-m = block/ > > Two remarks: > > 1) Isn't CONFIG_USER_ONLY set to y even if tools are built?
Yes, you right. I didn't test combination "--enable-user --enable-tools --disable-system" > > 2) Notwithstanding the answer to (1), why is this part needed at all? > The only things that have dependencies on crypto-obj-y, io-obj-y etc. > are $(SOFTMMU_SUBDIR_RULES), the tools, and the tests that you are > disabling already. Therefore, why are they built at all for user-only > builds? The change was based on the comments in the file. And for the crypto part we need it and this could explain: commit fb37726db77b21f3731b90693d2c93ade1777528 Author: Daniel P. Berrange <berra...@redhat.com> Date: Wed Sep 2 10:57:27 2015 +0100 crypto: move crypto objects out of libqemuutil.la Future patches will be adding more crypto related APIs which rely on QOM infrastructure. This creates a problem, because QOM relies on library constructors to register objects. When you have a file in a static .a library though which is only referenced by a constructor the linker is dumb and will drop that file when linking to the final executable :-( The only workaround for this is to link the .a library to the executable using the -Wl,--whole-archive flag, but this creates its own set of problems because QEMU is relying on lazy linking for libqemuutil.a. Using --whole-archive majorly increases the size of final executables as they now contain a bunch of object code they don't actually use. The least bad option is to thus not include the crypto objects in libqemuutil.la, and instead define a crypto-obj-y variable that is referenced directly by all the executables that need this code (tools + softmmu, but not qemu-ga). We avoid pulling entire of crypto-obj-y into the userspace emulators as that would force them to link to gnutls too, which is not required. > 3) I don't really see the need or advantage in conditionalizing tests of > libqemuutil.a, which is built even for linux-user builds (even though > e.g. the coroutines code does not end up in the binary). Since most of > the tests you are removing are related to the block layer, perhaps you > can add > > CONFIG_BLOCK := $(call lor, $(CONFIG_SOFTMMU), $(call notempty,$(TOOLS)) > > and use it to conditionalize the testcases that depend on block-obj-y? > I agree. Thanks, Laurent