From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from rn-mailsvcp-ppex-lapp35.apple.com (rn-mailsvcp-ppex-lapp35.apple.com [17.179.253.44]) by mx.groups.io with SMTP id smtpd.web12.15915.1653538286214132770 for ; Wed, 25 May 2022 21:11:26 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@apple.com header.s=20180706 header.b=OzIY8YCu; spf=pass (domain: apple.com, ip: 17.179.253.44, mailfrom: afish@apple.com) Received: from pps.filterd (rn-mailsvcp-ppex-lapp35.rno.apple.com [127.0.0.1]) by rn-mailsvcp-ppex-lapp35.rno.apple.com (8.16.1.2/8.16.1.2) with SMTP id 24Q4BD1G001905; Wed, 25 May 2022 21:11:25 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apple.com; h=content-type : mime-version : subject : from : in-reply-to : date : cc : content-transfer-encoding : message-id : references : to; s=20180706; bh=iV0d47y+L5zMe2mYc1SC9dpJ/Tbd6t9JYsHeKFQXOdU=; b=OzIY8YCujYnpI917wnQ0aQQSkGKM9mVM26vERTh6KwklgDw4FToZMWV8OhicXgK1ffyH opxq1/MiYhCZ4JL0ndGLQVp7qiNMGI9+jLGLU3RuzzaqeyJfT1bpZg+qSZ+84rKmEbqT 31CES2CxpWxio4Z/tfHWh6vcSFFRAM6llvo5mzXgaTnfaeZDGRKS2o9m91dkiDW30WCf PDH6pgnGn2KDdJw4PX5qMubtVRfogtRb30E8xzButdn1Y39dW0xYf7I6m8wefTSDZ3rm tkDICKs+1LjW6u01VVXDp23mI3leXzd6KKGMFAKNVGE90wKSZfPZ1NIcEmS7DCQySAQ2 GA== Received: from rn-mailsvcp-mta-lapp02.rno.apple.com (rn-mailsvcp-mta-lapp02.rno.apple.com [10.225.203.150]) by rn-mailsvcp-ppex-lapp35.rno.apple.com with ESMTP id 3g93wdvs5u-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Wed, 25 May 2022 21:11:25 -0700 Received: from rn-mailsvcp-mmp-lapp02.rno.apple.com (rn-mailsvcp-mmp-lapp02.rno.apple.com [17.179.253.15]) by rn-mailsvcp-mta-lapp02.rno.apple.com (Oracle Communications Messaging Server 8.1.0.18.20220407 64bit (built Apr 7 2022)) with ESMTPS id <0RCH00MTX2B1RSF0@rn-mailsvcp-mta-lapp02.rno.apple.com>; Wed, 25 May 2022 21:11:25 -0700 (PDT) Received: from process_milters-daemon.rn-mailsvcp-mmp-lapp02.rno.apple.com by rn-mailsvcp-mmp-lapp02.rno.apple.com (Oracle Communications Messaging Server 8.1.0.18.20220407 64bit (built Apr 7 2022)) id <0RCH0110026X4R00@rn-mailsvcp-mmp-lapp02.rno.apple.com>; Wed, 25 May 2022 21:11:25 -0700 (PDT) X-Va-A: X-Va-T-CD: b2a6e213b1e93bac3561a11ee6934d40 X-Va-E-CD: 4c3770dc4d507cd1d231a50137551d1b X-Va-R-CD: 83ffc66b64bb84ade298839f1d0f4894 X-Va-CD: 0 X-Va-ID: 6d602d80-a095-4297-849b-856ad7ff9f60 X-V-A: X-V-T-CD: b2a6e213b1e93bac3561a11ee6934d40 X-V-E-CD: 4c3770dc4d507cd1d231a50137551d1b X-V-R-CD: 83ffc66b64bb84ade298839f1d0f4894 X-V-CD: 0 X-V-ID: 23985855-7ab8-43a9-9e57-9635fea80b80 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.486,18.0.874 definitions=2022-05-26_01:2022-05-25,2022-05-26 signatures=0 Received: from smtpclient.apple (unknown [17.11.163.155]) by rn-mailsvcp-mmp-lapp02.rno.apple.com (Oracle Communications Messaging Server 8.1.0.18.20220407 64bit (built Apr 7 2022)) with ESMTPSA id <0RCH00Z552B05S00@rn-mailsvcp-mmp-lapp02.rno.apple.com>; Wed, 25 May 2022 21:11:25 -0700 (PDT) MIME-version: 1.0 (Mac OS X Mail 15.0 \(3693.20.0.1.32\)) Subject: Re: [edk2-devel] including redfish libs results in multiple definitions of symbols From: "Andrew Fish" In-reply-to: <5c4b7ace-37ea-54d6-f881-7f0d074a4cce@gmail.com> Date: Wed, 25 May 2022 21:11:24 -0700 Cc: devel@edk2.groups.io, xzavierpower@gmail.com, "Chang, Abner" Message-id: <4B0C9781-28BC-4DB6-8A1A-192C39AE0A44@apple.com> References: <2BD5DBA6-E682-4983-A17A-1A61400CC383@apple.com> <5c4b7ace-37ea-54d6-f881-7f0d074a4cce@gmail.com> To: Ethin Probst X-Mailer: Apple Mail (2.3693.20.0.1.32) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.486,18.0.874 definitions=2022-05-26_01:2022-05-25,2022-05-26 signatures=0 Content-type: text/plain; charset=utf-8 Content-transfer-encoding: quoted-printable In edk2 speak Base just means does not depend on any phase of boot, so basi= cally standalone code. So you can pull a Base lib into SEC, PEI, DXE, SMM, = etc.=20 We never interned different Class Names for libs to map to the same library= class when we designed the build system.=20 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 wrote= : >=20 > aren't the Base*Libs there in case you want to override existing implemen= tations or implement custom versions of them? I'm pretty sure that's the lo= gic behind it -- its a hack of sorts to try to get OOP out of a purely proc= edural language. It works, but I don't think its necessarily ideal. But the= re really isn't much of an alternative. Then again, I might be wrong, too..= . >=20 > On 5/25/22 23:04, Andrew Fish via groups.io wrote: >>> On May 25, 2022, at 9:23 AM, M.T. > wrote: >>>=20 >>> Hello >>>=20 >>> I'm working on a small UEFI shell app. >>> I was hoping to make use of the JsonLib found in the Redfish Package. >>>=20 >>> 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 >>>=20 >>> BaseSortLib has symbol clashes with SortLib resulting in the following: >>>=20 >> 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 = =3D SortLib >> MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf:18: LIBRARY_CLASS = =3D SortLib|UEFI_APPLICATION UEFI_DRIVER UEFI_DRIVER DXE_RUNT= IME_DRIVER DXE_DRIVER >> /Volumes/Case/edk2(master)*>*git grep --recurse-submodules BaseSortLib = -- \*.inc >> RedfishPkg/RedfishLibs.dsc.inc:16:*BaseSortLib*|MdeModulePkg/Library/*Ba= seSortLib*/*BaseSortLib*.inf >> OK bingo bingo bingo=E2=80=A6. >> The way the edk2 works is you have a library class that maps to the incl= ude file. This is the name in the INF file that resolves linking. You can h= ave as many instances of the library class as you like. This is why the DSC= files have the | syntax as you are l= etting 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 bi= t 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:*BaseSortLi= b* >> I=E2=80=99m note sure why this fake BaseSortLib exists. Looks like we wo= uld 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 > >> Cc: Leif Lindholm > >> Cc: Nickle Wang > >> Cc: Peter O'Hanley > >> Reviewed-by: Nickle Wang > >> Acked-by: Leif Lindholm > >> Reviewed-by: Michael D Kinney > >> * >> * >> Thanks, >> Andrew Fish >>> /usr/bin/ld: UefiSortLib.obj (symbol from plugin): in function `Perform= QuickSort': >>> (.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 `Perform= QuickSort': >>> (.text+0x0): multiple definition of `DevicePathCompare'; BaseSortLib.ob= j (symbol from plugin):(.text+0x0): first defined here >>> /usr/bin/ld: UefiSortLib.obj (symbol from plugin): in function `Perform= QuickSort': >>> (.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 `Perform= QuickSort': >>> (.text+0x0): multiple definition of `StringCompare'; BaseSortLib.obj (s= ymbol from plugin):(.text+0x0): first defined here >>>=20 >>> I need SortLib for UEFIShell dependencies, and I need BaseSortLib for J= sonLib. >>> Is there some way around this? Or is Redfish meant to be standalone? >>>=20 >>> Thank you in advance >>> xp >>=20