From ea77bdf8697ea78b177a4e68b661af93da07d494 Mon Sep 17 00:00:00 2001 From: Bill Holmes Date: Fri, 10 Sep 2021 09:50:55 -0400 Subject: [PATCH] Enable COM in classlibs for win32 The runtime for Windows still has valid implementations for COM calls. In the case of this bug IsComOjbect needs to behave correctly. The intention of this PR is to set DISABLE_COM for only mac and linux for unity jit and unity apt profiles. fixes case 1358705 --- mcs/build/profiles/unityaot.make | 11 +++++++++-- mcs/build/profiles/unityjit.make | 4 +++- .../corlib/System.Runtime.InteropServices/Marshal.cs | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/mcs/build/profiles/unityaot.make b/mcs/build/profiles/unityaot.make index 779c260ad8ca..060115d09cac 100644 --- a/mcs/build/profiles/unityaot.make +++ b/mcs/build/profiles/unityaot.make @@ -31,7 +31,6 @@ PROFILE_MCS_FLAGS = \ -d:UNITY \ -d:UNITY_AOT \ -d:MOBILE,MOBILE_LEGACY \ - -d:DISABLE_COM \ -d:FULL_AOT_DESKTOP \ -d:FULL_AOT_RUNTIME \ $(PLATFORM_FLAGS) \ @@ -46,4 +45,12 @@ NO_INSTALL = yes AOT_FRIENDLY_PROFILE = yes ALWAYS_AOT_BCL = yes MOBILE_PROFILE = yes -NO_SRE = yes \ No newline at end of file +NO_SRE = yes + +ifeq ($(HOST_PLATFORM),macos) +PROFILE_MCS_FLAGS += -d:DISABLE_COM +endif + +ifeq ($(HOST_PLATFORM),linux) +PROFILE_MCS_FLAGS += -d:DISABLE_COM +endif diff --git a/mcs/build/profiles/unityjit.make b/mcs/build/profiles/unityjit.make index 5133e933e1be..94495c6d708b 100644 --- a/mcs/build/profiles/unityjit.make +++ b/mcs/build/profiles/unityjit.make @@ -11,7 +11,7 @@ profile-check: @: DEFAULT_REFERENCES = mscorlib -PROFILE_MCS_FLAGS = -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:UNITY_JIT -d:UNITY -d:WIN_PLATFORM -d:DISABLE_COM -nowarn:1699 -nostdlib $(PLATFORM_DEBUG_FLAGS) +PROFILE_MCS_FLAGS = -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:UNITY_JIT -d:UNITY -d:WIN_PLATFORM -nowarn:1699 -nostdlib $(PLATFORM_DEBUG_FLAGS) API_BIN_PROFILE = v4.7.1 FRAMEWORK_VERSION = 4.5 @@ -20,8 +20,10 @@ XBUILD_VERSION = 4.0 ifeq ($(HOST_PLATFORM),macos) MONO_FEATURE_APPLETLS=1 ENABLE_GSS=1 +PROFILE_MCS_FLAGS += -d:DISABLE_COM endif ifeq ($(HOST_PLATFORM),linux) ENABLE_GSS=1 +PROFILE_MCS_FLAGS += -d:DISABLE_COM endif diff --git a/mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs b/mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs index 4e1a4982dcf4..29d55eeb5530 100644 --- a/mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs +++ b/mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs @@ -856,7 +856,7 @@ public static object GetUniqueObjectForIUnknown (IntPtr unknown) throw new PlatformNotSupportedException (); } -#if (!MOBILE && !UNITY) || UNITY_AOT +#if (!MOBILE && !DISABLE_COM) || (UNITY_AOT && !DISABLE_COM) [MethodImplAttribute (MethodImplOptions.InternalCall)] public extern static bool IsComObject (object o); #else