public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Andrew Fish" <afish@apple.com>
To: edk2-devel-groups-io <devel@edk2.groups.io>,
	xzavierpower@gmail.com, "Chang, Abner" <abner.chang@hpe.com>
Subject: Re: [edk2-devel] including redfish libs results in multiple definitions of symbols
Date: Wed, 25 May 2022 21:04:05 -0700	[thread overview]
Message-ID: <2BD5DBA6-E682-4983-A17A-1A61400CC383@apple.com> (raw)
In-Reply-To: <CAEsd5RsWaR06F9TW-jTaArA0ukvMtSeM0aT6SQN1Sc47da=G8g@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 4407 bytes --]



> On May 25, 2022, at 9:23 AM, M.T. <xzavierpower@gmail.com> wrote:
> 
> Hello
> 
> I'm working on a small UEFI shell app.
> I was hoping to make use of the JsonLib found in the Redfish Package.
> 
> When I include the Redfish JsonLib and it's dependencies:
> JsonLib|RedfishPkg/Library/JsonLib/JsonLib.inf
> Ucs2Utf8Lib|RedfishPkg/Library/BaseUcs2Utf8Lib/BaseUcs2Utf8Lib.inf
> RedfishCrtLib|RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.inf
> BaseSortLib|MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf
> 
> BaseSortLib has symbol clashes with SortLib resulting in the following:
> 

It looks like BaseSortLib and and SortLib are the same library class so you should only have one. 

/Volumes/Case/edk2(master)>git grep --recurse-submodules SortLib  -- \*.inf | grep LIBRARY_CLASS 
MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf:18:  LIBRARY_CLASS                  = SortLib
MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf:18:  LIBRARY_CLASS                  = SortLib|UEFI_APPLICATION UEFI_DRIVER UEFI_DRIVER DXE_RUNTIME_DRIVER DXE_DRIVER


/Volumes/Case/edk2(master)>git grep --recurse-submodules BaseSortLib  -- \*.inc
RedfishPkg/RedfishLibs.dsc.inc:16:  BaseSortLib|MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf

OK bingo bingo bingo….

The way the edk2 works is you have a library class that maps to the include file. This is the name in the INF file that resolves linking. You can have as many instances of the library class as you like. This is why the DSC files have the <library class name>|<path to INF file> syntax as you are letting the build pick which instance of the library to use. You can control this per driver/app if you want.

It looks to me like BaseSortLib is an alias for SortLib and that is a bit of hack. 

You could try making sure that BaseSortLib and SortLib point to the same library instance 

The other option would be to edit RedfishCrtLib.inf and make BaseSortLib SortLib

/Volumes/Case/edk2(master)>git grep --recurse-submodules BaseSortLib  -- \*.inf
MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf:13:  BASE_NAME                      = BaseSortLib
MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf:14:  MODULE_UNI_FILE                = BaseSortLib.uni
MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf:25:  BaseSortLib.c
RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.inf:28:  BaseSortLib

I’m note sure why this fake BaseSortLib exists. Looks like we would need to ask Abner?

commit 6e9233f968735219b2038c5dd23a46be2c021807
Author: Abner Chang <abner.chang@hpe.com>
Date:   Fri Dec 4 12:30:05 2020 +0800

    RedfishPkg/RedfishCrtLib: Redfish C runtime library
    
    Redfish CRT library is currently used by edk2 JsonLib
    (open source jansson project) and edk2 RedfishLib
    (libredfish open source project). Redfish CrtLib library
    provides the necessary C runtime equivalent edk2 functions
    for open source projects.
    
    Signed-off-by: Abner Chang <abner.chang@hpe.com>
    
    Cc: Leif Lindholm <leif@nuviainc.com>
    Cc: Nickle Wang <nickle.wang@hpe.com>
    Cc: Peter O'Hanley <peter.ohanley@hpe.com>
    Reviewed-by: Nickle Wang <nickle.wang@hpe.com>
    Acked-by: Leif Lindholm <leif@nuviainc.com>
    Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>


Thanks,

Andrew Fish

> /usr/bin/ld: UefiSortLib.obj (symbol from plugin): in function `PerformQuickSort':
> (.text+0x0): multiple definition of `PerformQuickSort'; BaseSortLib.obj (symbol from plugin):(.text+0x0): first defined here
> /usr/bin/ld: UefiSortLib.obj (symbol from plugin): in function `PerformQuickSort':
> (.text+0x0): multiple definition of `DevicePathCompare'; BaseSortLib.obj (symbol from plugin):(.text+0x0): first defined here
> /usr/bin/ld: UefiSortLib.obj (symbol from plugin): in function `PerformQuickSort':
> (.text+0x0): multiple definition of `StringNoCaseCompare'; BaseSortLib.obj (symbol from plugin):(.text+0x0): first defined here
> /usr/bin/ld: UefiSortLib.obj (symbol from plugin): in function `PerformQuickSort':
> (.text+0x0): multiple definition of `StringCompare'; BaseSortLib.obj (symbol from plugin):(.text+0x0): first defined here
> 
> I need SortLib for UEFIShell dependencies, and I need BaseSortLib for JsonLib.
> Is there some way around this?  Or is Redfish meant to be standalone?
> 
> Thank you in advance
> xp
> 


[-- Attachment #2: Type: text/html, Size: 17659 bytes --]

  parent reply	other threads:[~2022-05-26  4:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-25 16:23 including redfish libs results in multiple definitions of symbols M.T.
2022-05-25 17:20 ` [edk2-devel] " Kilian Kegel
     [not found] ` <16F268C9DA792DE0.12338@groups.io>
2022-05-25 17:32   ` Kilian Kegel
2022-05-26  4:04 ` Andrew Fish [this message]
2022-05-26  4:07   ` Ethin Probst
2022-05-26  4:11     ` Andrew Fish
2022-05-26 15:32       ` M.T.
2022-05-26 17:06         ` Kilian Kegel
2022-05-27  4:59           ` Abner Chang

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=2BD5DBA6-E682-4983-A17A-1A61400CC383@apple.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