Skip to content
This repository was archived by the owner on Nov 1, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Documentation/prerequisites-for-building.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ sudo apt-get install cmake clang-3.9 libicu52 libunwind8
1. Install [Command Line Tools for XCode 8](https://developer.apple.com/xcode/download/) or higher.
2. Install [CMake](https://cmake.org/download/). Launch `/Applications/CMake.app/Contents/MacOS/CMake` GUI. Goto "OSX App Menu -> Tools -> Install For Command Line Use" and follow the steps. CMake < 3.6 has [a bug](https://cmake.org/Bug/view.php?id=16064) that can make `--install` fail. Do `sudo mkdir /usr/local/bin` to work around.
3. Install OpenSSL. Build tools have a dependency on OpenSSL. You can use [Homebrew](http://brew.sh/) to install it: with Homebrew installed, run `brew install openssl` followed by `ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/`, followed by `ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/`.
4. Install ICU (International Components for Unicode). It can be obtained via [Homebrew](http://brew.sh/): run `brew install icu4c` followed by `brew link --force icu4c`
2 changes: 2 additions & 0 deletions src/BuildIntegration/Microsoft.NETCore.Native.Unix.props
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ See the LICENSE file in the project root for more information.
<ItemGroup>
<AdditionalNativeLibrary Include="$(IlcPath)/sdk/libSystem.Private.CoreLib.Native.a" />
<AdditionalNativeLibrary Include="$(IlcPath)/framework/System.Native.a" />
<AdditionalNativeLibrary Include="$(IlcPath)/framework/libSystem.Globalization.Native.a" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have this inconsistency in library naming? We have System.Native.a, but libSystem.Globalization.Native.a. On CoreCLR, none of the shared libraries that are named with System.XXXX have the lib prefix, so it seems strange to have it for some of the static ones.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree we should fix the names to be consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't libXXX more adopted naming convention in the industry? Why did we name those libs as such on CoreCLR in the first place? Shall we fix libSystem.Globalization.Native.a or System.Native.a ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have made this choice a long time ago so that the shared library name matches the corresponding managed assembly. You can see the quite long discussion here: dotnet/coreclr#745

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pointer @janvorli. I'll update libSystem.Globalization.Native.a name

</ItemGroup>

<ItemGroup>
Expand All @@ -51,5 +52,6 @@ See the LICENSE file in the project root for more information.
<LinkerArg Include="-ldl" />
<LinkerArg Include="-lm" />
<LinkerArg Include="-lrt" Condition="'$(TargetOS)' != 'OSX'" />
<LinkerArg Include="-licucore" Condition="'$(TargetOS)' == 'OSX'" />
</ItemGroup>
</Project>
65 changes: 48 additions & 17 deletions src/System.Private.CoreLib/src/System.Private.CoreLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -498,11 +498,14 @@
<Compile Include="System\Runtime\InteropServices\GCHandle.cs" />
<Compile Include="System\Runtime\InteropServices\GCHandleType.cs" />
<Compile Include="System\Runtime\InteropServices\InteropExtensions.cs" />
<Compile Include="System\Runtime\InteropServices\MarshalAsAttribute.cs" />
<Compile Include="System\Runtime\InteropServices\NativeCallableAttribute.cs" />
<Compile Include="System\Runtime\InteropServices\PInvokeMarshal.cs" />
<Compile Include="System\Runtime\InteropServices\SafeBuffer.cs" />
<Compile Include="System\Runtime\InteropServices\SafeHandle.cs" />
<Compile Include="System\Runtime\InteropServices\UnmanagedFunctionPointerAttribute.cs" />
<Compile Include="System\Runtime\InteropServices\UnmanagedType.cs" />
<Compile Include="System\Runtime\InteropServices\VarEnum.cs" />
<Compile Include="System\Runtime\InteropServices\WindowsRuntime\EventRegistrationToken.cs" />
<Compile Include="System\Runtime\Versioning\NonVersionableAttribute.cs" />
<Compile Include="System\Runtime\Versioning\TargetFrameworkAttribute.cs" />
Expand Down Expand Up @@ -932,20 +935,33 @@
<Link>Interop\Windows\mincore\Interop.QueryUnbiasedInterruptTime.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup Condition="'$(TargetsUnix)'=='true'">
<Compile Include="Microsoft\Win32\SafeHandles\SafeFileHandle.Unix.cs" />
<Compile Include="System\TimeZoneInfo.Unix.cs" />
<!--
<!-- Dummy globalization implementation -->
<ItemGroup Condition="'$(TargetsUnix)' == 'true' And '$(EnableDummyGlobalizationImplementation)' == 'true'">
<Compile Include="System\Globalization\HijriCalendar.Dummy.cs" />
<Compile Include="System\Globalization\JapaneseCalendar.Dummy.cs" />
<Compile Include="System\Globalization\CultureInfo.Dummy.cs" />
<Compile Include="System\Globalization\CompareInfo.Dummy.cs" />
<Compile Include="System\Globalization\CultureData.Dummy.cs" />
<Compile Include="System\Globalization\TextInfo.Dummy.cs" />
<Compile Include="System\Globalization\CalendarData.Dummy.cs" />
<Compile Include="System\Globalization\IdnMapping.Dummy.cs" />
<Compile Include="System\Text\Normalization.Dummy.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsUnix)' == 'true' And '$(EnableDummyGlobalizationImplementation)' != 'true'">
<Compile Include="System\Globalization\HijriCalendar.Unix.cs" />
<Compile Include="System\Globalization\JapaneseCalendar.Unix.cs" />
<Compile Include="System\Globalization\CultureInfo.Unix.cs" />
<Compile Include="System\Globalization\CompareInfo.Unix.cs" />
<Compile Include="System\Globalization\CultureData.Unix.cs" />
<Compile Include="System\Globalization\LocaleData.Unix.cs" />
<Compile Include="System\Globalization\TextInfo.Unix.cs" />
<Compile Include="System\Globalization\CalendarData.Unix.cs" />
<Compile Include="System\Globalization\IdnMapping.Unix.cs" />
<Compile Include="System\Text\Normalization.Unix.cs" />
-->
</ItemGroup>
<ItemGroup Condition="'$(TargetsUnix)'=='true'">
<Compile Include="Microsoft\Win32\SafeHandles\SafeFileHandle.Unix.cs" />
<Compile Include="System\TimeZoneInfo.Unix.cs" />
<Compile Include="System\DateTime.Unix.cs" />
<Compile Include="System\Globalization\FormatProvider.FormatAndParse.Unix.cs" />
<Compile Include="System\Environment.Unix.cs" />
Expand Down Expand Up @@ -1048,18 +1064,33 @@
<Compile Include="..\..\Common\src\Interop\Unix\System.Native\Interop.Write.cs">
<Link>Interop\Unix\System.Native\Interop.Write.cs</Link>
</Compile>
</ItemGroup>
<!-- Dummy globalization implementation -->
<ItemGroup Condition="'$(TargetsUnix)'=='true'">
<Compile Include="System\Globalization\HijriCalendar.Dummy.cs" />
<Compile Include="System\Globalization\JapaneseCalendar.Dummy.cs" />
<Compile Include="System\Globalization\CultureInfo.Dummy.cs" />
<Compile Include="System\Globalization\CompareInfo.Dummy.cs" />
<Compile Include="System\Globalization\CultureData.Dummy.cs" />
<Compile Include="System\Globalization\TextInfo.Dummy.cs" />
<Compile Include="System\Globalization\CalendarData.Dummy.cs" />
<Compile Include="System\Globalization\IdnMapping.Dummy.cs" />
<Compile Include="System\Text\Normalization.Dummy.cs" />
<Compile Include="..\..\Common\src\Interop\Unix\System.Globalization.Native\Interop.Calendar.cs">
<Link>Interop\Unix\System.Globalization.Native\Interop.Calendar.cs</Link>
</Compile>
<Compile Include="..\..\Common\src\Interop\Unix\System.Globalization.Native\Interop.Casing.cs">
<Link>Interop\Unix\System.Globalization.Native\Interop.Casing.cs</Link>
</Compile>
<Compile Include="..\..\Common\src\Interop\Unix\System.Globalization.Native\Interop.Collation.cs">
<Link>Interop\Unix\System.Globalization.Native\Interop.Collation.cs</Link>
</Compile>
<Compile Include="..\..\Common\src\Interop\Unix\System.Globalization.Native\Interop.Idna.cs">
<Link>Interop\Unix\System.Globalization.Native\Interop.Idna.cs</Link>
</Compile>
<Compile Include="..\..\Common\src\Interop\Unix\System.Globalization.Native\Interop.Locale.cs">
<Link>Interop\Unix\System.Globalization.Native\Interop.Locale.cs</Link>
</Compile>
<Compile Include="..\..\Common\src\Interop\Unix\System.Globalization.Native\Interop.Normalization.cs">
<Link>Interop\Unix\System.Globalization.Native\Interop.Normalization.cs</Link>
</Compile>
<Compile Include="..\..\Common\src\Interop\Unix\System.Globalization.Native\Interop.ResultCode.cs">
<Link>Interop\Unix\System.Globalization.Native\Interop.ResultCode.cs</Link>
</Compile>
<Compile Include="..\..\Common\src\Interop\Unix\System.Globalization.Native\Interop.TimeZoneInfo.cs">
<Link>Interop\Unix\System.Globalization.Native\Interop.TimeZoneInfo.cs</Link>
</Compile>
<Compile Include="..\..\Common\src\Interop\Unix\System.Globalization.Native\Interop.Utils.cs">
<Link>Interop\Unix\System.Globalization.Native\Interop.Utils.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\Common\src\System\Collections\Generic\LowLevelList.cs">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,12 @@ private unsafe int IndexOfCore(string source, string target, int startIndex, int
{
return IndexOfOrdinal(source, target, startIndex, count, ignoreCase: false);
}

#if CORECLR
if (_isAsciiEqualityOrdinal && CanUseAsciiOrdinalForOptions(options) && source.IsFastSort() && target.IsFastSort())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why removed this code? my understanding this can still work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we should keep the exact code we have in coreclr under \mscorlib\corefx\System\Globalization. right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have limitation in corert for keeping such code?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The IsFastSort, etc. bits are not cached in object pre-header in CoreRT. I agree we should keep the CoreCLR specific code under #if CORECLR so that we can share the sources.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do.

{
return IndexOf(source, target, startIndex, count, GetOrdinalCompareOptions(options));
}

#endif
fixed (char* pSource = source)
{
int index = Interop.GlobalizationInterop.IndexOf(_sortHandle, target, target.Length, pSource + startIndex, count, options);
Expand All @@ -204,10 +204,12 @@ private unsafe int LastIndexOfCore(string source, string target, int startIndex,
return LastIndexOfOrdinal(source, target, startIndex, count, ignoreCase: false);
}

#if CORECLR
if (_isAsciiEqualityOrdinal && CanUseAsciiOrdinalForOptions(options) && source.IsFastSort() && target.IsFastSort())
{
return LastIndexOf(source, target, startIndex, count, GetOrdinalCompareOptions(options));
}
#endif

// startIndex is the index into source where we start search backwards from. leftStartIndex is the index into source
// of the start of the string that is count characters away from startIndex.
Expand All @@ -227,10 +229,12 @@ private bool StartsWith(string source, string prefix, CompareOptions options)
Debug.Assert(!string.IsNullOrEmpty(prefix));
Debug.Assert((options & (CompareOptions.Ordinal | CompareOptions.OrdinalIgnoreCase)) == 0);

#if CORECLR
if (_isAsciiEqualityOrdinal && CanUseAsciiOrdinalForOptions(options) && source.IsFastSort() && prefix.IsFastSort())
{
return IsPrefix(source, prefix, GetOrdinalCompareOptions(options));
}
#endif

return Interop.GlobalizationInterop.StartsWith(_sortHandle, prefix, prefix.Length, source, source.Length, options);
}
Expand All @@ -241,10 +245,12 @@ private bool EndsWith(string source, string suffix, CompareOptions options)
Debug.Assert(!string.IsNullOrEmpty(suffix));
Debug.Assert((options & (CompareOptions.Ordinal | CompareOptions.OrdinalIgnoreCase)) == 0);

#if CORECLR
if (_isAsciiEqualityOrdinal && CanUseAsciiOrdinalForOptions(options) && source.IsFastSort() && suffix.IsFastSort())
{
return IsSuffix(source, suffix, GetOrdinalCompareOptions(options));
}
#endif

return Interop.GlobalizationInterop.EndsWith(_sortHandle, suffix, suffix.Length, source, source.Length, options);
}
Expand All @@ -256,13 +262,13 @@ private unsafe SortKey CreateSortKey(String source, CompareOptions options)

if ((options & ValidSortkeyCtorMaskOffFlags) != 0)
{
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidFlag"), nameof(options));
throw new ArgumentException(SR.Argument_InvalidFlag, nameof(options));
}

byte [] keyData;
if (source.Length == 0)
{
keyData = EmptyArray<Byte>.Value;
keyData = Array.Empty<Byte>();
}
else
{
Expand Down Expand Up @@ -348,9 +354,35 @@ internal unsafe int GetHashCodeOfStringCore(string source, CompareOptions option
}
}

[DllImport(JitHelpers.QCall)]
[SuppressUnmanagedCodeSecurity]
private static unsafe extern int InternalHashSortKey(byte* sortKey, int sortKeyLength, [MarshalAs(UnmanagedType.Bool)] bool forceRandomizedHashing, long additionalEntropy);
private static unsafe int InternalHashSortKey(byte* sortKey, int sortKeyLength, bool forceRandomizedHashing, long additionalEntropy)
{
if (forceRandomizedHashing || additionalEntropy != 0)
{
// TODO: Random hashing is yet to be done
// Active Issue: https://github.com/dotnet/corert/issues/2588
throw new NotImplementedException();
}
else
{
int hash1 = 5381;
int hash2 = hash1;
if (sortKeyLength == 0)
{
return 0;
}
if (sortKeyLength == 1)
{
return (((hash1 << 5) + hash1) ^ sortKey[0]) + (hash2 * 1566083941);
}

for (int i = 0; i < (sortKeyLength & ~1); i += 2)
{
hash1 = ((hash1 << 5) + hash1) ^ sortKey[i];
hash2 = ((hash2 << 5) + hash2) ^ sortKey[i+1];
}
return hash1 + (hash2 * 1566083941);
}
}

private static CompareOptions GetOrdinalCompareOptions(CompareOptions options)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public partial class CompareInfo
// The interesting part is that since haw-US doesn't have its own sort, it has to point at another
// locale, which is what SCOMPAREINFO does.

private readonly String _name; // The name used to construct this CompareInfo
private readonly String _sortName; // The name that defines our behavior
private String _name; // The name used to construct this CompareInfo
private String _sortName; // The name that defines our behavior

private SortVersion _sortVersion;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal static CultureInfo GetUserDefaultCulture()
if (CultureData.GetDefaultLocaleName(out localeName))
{
cultureInfo = GetCultureByName(localeName, true);
cultureInfo.m_isReadOnly = true;
cultureInfo._isReadOnly = true;
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ private unsafe string ChangeCase(string s, bool toUpper)
{
fixed (char* pResult = result)
{
#if CORECLR
if (IsAsciiCasingSameAsInvariant && s.IsAscii())
{
int length = s.Length;
Expand All @@ -69,6 +70,7 @@ private unsafe string ChangeCase(string s, bool toUpper)
}
}
else
#endif
{
ChangeCase(pSource, s.Length, pResult, result.Length, toUpper);
}
Expand Down
3 changes: 0 additions & 3 deletions src/System.Private.Interop/src/System.Private.Interop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@
<Compile Include="System\Runtime\InteropServices\Marshal.cs" />
<Compile Include="System\Runtime\InteropServices\MarshalAdapter.cs" />
<Compile Include="System\Runtime\InteropServices\MarshalImpl.cs" />
<Compile Include="System\Runtime\InteropServices\MarshalAsAttribute.cs" />
<Compile Include="System\Runtime\InteropServices\MarshalDirectiveException.cs" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add forwarders for these from System.Private.Interop to System.Private.CoreLib so that the existing ProjectN corefx drop does not break?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do.

<Compile Include="System\Runtime\InteropServices\MissingInteropDataException.cs" />
<Compile Include="System\Runtime\InteropServices\OptionalAttribute.cs" />
Expand All @@ -153,9 +152,7 @@
<Compile Include="System\Runtime\InteropServices\SafeArrayTypeMismatchException.cs" />
<Compile Include="System\Runtime\InteropServices\SEHException.cs" />
<Compile Include="System\Runtime\InteropServices\TypeIdentifierAttribute.cs" />
<Compile Include="System\Runtime\InteropServices\UnmanagedType.cs" />
<Compile Include="System\Runtime\InteropServices\UnknownWrapper.cs" />
<Compile Include="System\Runtime\InteropServices\VarEnum.cs" />
<Compile Include="System\Runtime\InteropServices\Variant.cs" />
<Compile Include="System\Runtime\InteropServices\VariantWrapper.cs" />
<Compile Include="System\Runtime\InteropServices\ComWeakReferenceHelpers.cs" />
Expand Down
3 changes: 3 additions & 0 deletions src/System.Private.Interop/src/TypeForwarders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
// See the LICENSE file in the project root for more information.

[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.InteropServices.SafeBuffer))]
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.InteropServices.MarshalAsAttribute))]
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.InteropServices.UnmanagedType))]
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.InteropServices.VarEnum))]
3 changes: 2 additions & 1 deletion src/packaging/netcoreapp/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"System.Linq": "4.4.0-beta-24913-02",
"System.Runtime.CompilerServices.Unsafe": "4.4.0-beta-24913-02",

"runtime.native.System": "4.4.0-beta-24913-02"
"runtime.native.System": "4.4.0-beta-24913-02",
"Microsoft.NETCore.Native": "1.2.0-beta-24911-02"
}
}
},
Expand Down
3 changes: 3 additions & 0 deletions src/packaging/packages.targets
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

<JitPackageVersion>1.2.0-beta-24911-02</JitPackageVersion>

<MicrosoftNetCoreNativePackageVersion>1.2.0-beta-24911-02</MicrosoftNetCoreNativePackageVersion>

<ObjectWriterPackageVersion>1.0.13-prerelease-00001</ObjectWriterPackageVersion>
<ObjectWriterNuPkgRid Condition="'$(OSGroup)'=='Linux'">ubuntu.14.04-x64</ObjectWriterNuPkgRid>
<ObjectWriterNuPkgRid Condition="'$(ObjectWriterNuPkgRid)'==''">$(NuPkgRid)</ObjectWriterNuPkgRid>
Expand Down Expand Up @@ -172,6 +174,7 @@
<ILCompilerFrameworkFiles Include="System.Runtime.CompilerServices.Unsafe/$(CoreFxPackageVersion)/lib/netstandard1.0/System.Runtime.CompilerServices.Unsafe.dll" />

<ILCompilerFrameworkFiles Include="runtime.$(NuPkgRid).runtime.native.System/$(CoreFxPackageVersion)/runtimes/$(NuPkgRid)/native/System.Native.a" Condition="'$(OsEnvironment)'!='Windows_NT'" />
<ILCompilerFrameworkFiles Include="runtime.$(NuPkgRid).Microsoft.NETCore.Native/$(MicrosoftNetCoreNativePackageVersion)/runtimes/$(NuPkgRid)/native/libSystem.Globalization.Native.a" Condition="'$(OsEnvironment)'!='Windows_NT'" />

<ILCompilerSdkBinPlace Include="@(ILCompilerFrameworkFiles)">
<Text><![CDATA[ <file src="packages/%(Identity)" target="runtimes/$(NuPkgRid)/native/framework/%(Filename)%(Extension)" /> ]]></Text>
Expand Down