Hi,
We are facing Build error in Old platforms after adding GLOBAL_REMOVE_IF_UNREFERENCED in CryptoPkg's CryptTs.c file in edk202211 tag.
GLOBAL_REMOVE_IF_UNREFERENCED macro is defined in MdePkg/Include/Base.h
//
// The Microsoft* C compiler can removed references to unreferenced data items
// if the /OPT:REF linker option is used. We defined a macro as this is a
// a non standard extension
//
#if defined (_MSC_VER) && _MSC_VER < 1800 && !defined (MDE_CPU_EBC)
///
/// Remove global variable from the linked image if there are no references to
/// it after all compiler and linker optimizations have been performed.
///
///
#define GLOBAL_REMOVE_IF_UNREFERENCED __declspec(selectany)
#else
///
/// Remove the global variable from the linked image if there are no references
/// to it after all compiler and linker optimizations have been performed.
///
///
#define GLOBAL_REMOVE_IF_UNREFERENCED
#endif
Facing Below Build Error:
Building ... d:\bakerville\crypto\5.14_bakerville_0acjf044\MdePkg\Library\DxeServicesLib\DxeServicesLib.inf [X64]
d:\bakerville\crypto\5.14_bakerville_0acjf044\CryptoPkg\Library\BaseCryptLib\Pk\CryptTs.c(58) : error C2496: 'TS_MESSAGE_IMPRINT_new' : 'selectany' can only be applied to data items with external linkage
d:\bakerville\crypto\5.14_bakerville_0acjf044\CryptoPkg\Library\BaseCryptLib\Pk\CryptTs.c(89) : error C2496: 'TS_ACCURACY_new' : 'selectany' can only be applied to data items with external linkage
d:\bakerville\crypto\5.14_bakerville_0acjf044\CryptoPkg\Library\BaseCryptLib\Pk\CryptTs.c(141) : error C2496: 'TS_TST_INFO_new' : 'selectany' can only be applied to data items with external linkage
NMAKE : fatal error U1077: 'F:\Tools\WINDDK\7600.16385.1\bin\x86\amd64\cl.exe' : return code '0x2'
Stop.
AmiFlashLibCommon.c
Assembling: d:\bakerville\crypto\5.14_bakerville_0acjf044\Build\YubaCity\RELEASE_MYTOOLS\X64\AmiCompatibilityPkg\Library\AmiDxeLib\OUTPUT\x64\x64AsmLib\GetCpuTimer.iii
build...
: error 7000: Failed to execute command
nmake.exe /nologo -s tbuild [d:\bakerville\crypto\5.14_bakerville_0acjf044\Build\YubaCity\RELEASE_MYTOOLS\X64\CryptoPkg\Library\BaseCryptLib\BaseCryptLib]
After commenting GLOBAL_REMOVE_IF_UNREFERENCED macro in CryptTs.c file, project builds successfully. Kindly, provide your comments.
Thanks,
Sountharya