[DRAFT] MSVC: Add msvc_crt_link
options
#3178
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently libc hard codes the MSVC CRT that's used by the compiler. Users can select between two CRTs (dynamic and static) by toggling the
target-feature=crt-static
option. However, this is far from ideal given the number of possible configurations, especially when attempting to co-exist with existing C/C++ builds.At a minimum, it's also useful to be able to use the debug or release versions of these libraries. The following table shows these possible combinations:
msvcrt
msvcrtd
libcmt
libcmtd
Furthermore, users may want to disable linking the crt entirely so that they can fully control what is linked and how.
To support these different configurations, this PR adds a new cfg,
msvc_crt_link=option
, whereoption
is the link configuration option. This can be set in global rustflags (using--cfg
) so that it's applied consistently. The two possible options are:debug
: Use the debug versions of the CRT librariesnocrt
: disable all CRT linking. This obviously overrides all other options because nothing is linked