From def1bdd693046fc40ada9e9f004f1001adf0160b Mon Sep 17 00:00:00 2001 From: Leonard Hecker Date: Tue, 26 Oct 2021 21:08:49 +0200 Subject: [PATCH] Compile OpenConsoleProxy without CRT (#11610) After this commit OpenConsoleProxy will be built without a CRT. This cuts down its binary size and DLL dependency bloat. We hope that this fixes a COM server activation bug if the user doesn't have a CRT installed globally on their system. Fixes #11529 --- .github/actions/spelling/expect/expect.txt | 3 +++ src/common.build.pre.props | 3 ++- src/cppwinrt.build.pre.props | 2 +- src/host/proxy/Host.Proxy.vcxproj | 19 +++++++++++++++---- src/host/proxy/Host.Proxy.vcxproj.filters | 3 +++ src/host/proxy/nodefaultlib_shim.h | 18 ++++++++++++++++++ 6 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 src/host/proxy/nodefaultlib_shim.h diff --git a/.github/actions/spelling/expect/expect.txt b/.github/actions/spelling/expect/expect.txt index dccd6d740..c18d880e4 100644 --- a/.github/actions/spelling/expect/expect.txt +++ b/.github/actions/spelling/expect/expect.txt @@ -938,6 +938,7 @@ GTP guc gui guidatom +guiddef GValue GWL GWLP @@ -1535,6 +1536,7 @@ NOCOLOR NOCOMM NOCONTEXTHELP NOCOPYBITS +nodefaultlib nodiscard NODUP noexcept @@ -2232,6 +2234,7 @@ STARTWPARMSW Statusline stdafx STDAPI +stdc stdcall stdcpp stderr diff --git a/src/common.build.pre.props b/src/common.build.pre.props index ca15b0a04..1ec821e3f 100644 --- a/src/common.build.pre.props +++ b/src/common.build.pre.props @@ -107,7 +107,7 @@ C4467: usage of ATL attributes is deprecated Conhost code still uses ATL. --> - 4103;4201;4312;4467;%(DisableSpecificWarnings) + 4103;4201;4312;4467;5105;%(DisableSpecificWarnings) _WINDOWS;EXTERNAL_BUILD;%(PreprocessorDefinitions) true precomp.h @@ -117,6 +117,7 @@ false false stdcpp17 + stdc17 /utf-8 %(AdditionalOptions) Guard Fast diff --git a/src/cppwinrt.build.pre.props b/src/cppwinrt.build.pre.props index 4587ab3ea..2022dbc7f 100644 --- a/src/cppwinrt.build.pre.props +++ b/src/cppwinrt.build.pre.props @@ -75,7 +75,7 @@ true true %(AdditionalOptions) /bigobj /Zc:twoPhase- - 5104;5105;28204;%(DisableSpecificWarnings) + 5104;28204;%(DisableSpecificWarnings) $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) diff --git a/src/host/proxy/Host.Proxy.vcxproj b/src/host/proxy/Host.Proxy.vcxproj index 45fc697f2..5888ce0c3 100644 --- a/src/host/proxy/Host.Proxy.vcxproj +++ b/src/host/proxy/Host.Proxy.vcxproj @@ -11,7 +11,7 @@ - REGISTER_PROXY_DLL;WIN32;%(PreprocessorDefinitions) NotUsing + false + false + nodefaultlib_shim.h;%(ForcedIncludeFiles) OpenConsoleProxy.def + + + true + DllMain - \ No newline at end of file + diff --git a/src/host/proxy/Host.Proxy.vcxproj.filters b/src/host/proxy/Host.Proxy.vcxproj.filters index df6bcbd10..1cdf7ca25 100644 --- a/src/host/proxy/Host.Proxy.vcxproj.filters +++ b/src/host/proxy/Host.Proxy.vcxproj.filters @@ -41,6 +41,9 @@ Header Files + + Header Files + diff --git a/src/host/proxy/nodefaultlib_shim.h b/src/host/proxy/nodefaultlib_shim.h new file mode 100644 index 000000000..09c0ad53c --- /dev/null +++ b/src/host/proxy/nodefaultlib_shim.h @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +#include + +#if !defined(_M_IX86) && !defined(_M_X64) + +// ARM64 doesn't define a (__builtin_)memcmp function without CRT, +// but we need one to compile IID_GENERIC_CHECK_IID. +// Luckily we only ever use memcmp for IIDs. +#pragma function(memcmp) +inline int memcmp(const IID* a, const IID* b, size_t count) +{ + (void)(count); + return 1 - InlineIsEqualGUID(a, b); +} + +#endif