commit:     0e595381994264d0fc5d53c1b28a3048ad0223b9
Author:     Dmitry Kalyanov <Kalyanov.Dmitry <AT> gmail <DOT> com>
AuthorDate: Sun Jul  2 15:23:53 2017 +0000
Commit:     Mikhail Pukhlikov <cynede <AT> gentoo <DOT> org>
CommitDate: Sun Jul  2 15:23:53 2017 +0000
URL:        https://gitweb.gentoo.org/proj/dotnet.git/commit/?id=0e595381

Improve ebuild for .NET Core (LLVM-4 and heimdal)

This adds support for building .NET Core with LLVM 4 (mostly backported
from https://github.com/dotnet/coreclr/pull/11226).
Also added a 'heimdal' USE flag to allow use of Heimdal implementation
of Kerberos rather than MIT-KRB5.

 dev-dotnet/dotnet-cli/dotnet-cli-1.1.1-r2.ebuild   | 218 +++++++++++++++++++++
 .../files/coreclr-1.0.6-llvm4-intsafe.patch        | 117 +++++++++++
 .../dotnet-cli/files/coreclr-1.0.6-llvm4.patch     | 176 +++++++++++++++++
 .../files/coreclr-1.1.1-builtin-redefinition.patch |  40 ++++
 .../files/coreclr-1.1.1-llvm4-intsafe.patch        | 117 +++++++++++
 .../dotnet-cli/files/coreclr-1.1.1-llvm4.patch     | 136 +++++++++++++
 .../dotnet-cli/files/corefx-1.0.4-werror.patch     |  11 ++
 .../dotnet-cli/files/corefx-1.1.1-werror.patch     |  11 ++
 8 files changed, 826 insertions(+)

diff --git a/dev-dotnet/dotnet-cli/dotnet-cli-1.1.1-r2.ebuild 
b/dev-dotnet/dotnet-cli/dotnet-cli-1.1.1-r2.ebuild
new file mode 100644
index 0000000..b94d2f1
--- /dev/null
+++ b/dev-dotnet/dotnet-cli/dotnet-cli-1.1.1-r2.ebuild
@@ -0,0 +1,218 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+#BASED ON https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=dotnet-cli
+
+EAPI="6"
+
+CORE_V1_0=1.0.3
+CLI_V1_0=1.0.0-preview2-003156
+CORECLR_V1_0=1.0.6
+COREFX_V1_0=1.0.4
+
+DIST='debian-x64'
+
+COREFX=corefx-${COREFX_V}
+
+DESCRIPTION=".NET Core cli utility for building, testing, packaging and 
running projects"
+HOMEPAGE="https://www.microsoft.com/net/core";
+LICENSE="MIT"
+
+IUSE="heimdal"
+SRC_URI="https://github.com/dotnet/coreclr/archive/v${CORECLR_V1_0}.tar.gz -> 
coreclr-${CORECLR_V1_0}.tar.gz
+       https://github.com/dotnet/corefx/archive/v${COREFX_V1_0}.tar.gz -> 
corefx-${COREFX_V1_0}.tar.gz
+       
https://download.microsoft.com/download/0/3/0/030449F5-F093-44A6-9889-E19B50A59777/sdk/dotnet-dev-${DIST}.${CLI_V1_0}.tar.gz
+       https://github.com/dotnet/coreclr/archive/v${PV}.tar.gz -> 
coreclr-${PV}.tar.gz
+       https://github.com/dotnet/corefx/archive/v${PV}.tar.gz -> 
corefx-${PV}.tar.gz
+       
https://download.microsoft.com/download/F/D/5/FD52A2F7-65B6-4912-AEDD-4015DF6D8D22/dotnet-${PV}-sdk-${DIST}.tar.gz";
+
+SLOT="0"
+KEYWORDS="~amd64"
+
+RDEPEND="
+       >=sys-devel/llvm-4.0
+       >=dev-util/lldb-4.0
+       >=sys-libs/libunwind-1.1-r1
+       >=dev-libs/icu-57.1
+       >=dev-util/lttng-ust-2.8.1
+       >=dev-libs/openssl-1.0.2h-r2
+       >=net-misc/curl-7.49.0
+       heimdal? (
+               >=app-crypt/heimdal-1.5.3-r2
+       )
+       !heimdal? (
+               >=app-crypt/mit-krb5-1.14.2
+       )
+       >=sys-libs/zlib-1.2.8-r1 "
+DEPEND="${RDEPEND}
+       >=dev-util/cmake-3.3.1-r1
+       >=sys-devel/make-4.1-r1
+       >=sys-devel/clang-3.7.1-r100
+       >=sys-devel/gettext-0.19.7"
+
+PATCHES=(
+       "${FILESDIR}/coreclr-${CORECLR_V1_0}-gcc6-clang39.patch"
+       "${FILESDIR}/coreclr-${CORECLR_V1_0}-clang39-commit-9db7fb1.patch"
+       "${FILESDIR}/coreclr-${CORECLR_V1_0}-icu57-commit-352df35.patch"
+       "${FILESDIR}/coreclr-${CORECLR_V1_0}-llvm4.patch"
+       "${FILESDIR}/coreclr-${CORECLR_V1_0}-llvm4-intsafe.patch"
+       "${FILESDIR}/coreclr-${PV}-clang39-commit-9db7fb1.patch"
+       "${FILESDIR}/coreclr-${PV}-exceptionhandling.patch"
+       "${FILESDIR}/coreclr-${PV}-builtin-redefinition.patch"
+       "${FILESDIR}/corefx-${PV}-init-tools-script.patch"
+       "${FILESDIR}/coreclr-${PV}-llvm4.patch"
+       "${FILESDIR}/coreclr-${PV}-llvm4-intsafe.patch"
+       "${FILESDIR}/corefx-${COREFX_V1_0}-werror.patch"
+       "${FILESDIR}/corefx-${PV}-run-script.patch"
+       "${FILESDIR}/corefx-${PV}-werror.patch"
+)
+
+S=${WORKDIR}
+CLI_1_0_S="${S}/tools-dotnet"
+CORECLR_1_0_S="${S}/coreclr-${CORECLR_V1_0}"
+COREFX_1_0_S="${S}/corefx-${COREFX_V1_0}"
+CLI_S="${S}/dotnetcli-${PV}"
+CORECLR_S="${S}/coreclr-${PV}"
+COREFX_S="${S}/corefx-${PV}"
+
+CORECLR_FILES=(
+       'libclrjit.so'
+       'libcoreclr.so'
+       'libcoreclrtraceptprovider.so'
+       'libdbgshim.so'
+       'libmscordaccore.so'
+       'libmscordbi.so'
+       'libsos.so'
+       'libsosplugin.so'
+       'System.Globalization.Native.so'
+)
+
+COREFX_FILES=(
+       'System.IO.Compression.Native.so'
+       'System.Native.a'
+       'System.Native.so'
+       'System.Net.Http.Native.so'
+       'System.Net.Security.Native.so'
+)
+
+CRYPTO_V1_0_FILES=(
+       'System.Security.Cryptography.Native.so'
+)
+
+CRYPTO_FILES=(
+       'System.Security.Cryptography.Native.OpenSsl.so'
+)
+
+pkg_pretend() {
+       # If FEATURES="-sandbox -usersandbox" are not set dotnet will hang 
while compiling.
+       if has sandbox $FEATURES || has usersandbox $FEATURES ; then
+               die ".NET core command-line (CLI) tools require sandbox and 
usersandbox to be disabled in FEATURES."
+       fi
+}
+
+src_unpack() {
+       unpack "coreclr-${CORECLR_V1_0}.tar.gz" "corefx-${COREFX_V1_0}.tar.gz" 
"coreclr-${PV}.tar.gz" "corefx-${PV}.tar.gz"
+       mkdir "${CLI_1_0_S}" "${CLI_S}" || die
+       cd "${CLI_S}" || die
+       unpack "dotnet-${PV}-sdk-${DIST}.tar.gz"
+       cd "${CLI_1_0_S}" || die
+       unpack "dotnet-dev-${DIST}.${CLI_V1_0}.tar.gz"
+}
+
+src_prepare() {
+       cp "${FILESDIR}/corefx-${PV}-buildtools.patch" 
"${COREFX_S}/buildtools.patch"
+
+       for file in "${CORECLR_FILES[@]}"; do
+               rm "${CLI_S}/shared/Microsoft.NETCore.App/${PV}/${file}"
+               rm "${CLI_S}/shared/Microsoft.NETCore.App/1.0.4/${file}"
+               rm 
"${CLI_1_0_S}/shared/Microsoft.NETCore.App/${CORE_V1_0}/${file}"
+       done
+
+       for file in "${COREFX_FILES[@]}"; do
+               rm "${CLI_S}/shared/Microsoft.NETCore.App/${PV}/${file}"
+               rm "${CLI_S}/shared/Microsoft.NETCore.App/1.0.4/${file}"
+               rm 
"${CLI_1_0_S}/shared/Microsoft.NETCore.App/${CORE_V1_0}/${file}"
+       done
+
+       for file in "${CRYPTO_FILES[@]}"; do
+               rm "${CLI_S}/shared/Microsoft.NETCore.App/${PV}/${file}"
+       done
+
+       for file in "${CRYPTO_V1_0_FILES[@]}"; do
+               rm "${CLI_S}/shared/Microsoft.NETCore.App/1.0.4/${file}"
+               rm 
"${CLI_1_0_S}/shared/Microsoft.NETCore.App/${CORE_V1_0}/${file}"
+       done
+
+       default_src_prepare
+}
+
+src_compile() {
+       local buildargs=""
+
+       if use heimdal; then
+               # build uses mit-krb5 by default but lets override to heimdal
+               buildargs="${buildargs} cmakeargs -DHeimdalGssApi=ON"
+       fi
+
+       local dest="${CLI_1_0_S}/shared/Microsoft.NETCore.App/${CORE_V1_0}/"
+
+       cd "${COREFX_1_0_S}" || die
+       ./build.sh native x64 release ${buildargs} || die
+
+       for file in "${COREFX_FILES[@]}"; do
+               cp -pP "${COREFX_1_0_S}/bin/Linux.x64.Release/Native/${file}" 
"${dest}" || die
+       done
+
+       for file in "${CRYPTO_V1_0_FILES[@]}"; do
+               cp -pP "${COREFX_1_0_S}/bin/Linux.x64.Release/Native/${file}" 
"${dest}" || die
+       done
+
+       cd "${S}" || die
+       rm -rf "${COREFX_1_0_S}" || die
+
+       cd "${CORECLR_1_0_S}" || die
+       ./build.sh x64 release || die
+
+       for file in "${CORECLR_FILES[@]}"; do
+               cp -pP "${CORECLR_1_0_S}/bin/Product/Linux.x64.Release/${file}" 
"${dest}" || die
+       done
+
+       cd "${S}" || die
+       rm -rf "${CORECLR_1_0_S}" || die
+
+       cd "${COREFX_S}" || die
+       ./src/Native/build-native.sh x64 release ${buildargs} || die
+
+       cd "${CORECLR_S}" || die
+       ./build.sh x64 release || die
+}
+
+src_install() {
+       local dest="/opt/dotnet_cli"
+       local ddest="${D}/${dest}"
+       local ddest_core="${ddest}/shared/Microsoft.NETCore.App"
+
+       dodir "${dest}"
+       cp -pPR "${CLI_S}"/* "${ddest}" || die
+
+       for file in "${CORECLR_FILES[@]}"; do
+               cp -pP "${CORECLR_S}/bin/Product/Linux.x64.Release/${file}" 
"${ddest_core}/${PV}/" || die
+               cp -pP "${CORECLR_S}/bin/Product/Linux.x64.Release/${file}" 
"${ddest_core}/1.0.4/" || die
+       done
+
+       for file in "${COREFX_FILES[@]}"; do
+               cp -pP "${COREFX_S}/bin/Linux.x64.Release/Native/${file}" 
"${ddest_core}/${PV}/" || die
+               cp -pP "${COREFX_S}/bin/Linux.x64.Release/Native/${file}" 
"${ddest_core}/1.0.4/" || die
+       done
+
+       for file in "${CRYPTO_FILES[@]}"; do
+               cp -pP "${COREFX_S}/bin/Linux.x64.Release/Native/${file}" 
"${ddest_core}/${PV}/" || die
+       done
+
+       for file in "${CRYPTO_V1_0_FILES[@]}"; do
+               cp -pP "${COREFX_S}/bin/Linux.x64.Release/Native/${file}" 
"${ddest_core}/1.0.4/" || die
+       done
+
+       dosym "../../opt/dotnet_cli/dotnet" "/usr/bin/dotnet"
+}

diff --git a/dev-dotnet/dotnet-cli/files/coreclr-1.0.6-llvm4-intsafe.patch 
b/dev-dotnet/dotnet-cli/files/coreclr-1.0.6-llvm4-intsafe.patch
new file mode 100644
index 0000000..2684bbb
--- /dev/null
+++ b/dev-dotnet/dotnet-cli/files/coreclr-1.0.6-llvm4-intsafe.patch
@@ -0,0 +1,117 @@
+--- a/coreclr-1.0.6/src/pal/inc/rt/intsafe.h   2017-07-01 21:44:44.431947107 
+0300
++++ b/coreclr-1.0.6/src/pal/inc/rt/intsafe.h   2017-07-01 21:45:03.236947035 
+0300
+@@ -1449,114 +1449,4 @@
+ //
+ #define DWordPtrMult  ULongPtrMult
+ 
+-//
+-// size_t multiplication
+-//
+-#define SizeTMult             UIntPtrMult
+-
+-//
+-// SIZE_T multiplication
+-//
+-#define SIZETMult             ULongPtrMult
+-
+-//
+-// ULONGLONG multiplication
+-//
+-__inline
+-HRESULT
+-ULongLongMult(
+-    IN ULONGLONG ullMultiplicand,
+-    IN ULONGLONG ullMultiplier,
+-    OUT ULONGLONG* pullResult)
+-{
+-    HRESULT hr = INTSAFE_E_ARITHMETIC_OVERFLOW;
+-#ifdef _AMD64_
+-    ULONGLONG u64ResultHigh;
+-    ULONGLONG u64ResultLow;
+-    
+-    *pullResult = ULONGLONG_ERROR;
+-    
+-    u64ResultLow = UnsignedMultiply128(ullMultiplicand, ullMultiplier, 
&u64ResultHigh);
+-    if (u64ResultHigh == 0)
+-    {
+-        *pullResult = u64ResultLow;
+-        hr = S_OK;
+-    }
+-#else
+-    // 64x64 into 128 is like 32.32 x 32.32.
+-    //
+-    // a.b * c.d = a*(c.d) + .b*(c.d) = a*c + a*.d + .b*c + .b*.d
+-    // back in non-decimal notation where A=a*2^32 and C=c*2^32:  
+-    // A*C + A*d + b*C + b*d
+-    // So there are four components to add together.
+-    //   result = (a*c*2^64) + (a*d*2^32) + (b*c*2^32) + (b*d)
+-    //
+-    // a * c must be 0 or there would be bits in the high 64-bits
+-    // a * d must be less than 2^32 or there would be bits in the high 64-bits
+-    // b * c must be less than 2^32 or there would be bits in the high 64-bits
+-    // then there must be no overflow of the resulting values summed up.
+-    
+-    ULONG dw_a;
+-    ULONG dw_b;
+-    ULONG dw_c;
+-    ULONG dw_d;
+-    ULONGLONG ad = 0;
+-    ULONGLONG bc = 0;
+-    ULONGLONG bd = 0;
+-    ULONGLONG ullResult = 0;
+-    
+-    *pullResult = ULONGLONG_ERROR;
+-
+-    dw_a = (ULONG)(ullMultiplicand >> 32);
+-    dw_c = (ULONG)(ullMultiplier >> 32);
+-
+-    // common case -- if high dwords are both zero, no chance for overflow
+-    if ((dw_a == 0) && (dw_c == 0))
+-    {
+-        dw_b = (DWORD)ullMultiplicand;
+-        dw_d = (DWORD)ullMultiplier;
+-
+-        *pullResult = (((ULONGLONG)dw_b) * (ULONGLONG)dw_d);
+-        hr = S_OK;
+-    }
+-    else
+-    {
+-        // a * c must be 0 or there would be bits set in the high 64-bits
+-        if ((dw_a == 0) ||
+-            (dw_c == 0))
+-        {
+-            dw_d = (DWORD)ullMultiplier;
+-
+-            // a * d must be less than 2^32 or there would be bits set in the 
high 64-bits
+-            ad = (((ULONGLONG)dw_a) * (ULONGLONG)dw_d);
+-            if ((ad & HIDWORD_MASK) == 0)
+-            {
+-                dw_b = (DWORD)ullMultiplicand;
+-
+-                // b * c must be less than 2^32 or there would be bits set in 
the high 64-bits
+-                bc = (((ULONGLONG)dw_b) * (ULONGLONG)dw_c);
+-                if ((bc & HIDWORD_MASK) == 0)
+-                {
+-                    // now sum them all up checking for overflow.
+-                    // shifting is safe because we already checked for 
overflow above
+-                    if (SUCCEEDED(ULongLongAdd(bc << 32, ad << 32, 
&ullResult)))                        
+-                    {
+-                        // b * d
+-                        bd = (((ULONGLONG)dw_b) * (ULONGLONG)dw_d);
+-                    
+-                        if (SUCCEEDED(ULongLongAdd(ullResult, bd, 
&ullResult)))
+-                        {
+-                            *pullResult = ullResult;
+-                            hr = S_OK;
+-                        }
+-                    }
+-                }
+-            }
+-        }
+-    }
+-#endif // _AMD64_  
+-    
+-    return hr;
+-}
+-
+ #endif // _INTSAFE_H_INCLUDED_

diff --git a/dev-dotnet/dotnet-cli/files/coreclr-1.0.6-llvm4.patch 
b/dev-dotnet/dotnet-cli/files/coreclr-1.0.6-llvm4.patch
new file mode 100644
index 0000000..b5bb5e8
--- /dev/null
+++ b/dev-dotnet/dotnet-cli/files/coreclr-1.0.6-llvm4.patch
@@ -0,0 +1,176 @@
+--- before/coreclr-1.0.6/src/pal/inc/pal.h     2017-02-09 10:11:27.000000000 
+0300
++++ after/coreclr-1.0.6/src/pal/inc/pal.h      2017-07-01 01:33:36.727950051 
+0300
+@@ -5964,6 +5964,12 @@
+ }
+ #endif
+
++#ifndef __has_builtin
++#define __has_builtin(x) 0
++#endif
++
++#if !__has_builtin(_rotl)
++
+ /*++
+ Function:
+ _rotl
+@@ -5982,11 +5988,15 @@
+     return retval;
+ }
+
++#endif
++
+ // On 64 bit unix, make the long an int.
+ #ifdef BIT64
+ #define _lrotl _rotl
+ #endif // BIT64
+
++#if !__has_builtin(_rotr)
++
+ /*++
+ Function:
+ _rotr
+@@ -6005,6 +6015,8 @@
+     return retval;
+ }
+
++#endif
++
+ PALIMPORT int __cdecl abs(int);
+ PALIMPORT double __cdecl fabs(double);
+ #ifndef PAL_STDCPP_COMPAT
+diff --git a/src/pal/inc/pal_mstypes.h b/src/pal/inc/pal_mstypes.h
+index 0ca2871f2b7..0aa35ae1e5a 100644
+--- a/coreclr-1.0.6/src/pal/inc/pal_mstypes.h
++++ b/coreclr-1.0.6/src/pal/inc/pal_mstypes.h
+@@ -556,7 +556,7 @@ typedef LONG_PTR SSIZE_T, *PSSIZE_T;
+ #endif
+
+ #ifndef SSIZE_T_MIN
+-#define SSIZE_T_MIN I64(-9223372036854775808)
++#define SSIZE_T_MIN I64(0x8000000000000000)
+ #endif
+
+ #ifndef PAL_STDCPP_COMPAT
+diff --git a/src/gc/gc.cpp b/src/gc/gc.cpp
+index 745b24f5916..08de1facb28 100644
+--- a/coreclr-1.0.6/src/gc/gc.cpp
++++ b/coreclr-1.0.6/src/gc/gc.cpp
+@@ -20356,7 +20356,7 @@ size_t gc_heap::update_brick_table (uint8_t* tree, 
size_t current_brick,
+     dprintf (3, ("tree: %Ix, current b: %Ix, x: %Ix, plug_end: %Ix",
+         tree, current_brick, x, plug_end));
+
+-    if (tree > 0)
++    if (tree != NULL)
+     {
+         dprintf (3, ("b- %Ix->%Ix pointing to tree %Ix",
+             current_brick, (size_t)(tree - brick_address (current_brick)), 
tree));
+diff --git a/src/pal/inc/rt/intsafe.h b/src/pal/inc/rt/intsafe.h
+index 4ed70e7423f..6e28175e220 100644
+--- a/coreclr-1.0.6/src/pal/inc/rt/intsafe.h
++++ b/coreclr-1.0.6/src/pal/inc/rt/intsafe.h
+@@ -18,26 +18,6 @@
+
+ #include <specstrings.h>    // for IN, etc.
+
+-
+-#if defined(_AMD64_)
+-#ifdef __cplusplus
+-extern "C" {
+-#endif
+-#define UnsignedMultiply128 _umul128
+-ULONG64
+-UnsignedMultiply128 (
+-    IN ULONG64  Multiplier,
+-    IN ULONG64  Multiplicand,
+-    OUT ULONG64 *HighProduct
+-    );
+-#ifdef _MSC_VER
+-#pragma intrinsic(_umul128)
+-#endif // _MSC_VER
+-#ifdef __cplusplus
+-}
+-#endif
+-#endif // _AMD64_
+-
+ #ifndef FEATURE_PAL
+
+ #ifdef  _WIN64
+@@ -1444,23 +1424,6 @@
+ }
+
+ //
+-// UINT_PTR multiplication
+-//
+-#ifdef _WIN64
+-#define UIntPtrMult     ULongLongMult
+-#else
+-__inline
+-HRESULT
+-UIntPtrMult(
+-    IN UINT_PTR ulMultiplicand,
+-    IN UINT_PTR ulMultiplier,
+-    OUT UINT_PTR* pulResult)
+-{
+-      return UIntMult((UINT)ulMultiplicand, (UINT)ulMultiplier, 
(UINT*)pulResult);
+-}
+-#endif // _WIN64
+-
+-//
+ // ULONG multiplication
+ //
+ __inline
+@@ -1475,23 +1438,6 @@
+     return ULongLongToULong(ull64Result, pulResult);
+ }
+
+-//
+-// ULONG_PTR multiplication
+-//
+-#ifdef _WIN64
+-#define ULongPtrMult    ULongLongMult
+-#else
+-__inline
+-HRESULT
+-ULongPtrMult(
+-    IN ULONG_PTR ulMultiplicand,
+-    IN ULONG_PTR ulMultiplier,
+-    OUT ULONG_PTR* pulResult)
+-{
+-      return ULongMult((ULONG)ulMultiplicand, (ULONG)ulMultiplier, 
(ULONG*)pulResult);
+-}
+-#endif // _WIN64
+-
+
+ //
+ // DWORD multiplication
+diff --git a/src/vm/amd64/unixstubs.cpp b/src/vm/amd64/unixstubs.cpp
+index 29041490845..76d3cf18902 100644
+--- a/coreclr-1.0.6/src/vm/amd64/unixstubs.cpp
++++ b/coreclr-1.0.6/src/vm/amd64/unixstubs.cpp
+@@ -37,7 +37,7 @@ extern "C"
+               "  mov %%edx, 12(%[result])\n" \
+             : "=a"(eax) /*output in eax*/\
+             : "a"(arg), [result]"r"(result) /*inputs - arg in eax, result in 
any register*/\
+-            : "eax", "rbx", "ecx", "edx" /* registers that are clobbered*/
++            : "rbx", "ecx", "edx" /* registers that are clobbered*/
+           );
+         return eax;
+     }
+@@ -52,7 +52,7 @@ extern "C"
+               "  mov %%edx, 12(%[result])\n" \
+             : "=a"(eax) /*output in eax*/\
+             : "c"(arg1), "a"(arg2), [result]"r"(result) /*inputs - arg1 in 
ecx, arg2 in eax, result in any register*/\
+-            : "eax", "rbx", "ecx", "edx" /* registers that are clobbered*/
++            : "rbx", "edx" /* registers that are clobbered*/
+           );
+         return eax;
+     }
+@@ -63,7 +63,7 @@ extern "C"
+         __asm("  xgetbv\n" \
+             : "=a"(eax) /*output in eax*/\
+             : "c"(0) /*inputs - 0 in ecx*/\
+-            : "eax", "edx" /* registers that are clobbered*/
++            : "edx" /* registers that are clobbered*/
+           );
+         // check OS has enabled both XMM and YMM state support
+         return ((eax & 0x06) == 0x06) ? 1 : 0;

diff --git 
a/dev-dotnet/dotnet-cli/files/coreclr-1.1.1-builtin-redefinition.patch 
b/dev-dotnet/dotnet-cli/files/coreclr-1.1.1-builtin-redefinition.patch
new file mode 100644
index 0000000..7ee48fe
--- /dev/null
+++ b/dev-dotnet/dotnet-cli/files/coreclr-1.1.1-builtin-redefinition.patch
@@ -0,0 +1,40 @@
+--- before/coreclr-1.1.1/src/pal/inc/pal.h     2017-02-09 10:16:50.000000000 
+0300
++++ after/coreclr-1.1.1/src/pal/inc/pal.h      2017-07-01 01:34:53.949949756 
+0300
+@@ -5967,6 +5967,12 @@
+ }
+ #endif
+ 
++#ifndef __has_builtin
++#define __has_builtin(x) 0
++#endif
++
++#if !__has_builtin(_rotl)
++
+ /*++
+ Function:
+ _rotl
+@@ -5985,11 +5991,15 @@
+     return retval;
+ }
+ 
++#endif
++
+ // On 64 bit unix, make the long an int.
+ #ifdef BIT64
+ #define _lrotl _rotl
+ #endif // BIT64
+ 
++#if !__has_builtin(_rotr)
++
+ /*++
+ Function:
+ _rotr
+@@ -6008,6 +6018,8 @@
+     return retval;
+ }
+ 
++#endif
++
+ PALIMPORT int __cdecl abs(int);
+ #ifndef PAL_STDCPP_COMPAT
+ PALIMPORT LONG __cdecl labs(LONG);

diff --git a/dev-dotnet/dotnet-cli/files/coreclr-1.1.1-llvm4-intsafe.patch 
b/dev-dotnet/dotnet-cli/files/coreclr-1.1.1-llvm4-intsafe.patch
new file mode 100644
index 0000000..1fb2487
--- /dev/null
+++ b/dev-dotnet/dotnet-cli/files/coreclr-1.1.1-llvm4-intsafe.patch
@@ -0,0 +1,117 @@
+--- a/coreclr-1.1.1/src/pal/inc/rt/intsafe.h   2017-07-01 23:09:42.103927661 
+0300
++++ b/coreclr-1.1.1/src/pal/inc/rt/intsafe.h   2017-07-01 23:10:17.995927524 
+0300
+@@ -1449,114 +1449,4 @@
+ //
+ #define DWordPtrMult  ULongPtrMult
+ 
+-//
+-// size_t multiplication
+-//
+-#define SizeTMult             UIntPtrMult
+-
+-//
+-// SIZE_T multiplication
+-//
+-#define SIZETMult             ULongPtrMult
+-
+-//
+-// ULONGLONG multiplication
+-//
+-__inline
+-HRESULT
+-ULongLongMult(
+-    IN ULONGLONG ullMultiplicand,
+-    IN ULONGLONG ullMultiplier,
+-    OUT ULONGLONG* pullResult)
+-{
+-    HRESULT hr = INTSAFE_E_ARITHMETIC_OVERFLOW;
+-#ifdef _AMD64_
+-    ULONGLONG u64ResultHigh;
+-    ULONGLONG u64ResultLow;
+-    
+-    *pullResult = ULONGLONG_ERROR;
+-    
+-    u64ResultLow = UnsignedMultiply128(ullMultiplicand, ullMultiplier, 
&u64ResultHigh);
+-    if (u64ResultHigh == 0)
+-    {
+-        *pullResult = u64ResultLow;
+-        hr = S_OK;
+-    }
+-#else
+-    // 64x64 into 128 is like 32.32 x 32.32.
+-    //
+-    // a.b * c.d = a*(c.d) + .b*(c.d) = a*c + a*.d + .b*c + .b*.d
+-    // back in non-decimal notation where A=a*2^32 and C=c*2^32:  
+-    // A*C + A*d + b*C + b*d
+-    // So there are four components to add together.
+-    //   result = (a*c*2^64) + (a*d*2^32) + (b*c*2^32) + (b*d)
+-    //
+-    // a * c must be 0 or there would be bits in the high 64-bits
+-    // a * d must be less than 2^32 or there would be bits in the high 64-bits
+-    // b * c must be less than 2^32 or there would be bits in the high 64-bits
+-    // then there must be no overflow of the resulting values summed up.
+-    
+-    ULONG dw_a;
+-    ULONG dw_b;
+-    ULONG dw_c;
+-    ULONG dw_d;
+-    ULONGLONG ad = 0;
+-    ULONGLONG bc = 0;
+-    ULONGLONG bd = 0;
+-    ULONGLONG ullResult = 0;
+-    
+-    *pullResult = ULONGLONG_ERROR;
+-
+-    dw_a = (ULONG)(ullMultiplicand >> 32);
+-    dw_c = (ULONG)(ullMultiplier >> 32);
+-
+-    // common case -- if high dwords are both zero, no chance for overflow
+-    if ((dw_a == 0) && (dw_c == 0))
+-    {
+-        dw_b = (DWORD)ullMultiplicand;
+-        dw_d = (DWORD)ullMultiplier;
+-
+-        *pullResult = (((ULONGLONG)dw_b) * (ULONGLONG)dw_d);
+-        hr = S_OK;
+-    }
+-    else
+-    {
+-        // a * c must be 0 or there would be bits set in the high 64-bits
+-        if ((dw_a == 0) ||
+-            (dw_c == 0))
+-        {
+-            dw_d = (DWORD)ullMultiplier;
+-
+-            // a * d must be less than 2^32 or there would be bits set in the 
high 64-bits
+-            ad = (((ULONGLONG)dw_a) * (ULONGLONG)dw_d);
+-            if ((ad & HIDWORD_MASK) == 0)
+-            {
+-                dw_b = (DWORD)ullMultiplicand;
+-
+-                // b * c must be less than 2^32 or there would be bits set in 
the high 64-bits
+-                bc = (((ULONGLONG)dw_b) * (ULONGLONG)dw_c);
+-                if ((bc & HIDWORD_MASK) == 0)
+-                {
+-                    // now sum them all up checking for overflow.
+-                    // shifting is safe because we already checked for 
overflow above
+-                    if (SUCCEEDED(ULongLongAdd(bc << 32, ad << 32, 
&ullResult)))                        
+-                    {
+-                        // b * d
+-                        bd = (((ULONGLONG)dw_b) * (ULONGLONG)dw_d);
+-                    
+-                        if (SUCCEEDED(ULongLongAdd(ullResult, bd, 
&ullResult)))
+-                        {
+-                            *pullResult = ullResult;
+-                            hr = S_OK;
+-                        }
+-                    }
+-                }
+-            }
+-        }
+-    }
+-#endif // _AMD64_  
+-    
+-    return hr;
+-}
+-
+ #endif // _INTSAFE_H_INCLUDED_

diff --git a/dev-dotnet/dotnet-cli/files/coreclr-1.1.1-llvm4.patch 
b/dev-dotnet/dotnet-cli/files/coreclr-1.1.1-llvm4.patch
new file mode 100644
index 0000000..388f73a
--- /dev/null
+++ b/dev-dotnet/dotnet-cli/files/coreclr-1.1.1-llvm4.patch
@@ -0,0 +1,136 @@
+diff --git a/src/pal/inc/pal_mstypes.h b/src/pal/inc/pal_mstypes.h
+index 0ca2871f2b7..0aa35ae1e5a 100644
+--- a/coreclr-1.1.1/src/pal/inc/pal_mstypes.h
++++ b/coreclr-1.1.1/src/pal/inc/pal_mstypes.h
+@@ -556,7 +556,7 @@ typedef LONG_PTR SSIZE_T, *PSSIZE_T;
+ #endif
+
+ #ifndef SSIZE_T_MIN
+-#define SSIZE_T_MIN I64(-9223372036854775808)
++#define SSIZE_T_MIN I64(0x8000000000000000)
+ #endif
+
+ #ifndef PAL_STDCPP_COMPAT
+diff --git a/src/gc/gc.cpp b/src/gc/gc.cpp
+index 745b24f5916..08de1facb28 100644
+--- a/coreclr-1.1.1/src/gc/gc.cpp
++++ b/coreclr-1.1.1/src/gc/gc.cpp
+@@ -20356,7 +20356,7 @@ size_t gc_heap::update_brick_table (uint8_t* tree, 
size_t current_brick,
+     dprintf (3, ("tree: %Ix, current b: %Ix, x: %Ix, plug_end: %Ix",
+         tree, current_brick, x, plug_end));
+
+-    if (tree > 0)
++    if (tree != NULL)
+     {
+         dprintf (3, ("b- %Ix->%Ix pointing to tree %Ix",
+             current_brick, (size_t)(tree - brick_address (current_brick)), 
tree));
+diff --git a/src/pal/inc/rt/intsafe.h b/src/pal/inc/rt/intsafe.h
+index 4ed70e7423f..6e28175e220 100644
+--- a/coreclr-1.1.1/src/pal/inc/rt/intsafe.h
++++ b/coreclr-1.1.1/src/pal/inc/rt/intsafe.h
+@@ -18,26 +18,6 @@
+
+ #include <specstrings.h>    // for IN, etc.
+
+-
+-#if defined(_AMD64_)
+-#ifdef __cplusplus
+-extern "C" {
+-#endif
+-#define UnsignedMultiply128 _umul128
+-ULONG64
+-UnsignedMultiply128 (
+-    IN ULONG64  Multiplier,
+-    IN ULONG64  Multiplicand,
+-    OUT ULONG64 *HighProduct
+-    );
+-#ifdef _MSC_VER
+-#pragma intrinsic(_umul128)
+-#endif // _MSC_VER
+-#ifdef __cplusplus
+-}
+-#endif
+-#endif // _AMD64_
+-
+ #ifndef FEATURE_PAL
+
+ #ifdef  _WIN64
+@@ -1444,23 +1424,6 @@
+ }
+
+ //
+-// UINT_PTR multiplication
+-//
+-#ifdef _WIN64
+-#define UIntPtrMult     ULongLongMult
+-#else
+-__inline
+-HRESULT
+-UIntPtrMult(
+-    IN UINT_PTR ulMultiplicand,
+-    IN UINT_PTR ulMultiplier,
+-    OUT UINT_PTR* pulResult)
+-{
+-      return UIntMult((UINT)ulMultiplicand, (UINT)ulMultiplier, 
(UINT*)pulResult);
+-}
+-#endif // _WIN64
+-
+-//
+ // ULONG multiplication
+ //
+ __inline
+@@ -1475,23 +1438,6 @@
+     return ULongLongToULong(ull64Result, pulResult);
+ }
+
+-//
+-// ULONG_PTR multiplication
+-//
+-#ifdef _WIN64
+-#define ULongPtrMult    ULongLongMult
+-#else
+-__inline
+-HRESULT
+-ULongPtrMult(
+-    IN ULONG_PTR ulMultiplicand,
+-    IN ULONG_PTR ulMultiplier,
+-    OUT ULONG_PTR* pulResult)
+-{
+-      return ULongMult((ULONG)ulMultiplicand, (ULONG)ulMultiplier, 
(ULONG*)pulResult);
+-}
+-#endif // _WIN64
+-
+
+ //
+ // DWORD multiplication
+diff --git a/src/vm/amd64/unixstubs.cpp b/src/vm/amd64/unixstubs.cpp
+index 29041490845..76d3cf18902 100644
+--- a/coreclr-1.1.1/src/vm/amd64/unixstubs.cpp
++++ b/coreclr-1.1.1/src/vm/amd64/unixstubs.cpp
+@@ -37,7 +37,7 @@ extern "C"
+               "  mov %%edx, 12(%[result])\n" \
+             : "=a"(eax) /*output in eax*/\
+             : "a"(arg), [result]"r"(result) /*inputs - arg in eax, result in 
any register*/\
+-            : "eax", "rbx", "ecx", "edx", "memory" /* registers that are 
clobbered, *result is clobbered */
++            : "rbx", "ecx", "edx", "memory" /* registers that are clobbered, 
*result is clobbered */
+           );
+         return eax;
+     }
+@@ -52,7 +52,7 @@ extern "C"
+               "  mov %%edx, 12(%[result])\n" \
+             : "=a"(eax) /*output in eax*/\
+             : "c"(arg1), "a"(arg2), [result]"r"(result) /*inputs - arg1 in 
ecx, arg2 in eax, result in any register*/\
+-            : "eax", "rbx", "ecx", "edx", "memory" /* registers that are 
clobbered, *result is clobbered */
++            : "rbx", "edx", "memory" /* registers that are clobbered, *result 
is clobbered */
+           );
+         return eax;
+     }
+@@ -63,7 +63,7 @@ extern "C"
+         __asm("  xgetbv\n" \
+             : "=a"(eax) /*output in eax*/\
+             : "c"(0) /*inputs - 0 in ecx*/\
+-            : "eax", "edx" /* registers that are clobbered*/
++            : "edx" /* registers that are clobbered*/
+           );
+         // check OS has enabled both XMM and YMM state support
+         return ((eax & 0x06) == 0x06) ? 1 : 0;

diff --git a/dev-dotnet/dotnet-cli/files/corefx-1.0.4-werror.patch 
b/dev-dotnet/dotnet-cli/files/corefx-1.0.4-werror.patch
new file mode 100644
index 0000000..e34868c
--- /dev/null
+++ b/dev-dotnet/dotnet-cli/files/corefx-1.0.4-werror.patch
@@ -0,0 +1,11 @@
+--- before/corefx-1.0.4/src/Native/CMakeLists.txt      2017-02-10 
06:02:30.000000000 +0300
++++ after/corefx-1.0.4/src/Native/CMakeLists.txt       2017-07-01 
00:59:23.425957884 +0300
+@@ -15,7 +15,7 @@
+ add_compile_options(-Wno-disabled-macro-expansion)
+ add_compile_options(-Wno-c++98-compat)
+ add_compile_options(-Wno-c++98-compat-pedantic)
+-add_compile_options(-Werror)
++#add_compile_options(-Werror)
+ add_compile_options(-fPIC)
+ add_compile_options(-I${CMAKE_CURRENT_SOURCE_DIR}/Common)
+ add_compile_options(-I${CMAKE_CURRENT_BINARY_DIR}/Common)

diff --git a/dev-dotnet/dotnet-cli/files/corefx-1.1.1-werror.patch 
b/dev-dotnet/dotnet-cli/files/corefx-1.1.1-werror.patch
new file mode 100644
index 0000000..2370d6d
--- /dev/null
+++ b/dev-dotnet/dotnet-cli/files/corefx-1.1.1-werror.patch
@@ -0,0 +1,11 @@
+--- before/corefx-1.1.1/src/Native/Unix/CMakeLists.txt 2017-02-22 
19:42:11.000000000 +0300
++++ after/corefx-1.1.1/src/Native/Unix/CMakeLists.txt  2017-07-01 
00:59:39.256957823 +0300
+@@ -15,7 +15,7 @@
+ add_compile_options(-Wno-disabled-macro-expansion)
+ add_compile_options(-Wno-c++98-compat)
+ add_compile_options(-Wno-c++98-compat-pedantic)
+-add_compile_options(-Werror)
++#add_compile_options(-Werror)
+ add_compile_options(-fPIC)
+ add_compile_options(-I${CMAKE_CURRENT_SOURCE_DIR}/Common)
+ add_compile_options(-I${CMAKE_CURRENT_BINARY_DIR}/Common)

Reply via email to