Integrate fixes from dotnet/runtimelab:feature/NativeAOT (#45305)
authorJan Kotas <jkotas@microsoft.com>
Mon, 30 Nov 2020 18:14:57 +0000 (10:14 -0800)
committerGitHub <noreply@github.com>
Mon, 30 Nov 2020 18:14:57 +0000 (10:14 -0800)
eng/Configurations.props
src/coreclr/src/gc/unix/cgroup.cpp
src/coreclr/src/gc/unix/config.gc.h.in
src/coreclr/src/gc/unix/configure.cmake
src/coreclr/src/tools/Common/JitInterface/CorInfoImpl.cs
src/coreclr/src/tools/Common/TypeSystem/Common/MetadataVirtualMethodAlgorithm.cs
src/coreclr/src/tools/Common/TypeSystem/Ecma/MetadataExtensions.cs
src/coreclr/src/tools/Common/TypeSystem/Interop/MethodDesc.Interop.cs
src/libraries/Common/src/System/Sha1ForNonSecretPurposes.cs
src/libraries/Native/build-native.cmd
src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems

index 09814ae..7034d1d 100644 (file)
     <_runtimeOSVersionIndex>$(_runtimeOS.IndexOfAny(".-0123456789"))</_runtimeOSVersionIndex>
     <_runtimeOSFamily Condition="'$(_runtimeOSVersionIndex)' != '-1'">$(_runtimeOS.SubString(0, $(_runtimeOSVersionIndex)))</_runtimeOSFamily>
 
-    <_buildingInOSX>$([MSBuild]::IsOSPlatform('OSX'))</_buildingInOSX>
     <_portableOS>linux</_portableOS>
     <_portableOS Condition="'$(_runtimeOS)' == 'linux-musl'">linux-musl</_portableOS>
-    <_portableOS Condition="$(_buildingInOSX)">osx</_portableOS>
+    <_portableOS Condition="$([MSBuild]::IsOSPlatform('OSX'))">osx</_portableOS>
     <_portableOS Condition="'$(_runtimeOSFamily)' == 'win' or '$(TargetOS)' == 'windows'">win</_portableOS>
     <_portableOS Condition="'$(_runtimeOSFamily)' == 'FreeBSD'">freebsd</_portableOS>
     <_portableOS Condition="'$(_runtimeOSFamily)' == 'illumos'">illumos</_portableOS>
     <_toolRuntimeRID Condition="'$(_runtimeOS)' == 'linux-musl' and $(TargetArchitecture.StartsWith('arm')) and !$(_hostArch.StartsWith('arm'))">linux-x64</_toolRuntimeRID>
 
     <!-- There are no WebAssembly tools, so use the default ones -->
-    <_toolRuntimeRID Condition="'$(_runtimeOS)' == 'browser' and '$(TargetOS)' == 'windows'">win-x64</_toolRuntimeRID>
-    <_toolRuntimeRID Condition="'$(_runtimeOS)' == 'browser' and '$(TargetOS)' != 'windows' and $(_buildingInOSX)">osx-x64</_toolRuntimeRID>
-    <_toolRuntimeRID Condition="'$(_runtimeOS)' == 'browser' and '$(TargetOS)' != 'windows' and !$(_buildingInOSX)">linux-x64</_toolRuntimeRID>
+    <_toolRuntimeRID Condition="'$(_runtimeOS)' == 'browser'">linux-x64</_toolRuntimeRID>
+    <_toolRuntimeRID Condition="'$(_runtimeOS)' == 'browser' and $([MSBuild]::IsOSPlatform('WINDOWS'))">win-x64</_toolRuntimeRID>
+    <_toolRuntimeRID Condition="'$(_runtimeOS)' == 'browser' and $([MSBuild]::IsOSPlatform('OSX'))">osx-x64</_toolRuntimeRID>
 
     <!-- There are no Android tools, so use the default ones -->
-    <_toolRuntimeRID Condition="'$(_runtimeOS)' == 'android' and '$(TargetOS)' == 'windows'">win-x64</_toolRuntimeRID>
-    <_toolRuntimeRID Condition="'$(_runtimeOS)' == 'android' and '$(TargetOS)' != 'windows' and $(_buildingInOSX)">osx-x64</_toolRuntimeRID>
-    <_toolRuntimeRID Condition="'$(_runtimeOS)' == 'android' and '$(TargetOS)' != 'windows' and !$(_buildingInOSX)">linux-x64</_toolRuntimeRID>
+    <_toolRuntimeRID Condition="'$(_runtimeOS)' == 'android'">linux-x64</_toolRuntimeRID>
+    <_toolRuntimeRID Condition="'$(_runtimeOS)' == 'android' and $([MSBuild]::IsOSPlatform('WINDOWS'))">win-x64</_toolRuntimeRID>
+    <_toolRuntimeRID Condition="'$(_runtimeOS)' == 'android' and $([MSBuild]::IsOSPlatform('OSX'))">osx-x64</_toolRuntimeRID>
 
     <!-- There are no iOS or tvOS tools and it can be built on OSX only, so use that -->
     <_toolRuntimeRID Condition="'$(_runtimeOS)' == 'ios' or '$(_runtimeOS)' == 'tvos'">osx-x64</_toolRuntimeRID>
+
     <MicrosoftNetCoreIlasmPackageRuntimeId>$(_toolRuntimeRID)</MicrosoftNetCoreIlasmPackageRuntimeId>
 
     <_packageRID Condition="'$(PortableBuild)' == 'true'">$(_portableOS)-$(TargetArchitecture)</_packageRID>
index d61026f..51b308d 100644 (file)
@@ -31,6 +31,8 @@ Abstract:
 #include <errno.h>
 #include <limits>
 
+#include "config.gc.h"
+
 #include "cgroup.h"
 
 #ifndef SIZE_T_MAX
index e633193..dbcf506 100644 (file)
@@ -30,6 +30,6 @@
 #cmakedefine01 HAVE_SYSINFO_WITH_MEM_UNIT
 #cmakedefine01 HAVE_XSW_USAGE
 #cmakedefine01 HAVE_XSWDEV
-
+#cmakedefine01 HAVE_NON_LEGACY_STATFS
 
 #endif // __CONFIG_H__
index 99f848c..02c4725 100644 (file)
@@ -119,4 +119,30 @@ int main(int argc, char **argv)
     return 0;
 }" HAVE_XSW_USAGE)
 
+check_struct_has_member(
+    "struct statfs"
+    f_fstypename
+    "sys/mount.h"
+    HAVE_STATFS_FSTYPENAME)
+
+check_struct_has_member(
+    "struct statvfs"
+    f_fstypename
+    "sys/mount.h"
+    HAVE_STATVFS_FSTYPENAME)
+
+# statfs: Find whether this struct exists
+if (HAVE_STATFS_FSTYPENAME OR HAVE_STATVFS_FSTYPENAME)
+    set (STATFS_INCLUDES sys/mount.h)
+else ()
+    set (STATFS_INCLUDES sys/statfs.h)
+endif ()
+
+check_prototype_definition(
+    statfs
+    "int statfs(const char *path, struct statfs *buf)"
+    0
+    ${STATFS_INCLUDES}
+    HAVE_NON_LEGACY_STATFS)
+
 configure_file(${CMAKE_CURRENT_LIST_DIR}/config.gc.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.gc.h)
index 122987d..99ced50 100644 (file)
@@ -588,10 +588,7 @@ namespace Internal.JitInterface
                 }
                 else
                 {
-                    // Use platform default
-                    sig->callConv = _compilation.TypeSystemContext.Target.IsWindows
-                        ? CorInfoCallConv.CORINFO_CALLCONV_STDCALL
-                        : CorInfoCallConv.CORINFO_CALLCONV_C;
+                    sig->callConv = (CorInfoCallConv)PlatformDefaultUnmanagedCallingConvention();
                 }
             }
 
@@ -1043,10 +1040,19 @@ namespace Internal.JitInterface
             return type.IsIntrinsic;
         }
 
+        private MethodSignatureFlags PlatformDefaultUnmanagedCallingConvention()
+        {
+            return _compilation.TypeSystemContext.Target.IsWindows ?
+                MethodSignatureFlags.UnmanagedCallingConventionStdCall : MethodSignatureFlags.UnmanagedCallingConventionCdecl;
+        }
+
         private CorInfoUnmanagedCallConv getUnmanagedCallConv(CORINFO_METHOD_STRUCT_* method)
         {
             MethodSignatureFlags unmanagedCallConv = HandleToObject(method).GetPInvokeMethodMetadata().Flags.UnmanagedCallingConvention;
 
+            if (unmanagedCallConv == MethodSignatureFlags.None)
+                unmanagedCallConv = PlatformDefaultUnmanagedCallingConvention();
+
             // Verify that it is safe to convert MethodSignatureFlags.UnmanagedCallingConvention to CorInfoUnmanagedCallConv via a simple cast
             Debug.Assert((int)CorInfoUnmanagedCallConv.CORINFO_UNMANAGED_CALLCONV_C == (int)MethodSignatureFlags.UnmanagedCallingConventionCdecl);
             Debug.Assert((int)CorInfoUnmanagedCallConv.CORINFO_UNMANAGED_CALLCONV_STDCALL == (int)MethodSignatureFlags.UnmanagedCallingConventionStdCall);
index cfd0a64..a14d558 100644 (file)
@@ -586,9 +586,6 @@ namespace Internal.TypeSystem
         //    See current interface call resolution for details on how that happens.
         private static MethodDesc ResolveInterfaceMethodToVirtualMethodOnType(MethodDesc interfaceMethod, MetadataType currentType)
         {
-            if (currentType.IsInterface)
-                return null;
-
             MethodDesc methodImpl = FindImplFromDeclFromMethodImpls(currentType, interfaceMethod);
             if (methodImpl != null)
                 return methodImpl;
index 157d774..4cbc5f3 100644 (file)
@@ -232,7 +232,7 @@ namespace Internal.TypeSystem.Ecma
                         flags.UnmanagedCallingConvention = MethodSignatureFlags.UnmanagedCallingConventionThisCall;
                         break;
                     case CallingConvention.Winapi:
-                        flags.UnmanagedCallingConvention = MethodSignatureFlags.UnmanagedCallingConventionStdCall;
+                        // Platform default
                         break;
                 }
             }
index 4db5df4..dc5a996 100644 (file)
@@ -158,14 +158,13 @@ namespace Internal.TypeSystem
             {
                 switch (_attributes & PInvokeAttributes.CallingConventionMask)
                 {
-                    case PInvokeAttributes.CallingConventionWinApi:
-                        return MethodSignatureFlags.UnmanagedCallingConventionStdCall; // TODO: CDecl for varargs
                     case PInvokeAttributes.CallingConventionCDecl:
                         return MethodSignatureFlags.UnmanagedCallingConventionCdecl;
                     case PInvokeAttributes.CallingConventionStdCall:
                         return MethodSignatureFlags.UnmanagedCallingConventionStdCall;
                     case PInvokeAttributes.CallingConventionThisCall:
                         return MethodSignatureFlags.UnmanagedCallingConventionThisCall;
+                    case PInvokeAttributes.CallingConventionWinApi: // Platform default
                     case PInvokeAttributes.None:
                         return MethodSignatureFlags.None;
                     default:
index 4ea03f2..bf87f32 100644 (file)
@@ -79,7 +79,11 @@ namespace System
         /// bytes will be lost. If the buffer is larger than 20 bytes, the
         /// rest of the buffer is left unmodified.
         /// </param>
+#if ES_BUILD_STANDALONE
         public void Finish(byte[] output)
+#else
+        public void Finish(Span<byte> output)
+#endif
         {
             long l = _length + 8 * _pos;
             Append(0x80);
index c0005c4..8568899 100644 (file)
@@ -158,7 +158,7 @@ set __generatorArgs=
 if [%__Ninja%] == [1] (
     set __generatorArgs=
 ) else if [%__BuildArch%] == [wasm] (
-    set __generatorArgs=-j
+    set __generatorArgs=
 ) else (
     set __generatorArgs=/p:Platform=%__BuildArch% /p:PlatformToolset="%__PlatformToolset%" -noWarn:MSB8065
 )
index 3266f4f..5e67e04 100644 (file)
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\LazyThreadSafetyMode.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\LockRecursionException.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\LowLevelLock.cs" Condition="'$(FeatureSharedLowLevelLock)' == 'true'" />
+    <Compile Include="$(MSBuildThisFileDirectory)System\Threading\LowLevelSpinWaiter.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\LowLevelMonitor.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\ManualResetEvent.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\ManualResetEventSlim.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\Thread.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\ThreadAbortException.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\ThreadExceptionEventArgs.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)System\Threading\ThreadInt64PersistentCounter.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\ThreadInterruptedException.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\ThreadLocal.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\ThreadPool.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\PortableThreadPool.CpuUtilizationReader.Windows.cs" Condition="'$(TargetsWindows)' == 'true'" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\LowLevelLifoSemaphore.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\LowLevelLifoSemaphore.Windows.cs" Condition="'$(TargetsWindows)' == 'true'" />
-    <Compile Include="$(MSBuildThisFileDirectory)System\Threading\LowLevelSpinWaiter.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\RegisteredWaitHandle.Portable.cs" />
-    <Compile Include="$(MSBuildThisFileDirectory)System\Threading\ThreadInt64PersistentCounter.cs" />
   </ItemGroup>
 </Project>