-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
vcpkg_check_linkage: Better explain the ONLY_DYNAMIC_LIBRARY situation #42508
base: master
Are you sure you want to change the base?
Changes from 2 commits
ceca62d
c49622c
b5217c3
d1a6a21
ad795b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -20,10 +20,27 @@ function(vcpkg_check_linkage) | |||||||||
message(STATUS "Note: ${PORT} only supports static library linkage. Building static library.") | ||||||||||
set(VCPKG_LIBRARY_LINKAGE static PARENT_SCOPE) | ||||||||||
elseif(arg_ONLY_DYNAMIC_LIBRARY AND "${VCPKG_LIBRARY_LINKAGE}" STREQUAL "static") | ||||||||||
message(STATUS "Note: ${PORT} only supports dynamic library linkage. Building dynamic library.") | ||||||||||
if("${VCPKG_CRT_LINKAGE}" STREQUAL "static") | ||||||||||
message(FATAL_ERROR "Refusing to build unexpected dynamic library against the static CRT. | ||||||||||
If this is desired, please configure your triplet to directly request this configuration.") | ||||||||||
if("${VCPKG_CRT_LINKAGE}" STREQUAL "static") | ||||||||||
message(FATAL_ERROR "This port can only build as a dynamic library, but the triplet \ | ||||||||||
ras0219-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
selects a static library and a static CRT. Building a dynamic library with a static CRT creates \ | ||||||||||
conditions many developers find surprising, and for which most ports are unprepared, so vcpkg will \ | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
not change VCPKG_LIBRARY_LINKAGE to dynamic for you in this case. | ||||||||||
For example, on Windows, each DLL will get its own copy of the CRT, meaning such DLLs cannot share \ | ||||||||||
standard library components over the DLL boundary. On non-Windows, different .sos or .dylibs may \ | ||||||||||
cause mutually incompatible symbols from different CRT versions to be concurrently loaded. | ||||||||||
If you can edit the port calling vcpkg_check_linkage emitting this message, consider adding \ | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
(!static | !static-crt) to the \"supports\" expression so that this combination can fail early. | ||||||||||
If you are merely consuming this port, you can consider choosing a triplet which selects a dynamic \ | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
CRT and/or library linkage. If you really know what you're doing, understand the potential \ | ||||||||||
problems a static CRT with a dynamic library can cause, and are confident that this port safely \ | ||||||||||
handles that configuration and want to proceed anyway, author a custom triplet which explicitly \ | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
sets VCPKG_LIBRARY_LINKAGE to dynamic and VCPKG_CRT_LINKAGE to static. For example: | ||||||||||
if(\"\${PORT}\" STREQUAL \"${PORT}\") | ||||||||||
set(VCPKG_LIBRARY_LINKAGE dynamic) | ||||||||||
set(VCPKG_CRT_LINKAGE static) | ||||||||||
endif()") | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest to move these details to https://learn.microsoft.com/vcpkg/maintainers/functions/vcpkg_check_linkage, and to only print a link here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, please! This is way too long! Nobody will read this 17 lines long message! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I don't think someone unwilling to read the 17 line message will be willing to go to separate documentation pages and read the same message either. |
||||||||||
else() | ||||||||||
message(STATUS "Note: ${PORT} only supports dynamic library linkage. Building dynamic library.") | ||||||||||
endif() | ||||||||||
set(VCPKG_LIBRARY_LINKAGE dynamic PARENT_SCOPE) | ||||||||||
endif() | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick?