[vcpkg-cmake-config] Check for unguarded release lib paths
-
What does your PR fix?
Finds unguarded release lib paths in main cmake config files. Unlike per-build-type files, main config files are used for release and debug. Unexpected mixing breaks builds. Examples: szip in hdf5, openssl in aws-sdk-cpp (https://github.com/microsoft/vcpkg/pull/21239#issuecomment-964971664, https://github.com/microsoft/vcpkg/pull/20289#issuecomment-962888771).
-
Which triplets are supported/not supported? Have you updated the CI baseline?
all, no
-
Does your PR follow the maintainer guide?
yes
-
If you have added/updated a port: Have you run
./vcpkg x-add-version --alland committed the result?Waiting for feedback on idea and implementation.
I expected some false positives, but it looks like there are only real issues. x64-linux:
aws-sdk-cpp/stdout-x64-linux.log: Unguarded release path /lib/ path at [>>>]:
aws-sdk-cpp/stdout-x64-linux.log: INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:pthread>;\$<\$<NOT:\$<CONFIG:DEBUG>>:/mnt/vcpkg-ci/installed/x64-linux/lib/libcurl.a>;\$<\$<CONFIG:DEBUG>:/mnt/vcpkg-ci/installed/x64-linux/debug/lib/libcurl-d.a>;\$<LINK_ONLY:dl>;\$<LINK_ONLY:-lpthread>;\$<LINK_ONLY:OpenSSL::SSL>;\$<LINK_ONLY:OpenSSL::Crypto>;\$<LINK_ONLY:ZLIB::ZLIB>;[>>>]/mnt/vcpkg-ci/installed/x64-linux/lib/libssl.a;/mnt/vcpkg-ci/installed/x64-linux/lib/libcrypto.a;\$<LINK_ONLY:-lpthread>;\$<LINK_ONLY:dl>;\$<LINK_ONLY:dl>;\$<LINK_ONLY:-lpthread>;/mnt/vcpkg-ci/installed/x64-linux/lib/libz.a;AWS::aws-crt-cpp"
crossguid/stdout-x64-linux.log: Unguarded release path /lib/ path at [>>>]:
crossguid/stdout-x64-linux.log: INTERFACE_LINK_LIBRARIES "[>>>]/mnt/vcpkg-ci/installed/x64-linux/lib/libuuid.a"
freealut/stdout-x64-linux.log: Unguarded release path /lib/ path at [>>>]:
freealut/stdout-x64-linux.log: INTERFACE_LINK_LIBRARIES "[>>>]/mnt/vcpkg-ci/installed/x64-linux/lib/libopenal.a;m"
freetype/stdout-x64-linux.log: Unguarded release path /lib/ path at [>>>]:
freetype/stdout-x64-linux.log: INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:ZLIB::ZLIB>;\$<\$<NOT:\$<CONFIG:DEBUG>>:/mnt/vcpkg-ci/installed/x64-linux/lib/libbz2.a>;\$<\$<CONFIG:DEBUG>:/mnt/vcpkg-ci/installed/x64-linux/debug/lib/libbz2d.a>;\$<\$<NOT:\$<CONFIG:DEBUG>>:/mnt/vcpkg-ci/installed/x64-linux/lib/libpng.a>;\$<\$<CONFIG:DEBUG>:/mnt/vcpkg-ci/installed/x64-linux/debug/lib/libpng16d.a>;\$<\$<NOT:\$<CONFIG:DEBUG>>:/mnt/vcpkg-ci/installed/x64-linux/lib/libz.a>;\$<\$<CONFIG:DEBUG>:/mnt/vcpkg-ci/installed/x64-linux/debug/lib/libz.a>;\$<LINK_ONLY:m>;[>>>]/mnt/vcpkg-ci/installed/x64-linux/lib/libbrotlidec-static.a;/mnt/vcpkg-ci/installed/x64-linux/lib/libbrotlicommon-static.a"
hdf5/stdout-x64-linux.log: Unguarded release path /lib/ path at [>>>]:
hdf5/stdout-x64-linux.log: INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:m>;\$<LINK_ONLY:dl>;\$<\$<NOT:\$<CONFIG:DEBUG>>:/mnt/vcpkg-ci/installed/x64-linux/lib/libz.a>;\$<\$<CONFIG:DEBUG>:/mnt/vcpkg-ci/installed/x64-linux/debug/lib/libz.a>;[>>>]/mnt/vcpkg-ci/installed/x64-linux/lib/libszip.a;\$<LINK_ONLY:\$<\$<BOOL:OFF>:>>;\$<\$<NOT:\$<PLATFORM_ID:Windows>>:dl>;\$<LINK_ONLY:\$<\$<BOOL:OFF>:Threads::Threads>>"
lapack-reference/stdout-x64-linux.log: Unguarded release path /lib/ path at [>>>]:
lapack-reference/stdout-x64-linux.log: set(LAPACK_blas_LIBRARIES "[>>>]/mnt/vcpkg-ci/installed/x64-linux/lib/libopenblas.a;-lpthread")
leptonica/stdout-x64-linux.log: Unguarded release path /lib/ path at [>>>]:
leptonica/stdout-x64-linux.log: INTERFACE_INCLUDE_DIRECTORIES "/mnt/vcpkg-ci/installed/x64-linux/include;/mnt/vcpkg-ci/installed/x64-linux/include;[>>>]/mnt/vcpkg-ci/installed/x64-linux/lib/pkgconfig/../../include;/mnt/vcpkg-ci/installed/x64-linux/include;/mnt/vcpkg-ci/installed/x64-linux/include;/mnt/vcpkg-ci/installed/x64-linux/include;/mnt/vcpkg-ci/installed/x64-linux/include;/mnt/vcpkg-ci/installed/x64-linux/include"
libavif/stdout-x64-linux.log: Unguarded release path /lib/ path at [>>>]:
libavif/stdout-x64-linux.log: INTERFACE_LINK_LIBRARIES "[>>>]/mnt/vcpkg-ci/installed/x64-linux/lib/libaom.a;-L/mnt/vcpkg-ci/installed/x64-linux/lib/pkgconfig/../../lib;\$<LINK_ONLY:-laom>;\$<LINK_ONLY:-lm>;\$<LINK_ONLY:-lpthread>;\$<LINK_ONLY:m>;\$<LINK_ONLY:Threads::Threads>;/mnt/vcpkg-ci/installed/x64-linux/lib/libyuv.a"
libdatachannel/stdout-x64-linux.log: Unguarded release path /lib/ path at [>>>]:
libdatachannel/stdout-x64-linux.log: INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:Threads::Threads>;[>>>]/mnt/vcpkg-ci/installed/x64-linux/lib/libusrsctp.a;\$<LINK_ONLY:OpenSSL::SSL>;\$<LINK_ONLY:LibJuice::LibJuice>"
libdjinterop/stdout-x64-linux.log: Unguarded release path /lib/ path at [>>>]:
libdjinterop/stdout-x64-linux.log: INTERFACE_LINK_LIBRARIES "\$<\$<NOT:\$<CONFIG:DEBUG>>:/mnt/vcpkg-ci/installed/x64-linux/lib/libz.a>;\$<\$<CONFIG:DEBUG>:/mnt/vcpkg-ci/installed/x64-linux/debug/lib/libz.a>;[>>>]/mnt/vcpkg-ci/installed/x64-linux/lib/libsqlite3.a"
libevent/stdout-x64-linux.log: Unguarded release path /lib/ path at [>>>]:
libevent/stdout-x64-linux.log: INTERFACE_LINK_LIBRARIES "-lpthread;libevent::core;[>>>]/mnt/vcpkg-ci/installed/x64-linux/lib/libssl.a;/mnt/vcpkg-ci/installed/x64-linux/lib/libcrypto.a;-lpthread;dl;dl;-lpthread"
libftdi1/stdout-x64-linux.log: Unguarded release path /lib/ path at [>>>]:
libftdi1/stdout-x64-linux.log: set ( LIBFTDI_LIBRARIES "ftdi1;[>>>]/mnt/vcpkg-ci/installed/x64-linux/lib/libusb-1.0.a" )
libheif/stdout-x64-linux.log: Unguarded release path /lib/ path at [>>>]:
libheif/stdout-x64-linux.log: INTERFACE_LINK_LIBRARIES "[>>>]/mnt/vcpkg-ci/installed/x64-linux/lib/liblibde265.a;/mnt/vcpkg-ci/installed/x64-linux/lib/libx265.a;/mnt/vcpkg-ci/installed/x64-linux/lib/libaom.a"
libssh/stdout-x64-linux.log: Unguarded release path /lib/ path at [>>>]:
libssh/stdout-x64-linux.log: INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:rt>;[>>>]/mnt/vcpkg-ci/installed/x64-linux/lib/libmbedcrypto.a;-Wl,--version-script,\"/mnt/vcpkg-ci/buildtrees/libssh/src/b6ec41911d-067f95b6bb.clean/src/libssh.map\""
libwebsockets/stdout-x64-linux.log: Unguarded release path /lib/ path at [>>>]:
libwebsockets/stdout-x64-linux.log: INTERFACE_LINK_LIBRARIES "[>>>]/mnt/vcpkg-ci/installed/x64-linux/lib/libssl.a;/mnt/vcpkg-ci/installed/x64-linux/lib/libcrypto.a;-lpthread;dl;dl;-lpthread;\$<\$<NOT:\$<CONFIG:DEBUG>>:/mnt/vcpkg-ci/installed/x64-linux/lib/libz.a>;\$<\$<CONFIG:DEBUG>:/mnt/vcpkg-ci/installed/x64-linux/debug/lib/libz.a>;/mnt/vcpkg-ci/installed/x64-linux/lib/liblibuv.a"
log4cxx/stdout-x64-linux.log: Unguarded release path /lib/ path at [>>>]:
log4cxx/stdout-x64-linux.log: INTERFACE_LINK_LIBRARIES "[>>>]/mnt/vcpkg-ci/installed/x64-linux/lib/libaprutil-1.a;\$<LINK_ONLY:expat::expat>;/mnt/vcpkg-ci/installed/x64-linux/lib/libapr-1.a;\$<LINK_ONLY:pthread>"
minizip-ng/stdout-x64-linux.log: Unguarded release path /lib/ path at [>>>]:
minizip-ng/stdout-x64-linux.log: INTERFACE_LINK_DIRECTORIES "[>>>]/mnt/vcpkg-ci/installed/x64-linux/lib/pkgconfig/../../lib;/mnt/vcpkg-ci/installed/x64-linux/lib/pkgconfig/../../lib"
open62541/stdout-x64-linux.log: Unguarded release path /lib/ path at [>>>]:
open62541/stdout-x64-linux.log: INTERFACE_LINK_LIBRARIES "[>>>]/mnt/vcpkg-ci/installed/x64-linux/lib/libssl.a;/mnt/vcpkg-ci/installed/x64-linux/lib/libcrypto.a;-lpthread;dl;dl;-lpthread;m;pthread;rt"
realsense2/stdout-x64-linux.log: Unguarded release path /lib/ path at [>>>]:
realsense2/stdout-x64-linux.log: INTERFACE_LINK_LIBRARIES "[>>>]/mnt/vcpkg-ci/installed/x64-linux/lib/libusb-1.0.a"
simage/stdout-x64-linux.log: Unguarded release path /lib/ path at [>>>]:
simage/stdout-x64-linux.log: INTERFACE_LINK_LIBRARIES "[>>>]/mnt/vcpkg-ci/installed/x64-linux/lib/libgif.a;\$<\$<NOT:\$<CONFIG:DEBUG>>:/mnt/vcpkg-ci/installed/x64-linux/lib/libjpeg.a>;\$<\$<CONFIG:DEBUG>:/mnt/vcpkg-ci/installed/x64-linux/debug/lib/libjpeg.a>;\$<\$<NOT:\$<CONFIG:DEBUG>>:/mnt/vcpkg-ci/installed/x64-linux/lib/libpng.a>;\$<\$<CONFIG:DEBUG>:/mnt/vcpkg-ci/installed/x64-linux/debug/lib/libpng16d.a>;\$<\$<NOT:\$<CONFIG:DEBUG>>:/mnt/vcpkg-ci/installed/x64-linux/lib/libz.a>;\$<\$<CONFIG:DEBUG>:/mnt/vcpkg-ci/installed/x64-linux/debug/lib/libz.a>;\$<LINK_ONLY:m>;\$<LINK_ONLY:m>;/mnt/vcpkg-ci/installed/x64-linux/lib/libsndfile.a;/mnt/vcpkg-ci/installed/x64-linux/lib/libFLAC.a;/mnt/vcpkg-ci/installed/x64-linux/lib/libvorbis.a;/mnt/vcpkg-ci/installed/x64-linux/lib/libvorbisfile.a;/mnt/vcpkg-ci/installed/x64-linux/lib/libvorbisenc.a;/mnt/vcpkg-ci/installed/x64-linux/lib/libogg.a;/mnt/vcpkg-ci/installed/x64-linux/lib/libopus.a;\$<\$<NOT:\$<CONFIG:DEBUG>>:/mnt/vcpkg-ci/installed/x64-linux/lib/libtiff.a>;\$<\$<CONFIG:DEBUG>:/mnt/vcpkg-ci/installed/x64-linux/debug/lib/libtiffd.a>;\$<\$<NOT:\$<CONFIG:DEBUG>>:/mnt/vcpkg-ci/installed/x64-linux/lib/liblzma.a>;\$<\$<CONFIG:DEBUG>:/mnt/vcpkg-ci/installed/x64-linux/debug/lib/liblzmad.a>;/mnt/vcpkg-ci/installed/x64-linux/lib/libzstd.a;\$<\$<NOT:\$<CONFIG:DEBUG>>:/mnt/vcpkg-ci/installed/x64-linux/lib/libz.a>;\$<\$<CONFIG:DEBUG>:/mnt/vcpkg-ci/installed/x64-linux/debug/lib/libz.a>;/mnt/vcpkg-ci/installed/x64-linux/lib/libgif.a"
Windows (x64-windows):
freealut/stdout-x64-windows.log: Unguarded release path /lib/ path at [>>>]:
freealut/stdout-x64-windows.log: INTERFACE_LINK_LIBRARIES "[>>>]D:/installed/x64-windows/lib/OpenAL32.lib"
lapack-reference/stdout-x64-windows.log: Unguarded release path /lib/ path at [>>>]:
lapack-reference/stdout-x64-windows.log: set(LAPACK_blas_LIBRARIES "[>>>]D:/installed/x64-windows/lib/openblas.lib")
leptonica/stdout-x64-windows.log: Unguarded release path /lib/ path at [>>>]:
leptonica/stdout-x64-windows.log: INTERFACE_LINK_LIBRARIES "[>>>]D:/installed/x64-windows/lib/gif.lib;\$<\$<NOT:\$<CONFIG:DEBUG>>:D:/installed/x64-windows/lib/jpeg.lib>;\$<\$<CONFIG:DEBUG>:D:/installed/x64-windows/debug/lib/jpeg.lib>;\$<\$<NOT:\$<CONFIG:DEBUG>>:D:/installed/x64-windows/lib/libpng16.lib>;\$<\$<CONFIG:DEBUG>:D:/installed/x64-windows/debug/lib/libpng16d.lib>;\$<\$<NOT:\$<CONFIG:DEBUG>>:D:/installed/x64-windows/lib/zlib.lib>;\$<\$<CONFIG:DEBUG>:D:/installed/x64-windows/debug/lib/zlibd.lib>;\$<\$<NOT:\$<CONFIG:DEBUG>>:D:/installed/x64-windows/lib/tiff.lib>;\$<\$<CONFIG:DEBUG>:D:/installed/x64-windows/debug/lib/tiffd.lib>;WebP::webp;WebP::libwebpmux;\$<\$<NOT:\$<CONFIG:DEBUG>>:D:/installed/x64-windows/lib/zlib.lib>;\$<\$<CONFIG:DEBUG>:D:/installed/x64-windows/debug/lib/zlibd.lib>"
libdjinterop/stdout-x64-windows.log: Unguarded release path /lib/ path at [>>>]:
libdjinterop/stdout-x64-windows.log: INTERFACE_LINK_LIBRARIES "\$<\$<NOT:\$<CONFIG:DEBUG>>:D:/installed/x64-windows/lib/zlib.lib>;\$<\$<CONFIG:DEBUG>:D:/installed/x64-windows/debug/lib/zlibd.lib>;[>>>]D:/installed/x64-windows/lib/sqlite3.lib"
libftdi1/stdout-x64-windows.log: Unguarded release path /lib/ path at [>>>]:
libftdi1/stdout-x64-windows.log: set ( LIBFTDI_LIBRARIES "ftdi1;[>>>]D:/installed/x64-windows/lib/libusb-1.0.lib" )
libwebsockets/stdout-x64-windows.log: Unguarded release path /lib/ path at [>>>]:
libwebsockets/stdout-x64-windows.log: INTERFACE_LINK_LIBRARIES "[>>>]D:/installed/x64-windows/lib/libssl.lib;D:/installed/x64-windows/lib/libcrypto.lib;\$<\$<NOT:\$<CONFIG:DEBUG>>:D:/installed/x64-windows/lib/pthreadVC3.lib>;\$<\$<CONFIG:DEBUG>:D:/installed/x64-windows/debug/lib/pthreadVC3d.lib>;\$<\$<NOT:\$<CONFIG:DEBUG>>:D:/installed/x64-windows/lib/pthreadVC3.lib>;\$<\$<CONFIG:DEBUG>:D:/installed/x64-windows/debug/lib/pthreadVC3d.lib>;ws2_32.lib;userenv.lib;psapi.lib;iphlpapi.lib;crypt32.lib;\$<\$<NOT:\$<CONFIG:DEBUG>>:D:/installed/x64-windows/lib/zlib.lib>;\$<\$<CONFIG:DEBUG>:D:/installed/x64-windows/debug/lib/zlibd.lib>;D:/installed/x64-windows/lib/libuv.lib"
open62541/stdout-x64-windows.log: Unguarded release path /lib/ path at [>>>]:
open62541/stdout-x64-windows.log: INTERFACE_LINK_LIBRARIES "[>>>]D:/installed/x64-windows/lib/libssl.lib;D:/installed/x64-windows/lib/libcrypto.lib;ws2_32;iphlpapi"
opencascade/stdout-x64-windows.log: Unguarded release path /lib/ path at [>>>]:
opencascade/stdout-x64-windows.log: INTERFACE_LINK_LIBRARIES "TKernel;TKMath;user32.lib;advapi32.lib;advapi32.lib;user32.lib;windowscodecs;[>>>]D:/installed/x64-windows/lib/freetype.lib;winmm.lib"
Maybe it should be merged with VCPKG_CMAKE_CONFIG_NO_LIB_PATH_CHECK initially enabled if unset. So the check would be warning immediately. Later we can remove the initial VCPKG_CMAKE_CONFIG_NO_LIB_PATH_CHECK setting.
I surprised that only so few cases of wrong INTERFACE_LINK_LIBRARIES exists.
I surprised that only so few cases of wrong
INTERFACE_LINK_LIBRARIESexists.
- The check is only in vcpg-cmake-config at this point. Ports using the old config fixup are not covered.
- Optional features are not covered.
- As far as the problem occurs in a target's property,
- it is not found (but may have effects) in ports which consume the target,
- depending ports are skipped in CI ("cascade").
Suggestion:
- Extend to legacy fixup.
- Turn the errors into warning unless building in editable mode (making the PR mergeable)
- Collect the warnings from all ports during CI, and create AZP/GH warning(s).
One frequent pattern:
The openssl wrapper doesn't properly setup release+debug in ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY}.
- Extend to legacy fixup.
- Turn the errors into warning ~unless building in editable mode (making the PR mergeable)~
- Collect the warnings from all ports during CI, and create AZP/GH warning(s).
Implemented. This change now rebuilds the world, installing app. ~1310 ports on x64-windows.
Any progress in this PR? I'd like this.
I was hesitating to remove draft state while it is not ready for merge. But is ready for review.
Okay, I need some professional advice.
Can you please merge to master?
Merged master.
Now that this is reviewed, #21763 could probably be bundled with this one, even if they touch different ports.
Now that this is reviewed, #21763 could probably be bundled with this one, even if they touch different ports.
I think we'd better to merge that changes in the PR which modified vcpkg-cmake.
AFAICT #22546 should be the the fix for most of the warnings which are generated here.
I don't understand why this is done in CMake, and not in the C++ post-build stuff. Can you explain why?
I don't understand why this is done in CMake, and not in the C++ post-build stuff. Can you explain why?
Because that's how I did it. And because it unfolds its effect right here in building the broken universe.
(It is not even clear to me if you refer to the vcpkg-cmake-config changes (which seem to be extremly close the spot which introduces the issue), or if you refer to the AZP markup.
@dg0yt I mean, why do we not check for unguarded release libs in the same place we have our other checks (i.e., for absolute paths in libraries); having it in the CMake makes it more difficult to test and such.
<off-topic>Why don't we stop mixing release and debug variants in the same installed tree?</off-topic>
a) I know close to nothing about "our other checks". I don't think there is good documentation.
b) This PR started as a probe into the feasibility of dealing with this issue, and it turned out to be sufficient. If we find someone who implements the same in C++, fine for me.
c) I hooked into a spot where the files of interest are already read (and indeed the spot were vcpkg causes the problem, #22546).
d) Having it in the CMake scripts makes it quite easy to test IMO. In vcpkg CI. Locally with vpckg install. (Note: you don't need to rebuild your world, your can just swap the installed cmake script as you can swap the vcpkg tool blob.
I do understand that we might wish to
- have an option to turn the test off,
- apply the test to files/ports which are not handled by
vcpkg-cmake-config(e.g. because handled by the legacy functions) - benefit from better performance in C++.
I also don't mind to put this on hold until #22546 is accepted. If that PR resolves most of these port bug, this PR is much less important.
So I think we can continue this PR now?
So I think we can continue this PR now?
Considering dg0yt appears unwilling to implement these changes in C++ and we appear to be unwilling to add additional tests that occur only in CMake world I think this is appropriate to leave as draft until one or both of those changes.
Ping @dg0yt for response. Is work still being done for this PR?
"to leave as draft", https://github.com/microsoft/vcpkg/pull/21415#issuecomment-1049191280
This check only works when there are absolute path in the cmake config file?
This check only works when there are absolute path in the cmake config file?
Yes, absolute paths in the main config file.
For another approach cf. scripts/test_ports/cmake-user/project/CMakeLists.txt.
I surprised that only so few cases of wrong
INTERFACE_LINK_LIBRARIESexists.
~One year later: 242 hits in 33 packages for x64-windows.~ I didn't properly merge the master changes in my first attempt. But there are still enough hits left.
False positives:
- [ ]
\$<\$<NOT:\$<CONFIG:DEBUG>>:-L[>>>]/mnt/vcpkg-ci/installed/x64-linux/lib/pkgconfig/../../lib>(libavif:x64-windows) - [ ]
INTERFACE_INCLUDE_DIRECTORIES "[>>>]/mnt/vcpkg-ci/installed/x64-linux/lib/pkgconfig/../../include;${_IMPORT_PREFIX}/include"(wolfmgtt:x64-windows)
Closing this PR as there has not been activity in over 4 months. Please feel free to reopen it, or another PR, should you wish to continue this.
Please feel free to reopen it
Unprivileged contributors cannot reopen their own PRs here.