From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ua1-f49.google.com (mail-ua1-f49.google.com [209.85.222.49]) by mx.groups.io with SMTP id smtpd.web10.21239.1653579135961620020 for ; Thu, 26 May 2022 08:32:16 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cQRV8v05; spf=pass (domain: gmail.com, ip: 209.85.222.49, mailfrom: xzavierpower@gmail.com) Received: by mail-ua1-f49.google.com with SMTP id z15so692023uad.7 for ; Thu, 26 May 2022 08:32:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=fqXuJD/74UrFqmfwcc5G5QiGcKHj70Za2bahSx6mxtE=; b=cQRV8v054T6sg5NvJR9P4kpFOovjq4RZjsDW7qO9M4asoH52fzd3NA6r+3e9n9bOo4 SUVFx1MFdydIRXa8E4aqfsBPbUXi9sXNV3IS92udyG3d3HzcNd6eBeVmznN9Mw09WhAH 9njUD1NxhZeXrLdc3z6H1yu33Pzo+4AyYHxW7KqNumBRMCfcQ0eHtvu0uWiOlkzY9O70 VTBRKI6yita+IA7NJQif7PC/3ulNeA/CVamTkXG1PAdWfJctaa21sQ0FLbMjrplUzmIe FvfDIWHNsNWhCUDMcx0J3dZY6mPQI/+9qffoUCnUG/3b4q9B7D3V2pKb4f4uN0criGN6 A9Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fqXuJD/74UrFqmfwcc5G5QiGcKHj70Za2bahSx6mxtE=; b=jZWMJEX0edPGj3YxdveO2/TlA88stmxnCNK8LBZbeHBTODXOpss4znuNgKZMJKXz5n 0vaMvN3F1OUkBbE3K2Gs2/f9zxoPmcEspyBWstWYab0y4Q4YEGiVnvb3sI+MuNuQnYsx NB96gzQvPCnl6ST8sC5CE+WsGU0SG0O8DF1OZhQo3MNf4oJkIAx0BzbtjbNKr/vYkeHa g9xNN7X8Lgz6ov9Tk8uzQ2yZsgMI+NGJaKsl1yrVLPtx9FKQ2GFmwvj7c2ngFF8+XBvD DpqylUxUkjZ8gkuEJfTGGSri5vx4wi4Yl75HGIf8YVdui0Hcjmf1ti6MFy15FezaRi5l VeIg== X-Gm-Message-State: AOAM531IwnoP6gzYmjnxN1kJnlQv3xc63C+c0WJSembYouH4vvV1L1PW vKlDbEkc2JvpGfaxSC8WCsRoQ7o7HJZJNWV7WmhZ2fmDIzs= X-Google-Smtp-Source: ABdhPJyb9HpsZAsMhqXrGSzf5lX3F3RpHJXRc6tvHRX/z6ZXrDgBXGCv5xHzaSfDFxBNM15CR2KeqbBM0+gmWbHCHcw= X-Received: by 2002:ab0:2643:0:b0:369:2534:815 with SMTP id q3-20020ab02643000000b0036925340815mr3035183uao.24.1653579134842; Thu, 26 May 2022 08:32:14 -0700 (PDT) MIME-Version: 1.0 References: <2BD5DBA6-E682-4983-A17A-1A61400CC383@apple.com> <5c4b7ace-37ea-54d6-f881-7f0d074a4cce@gmail.com> <4B0C9781-28BC-4DB6-8A1A-192C39AE0A44@apple.com> In-Reply-To: <4B0C9781-28BC-4DB6-8A1A-192C39AE0A44@apple.com> From: "M.T." Date: Thu, 26 May 2022 11:32:05 -0400 Message-ID: Subject: Re: [edk2-devel] including redfish libs results in multiple definitions of symbols To: devel@edk2.groups.io, afish@apple.com Cc: Ethin Probst , "Chang, Abner" Content-Type: multipart/alternative; boundary="000000000000f0b8c405dfebe408" --000000000000f0b8c405dfebe408 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thank you for the feedback Kilian, your suggestion makes sense unfortunately I am working with GNU toolchain so I don't think I will be able to take advantage of it just yet. Andrew, I have not thought about renaming the libraries, I will give this a try to see if I can get rid of the duplicate symbols, it seems like it should work, thank you very much for that suggestion. Thank you xp On Thu, May 26, 2022 at 12:11 AM Andrew Fish via groups.io wrote: > In edk2 speak Base just means does not depend on any phase of boot, so > basically standalone code. So you can pull a Base lib into SEC, PEI, DXE, > SMM, etc. > > We never interned different Class Names for libs to map to the same > library class when we designed the build system. > > One of the driving factors for the library classes was to not have to > change your vendors driver INF file id you wanted to use a different > instance of the DebugLib etc. > > Thanks, > > Andrew Fish > > > On May 25, 2022, at 9:07 PM, Ethin Probst > wrote: > > > > aren't the Base*Libs there in case you want to override existing > implementations or implement custom versions of them? I'm pretty sure > that's the logic behind it -- its a hack of sorts to try to get OOP out o= f > a purely procedural language. It works, but I don't think its necessarily > ideal. But there really isn't much of an alternative. Then again, I might > be wrong, too... > > > > On 5/25/22 23:04, Andrew Fish via groups.io wrote: > >>> 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.i= nf > >>> BaseSortLib|MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf > >>> > >>> BaseSortLib has symbol clashes with SortLib resulting in the followin= g: > >>> > >> It looks like BaseSortLib and and SortLib are the same library class s= o > 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 > =3D SortLib > >> MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf:18: LIBRARY_CLASS > =3D 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/*Bas= eSortLib*/*BaseSortLib*.inf > >> OK bingo bingo bingo=E2=80=A6. > >> 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 | 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 > =3D *BaseSortLib* > >> MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf:14: MODULE_UNI_FILE > =3D *BaseSortLib*.uni > >> MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf:25:*BaseSortLib*.c > >> > RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.inf:28:*BaseSortLib= * > >> I=E2=80=99m note sure why this fake BaseSortLib exists. Looks like we = would > need to ask Abner? > >> * > >> * > >> commit 6e9233f968735219b2038c5dd23a46be2c021807 > >> Author: Abner Chang > > >> 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 > > >> Cc: Nickle Wang > > >> 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 > >> > > > >=20 > > > --000000000000f0b8c405dfebe408 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thank you for the feedback

Kilian, your= suggestion makes sense unfortunately=C2=A0I am working with GNU toolchain = so I don't think I will be able to take advantage of it just yet.
=

Andrew, I have not thought about renaming the libraries= , I will give this a try to see if I can get rid of the duplicate symbols, = it seems like it should work, thank you=C2=A0very much for that suggestion.=

Thank you
xp

On Thu, May 26, 2= 022 at 12:11 AM Andrew Fish via groups.io = <afish=3Dapple.com@groups.io&= gt; wrote:
In ed= k2 speak Base just means does not depend on any phase of boot, so basically= standalone code. So you can pull a Base lib into SEC, PEI, DXE, SMM, etc. =

We never interned different Class Names for libs to map to the same library= class when we designed the build system.

One of the driving factors for the library classes was to not have to chang= e your vendors driver INF file id you wanted to use a different instance of= the DebugLib etc.

Thanks,

Andrew Fish

> On May 25, 2022, at 9:07 PM, Ethin Probst <harlydavidsen@gmail.com> wrote:=
>
> aren't the Base*Libs there in case you want to override existing i= mplementations or implement custom versions of them? I'm pretty sure th= at's the logic behind it -- its a hack of sorts to try to get OOP out o= f a purely procedural language. It works, but I don't think its necessa= rily ideal. But there really isn't much of an alternative. Then again, = I might be wrong, too...
>
> On 5/25/22 23:04, Andrew Fish via groups.io wrote:
>>> On May 25, 2022, at 9:23 AM, M.T. <xzavierpower@gmail.com <mailto:<= a href=3D"mailto:xzavierpower@gmail.com" target=3D"_blank">xzavierpower@gma= il.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 P= ackage.
>>>
>>> When I include the Redfish JsonLib and it's dependencies:<= br> >>> JsonLib|RedfishPkg/Library/JsonLib/JsonLib.inf
>>> Ucs2Utf8Lib|RedfishPkg/Library/BaseUcs2Utf8Lib/BaseUcs2Utf8Lib= .inf
>>> RedfishCrtLib|RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishC= rtLib.inf
>>> BaseSortLib|MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf >>>
>>> BaseSortLib has symbol clashes with SortLib resulting in the f= ollowing:
>>>
>> It looks like BaseSortLib and and SortLib are the same library cla= ss so you should only have one.
>> /Volumes/Case/edk2(master)*>*git grep --recurse-submodules Sort= Lib=C2=A0 -- \*.inf | grep LIBRARY_CLASS
>> MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf:18:=C2=A0 LIBRARY= _CLASS=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =3D SortLib
>> MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf:18:=C2=A0 LIBRARY= _CLASS=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =3D SortLib|UEFI_APPLICATION UEFI_DRIVER UEFI_DRIVER DXE_RUNTIME_DRIVER DXE= _DRIVER
>> /Volumes/Case/edk2(master)*>*git grep --recurse-submodules Base= SortLib=C2=A0 -- \*.inc
>> RedfishPkg/RedfishLibs.dsc.inc:16:*BaseSortLib*|MdeModulePkg/Libra= ry/*BaseSortLib*/*BaseSortLib*.inf
>> OK bingo bingo bingo=E2=80=A6.
>> The way the edk2 works is you have a library class that maps to th= e 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 t= he DSC files have the <library class name>|<path to INF file> s= yntax as you are letting the build pick which instance of the library to us= e. You can control this per driver/app if you want.
>> It looks to me like BaseSortLib is an alias for SortLib and that i= s a bit of hack.
>> You could try making sure that BaseSortLib and SortLib point to th= e same library instance
>> The other option would be to edit RedfishCrtLib.inf and make BaseS= ortLib SortLib
>> /Volumes/Case/edk2(master)*>*git grep --recurse-submodules Base= SortLib=C2=A0 -- \*.inf
>> MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf:13:=C2=A0 BASE_NA= ME=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0=3D *BaseSortLib*
>> MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf:14:=C2=A0 MODULE_= UNI_FILE=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=3D *= BaseSortLib*.uni
>> MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf:25:*BaseSortLib*.= c
>> RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.inf:28:*Base= SortLib*
>> I=E2=80=99m note sure why this fake BaseSortLib exists. Looks like= we would need to ask Abner?
>> *
>> *
>> commit 6e9233f968735219b2038c5dd23a46be2c021807
>> Author: Abner Chang <abner.chang@hpe.com <mailto:abner.chang@hpe.com>>
>> Date:=C2=A0 =C2=A0Fri Dec 4 12:30:05 2020 +0800
>>=C2=A0 =C2=A0 =C2=A0RedfishPkg/RedfishCrtLib: Redfish C runtime lib= rary
>>=C2=A0 =C2=A0 =C2=A0Redfish CRT library is currently used by edk2 J= sonLib
>>=C2=A0 =C2=A0 =C2=A0(open source jansson project) and edk2 RedfishL= ib
>>=C2=A0 =C2=A0 =C2=A0(libredfish open source project). Redfish CrtLi= b library
>>=C2=A0 =C2=A0 =C2=A0provides the necessary C runtime equivalent edk= 2 functions
>>=C2=A0 =C2=A0 =C2=A0for open source projects.
>>=C2=A0 =C2=A0 =C2=A0Signed-off-by: Abner Chang <abner.chang@hpe.com <mailto= :abner.chang@hpe.c= om>>
>>=C2=A0 =C2=A0 =C2=A0Cc: Leif Lindholm <leif@nuviainc.com <mailto:leif@nuviainc.com>> >>=C2=A0 =C2=A0 =C2=A0Cc: Nickle Wang <nickle.wang@hpe.com <mailto:nickle.wang@hpe.com>&= gt;
>>=C2=A0 =C2=A0 =C2=A0Cc: Peter O'Hanley <peter.ohanley@hpe.com <mailto= :peter.ohanley@h= pe.com>>
>>=C2=A0 =C2=A0 =C2=A0Reviewed-by: Nickle Wang <nickle.wang@hpe.com <mailto:<= a href=3D"mailto:nickle.wang@hpe.com" target=3D"_blank">nickle.wang@hpe.com= >>
>>=C2=A0 =C2=A0 =C2=A0Acked-by: Leif Lindholm <leif@nuviainc.com <mailto:leif@nuviainc.com>&= gt;
>>=C2=A0 =C2=A0 =C2=A0Reviewed-by: Michael D Kinney <michael.d.kinney@intel.c= om <mailto: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'; Ba= seSortLib.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'; B= aseSortLib.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'; BaseS= ortLib.obj (symbol from plugin):(.text+0x0): first defined here
>>>
>>> I need SortLib for UEFIShell dependencies, and I need BaseSort= Lib for JsonLib.
>>> Is there some way around this?=C2=A0 Or is Redfish meant to be= standalone?
>>>
>>> Thank you in advance
>>> xp
>>






--000000000000f0b8c405dfebe408--