From 188a1ee22344f181224d38df91fa8d214b76a020 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Mon, 30 Nov 2020 10:14:57 -0800 Subject: [PATCH] Integrate fixes from dotnet/runtimelab:feature/NativeAOT (#45305) --- eng/Configurations.props | 16 ++++++------- src/coreclr/src/gc/unix/cgroup.cpp | 2 ++ src/coreclr/src/gc/unix/config.gc.h.in | 2 +- src/coreclr/src/gc/unix/configure.cmake | 26 ++++++++++++++++++++++ .../src/tools/Common/JitInterface/CorInfoImpl.cs | 14 ++++++++---- .../Common/MetadataVirtualMethodAlgorithm.cs | 3 --- .../Common/TypeSystem/Ecma/MetadataExtensions.cs | 2 +- .../TypeSystem/Interop/MethodDesc.Interop.cs | 3 +-- .../Common/src/System/Sha1ForNonSecretPurposes.cs | 4 ++++ src/libraries/Native/build-native.cmd | 2 +- .../src/System.Private.CoreLib.Shared.projitems | 4 ++-- 11 files changed, 56 insertions(+), 22 deletions(-) diff --git a/eng/Configurations.props b/eng/Configurations.props index 09814ae..7034d1d 100644 --- a/eng/Configurations.props +++ b/eng/Configurations.props @@ -87,10 +87,9 @@ <_runtimeOSVersionIndex>$(_runtimeOS.IndexOfAny(".-0123456789")) <_runtimeOSFamily Condition="'$(_runtimeOSVersionIndex)' != '-1'">$(_runtimeOS.SubString(0, $(_runtimeOSVersionIndex))) - <_buildingInOSX>$([MSBuild]::IsOSPlatform('OSX')) <_portableOS>linux <_portableOS Condition="'$(_runtimeOS)' == 'linux-musl'">linux-musl - <_portableOS Condition="$(_buildingInOSX)">osx + <_portableOS Condition="$([MSBuild]::IsOSPlatform('OSX'))">osx <_portableOS Condition="'$(_runtimeOSFamily)' == 'win' or '$(TargetOS)' == 'windows'">win <_portableOS Condition="'$(_runtimeOSFamily)' == 'FreeBSD'">freebsd <_portableOS Condition="'$(_runtimeOSFamily)' == 'illumos'">illumos @@ -123,17 +122,18 @@ <_toolRuntimeRID Condition="'$(_runtimeOS)' == 'linux-musl' and $(TargetArchitecture.StartsWith('arm')) and !$(_hostArch.StartsWith('arm'))">linux-x64 - <_toolRuntimeRID Condition="'$(_runtimeOS)' == 'browser' and '$(TargetOS)' == 'windows'">win-x64 - <_toolRuntimeRID Condition="'$(_runtimeOS)' == 'browser' and '$(TargetOS)' != 'windows' and $(_buildingInOSX)">osx-x64 - <_toolRuntimeRID Condition="'$(_runtimeOS)' == 'browser' and '$(TargetOS)' != 'windows' and !$(_buildingInOSX)">linux-x64 + <_toolRuntimeRID Condition="'$(_runtimeOS)' == 'browser'">linux-x64 + <_toolRuntimeRID Condition="'$(_runtimeOS)' == 'browser' and $([MSBuild]::IsOSPlatform('WINDOWS'))">win-x64 + <_toolRuntimeRID Condition="'$(_runtimeOS)' == 'browser' and $([MSBuild]::IsOSPlatform('OSX'))">osx-x64 - <_toolRuntimeRID Condition="'$(_runtimeOS)' == 'android' and '$(TargetOS)' == 'windows'">win-x64 - <_toolRuntimeRID Condition="'$(_runtimeOS)' == 'android' and '$(TargetOS)' != 'windows' and $(_buildingInOSX)">osx-x64 - <_toolRuntimeRID Condition="'$(_runtimeOS)' == 'android' and '$(TargetOS)' != 'windows' and !$(_buildingInOSX)">linux-x64 + <_toolRuntimeRID Condition="'$(_runtimeOS)' == 'android'">linux-x64 + <_toolRuntimeRID Condition="'$(_runtimeOS)' == 'android' and $([MSBuild]::IsOSPlatform('WINDOWS'))">win-x64 + <_toolRuntimeRID Condition="'$(_runtimeOS)' == 'android' and $([MSBuild]::IsOSPlatform('OSX'))">osx-x64 <_toolRuntimeRID Condition="'$(_runtimeOS)' == 'ios' or '$(_runtimeOS)' == 'tvos'">osx-x64 + $(_toolRuntimeRID) <_packageRID Condition="'$(PortableBuild)' == 'true'">$(_portableOS)-$(TargetArchitecture) diff --git a/src/coreclr/src/gc/unix/cgroup.cpp b/src/coreclr/src/gc/unix/cgroup.cpp index d61026f..51b308d 100644 --- a/src/coreclr/src/gc/unix/cgroup.cpp +++ b/src/coreclr/src/gc/unix/cgroup.cpp @@ -31,6 +31,8 @@ Abstract: #include #include +#include "config.gc.h" + #include "cgroup.h" #ifndef SIZE_T_MAX diff --git a/src/coreclr/src/gc/unix/config.gc.h.in b/src/coreclr/src/gc/unix/config.gc.h.in index e633193..dbcf506 100644 --- a/src/coreclr/src/gc/unix/config.gc.h.in +++ b/src/coreclr/src/gc/unix/config.gc.h.in @@ -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__ diff --git a/src/coreclr/src/gc/unix/configure.cmake b/src/coreclr/src/gc/unix/configure.cmake index 99f848c..02c4725 100644 --- a/src/coreclr/src/gc/unix/configure.cmake +++ b/src/coreclr/src/gc/unix/configure.cmake @@ -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) diff --git a/src/coreclr/src/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/src/tools/Common/JitInterface/CorInfoImpl.cs index 122987d..99ced50 100644 --- a/src/coreclr/src/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/src/tools/Common/JitInterface/CorInfoImpl.cs @@ -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); diff --git a/src/coreclr/src/tools/Common/TypeSystem/Common/MetadataVirtualMethodAlgorithm.cs b/src/coreclr/src/tools/Common/TypeSystem/Common/MetadataVirtualMethodAlgorithm.cs index cfd0a64..a14d558 100644 --- a/src/coreclr/src/tools/Common/TypeSystem/Common/MetadataVirtualMethodAlgorithm.cs +++ b/src/coreclr/src/tools/Common/TypeSystem/Common/MetadataVirtualMethodAlgorithm.cs @@ -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; diff --git a/src/coreclr/src/tools/Common/TypeSystem/Ecma/MetadataExtensions.cs b/src/coreclr/src/tools/Common/TypeSystem/Ecma/MetadataExtensions.cs index 157d774..4cbc5f3 100644 --- a/src/coreclr/src/tools/Common/TypeSystem/Ecma/MetadataExtensions.cs +++ b/src/coreclr/src/tools/Common/TypeSystem/Ecma/MetadataExtensions.cs @@ -232,7 +232,7 @@ namespace Internal.TypeSystem.Ecma flags.UnmanagedCallingConvention = MethodSignatureFlags.UnmanagedCallingConventionThisCall; break; case CallingConvention.Winapi: - flags.UnmanagedCallingConvention = MethodSignatureFlags.UnmanagedCallingConventionStdCall; + // Platform default break; } } diff --git a/src/coreclr/src/tools/Common/TypeSystem/Interop/MethodDesc.Interop.cs b/src/coreclr/src/tools/Common/TypeSystem/Interop/MethodDesc.Interop.cs index 4db5df4..dc5a996 100644 --- a/src/coreclr/src/tools/Common/TypeSystem/Interop/MethodDesc.Interop.cs +++ b/src/coreclr/src/tools/Common/TypeSystem/Interop/MethodDesc.Interop.cs @@ -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: diff --git a/src/libraries/Common/src/System/Sha1ForNonSecretPurposes.cs b/src/libraries/Common/src/System/Sha1ForNonSecretPurposes.cs index 4ea03f2..bf87f32 100644 --- a/src/libraries/Common/src/System/Sha1ForNonSecretPurposes.cs +++ b/src/libraries/Common/src/System/Sha1ForNonSecretPurposes.cs @@ -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. /// +#if ES_BUILD_STANDALONE public void Finish(byte[] output) +#else + public void Finish(Span output) +#endif { long l = _length + 8 * _pos; Append(0x80); diff --git a/src/libraries/Native/build-native.cmd b/src/libraries/Native/build-native.cmd index c0005c4..8568899 100644 --- a/src/libraries/Native/build-native.cmd +++ b/src/libraries/Native/build-native.cmd @@ -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 ) diff --git a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems index 3266f4f..5e67e04 100644 --- a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems +++ b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems @@ -954,6 +954,7 @@ + @@ -995,6 +996,7 @@ + @@ -1955,8 +1957,6 @@ - - -- 2.7.4