Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Conversation

@gkhanna79
Copy link
Member

This removes the dependency on VCRuntime140.dll from the native components built in CoreCLR repo. By default, we static link all CRT pieces. However, for the Release build, we link into uCRT DLL while continuing to static link the CRT pieces corresponding to vcruntime140.dll. I have confirmed that the Release binaries only have dependency on the uCRT APISets that will be pushed down via WU.

Fixes https://github.com/dotnet/coreclr/issues/4334.

@jkotas @russellhadley PTAL

@weshaggard @ericstj - FYI

set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /LTCG /OPT:REF /OPT:ICF ${NO_INCREMENTAL_LINKER_FLAGS}")

# Force uCRT to be dynamically linked for Release build
set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")
Copy link
Member

Choose a reason for hiding this comment

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

Is overriding default lib the blessed (by C++) way to mix the static and dynamic linking? Similar things were hard to get right in the past - had subtle bugs.

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. This is what they suggested. This is possible now because runtime pieces remain statically linked while General library functions come from ucrt dynamically.

@jkotas
Copy link
Member

jkotas commented Apr 16, 2016

LGTM

# Define the uCRT lib reference
set(STATIC_MT_UCRT_LIB "libucrt$<$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>:d>.lib")
set(STATIC_UCRT_LIB "libucrt$<$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>:d>.lib")
set(DYNAMIC_UCRT_LIB "ucrt$<$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>:d>.lib")
Copy link

Choose a reason for hiding this comment

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

Where are these two getting used?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not yet. Defined for any future use for consistency.

Copy link

Choose a reason for hiding this comment

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

Gotcha. LGTM then. I'm working on the CoreFX version now.

@gkhanna79 gkhanna79 merged commit 1caf7b9 into dotnet:master Apr 18, 2016
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
Cleanup VCRuntime140.dll dependency from native components

Commit migrated from dotnet/coreclr@1caf7b9
@AraHaan
Copy link
Member

AraHaan commented Aug 12, 2022

Was this made to no longer be static linked since soon Windows 7 support will be dropped which means that .NET could default to use the OS's UCRT copy through dynamic (and not static) link?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants