Skip to content
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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

BillyONeal
Copy link
Member

@BillyONeal BillyONeal commented Dec 4, 2024

Related: #42456

I know the formatting looks strange; this is a workaround for FATAL_ERROR's behavior that inserts extra newlines :(

Output looks like this:

example output

@BillyONeal BillyONeal added category:vcpkg-bug The issue is with the vcpkg system (including helper scripts in `scripts/cmake/`) info:internal This PR or Issue was filed by the vcpkg team. labels Dec 4, 2024
Comment on lines 23 to 24
if("${VCPKG_CRT_LINKAGE}" STREQUAL "static")
message(FATAL_ERROR "This port can only build as a dynamic library, but the triplet \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick?

Suggested change
if("${VCPKG_CRT_LINKAGE}" STREQUAL "static")
message(FATAL_ERROR "This port can only build as a dynamic library, but the triplet \
if("${VCPKG_CRT_LINKAGE}" STREQUAL "static")
message(FATAL_ERROR "This port can only build as a dynamic library, but the triplet \

Comment on lines 28 to 41
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 \
(!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 \
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 \
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()")
Copy link
Contributor

Choose a reason for hiding this comment

The 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.
(And perhaps print the original intro "Refusing to build unexpected dynamic library against the static CRT.")

Copy link
Contributor

Choose a reason for hiding this comment

The 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!

Copy link
Member Author

Choose a reason for hiding this comment

The 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!

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.

if("${VCPKG_CRT_LINKAGE}" STREQUAL "static")
message(FATAL_ERROR "This port can only build as a dynamic library, but the triplet \
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 \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
conditions many developers find surprising, and for which most ports are unprepared, so vcpkg will \
conditions many developers find surprising and for which most ports are unprepared. Therefore, vcpkg will \

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 \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If you can edit the port calling vcpkg_check_linkage emitting this message, consider adding \
If you can edit the port calling vcpkg_check_linkage that emits this message, consider adding \

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 \
(!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 \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If you are merely consuming this port, you can consider choosing a triplet which selects a dynamic \
If you are consuming this port, consider choosing a triplet that selects a dynamic \

Comment on lines 35 to 36
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 \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 \
problems a static CRT with a dynamic library can cause, are confident that this port safely \
handles that configuration, and want to proceed anyway, author a custom triplet which explicitly \

@BillyONeal
Copy link
Member Author

I cancelled the build pending review of dg0yt's comment by other maintainers: #42508 (comment) and I'll apply everything else. (I just didn't want to cause another validation run with that outstanding)

@BillyONeal BillyONeal marked this pull request as draft December 4, 2024 20:50
@BillyONeal
Copy link
Member Author

The failures are baseline issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:vcpkg-bug The issue is with the vcpkg system (including helper scripts in `scripts/cmake/`) info:internal This PR or Issue was filed by the vcpkg team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants