Description
For supply chain security, #2381 replaced checked-in OBJ files (generated by an internal tool aliasobj
) with the linker's /ALTERNATENAME
option (which is strictly more reproducible, although not officially documented).
We had never done this before, and although I ensured that the mangled names were identical, I didn't consider all possible scenarios. In certain situations, using a third-party library compiled with an older MSVC toolset, and performing the final link with a newer MSVC toolset, can emit "unresolved external symbol" linker errors that look like:
[x86]
error LNK2001: unresolved external symbol __imp____std_init_once_begin_initialize@16
error LNK2001: unresolved external symbol __imp____std_init_once_complete@12
[x64, ARM, ARM64]
error LNK2019: unresolved external symbol __imp___std_init_once_begin_initialize
error LNK2019: unresolved external symbol __imp___std_init_once_complete
I apologize for breaking linker compatibility here. Due to the supply chain security impact (and the fact that the aliasobj
tool is still not yet publicly available), we can't undo this change. There are a couple of options to resolve these errors:
- Permanent fix: Rebuild the third-party library with VS 2022 17.2 or newer.
- Build system workaround: Add the following linker options, depending on the target architecture:
- For x86:
/ALTERNATENAME:__imp____std_init_once_begin_initialize@16=__imp__InitOnceBeginInitialize@16
/ALTERNATENAME:__imp____std_init_once_complete@12=__imp__InitOnceComplete@12
- For x64, ARM, and ARM64:
/ALTERNATENAME:__imp___std_init_once_begin_initialize=__imp_InitOnceBeginInitialize
/ALTERNATENAME:__imp___std_init_once_complete=__imp_InitOnceComplete
- For x86:
I've filed this issue so that the error messages are searchable. I can also answer further questions if you've encountered these errors (I may not see GitHub notifications, so you may need to get my attention in the STL's Discord server.)
Also tracked by DevCom-1684365 / internal VSO-1495049 / AB#1495049 .