From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57426) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VLWfO-0005LJ-2H for qemu-devel@nongnu.org; Mon, 16 Sep 2013 07:08:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VLWfG-0004B6-5I for qemu-devel@nongnu.org; Mon, 16 Sep 2013 07:08:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:21957) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VLWfF-0004Az-Rr for qemu-devel@nongnu.org; Mon, 16 Sep 2013 07:08:22 -0400 Message-ID: <5236E69B.3040502@redhat.com> Date: Mon, 16 Sep 2013 13:08:11 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1379314227-8855-1-git-send-email-famz@redhat.com> <1379314227-8855-6-git-send-email-famz@redhat.com> <20130916085902.GA6005@redhat.com> <5236D318.4080206@redhat.com> <20130916095121.GD22783@T430s.nay.redhat.com> <3AD10BC4-9EDC-4FDA-BC0D-D1380C5904C2@alex.org.uk> <5236DFBE.2000801@redhat.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alex Bligh Cc: peter.maydell@linaro.org, famz@redhat.com, mjt@tls.msk.ru, qemu-devel@nongnu.org, vilanova@ac.upc.edu, rth@twiddle.net Il 16/09/2013 13:00, Alex Bligh ha scritto: > > On 16 Sep 2013, at 11:38, Paolo Bonzini wrote: > >> No, librbd does need to be there for the other symbols that are not weak >> (e.g. rbd_aio_read). This approach cannot be "taken to the limit", i.e. >> removing the librbd dependency altogether. For example: >> >> xx.c: >> int f(void) >> { >> return 42; >> } >> >> yy.c: >> #pragma weak f >> extern int f(void); >> int main() >> { >> printf("%p %d", f, f ? f(): 67); >> } >> >> $ gcc xx.c -shared -o xx.so >> $ LD_RUN_PATH=$PWD gcc yy.c xx.so -o yy >> $ ./yy >> 0x4005b0 42 >> $ rm xx.so >> $ ./yy >> ./yy: error while loading shared libraries: xx.so: cannot open shared >> object file: No such file or directory > > I think you need to wrap f, i.e. take g as a pointer to f(), and > call g(). No, you need to do dlopen("librbd.so"), which is bad because then distros that can track .so dependencies will not do it anymore. qemu-devel had a patch to do exactly that. >> Also, the code _is_ ugly. Do it once and it's perhaps acceptable. Do >> it for libiscsi, librbd, libcurl, libssh2, SPICE, GTK+, SDL etc. and it >> becomes unmaintainable. > > I agree it's ugly. However, it's pretty much the only way to cope > with different versions of libraries. But the reason to do modularization is not to "cope with different versions of libraries". In fact that's a problem that Fam's patches do not solve at all. The reason to do modularization is to make libraries optional, i.e. let them be completely absent. Paolo