未验证 提交 b0f0868d 编写于 作者: S Sven Boemer 提交者: GitHub

Fix platform-specific substitutions (#53179)

* These feature switches are dead code on non-windows. They were causing
linker warnings because the substitutions weren't being resolved.

See https://github.com/dotnet/sdk/pull/17676

* Fix condition

Check OS, not Platform. Use the same pattern as we do for other
Windows-specific XMLs.
上级 3bd75ba9
......@@ -24,6 +24,7 @@
<ItemGroup>
<ILLinkSubstitutionsXmls Include="$(ILLinkDirectory)ILLink.Substitutions.xml" />
<ILLinkSubstitutionsXmls Condition="'$(TargetsWindows)' == 'true'" Include="$(ILLinkDirectory)ILLink.Substitutions.Windows.xml" />
</ItemGroup>
<!-- Note that various places in SPCL depend on this resource name i.e. TplEventSource -->
......
<linker>
<assembly fullname="System.Private.CoreLib">
<type fullname="Internal.Runtime.InteropServices.InMemoryAssemblyLoader" feature="System.Runtime.InteropServices.EnableCppCLIHostActivation" featurevalue="false">
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" />
</type>
<type fullname="System.Runtime.InteropServices.Marshal" feature="System.Runtime.InteropServices.BuiltInComInterop.IsSupported" featurevalue="false">
<method signature="System.Boolean get_IsBuiltInComSupported()" body="stub" value="false" />
</type>
</assembly>
</linker>
......@@ -6,11 +6,5 @@
<type fullname="Internal.Runtime.InteropServices.ComponentActivator" feature="System.Runtime.InteropServices.EnableConsumingManagedCodeFromNativeHosting" featurevalue="false">
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" />
</type>
<type fullname="Internal.Runtime.InteropServices.InMemoryAssemblyLoader" feature="System.Runtime.InteropServices.EnableCppCLIHostActivation" featurevalue="false">
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" />
</type>
<type fullname="System.Runtime.InteropServices.Marshal" feature="System.Runtime.InteropServices.BuiltInComInterop.IsSupported" featurevalue="false">
<method signature="System.Boolean get_IsBuiltInComSupported()" body="stub" value="false" />
</type>
</assembly>
</linker>
......@@ -12,9 +12,11 @@ namespace Internal.Runtime.InteropServices
/// </summary>
public static class InMemoryAssemblyLoader
{
#if TARGET_WINDOWS
private static bool IsSupported { get; } = InitializeIsSupported();
private static bool InitializeIsSupported() => AppContext.TryGetSwitch("System.Runtime.InteropServices.EnableCppCLIHostActivation", out bool isSupported) ? isSupported : true;
#endif
/// <summary>
/// Loads into an isolated AssemblyLoadContext an assembly that has already been loaded into memory by the OS loader as a native module.
......
......@@ -195,9 +195,6 @@ private static void PrelinkCore(MethodInfo m)
[DllImport(RuntimeHelpers.QCall, CharSet = CharSet.Unicode)]
private static extern void InternalPrelink(RuntimeMethodHandleInternal m);
[DllImport(RuntimeHelpers.QCall)]
private static extern bool IsBuiltInComSupportedInternal();
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern /* struct _EXCEPTION_POINTERS* */ IntPtr GetExceptionPointers();
......@@ -236,9 +233,12 @@ private static object PtrToStructureHelper(IntPtr ptr, Type structureType)
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern bool IsPinnable(object? obj);
#if TARGET_WINDOWS
internal static bool IsBuiltInComSupported { get; } = IsBuiltInComSupportedInternal();
#if TARGET_WINDOWS
[DllImport(RuntimeHelpers.QCall)]
private static extern bool IsBuiltInComSupportedInternal();
/// <summary>
/// Returns the HInstance for this module. Returns -1 if the module doesn't have
/// an HInstance. In Memory (Dynamic) Modules won't have an HInstance.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册