aws / aws-lc

AWS-LC is a general-purpose cryptographic library maintained by the AWS Cryptography team for AWS and their customers. It іs based on code from the Google BoringSSL project and the OpenSSL project.
Other
398 stars 118 forks source link

Support CMAKE_MSVC_RUNTIME_LIBRARY #1737

Closed justsmth closed 3 months ago

justsmth commented 3 months ago

Description of changes:

Testing

I tested with both the Ninja and "Visual Studio 17 2022" generators.

cmake ~/repos/aws-lc -B ~/AWS-LC-BUILD -DBUILD_SHARED_LIBS=0 -DCMAKE_GENERATOR=Ninja -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
cmake ~/repos/aws-lc -B ~/AWS-LC-BUILD  -B C:\Users\Administrator\AWS-LC-BUILD\ -DBUILD_SHARED_LIBS=1 -DCMAKE_GENERATOR=Ninja -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
cmake ~/repos/aws-lc -B ~/AWS-LC-BUILD -DBUILD_SHARED_LIBS=0 -DCMAKE_GENERATOR="Visual Studio 17 2022" -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
cmake ~/repos/aws-lc -B ~/AWS-LC-BUILD -DBUILD_SHARED_LIBS=1 -DCMAKE_GENERATOR="Visual Studio 17 2022" -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded

Shared (not recommended, but technically possible)

Before

% for LIBR in `find "${AWS_LC_BUILD}" -name "*.dll"`; do echo ===== `basename $LIBR` =====; "${DUMPBIN}" //IMPORTS ${LIBR} | grep '.dll' ; done
...
===== crypto.dll =====
Dump of file C:\Users\Administrator\AWS-LC-BUILD\crypto\crypto.dll
    WS2_32.dll
    KERNEL32.dll
    VCRUNTIME140D.dll
    ucrtbased.dll

After

% for LIBR in `find "${AWS_LC_BUILD}" -name "*.dll"`; do echo ===== `basename $LIBR` =====; "${DUMPBIN}" //IMPORTS ${LIBR} | grep '.dll' ; done
...
===== crypto.dll =====
Dump of file C:\Users\Administrator\AWS-LC-BUILD\crypto\crypto.dll
    WS2_32.dll
    KERNEL32.dll

Static

Before

for LIBR in `find "${AWS_LC_BUILD}" -name "*.lib"`; do echo ===== `basename $LIBR` =====; "${DUMPBIN}" //DIRECTIVES ${LIBR} | grep 'DEFAULTLIB:MSVCRT' | wc -l ; done
...
===== crypto.lib =====
250
...

After

for LIBR in `find "${AWS_LC_BUILD}" -name "*.lib"`; do echo ===== `basename $LIBR` =====; "${DUMPBIN}" //DIRECTIVES ${LIBR} | grep 'DEFAULTLIB:MSVCRT' | wc -l ; done
...
===== crypto.lib =====
0
...

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.

codecov-commenter commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 78.44%. Comparing base (94f021b) to head (7e4f381).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1737 +/- ## ========================================== - Coverage 78.46% 78.44% -0.03% ========================================== Files 580 580 Lines 96779 96780 +1 Branches 13865 13866 +1 ========================================== - Hits 75936 75916 -20 - Misses 20226 20246 +20 - Partials 617 618 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

justinwsmith commented 3 months ago

It's not recommended to use static CRT with DLL libraries, especially when CRT objects (such as FILE) could be passed across the DLL boundary.