-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Add built-in dynamic build with static CRT #19005
Conversation
7068a7b
to
655f42a
Compare
I think the answer to this was a big NO, since it can introduce serious bug if objects get passed over DLL boundaries and allocated and then deallocated by different CRTs. |
This is known issue. If you pass C++ objects over dynamic library boundary without using the same CRT it is not safe. |
This is not generally true.
|
Whoever needs this triplet, knows why it is needed. |
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.
Since they are not the official triplets, please move these triplet file to triplets/community .
655f42a
to
ac1a3f1
Compare
@JackBoos Done. |
ac1a3f1
to
e270bd2
Compare
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.
How about rename the triplets to x64-windows-mt
and x86-windows-mt
?
Do you have a better name ? |
@NN--- I think |
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.
I don't believe we can ever merge this.
Most libraries in vcpkg are not prepared to deal with this type of configuration. They speak standard library types in their interfaces, or throw exceptions, neither of which are safe to do when the standard library types are "owned" by different C runtime instances. When you statically link with the C runtime in a DLL, each DLL gets its own entire copy of the C runtime, and all state that may depend on global variables therein is unsafe to use.
For example, the iterator debug machinery is protected by the debug lock, which is a global variable that lives in msvcp140.dll/libcpmt.lib. If you have a DLL that exposes a function that has a const std::vector&
, that library cannot be used in such a configuration, because each DLL thinks it is taking a lock protecting the debugging data structures, when in reality they are taking different locks.
(This problem is similar to static libraries using a dynamic CRT as previously discussed in #16387 and #15122 , but the probability of triggering the problem goes from "possible" to "certain" in this case, as even use of the core language triggers breakage.)
This is correct that using C++ API between libraries in such scenario is problematic. |
@BillyONeal's comment #19005 (review) explains why this can never be an official or community vcpkg triplet. However, if you are an advanced user with one of the few valid use cases, this is always a possible triplet to define on your own and use via Thanks for the PR! |
Describe the pull request
What does your PR fix?
Fixes Support for dynamic runtime with static linking? #1131
Which triplets are supported/not supported? Have you updated the CI baseline?
Adding new triplet for Windows.
It is possible to add it manually, however I see many developers are struggling with the same issue.
Building dynamic library (DLL) while not using dynamic dependency on VC Runtime.