Laszlo:
  Tools behavior tries to avoid the cycle between the library instances. From 
Library INF file, some ones depend on each other, but their constructor may 
have no dependency. If they are all considered even if they have no 
constructor, the cycle will easily happen, and cause tools break. So, BaseTools 
cares the library instance with the constructor. I agree it is not accurate, 
because INF file has no information to describe the library constructor 
dependency. For the failure case, we have to add the empty constructor function 
as its constructor to resolve the real dependency issue.

  For your case, I prefer to resolve the real dependency issue. Is the change 
for BaseOrderedCollectionRedBlackTreeLib enough? If yes, I suggest to only make 
this change now. If you add more dummy constructor functions, it may cause the 
cycle dependency happen. 

Thanks
Liming
-----Original Message-----
From: Laszlo Ersek [mailto:[email protected]] 
Sent: Saturday, September 06, 2014 7:42 PM
To: [email protected]; Gao, Liming; Kinney, Michael D
Subject: Re: [edk2] [PATCH 01/12] MdePkg: BaseOrderedCollectionRedBlackTreeLib: 
add constructor

Liming, Michael,

On 09/03/14 00:56, Laszlo Ersek wrote:
> Calls to constructors of interdependent library instances are 
> generated in the correct order only if all library instances in 
> question have constructors. If some have no constructors, then the 
> rest may see their constructors called out of order.
> 
> Cycle detection also only works when all library instances have 
> constructors.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Laszlo Ersek <[email protected]>
> ---
>  .../BaseOrderedCollectionRedBlackTreeLib.inf                   |  2 ++
>  .../BaseOrderedCollectionRedBlackTreeLib.c                     | 10 
> ++++++++++
>  2 files changed, 12 insertions(+)
> 
> diff --git 
> a/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedColle
> ctionRedBlackTreeLib.inf 
> b/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedColle
> ctionRedBlackTreeLib.inf
> index a68afc8..f846a79 100644
> --- 
> a/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedColle
> ctionRedBlackTreeLib.inf
> +++ b/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedC
> +++ ollectionRedBlackTreeLib.inf
> @@ -32,6 +32,8 @@
>    VERSION_STRING                 = 1.0
>    LIBRARY_CLASS                  = OrderedCollectionLib
>  
> +  CONSTRUCTOR                    = 
> BaseOrderedCollectionRedBlackTreeLibConstructor
> +
>  #
>  #  VALID_ARCHITECTURES           = IA32 X64 IPF EBC
>  #
> diff --git 
> a/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedColle
> ctionRedBlackTreeLib.c 
> b/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedColle
> ctionRedBlackTreeLib.c
> index 8d18a4b..23ba8de 100644
> --- 
> a/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedColle
> ctionRedBlackTreeLib.c
> +++ b/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedC
> +++ ollectionRedBlackTreeLib.c
> @@ -1452,3 +1452,13 @@ RedBlackTreeValidate (
>    DEBUG ((DEBUG_VERBOSE, "%a: Tree=%p BlackHeight=%Ld Count=%Ld\n",
>      __FUNCTION__, Tree, (INT64)BlackHeight, (INT64)ForwardCount));  }
> +
> +
> +RETURN_STATUS
> +EFIAPI
> +BaseOrderedCollectionRedBlackTreeLibConstructor (
> +  VOID
> +  )
> +{
> +  return RETURN_SUCCESS;
> +}
> 

This patchset has the same goal as the following code in 
"MdePkg/Library/UefiLib/UefiLib.c", found by Ard:

/**
  Empty constructor function that is required to resolve dependencies between
  libraries.

    ** DO NOT REMOVE **

  @param  ImageHandle   The firmware allocated handle for the EFI image.
  @param  SystemTable   A pointer to the EFI System Table.

  @retval EFI_SUCCESS   The constructor executed correctly.

**/
EFI_STATUS
EFIAPI
UefiLibConstructor (
  IN EFI_HANDLE        ImageHandle,
  IN EFI_SYSTEM_TABLE  *SystemTable
  )
{
  return EFI_SUCCESS;
}

Added in SVN r11181.

Thanks
Laszlo

------------------------------------------------------------------------------
Want excitement?
Manually upgrade your production database.
When you want reliability, choose Perforce.
Perforce version control. Predictably reliable.
http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to