public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Laszlo Ersek" <lersek@redhat.com>
To: Ard Biesheuvel <ard.biesheuvel@arm.com>,
	Sami Mujawar <sami.mujawar@arm.com>,
	devel@edk2.groups.io
Cc: leif@nuviainc.com, jian.j.wang@intel.com, hao.a.wu@intel.com,
	Alexandru.Elisei@arm.com, Andre.Przywara@arm.com,
	Matteo.Carlini@arm.com, Laura.Moretta@arm.com, nd@arm.com
Subject: Re: [PATCH v3 08/15] MdeModulePkg: Fix constructor invocation ordering
Date: Fri, 26 Jun 2020 15:22:35 +0200	[thread overview]
Message-ID: <9a142911-8c47-7139-45b8-1429d5aa16c7@redhat.com> (raw)
In-Reply-To: <333ca5d4-2959-4ebe-54df-c0f36f60f8b0@arm.com>

On 06/25/20 15:51, Ard Biesheuvel wrote:
> On 6/24/20 3:34 PM, Sami Mujawar wrote:
>> The BaseSerialPortLib16550 library does not implement
>> a constructor. This prevents the correct constructor
>> invocation order for dependent libraries.
>> e.g. A PlatformHookLib (for the Serial Port) may have
>> a dependency on retrieving data from a Hob. A Hob
>> library implementation may configure its initial state
>> in the HobLib constructor. Since BaseSerialPortLib16550
>> does not implement a constructor, the Basetools do not
>> resolve the correct order for constructor invocation.
>>
>> To fix this, add an empty constructor to the serial port
>> library BaseSerialPortLib16550.
>>
>> Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
> 
> Acked-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
> 
> Note to maintainers:
> this works around a long standing BaseTools bug where constructor
> dependencies do not propagate through a library that lacks a constructor.
> 
> For instance, in the following case
> 
>   LibA depends on LibB depends on LibC
> 
> the constructors are *only* guaranteed to be invoked in the correct
> order (LibC, then LibB, then LibA) if LibB has a constructor in the
> first place, otherwise, the remaining constructors for LibA and LibC
> could be emitted in any order.

By now I've flipped my "mental default" to "use a constructor *unless*
counter-indicated by something"...

If we get a cycle due to always using constructors, the tools at least
complain (and we know something's fishy). With the opposite default, I
simply cannot guarantee that my new library instance LibB will *never*
break an eventual LibA -> LibB -> LibC constructor dependency chain.

In my new lib instance, I'm of course aware of the LibB -> LibC
dependency, but I can't tell anything about a future LibA -> LibB
dependency. :(

So I guess it's prudent to always add a constructor, even if it's empty.

Laszlo


  reply	other threads:[~2020-06-26 13:22 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-24 13:34 [PATCH v3 00/15] Kvmtool guest firmware support for Arm Sami Mujawar
2020-06-24 13:34 ` [PATCH v3 01/15] PcAtChipsetPkg: Add MMIO Support to RTC driver Sami Mujawar
2020-06-25 11:24   ` Ard Biesheuvel
2020-06-29  2:36     ` [edk2-devel] " Guomin Jiang
2020-06-24 13:34 ` [PATCH v3 02/15] ArmVirtPkg: Add Kvmtool RTC Fdt Client Library Sami Mujawar
2020-06-25 11:31   ` Ard Biesheuvel
2020-06-24 13:34 ` [PATCH v3 03/15] ArmPlatformPkg: Dynamic flash variable base Sami Mujawar
2020-06-24 13:34 ` [PATCH v3 04/15] ArmVirtPkg: Add kvmtool platform driver Sami Mujawar
2020-06-25 11:35   ` Ard Biesheuvel
2020-06-24 13:34 ` [PATCH v3 05/15] ArmVirtPkg: kvmtool platform memory map Sami Mujawar
2020-06-24 13:34 ` [PATCH v3 06/15] ArmVirtPkg: Add Kvmtool NOR flash lib Sami Mujawar
2020-06-25  8:45   ` Philippe Mathieu-Daudé
2020-06-25 11:19     ` [edk2-devel] " Ard Biesheuvel
2020-06-25 11:41       ` Philippe Mathieu-Daudé
2020-06-25 11:38   ` Ard Biesheuvel
2020-06-25 17:33     ` Sami Mujawar
2020-06-24 13:34 ` [PATCH v3 07/15] ArmVirtPkg: Early serial port initialisation Sami Mujawar
2020-06-25 11:42   ` Ard Biesheuvel
2020-06-26  9:23     ` Julien Grall
2020-06-24 13:34 ` [PATCH v3 08/15] MdeModulePkg: Fix constructor invocation ordering Sami Mujawar
2020-06-25 13:51   ` Ard Biesheuvel
2020-06-26 13:22     ` Laszlo Ersek [this message]
2020-06-27 11:37       ` Ard Biesheuvel
2020-06-24 13:34 ` [PATCH v3 09/15] ArmVirtPkg: GUID Hob for 16550 UART base address Sami Mujawar
2020-06-25 13:52   ` Ard Biesheuvel
2020-06-24 13:34 ` [PATCH v3 10/15] ArmVirtPkg: 16550 UART Platform hook library Sami Mujawar
2020-06-25 13:56   ` Ard Biesheuvel
2020-06-24 13:34 ` [PATCH v3 11/15] ArmVirtPkg: Add Kvmtool Platform Pei Lib Sami Mujawar
2020-06-25 14:05   ` Ard Biesheuvel
2020-06-24 13:34 ` [PATCH v3 12/15] ArmVirtPkg: Support for kvmtool virtual platform Sami Mujawar
2020-06-25 14:08   ` Ard Biesheuvel
2020-06-26 13:26     ` Laszlo Ersek
2020-06-24 13:34 ` [PATCH v3 13/15] ArmVirtPkg: Package dependency for MC146818 RTC Sami Mujawar
2020-06-25 14:08   ` Ard Biesheuvel
2020-06-24 13:34 ` [PATCH v3 14/15] ArmVirtPkg: Add kvmtool to package dictionary Sami Mujawar
2020-06-25 14:09   ` Ard Biesheuvel
2020-06-24 13:34 ` [PATCH v3 15/15] Maintainer.txt: Add Kvmtool platform reviewer Sami Mujawar
2020-06-25 14:09   ` Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9a142911-8c47-7139-45b8-1429d5aa16c7@redhat.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox