Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MdePkg/BaseMemoryLib: Prevent VS2022 (17.5) linker failure #290

Commits on Mar 1, 2023

  1. MdePkg/BaseMemoryLib: Prevent VS2022 (17.5) linker failure

    After updating from Visual Studio 17.4 to 17.5, a large number of
    linker failures began to appear in several modules because `memset`
    is an unresolved symbol.
    
    It was found that the following functions in BaseMemoryLib/MemLibGeneric.c
    were having their loop pattern replaced with the `memset` intrinsic
    function:
    
    - `InternalMemSetMem16()`
    - `InternalMemSetMem32()`
    - `InternalMemSetMem64()`
    
    An example of an error related to `InternalMemSetMem64()` in
    VariableSmmRuntimeDxe is shown below:
    
    ```
    INFO - BaseMemoryLib.lib(MemLibGeneric.obj) : error LNK2001:
             unresolved external symbol memset
    INFO - <...>\VariableSmmRuntimeDxe.dll : fatal error LNK1120:
             1 unresolved externals
    ```
    
    This was reproduced in several environments including:
    
    - Public VM image:
      https://github.com/actions/runner-images/blob/win22/20230226.1/images/win/Windows2022-Readme.md
    
    - Locally when updating from 17.4.4 to 17.5.1
    
    > Note: The previous public VM image (with 17.4) did not have this issue
      https://github.com/actions/runner-images/blob/win22/20230219.1/images/win/Windows2022-Readme.md
    
    This change updates the type cast for the destination buffer to be
    `volatile` data to prevent this optimization and introduce a minimal
    delta to prior implementation.
    
    Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
    makubacki committed Mar 1, 2023
    Configuration menu
    Copy the full SHA
    23a68b6 View commit details
    Browse the repository at this point in the history