Skip to content

Commit 35d7dec

Browse files
authored
[FIPS 2025 CHERRYPICK] Fix shared library install on Windows: place DLLs in bin directory (#3225) (#3253)
Cherry-pick #3225 onto the FIPS 2025 branch. ------ ### Description of changes: CMake classifies DLL files as `RUNTIME` artifacts, not `LIBRARY` artifacts. Our install rules only specified `LIBRARY DESTINATION` and `ARCHIVE DESTINATION`, so `cmake --install` was silently skipping the DLL files on Windows. This adds `RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}` to the install rules for both `crypto` and `ssl`. On non-Windows platforms the clause is harmlessly ignored since `.so`/`.dylib` are `LIBRARY` type. ### Testing: Added a `build_and_install` step to `run_windows_tests.bat` that builds with `BUILD_SHARED_LIBS=1`, runs `cmake --install`, and asserts that `crypto.dll` and `ssl.dll` are present in the install prefix's `bin/` directory. 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.
1 parent 8bc6825 commit 35d7dec

3 files changed

Lines changed: 40 additions & 1 deletion

File tree

crypto/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,8 @@ install(TARGETS crypto
939939
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
940940
LIBRARY
941941
DESTINATION ${CMAKE_INSTALL_LIBDIR}
942-
NAMELINK_SKIP)
942+
NAMELINK_SKIP
943+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
943944

944945
if(MSVC AND CMAKE_BUILD_TYPE_LOWER MATCHES "relwithdebinfo" AND FIPS)
945946
install (FILES $<TARGET_FILE_DIR:crypto>/crypto.pdb DESTINATION ${CMAKE_INSTALL_LIBDIR})

ssl/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ install(TARGETS ssl
118118
LIBRARY
119119
DESTINATION ${CMAKE_INSTALL_LIBDIR}
120120
NAMELINK_SKIP
121+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
121122
)
122123

123124
if(MSVC AND CMAKE_BUILD_TYPE_LOWER MATCHES "relwithdebinfo" AND FIPS)

tests/ci/run_windows_tests.bat

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ call :build_and_test Release "-DOPENSSL_NO_ASM=1" || goto error
3535
@rem tests or copy them around so Windows can find it in the same directory. Instead just put the dll's location onto the path
3636
set PATH=%BUILD_DIR%;%BUILD_DIR%\crypto;%BUILD_DIR%\ssl;%PATH%
3737
call :build_and_test Release "-DBUILD_SHARED_LIBS=1" || goto error
38+
@rem Reuse the build tree from the preceding shared build to verify that
39+
@rem `cmake --install` places DLLs in bin/ and import libraries in lib/.
40+
call :verify_install || goto error
3841
call :build_and_test Release "-DBUILD_SHARED_LIBS=1 -DFIPS=1" || goto error
3942
if /i not "%ARCH_OPTION%" == "arm64" (
4043
@rem For FIPS on Windows/x86-64 we also have a RelWithDebInfo build to generate debug symbols.
@@ -105,3 +108,37 @@ exit /b %errorlevel%
105108
:error
106109
echo Failed with error #%errorlevel%.
107110
exit /b 1
111+
112+
@rem Runs `cmake --install` against the already-configured %BUILD_DIR% and
113+
@rem verifies that the expected shared-library artifacts land in the
114+
@rem conventional Windows install layout: DLLs in bin/, import libs in lib/.
115+
@rem Assumes the caller has already done a BUILD_SHARED_LIBS=1 build.
116+
:verify_install
117+
@echo on
118+
set INSTALL_DIR=%TEMP%\awslc_install
119+
rmdir /s /q "%INSTALL_DIR%" 2>nul
120+
121+
@echo LOG: %date%-%time% running cmake install into %INSTALL_DIR%
122+
cmake --install "%BUILD_DIR%" --prefix "%INSTALL_DIR%" || goto error
123+
124+
@echo LOG: %date%-%time% verifying install layout
125+
dir "%INSTALL_DIR%\bin\"
126+
dir "%INSTALL_DIR%\lib\"
127+
if not exist "%INSTALL_DIR%\bin\crypto.dll" (
128+
echo ERROR: crypto.dll not found in %INSTALL_DIR%\bin\
129+
goto error
130+
)
131+
if not exist "%INSTALL_DIR%\bin\ssl.dll" (
132+
echo ERROR: ssl.dll not found in %INSTALL_DIR%\bin\
133+
goto error
134+
)
135+
if not exist "%INSTALL_DIR%\lib\crypto.lib" (
136+
echo ERROR: crypto.lib not found in %INSTALL_DIR%\lib\
137+
goto error
138+
)
139+
if not exist "%INSTALL_DIR%\lib\ssl.lib" (
140+
echo ERROR: ssl.lib not found in %INSTALL_DIR%\lib\
141+
goto error
142+
)
143+
@echo LOG: %date%-%time% install verification passed
144+
exit /b 0

0 commit comments

Comments
 (0)