Skip to content

Replacing checked-in OBJ files with /ALTERNATENAME broke linker compatibility #2655

Closed
@StephanTLavavej

Description

@StephanTLavavej

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:

  1. Permanent fix: Rebuild the third-party library with VS 2022 17.2 or newer.
  2. 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

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 .

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixedSomething works now, yay!high priorityImportant!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions