From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io0-x234.google.com (mail-io0-x234.google.com [IPv6:2607:f8b0:4001:c06::234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id ADB6D21A00AFF for ; Sat, 24 Jun 2017 13:24:14 -0700 (PDT) Received: by mail-io0-x234.google.com with SMTP id z62so18014323ioi.3 for ; Sat, 24 Jun 2017 13:25:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=B+aTD16x7IrMQOtuBbiMsOoXnbfr26cjP6Zk8ACDu4c=; b=HI4Jk5xGU9tM6GEubB1eE9TwJC/5wyHQT94g3bIylvEtrQmuK7RS7Rq+sLnVo7MEQQ HyCC/XfMNmB+BEBUS+eF40zAeYrLs+mdhKJWXHlU8Mumm4wxzYzJAfFiY1TX3RihevFm 6Iomp8xeZFKOEjVmspOZs05TyPXq2kOgU4gBE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=B+aTD16x7IrMQOtuBbiMsOoXnbfr26cjP6Zk8ACDu4c=; b=c96lUvZF1mtc19Z2GUNTsmqEasNih4Eyh3Hzyo6EhHPrFWKe6zVCtbYY6KNmeJZkyl 4KkKL+537JCQZz+z+1RE3OKI0EKy32X7wdfyUqhmnuddGqyfIn8fsBY3XQRwTQn2ZxGY 0cRlMdtUgUpo5D6rOgwOIKyLZIGP6/WE47IC8RP3dxI2/D8EnekljMMn8011UjDXhYtJ ZG7yEDiHQVlnwb25qb6GvPMP/h6LsUGsBHSyD8UT6Rs12gW5Bn+0Ed0UG0Bzb4UuGs/Z WUuTp58JgQ3l5jVZNJU82hcLv8canPwkSepxyy9K+og/L4zvbEi+wG4LpINBJVt75wGu ssPw== X-Gm-Message-State: AKS2vOxgvIT0tHEZ3iZlG6/vmnPmrjphErlQh7scD8ctjJUt5vKY5QtD lJn4ioYzEqhtUd33b9yjDsqASKCSLDz8 X-Received: by 10.107.63.139 with SMTP id m133mr15573690ioa.87.1498335941319; Sat, 24 Jun 2017 13:25:41 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.134.134 with HTTP; Sat, 24 Jun 2017 13:25:40 -0700 (PDT) In-Reply-To: References: From: Ard Biesheuvel Date: Sat, 24 Jun 2017 20:25:40 +0000 Message-ID: To: "Kinney, Michael D" Cc: "David F." , "edk2-devel@lists.01.org" Subject: Re: Constructor Order X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 24 Jun 2017 20:24:15 -0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On 23 June 2017 at 02:59, Kinney, Michael D wr= ote: > David, > > Constructor order is determined by the build tool through evaluation of e= ach of the library instance dependencies as declared in the [LibraryClasses= ] section of the INF. This is a recursive algorithm to collect all the lib= rary instances because a module uses libs and each lib can use additional l= ibs. > > This process is described in the EDK II Build Specification in Section 8.= 2.5 Post processing. > > https://edk2-docs.gitbooks.io/edk-ii-build-specification/content/8_pre-bu= ild_autogen_stage/82_auto-generation_process.html#82-auto-generation-proces= s > > If you want a different order, then likely one or more of the lib instanc= es being linked to a module does not have correct information about its lib= dependencies in the [LibraryClasses] section of the INF. If the dependenc= ies are specified correctly, then the order generated by the build tool sho= uld be a valid order based on dependencies. There are some cases where the= re could be ties, such that the order could be different and still correct,= but there is no way to influence the order between ties. > Note that constructor dependencies don't apply transitively if an intermediate library in the dependency chain has no constructor. For example, if LibWithConstructorA depends on LibWithoutConstructorB, and the latter depends on LibWithConstructorC, the EDK2 tools don't guarantee that C's constructor has executed when A's constructor is invoked. I think this is a flaw in the implementation, but fixing this results in circular dependencies in many platforms that I have tried. so the best way to deal with this IMO is not to rely on constructor ordering at all, and which means you shouldn't call other libraries from the constructor of a library. --=20 Ard.