On 09/02/14 22:31, Ard Biesheuvel wrote:
> The need for the false dependency seems to be caused by the fact that
> AutoGen.py does not consider constructor ordering dependencies to be
> transitive via a library that has no constructor itself. In
> particular, my SerialPortLib's indirect dependency on
> UefiBootServicesTableLib via PcdLib does not result in
> UefiBootServicesTableLib's constructor being called before
> SerialPortLib's, causing my PcdGet() call to explode.
I'd like to emphasize / reformulate Ard's discovery.
Consider three library instances, L1, L2, and L3.
L1 has a constructor, Lib1Construct().
L2 has no constructor.
L3 has a constructor, Lib3Construct().
Assume that the INF file for L1 names a dependency on L2's class.
Further assume that the INF file for L2 names a dependency on L3's class.
Assume the following about Lib1Construct():
Lib1Construct()
Lib2SomeFunction()
Lib3SomeOtherFunction()
In other words, the constructor of L1 calls a function in L2 (which has
no constructor of its own). This L2 function in turn calls a function in
L3 (which *does* have a constructor).
The way BaseTools work right now it is possible that
Lib3SomeOtherFunction() is entered *before* Lib3Construct() runs.
I'd like to inquire if this is intended. The ApplyLibraryInstance()
method in "BaseTools/Source/Python/AutoGen/AutoGen.py" seems to confirm
such an intent, it has code and comments like:
if LibraryModule.ConstructorList != [] and LibraryModule
not in Constructor:
Constructor.append(LibraryModule)
ie. only append LibraryModule to Constructor if LibraryModule does have
a constructor, and
# for each node Item with a Constructor
for Item in LibraryList:
if Item not in Constructor:
continue
If this was in fact intended, then I'll have to add empty constructor
functions to all libraries I ever touched and/or that are in OvmfPkg:
MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf
OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.inf
OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.inf
OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf
OvmfPkg/Library/PlatformBdsLib/PlatformBdsLib.inf
OvmfPkg/Library/PlatformFvbLibNull/PlatformFvbLibNull.inf
OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.inf
OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSecLib.inf
OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf
OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.inf
OvmfPkg/Library/VirtioLib/VirtioLib.inf
OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceLib.inf
because otherwise library instances that these libs depend on, directly
or indirectly, might not see their constructors invoked in the correct
order.
Thanks
Laszlo
------------------------------------------------------------------------------
Slashdot TV.
Video for Nerds. Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel