From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M2tky-0001Yl-J7 for qemu-devel@nongnu.org; Sat, 09 May 2009 17:06:52 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M2tku-0001X9-40 for qemu-devel@nongnu.org; Sat, 09 May 2009 17:06:52 -0400 Received: from [199.232.76.173] (port=50023 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M2tkt-0001X3-Sv for qemu-devel@nongnu.org; Sat, 09 May 2009 17:06:47 -0400 Received: from mx20.gnu.org ([199.232.41.8]:47919) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1M2tkt-0006f2-Ki for qemu-devel@nongnu.org; Sat, 09 May 2009 17:06:47 -0400 Received: from mail.codesourcery.com ([65.74.133.4]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M2tks-0006Ug-Em for qemu-devel@nongnu.org; Sat, 09 May 2009 17:06:46 -0400 From: Paul Brook Subject: Re: [Qemu-devel] [RFC] New device API Date: Sat, 9 May 2009 22:06:37 +0100 References: <200905051231.09759.paul@codesourcery.com> <200905060204.32068.paul@codesourcery.com> <4A05EDD8.6030208@codemonkey.ws> In-Reply-To: <4A05EDD8.6030208@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200905092206.38341.paul@codesourcery.com> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org On Saturday 09 May 2009, Anthony Liguori wrote: > Paul Brook wrote: > > On Wednesday 06 May 2009, Paul Brook wrote: > >>>> The attached patch is my attempt at a new internal API for device > >>>> creation in qemu. > >>> > >>> Instead of recreating constructors, I think we should just use GCC's > >>> constructor attribute. This gives us ordering which will be important > >>> when dealing with buses. > >> > >> The reason I'm not using constructors is because you have to workaround > >> ordering issues. All constructors are run before main(), so there's a > >> very limited amount they can actually do, and constructor priorities are > >> not available on all hosts. > > > > Oh, the other thing is that constructors don't work when you put objects > > in a static library. You need am explicit dependency to pull in objects. > > Not if you enable -Wl,--whole-archive. It ends up looking like: > > gcc -o test-stub -g -Wall -O test-stub.c -Wl,--whole-archive libtest.a > -Wl,--no-whole-archive -L. > > And I've confirmed this works. Yes, but, eww. Plus it means you've got to pull in absolutely everything, whether you want it or not. Paul