Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
acd0bec
Rip out all uses of dumpbin for looking at DLLs.
BillyONeal Dec 12, 2022
d3e9e18
Add e2e test for no exports check.
BillyONeal Dec 14, 2022
f1fe1c0
Add end to end tests for DLLs with wrong arch and no appcontainer. Al…
BillyONeal Dec 14, 2022
09ecdfb
Add static lib with wrong CRT linkage test.
BillyONeal Dec 14, 2022
97f7f98
WIP directives
BillyONeal Dec 15, 2022
dd33985
Finish the directives ripout.
BillyONeal Dec 15, 2022
d76e94c
Add a both test case and fix bad extra newlines.
BillyONeal Dec 15, 2022
aceae2a
Fill in the URI.
BillyONeal Dec 15, 2022
dade311
Messages
BillyONeal Dec 15, 2022
fe4888c
Rip out looking for dumpbin elsewhere.
BillyONeal Dec 15, 2022
b60e19e
Unused local.
BillyONeal Dec 15, 2022
24daad2
Add the ability to read the first linker member in archives. This hap…
BillyONeal Jan 3, 2023
3dfdbe9
Merge remote-tracking branch 'origin/main' into kill-dumpbin
BillyONeal Jan 9, 2023
6fc321c
Add end to end test with an LLVM LTO lib and clean up the mismatched …
BillyONeal Jan 9, 2023
0801227
Whoops dupe directory :)
BillyONeal Jan 9, 2023
d77dd70
Add handling of LLVM bitcode libraries produced by -flto.
BillyONeal Jan 10, 2023
ef49056
Don't try to give non-Windows libs to Windows post build checks.
BillyONeal Jan 10, 2023
d15b5e6
Harden the lib reader.
BillyONeal Jan 10, 2023
813ade6
Harden the post build checks that use the lib reader.
BillyONeal Jan 10, 2023
8aae6c8
generate-message-map
BillyONeal Jan 10, 2023
a74ed3f
formatting
BillyONeal Jan 10, 2023
7542e44
Merge remote-tracking branch 'origin/main' into kill-dumpbin
BillyONeal Jan 19, 2023
adfb8ab
Fix build failure.
BillyONeal Jan 19, 2023
4ff7a05
Merge remote-tracking branch 'origin/main' into kill-dumpbin
BillyONeal Jan 26, 2023
d89beb5
Merge remote-tracking branch 'origin/main' into kill-dumpbin
BillyONeal Feb 6, 2023
480dd22
Define _FILE_OFFSET_BITS=64
BillyONeal Feb 6, 2023
60fae76
Use TestingRoot rather than manually cleaning WorkingRoot.
BillyONeal Feb 7, 2023
bb62d9d
Add command line flags to CRT kinds.
BillyONeal Feb 7, 2023
4b65e29
Some CR fixes.
BillyONeal Feb 7, 2023
8bb25d2
Use a real set for linker directives.
BillyONeal Feb 7, 2023
18e2fa5
Remove more dumpbin leftovers.
BillyONeal Feb 7, 2023
a48dfc7
Fix case sensitivity in old CRTs check.
BillyONeal Feb 7, 2023
86a8a5b
Extract append_floating_list. Change appends of single chars to call …
BillyONeal Feb 7, 2023
9d3816b
Append floating list typo
BillyONeal Feb 7, 2023
c23af93
Defer the string concat to when debug is on.,
BillyONeal Feb 7, 2023
b5aba78
Introduce try_read_all_from which combines the seek and read operations.
BillyONeal Feb 7, 2023
125f5c9
Report dll load errors as errors.
BillyONeal Feb 7, 2023
822ff4b
Merge remote-tracking branch 'origin/main' into kill-dumpbin
BillyONeal Feb 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ target_include_directories(vcpkglib PUBLIC include)
target_compile_definitions(vcpkglib PUBLIC
VCPKG_VERSION=${VCPKG_VERSION}
VCPKG_BASE_VERSION=${VCPKG_BASE_VERSION}
_FILE_OFFSET_BITS=64
)

if(NOT DEFINED VCPKG_STANDALONE_BUNDLE_SHA OR VCPKG_STANDALONE_BUNDLE_SHA STREQUAL "")
Expand Down
4 changes: 4 additions & 0 deletions azure-pipelines/e2e_assets/test-dll-port-template/build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mkdir "%~dp0debug"
mkdir "%~dp0release"
cl /MDd "%~dp0test.c" "%~dp0test.def" /Fo"%~dp0debug\test.obj" /Fe"%~dp0debug\test_dll.dll" /link /DLL
cl /MD "%~dp0test.c" "%~dp0test.def" /Fo"%~dp0release\test.obj" /Fe"%~dp0release\test_dll.dll" /link /DLL
14 changes: 14 additions & 0 deletions azure-pipelines/e2e_assets/test-dll-port-template/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/bin")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/lib")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug/bin")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug/lib")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/include")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/share")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/share/${PORT}")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/debug/test_dll.dll" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/bin")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/debug/test_dll.lib" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/release/test_dll.dll" DESTINATION "${CURRENT_PACKAGES_DIR}/bin")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/release/test_dll.lib" DESTINATION "${CURRENT_PACKAGES_DIR}/lib")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/test.h" DESTINATION "${CURRENT_PACKAGES_DIR}/include")
file(TOUCH "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright")
17 changes: 17 additions & 0 deletions azure-pipelines/e2e_assets/test-dll-port-template/test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <windows.h>
#include <stdio.h>

BOOLEAN WINAPI DllMain(HINSTANCE hDllHandle, DWORD nReason, LPVOID Reserved)
{
(void)Reserved;
if (nReason == DLL_PROCESS_ATTACH) {
DisableThreadLibraryCalls( hDllHandle );
}

return TRUE;
}

int __cdecl export_me() {
puts("You called the exported function!");
return 42;
}
4 changes: 4 additions & 0 deletions azure-pipelines/e2e_assets/test-dll-port-template/test.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
LIBRARY test_dll

EXPORTS
export_me
1 change: 1 addition & 0 deletions azure-pipelines/e2e_assets/test-dll-port-template/test.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// empty test header
4 changes: 4 additions & 0 deletions azure-pipelines/e2e_assets/test-dll-port-template/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "test-dll",
"version": "1.0.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
mkdir "%~dp0debug"
mkdir "%~dp0release"
mkdir "%~dp0both"
cl /c /MDd "%~dp0test.c" /Fo"%~dp0debug\test.obj"
lib "%~dp0debug\test.obj" /OUT:"%~dp0debug\test_lib.lib"
cl /c /DNDEBUG /MD "%~dp0test.c" /Fo"%~dp0release\test.obj"
lib "%~dp0release\test.obj" /OUT:"%~dp0release\test_lib.lib"
lib "%~dp0debug\test.obj" "%~dp0release\test.obj" /OUT:"%~dp0both\both_lib.lib"
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/lib")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug/lib")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/include")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/share")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/share/${PORT}")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/debug/test_lib.lib" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/both/both_lib.lib" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/release/test_lib.lib" DESTINATION "${CURRENT_PACKAGES_DIR}/lib")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/both/both_lib.lib" DESTINATION "${CURRENT_PACKAGES_DIR}/lib")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/test.h" DESTINATION "${CURRENT_PACKAGES_DIR}/include")
file(TOUCH "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright")
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <stdio.h>

#ifdef NDEBUG
int __cdecl use_ndebug() {
#else
int __cdecl use_no_ndebug() {
#endif
puts("You called the static lib function!");
return 42;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// empty test header
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "test-lib",
"version": "1.0.0"
}
Binary file not shown.
12 changes: 12 additions & 0 deletions azure-pipelines/e2e_ports/llvm-lto-lib/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/lib")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug/lib")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/llvm-lto-charset.lib"
DESTINATION "${CURRENT_PACKAGES_DIR}/lib")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/llvm-lto-charset.lib"
DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/include")
file(TOUCH "${CURRENT_PACKAGES_DIR}/include/llvm-lto-lib.h")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/share")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/share/${PORT}")
file(TOUCH "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright")
5 changes: 5 additions & 0 deletions azure-pipelines/e2e_ports/llvm-lto-lib/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "llvm-lto-lib",
"version": "1",
"supports": "windows"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
cmake_minimum_required(VERSION 3.24)
project(vcpkg-internal-dll-with-no-exports LANGUAGES C)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test.c" [[ #include <windows.h>
BOOLEAN WINAPI DllMain(HINSTANCE hDllHandle, DWORD nReason, LPVOID Reserved)
{
(void)Reserved;
if (nReason == DLL_PROCESS_ATTACH) {
DisableThreadLibraryCalls( hDllHandle );
}

return TRUE;
}
]])

file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test.h" [[
// empty test header
]])

add_library(no_exports "${CMAKE_CURRENT_BINARY_DIR}/test.c")
include(GNUInstallDirs)
install(TARGETS no_exports)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/test.c" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
SET(VCPKG_POLICY_DLLS_WITHOUT_LIBS enabled)
file(MAKE_DIRECTORY "${CURRENT_BUILDTREES_DIR}/src")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${CURRENT_BUILDTREES_DIR}/src")
vcpkg_cmake_configure(SOURCE_PATH "${CURRENT_BUILDTREES_DIR}/src")
vcpkg_cmake_install()
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/share")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/share/${PORT}")
file(REMOVE_RECURSE
"${CURRENT_PACKAGES_DIR}/debug/include"
"${CURRENT_PACKAGES_DIR}/debug/lib"
"${CURRENT_PACKAGES_DIR}/lib")
file(TOUCH "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright")
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "vcpkg-internal-dll-with-no-exports",
"version": "1.0.0",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
}
]
}
81 changes: 81 additions & 0 deletions azure-pipelines/end-to-end-tests-dir/post-build-checks.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
. $PSScriptRoot/../end-to-end-tests-prelude.ps1

if (-not $IsWindows) {
Write-Host 'Skipping e2e post build checks on non-Windows'
return
}

# DLLs with no exports
Refresh-TestRoot
[string]$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e_ports" vcpkg-internal-dll-with-no-exports --no-binarycaching
if (-not $buildOutput.Contains("$packagesRoot\vcpkg-internal-dll-with-no-exports_x86-windows\debug\bin\no_exports.dll") `
-or -not $buildOutput.Contains("$packagesRoot\vcpkg-internal-dll-with-no-exports_x86-windows\bin\no_exports.dll") `
-or -not $buildOutput.Contains('set(VCPKG_POLICY_DLLS_WITHOUT_EXPORTS enabled)')) {
throw 'Did not detect DLLs with no exports.'
}

# DLLs with wrong architecture
Refresh-TestRoot
mkdir "$TestingRoot/wrong-architecture"
Copy-Item -Recurse "$PSScriptRoot/../e2e_assets/test-dll-port-template" "$TestingRoot/wrong-architecture/test-dll"
Run-Vcpkg env "$TestingRoot/wrong-architecture/test-dll/build.cmd" --Triplet x64-windows
Throw-IfFailed

$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$TestingRoot/wrong-architecture" test-dll --no-binarycaching
$expected = "warning: The following files were built for an incorrect architecture:`n" + `
"warning: $packagesRoot\test-dll_x86-windows\debug\lib\test_dll.lib`n" + `
" Expected: x86, but was x64`n" + `
"warning: $packagesRoot\test-dll_x86-windows\lib\test_dll.lib`n" + `
" Expected: x86, but was x64`n" + `
"warning: The following files were built for an incorrect architecture:`n" + `
"warning: $packagesRoot\test-dll_x86-windows\debug\bin\test_dll.dll`n" + `
" Expected: x86, but was x64`n" + `
"warning: $packagesRoot\test-dll_x86-windows\bin\test_dll.dll`n" + `
" Expected: x86, but was x64`n"

if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect DLL with wrong architecture.'
}

# DLLs with no AppContainer bit
Refresh-TestRoot
mkdir "$TestingRoot/wrong-appcontainer"
Copy-Item -Recurse "$PSScriptRoot/../e2e_assets/test-dll-port-template" "$TestingRoot/wrong-appcontainer/test-dll"
Run-Vcpkg env "$TestingRoot/wrong-appcontainer/test-dll/build.cmd" --Triplet x64-windows
Throw-IfFailed

$buildOutput = Run-VcpkgAndCaptureOutput --triplet x64-uwp "--x-buildtrees-root=$buildtreesRoot" "--x-install-root=$installRoot" "--x-packages-root=$packagesRoot" install --overlay-ports="$TestingRoot/wrong-appcontainer" test-dll --no-binarycaching
$expected = "warning: The App Container bit must be set for Windows Store apps. The following DLLs do not have the App Container bit set:`n" + `
"`n" + `
" $packagesRoot\test-dll_x64-uwp\debug\bin\test_dll.dll`n" + `
" $packagesRoot\test-dll_x64-uwp\bin\test_dll.dll`n"

if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect DLL with wrong appcontainer.'
}

# Wrong CRT linkage
Refresh-TestRoot
mkdir "$TestingRoot/wrong-crt"
Copy-Item -Recurse "$PSScriptRoot/../e2e_assets/test-lib-port-template-dynamic-crt" "$TestingRoot/wrong-crt/test-lib"
Run-Vcpkg env "$TestingRoot/wrong-crt/test-lib/build.cmd" --Triplet x86-windows-static
Throw-IfFailed

$buildOutput = Run-VcpkgAndCaptureOutput --triplet x86-windows-static "--x-buildtrees-root=$buildtreesRoot" "--x-install-root=$installRoot" "--x-packages-root=$packagesRoot" install --overlay-ports="$TestingRoot/wrong-crt" test-lib --no-binarycaching
$expected = "warning: The following binaries should use the Static Debug (/MTd) CRT.`n" +
" $packagesRoot\test-lib_x86-windows-static\debug\lib\both_lib.lib links with:`n" +
" Dynamic Debug (/MDd)`n" +
" Dynamic Release (/MD)`n" +
" $packagesRoot\test-lib_x86-windows-static\debug\lib\test_lib.lib links with: Dynamic Debug (/MDd)`n" +
"To inspect the lib files, use:`n" +
" dumpbin.exe /directives mylibfile.lib`n" +
"warning: The following binaries should use the Static Release (/MT) CRT.`n" +
" $packagesRoot\test-lib_x86-windows-static\lib\both_lib.lib links with:`n" +
" Dynamic Debug (/MDd)`n" +
" Dynamic Release (/MD)`n" +
" $packagesRoot\test-lib_x86-windows-static\lib\test_lib.lib links with: Dynamic Release (/MD)`n" +
"To inspect the lib files, use:`n" +
" dumpbin.exe /directives mylibfile.lib`n"
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect lib with wrong CRT linkage.'
}
6 changes: 6 additions & 0 deletions azure-pipelines/end-to-end-tests-dir/regression-ports.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
. $PSScriptRoot/../end-to-end-tests-prelude.ps1

if ($IsWindows) {
Run-Vcpkg install --overlay-ports="$PSScriptRoot/../e2e_ports/llvm-lto-lib" llvm-lto-lib:x64-windows-static
Throw-IfFailed
}
Loading