diff options
author | Jan Kotas <jkotas@microsoft.com> | 2016-09-21 17:15:25 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-21 17:15:25 +0300 |
commit | f984c67526ddb71f8520efb7946d6b5e870ebcda (patch) | |
tree | e38f9387e79697c7fa451af42a116999861f38c5 | |
parent | 0431552a0ad2c50110c69f880843055e2ff61b23 (diff) | |
parent | a6f3b71eb5a69c392a524d3d7e51761d1129333a (diff) |
Merge pull request #1891 from dotnet/masternmirror
Merge master to nmirror
85 files changed, 1343 insertions, 962 deletions
diff --git a/.gitignore b/.gitignore index 1a7c6fea2..97450b767 100644 --- a/.gitignore +++ b/.gitignore @@ -143,6 +143,8 @@ publish/ *.publishproj # NuGet Packages +*.nuget.props +*.nuget.targets *.nupkg **/packages/* /packages/* diff --git a/Documentation/how-to-build-and-run-ilcompiler-in-console-shell-prompt.md b/Documentation/how-to-build-and-run-ilcompiler-in-console-shell-prompt.md index 841406aae..e2a7ea2e7 100644 --- a/Documentation/how-to-build-and-run-ilcompiler-in-console-shell-prompt.md +++ b/Documentation/how-to-build-and-run-ilcompiler-in-console-shell-prompt.md @@ -13,12 +13,10 @@ This will result in the following: - Restore nuget packages required for building - Build native and managed components of ILCompiler. The final binaries are placed to `<repo_root>\bin\Product\<OS>.<arch>.<Config>\packaging\publish1`. - Build and run tests -- Installs the latest CLI tools at `<repo_root>\Tools\dotnetcli` -# Setup CLI -To consume the CLI tools installed as part of the build, do the following: +# Install latest CLI tools -* Add `<repo_root>\Tools\dotnetcli` to the path +* Download latest CLI tools from https://github.com/dotnet/cli/ and add them to the path * On windows ensure you are using the 'VS2015 x64 Native Tools Command Prompt' (This is distinct from the 'Developer Command Prompt for VS2015') @@ -28,21 +26,24 @@ You should now be able to use the `dotnet` commands of the CLI tools. * Ensure that you have done a repo build per the instructions above. * Create a new folder and switch into it. -* Issue the command, `dotnet new`, on the command/shell prompt. This will add a template source file and corresponding project.json. If you get an error, please ensure the [pre-requisites](prerequisites-for-building.md) are installed. - +* Run `dotnet new --type MSBuild` on the command/shell prompt. This will add a project template. If you get an error, please ensure the [pre-requisites](prerequisites-for-building.md) are installed. +* Run `dotnet restore`. This will download nuget packages required for compilation +* Add the following line at the end of `.csproj` file that is part of your project. +``` + <Import Project="$(IlcPath)\Microsoft.NETCore.Native.targets" /> +``` ## Using RyuJIT ## This approach uses the same code-generator (RyuJIT), as [CoreCLR](https://github.com/dotnet/coreclr), for compiling the application. Linking is done using the platform specific linker. -From the shell/command prompt, issue the following commands, from the folder containing your source file and project.json, to generate the native executable +From the shell/command prompt, issue the following commands, from the folder containing your project, to generate the native executable ``` - dotnet restore - dotnet build --native --ilcpath <repo_root>\bin\Product\Windows_NT.x64.Debug\packaging\publish1 + dotnet build3 /p:IlcPath=<repo_root>\bin\Product\Windows_NT.x64.Debug\packaging\publish1 ``` -Native executable will be dropped in `./bin/[configuration]/[framework]/[runtime]/native/` folder and will have the same name as the folder in which your source file is present. +Native executable will be dropped in `./bin/[configuration]/native/` folder and will have the same name as the folder in which your source file is present. ## Using CPP Code Generator ## @@ -51,11 +52,10 @@ This approach uses platform specific C++ compiler and linker for compiling/linki From the shell/command prompt, issue the following commands to generate the native executable: ``` - dotnet restore - dotnet build --native --cpp --ilcpath <repo_root>\bin\Product\Windows_NT.x64.Debug\packaging\publish1 --cppcompilerflags /MTd + dotnet build3 /t:LinkNative /p:IlcPath=<repo_root>\bin\Product\Windows_NT.x64.Debug\packaging\publish1 /p:NativeCodeGen=cpp /p:AdditionalCppCompilerFlags=/MTd ``` -Omit `--cppcompilerflags /MTd` for release CoreRT build. +Omit `/p:AdditionalCppCompilerFlags=/MTd` for release CoreRT build. ## Workarounds for linker errors on Windows ## diff --git a/DotnetCLIVersion.txt b/DotnetCLIVersion.txt index b60ffc677..7a77ed32a 100644 --- a/DotnetCLIVersion.txt +++ b/DotnetCLIVersion.txt @@ -1 +1 @@ -1.0.0-rc2-002416 +1.0.0-preview3-003223 @@ -64,8 +64,8 @@ set "__IntermediatesDir=%__RootBinDir%\obj\Native\%__BuildOS%.%__BuildArch%.%__B set "__RelativeProductBinDir=bin\Product\%__BuildOS%.%__BuildArch%.%__BuildType%" set "__ReproProjectDir=%__ProjectDir%\src\ILCompiler\repro" -set "__ReproProjectBinDir=%__ReproProjectDir%\bin" -set "__ReproProjectObjDir=%__ReproProjectDir%\obj" +set "__ReproProjectBinDir=%__BinDir%\repro" +set "__ReproProjectObjDir=%__ObjDir%\repro" :: Generate path to be set for CMAKE_INSTALL_PREFIX to contain forward slash set "__CMakeBinDir=%__BinDir%" @@ -84,9 +84,6 @@ if exist "%__BinDir%" rd /s /q "%__BinDir%" if exist "%__ObjDir%" rd /s /q "%__ObjDir%" if exist "%__IntermediatesDir%" rd /s /q "%__IntermediatesDir%" -if exist "%__ReproProjectBinDir%" rd /s /q "%__ReproProjectBinDir%" -if exist "%__ReproProjectObjDir%" rd /s /q "%__ReproProjectObjDir%" - if exist "%__LogsDir%" del /f /q "%__LogsDir%\*_%__BuildOS%__%__BuildArch%__%__BuildType%.*" :MakeDirs @@ -202,15 +199,7 @@ exit /b 1 :AfterILCompilerBuild -setlocal -rem Workaround for --appdepsdkpath command line switch being ignored. -rem Copy the restored appdepsdk package to its default location. -pushd "%__ProjectDir%\tests" -call testenv.cmd %__BuildType% %__BuildArch% -popd -set /p DOTNET_VERSION=< "%~dp0DotnetCLIVersion.txt" -xcopy /S /Y "%CoreRT_AppDepSdkDir%" "%__DotNetCliPath%\sdk\%DOTNET_VERSION%\appdepsdk%\" -endlocal + :VsDevGenerateRespFiles if defined __SkipVsDev goto :AfterVsDevGenerateRespFiles @@ -218,26 +207,21 @@ set __GenRespFiles=0 if not exist "%__ObjDir%\ryujit.rsp" set __GenRespFiles=1 if not exist "%__ObjDir%\cpp.rsp" set __GenRespFiles=1 if "%__GenRespFiles%"=="1" ( - setlocal - pushd "%__ProjectDir%\tests" - call testenv.cmd %__BuildType% %__BuildArch% - popd - call "!VS140COMNTOOLS!\..\..\VC\vcvarsall.bat" %__BuildArch% + if exist "%__ReproProjectBinDir%" rd /s /q "%__ReproProjectBinDir%" + if exist "%__ReproProjectObjDir%" rd /s /q "%__ReproProjectObjDir%" - "%__DotNetCliPath%\dotnet.exe" build --native --ilcpath "%__BinDir%\packaging\publish1" --appdepsdkpath "%CoreRT_AppDepSdkDir%" "%__ReproProjectDir%" -c %__BuildType% - call :CopyResponseFile "%__ReproProjectObjDir%\%__BuildType%\dnxcore50\native\dotnet-compile-native-ilc.rsp" "%__ObjDir%\ryujit.rsp" + %_msbuildexe% "/p:IlcPath=%__BinDir%\packaging\publish1" /p:Configuration=%__BuildType% /t:IlcCompile "%__ReproProjectDir%\repro.csproj" + call :CopyResponseFile "%__ReproProjectObjDir%\native\ilc.rsp" "%__ObjDir%\ryujit.rsp" - rem Workaround for https://github.com/dotnet/cli/issues/1956 - rmdir /s /q "%__ReproProjectBinDir%" - rmdir /s /q "%__ReproProjectObjDir%" + if exist "%__ReproProjectBinDir%" rd /s /q "%__ReproProjectBinDir%" + if exist "%__ReproProjectObjDir%" rd /s /q "%__ReproProjectObjDir%" - set __AdditionalCompilerFlags= + set __ExtraArgs=/p:NativeCodeGen=cpp if /i "%__BuildType%"=="debug" ( - set __AdditionalCompilerFlags=--cppcompilerflags /MTd + set __ExtraArgs=!__ExtraArgs! "/p:AdditionalCppCompilerFlags=/MTd" ) - "%__DotNetCliPath%\dotnet.exe" build --native --cpp --ilcpath "%__BinDir%\packaging\publish1" --appdepsdkpath "%CoreRT_AppDepSdkDir%" "%__ReproProjectDir%" -c %__BuildType% !__AdditionalCompilerFlags! - call :CopyResponseFile "%__ReproProjectObjDir%\%__BuildType%\dnxcore50\native\dotnet-compile-native-ilc.rsp" "%__ObjDir%\cpp.rsp" - endlocal + %_msbuildexe% "/p:IlcPath=%__BinDir%\packaging\publish1" /p:Configuration=%__BuildType% /t:IlcCompile "%__ReproProjectDir%\repro.csproj" !__ExtraArgs! + call :CopyResponseFile "%__ReproProjectObjDir%\native\ilc.rsp" "%__ObjDir%\cpp.rsp" ) :AfterVsDevGenerateRespFiles @@ -83,7 +83,7 @@ build_managed_corert() ToolchainMilestone=testing fi - $__scriptpath/Tools/corerun $__scriptpath/Tools/MSBuild.exe "$__buildproj" /m /nologo /verbosity:minimal "/fileloggerparameters:Verbosity=normal;LogFile=$__buildlog" /t:Build /p:RepoPath=$__ProjectRoot /p:RepoLocalBuild="true" /p:RelativeProductBinDir=$__RelativeProductBinDir /p:CleanedTheBuild=$__CleanBuild /p:SkipTests=true /p:TestNugetRuntimeId=$__TestNugetRuntimeId /p:ToolNugetRuntimeId=$__ToolNugetRuntimeId /p:OSEnvironment=Unix /p:OSGroup=$__BuildOS /p:Configuration=$__BuildType /p:Platform=$__BuildArch /p:COMPUTERNAME=$(hostname) /p:USERNAME=$(id -un) /p:ToolchainMilestone=${ToolchainMilestone} $__UnprocessedBuildArgs + $__scriptpath/Tools/corerun $__scriptpath/Tools/MSBuild.exe "$__buildproj" /m /nologo /verbosity:minimal "/fileloggerparameters:Verbosity=normal;LogFile=$__buildlog" /t:Build /p:RepoPath=$__ProjectRoot /p:RepoLocalBuild="true" /p:RelativeProductBinDir=$__RelativeProductBinDir /p:CleanedTheBuild=$__CleanBuild /p:SkipTests=true /p:TestNugetRuntimeId=$__TestNugetRuntimeId /p:ToolNugetRuntimeId=$__ToolNugetRuntimeId /p:OSGroup=$__BuildOS /p:Configuration=$__BuildType /p:Platform=$__BuildArch /p:COMPUTERNAME=$(hostname) /p:USERNAME=$(id -un) /p:ToolchainMilestone=${ToolchainMilestone} $__UnprocessedBuildArgs BUILDERRORLEVEL=$? echo @@ -91,12 +91,6 @@ build_managed_corert() # Pull the build summary from the log file tail -n 4 "$__buildlog" echo Build Exit Code = $BUILDERRORLEVEL - - # Workaround for --appdepsdkpath command line switch being ignored. - # Copy the restored appdepsdk package to its default location. - source "${__ProjectRoot}/tests/testenv.sh" $__BuildType $__BuildArch - __DOTNET_TOOLS_VERSION=$(cat $__scriptpath/DotnetCLIVersion.txt) - cp -r "${CoreRT_AppDepSdkDir}" "${__dotnetclipath}/sdk/${__DOTNET_TOOLS_VERSION}/appdepsdk" } build_native_corert() @@ -5,6 +5,7 @@ $(OS) is set to Unix/Windows_NT. This comes from an environment variable on Windows and MSBuild on Unix. --> <PropertyGroup> + <OsEnvironment Condition="'$(OsEnvironment)'=='' and '$(OS)'=='OSX'">Unix</OsEnvironment> <OsEnvironment Condition="'$(OsEnvironment)'==''">$(OS)</OsEnvironment> </PropertyGroup> diff --git a/init-tools.cmd b/init-tools.cmd index 53c1b306b..dc54300b9 100644 --- a/init-tools.cmd +++ b/init-tools.cmd @@ -12,7 +12,7 @@ set BUILD_TOOLS_PATH=%PACKAGES_DIR%Microsoft.DotNet.BuildTools\%BUILDTOOLS_VERSI set PROJECT_JSON_PATH=%TOOLRUNTIME_DIR%\%BUILDTOOLS_VERSION% set PROJECT_JSON_FILE=%PROJECT_JSON_PATH%\project.json set PROJECT_JSON_CONTENTS={ "dependencies": { "Microsoft.DotNet.BuildTools": "%BUILDTOOLS_VERSION%" }, "frameworks": { "dnxcore50": { } } } -set BUILD_TOOLS_SEMAPHORE=%PROJECT_JSON_PATH%\init-tools-rev.completed +set BUILD_TOOLS_SEMAPHORE=%PROJECT_JSON_PATH%\init-tools.completed :: if force option is specified then clean the tool runtime and build tools package directory to force it to get recreated if [%1]==[force] ( @@ -38,12 +38,12 @@ echo Installing dotnet cli... if NOT exist "%DOTNET_PATH%" mkdir "%DOTNET_PATH%" set /p DOTNET_VERSION=< "%~dp0DotnetCLIVersion.txt" set DOTNET_ZIP_NAME=dotnet-dev-win-x64.%DOTNET_VERSION%.zip -set DOTNET_REMOTE_PATH=https://dotnetcli.blob.core.windows.net/dotnet/beta/Binaries/%DOTNET_VERSION%/%DOTNET_ZIP_NAME% +set DOTNET_REMOTE_PATH=https://dotnetcli.blob.core.windows.net/dotnet/Sdk/%DOTNET_VERSION%/%DOTNET_ZIP_NAME% set DOTNET_LOCAL_PATH=%DOTNET_PATH%%DOTNET_ZIP_NAME% echo Installing '%DOTNET_REMOTE_PATH%' to '%DOTNET_LOCAL_PATH%' >> "%INIT_TOOLS_LOG%" powershell -NoProfile -ExecutionPolicy unrestricted -Command "$retryCount = 0; $success = $false; do { try { (New-Object Net.WebClient).DownloadFile('%DOTNET_REMOTE_PATH%', '%DOTNET_LOCAL_PATH%'); $success = $true; } catch { if ($retryCount -ge 6) { throw; } else { $retryCount++; Start-Sleep -Seconds (5 * $retryCount); } } } while ($success -eq $false); Add-Type -Assembly 'System.IO.Compression.FileSystem' -ErrorVariable AddTypeErrors; if ($AddTypeErrors.Count -eq 0) { [System.IO.Compression.ZipFile]::ExtractToDirectory('%DOTNET_LOCAL_PATH%', '%DOTNET_PATH%') } else { (New-Object -com shell.application).namespace('%DOTNET_PATH%').CopyHere((new-object -com shell.application).namespace('%DOTNET_LOCAL_PATH%').Items(),16) }" >> "%INIT_TOOLS_LOG%" if NOT exist "%DOTNET_LOCAL_PATH%" ( - echo ERROR: Could not install dotnet cli correctly. See '%INIT_TOOLS_LOG%' for more details. + echo ERROR: Could not install dotnet cli correctly. See '%INIT_TOOLS_LOG%' for more details. 1>&2 exit /b 1 ) @@ -54,7 +54,7 @@ echo Restoring BuildTools version %BUILDTOOLS_VERSION%... echo Running: "%DOTNET_CMD%" restore "%PROJECT_JSON_FILE%" --no-cache --packages %PACKAGES_DIR% --source "%BUILDTOOLS_SOURCE%" >> "%INIT_TOOLS_LOG%" call "%DOTNET_CMD%" restore "%PROJECT_JSON_FILE%" --no-cache --packages %PACKAGES_DIR% --source "%BUILDTOOLS_SOURCE%" >> "%INIT_TOOLS_LOG%" if NOT exist "%BUILD_TOOLS_PATH%init-tools.cmd" ( - echo ERROR: Could not restore build tools correctly. See '%INIT_TOOLS_LOG%' for more details. + echo ERROR: Could not restore build tools correctly. See '%INIT_TOOLS_LOG%' for more details. 1>&2 exit /b 1 ) diff --git a/init-tools.sh b/init-tools.sh index 6dd1032a6..e23b7f3b3 100755 --- a/init-tools.sh +++ b/init-tools.sh @@ -15,40 +15,82 @@ __PROJECT_JSON_FILE=$__PROJECT_JSON_PATH/project.json __PROJECT_JSON_CONTENTS="{ \"dependencies\": { \"Microsoft.DotNet.BuildTools\": \"$__BUILD_TOOLS_PACKAGE_VERSION\" }, \"frameworks\": { \"dnxcore50\": { } } }" __INIT_TOOLS_DONE_MARKER=$__PROJECT_JSON_PATH/done -OSName=$(uname -s) -case $OSName in - Darwin) - OS=OSX - __DOTNET_PKG=dotnet-dev-osx-x64 - ulimit -n 2048 - ;; - - Linux) - OS=Linux - source /etc/os-release - if [ "$ID" == "centos" -o "$ID" == "rhel" ]; then - __DOTNET_PKG=dotnet-dev-centos-x64 - elif [ "$ID" == "ubuntu" -o "$ID" == "debian" ]; then - __DOTNET_PKG=dotnet-dev-ubuntu-x64 - else - echo "Unsupported Linux distribution '$ID' detected. Downloading ubuntu-x64 tools." - __DOTNET_PKG=dotnet-dev-ubuntu-x64 +# Extended version of platform detection logic from dotnet/cli/scripts/obtain/dotnet-install.sh 16692fc +get_current_linux_name() { + # Detect Distro + if [ "$(cat /etc/*-release | grep -cim1 ubuntu)" -eq 1 ]; then + if [ "$(cat /etc/*-release | grep -cim1 16.04)" -eq 1 ]; then + echo "ubuntu.16.04" + return 0 + fi + if [ "$(cat /etc/*-release | grep -cim1 16.10)" -eq 1 ]; then + echo "ubuntu.16.10" + return 0 fi - ;; - *) - echo "Unsupported OS '$OSName' detected. Downloading ubuntu-x64 tools." - OS=Linux - __DOTNET_PKG=dotnet-dev-ubuntu-x64 - ;; -esac + echo "ubuntu" + return 0 + elif [ "$(cat /etc/*-release | grep -cim1 centos)" -eq 1 ]; then + echo "centos" + return 0 + elif [ "$(cat /etc/*-release | grep -cim1 rhel)" -eq 1 ]; then + echo "rhel" + return 0 + elif [ "$(cat /etc/*-release | grep -cim1 debian)" -eq 1 ]; then + echo "debian" + return 0 + elif [ "$(cat /etc/*-release | grep -cim1 fedora)" -eq 1 ]; then + if [ "$(cat /etc/*-release | grep -cim1 23)" -eq 1 ]; then + echo "fedora.23" + return 0 + fi + if [ "$(cat /etc/*-release | grep -cim1 24)" -eq 1 ]; then + echo "fedora.24" + return 0 + fi + elif [ "$(cat /etc/*-release | grep -cim1 opensuse)" -eq 1 ]; then + if [ "$(cat /etc/*-release | grep -cim1 13.2)" -eq 1 ]; then + echo "opensuse.13.2" + return 0 + fi + if [ "$(cat /etc/*-release | grep -cim1 42.1)" -eq 1 ]; then + echo "opensuse.42.1" + return 0 + fi + fi + # Cannot determine Linux distribution, assuming Ubuntu 14.04. + echo "ubuntu" + return 0 +} + +if [ -z "$__DOTNET_PKG" ]; then +OSName=$(uname -s) + case $OSName in + Darwin) + OS=OSX + __DOTNET_PKG=dotnet-dev-osx-x64 + ulimit -n 2048 + ;; + + Linux) + __DOTNET_PKG="dotnet-dev-$(get_current_linux_name)-x64" + OS=Linux + ;; + + *) + echo "Unsupported OS '$OSName' detected. Downloading ubuntu-x64 tools." + OS=Linux + __DOTNET_PKG=dotnet-dev-ubuntu-x64 + ;; + esac +fi if [ ! -e $__INIT_TOOLS_DONE_MARKER ]; then if [ -e $__TOOLRUNTIME_DIR ]; then rm -rf -- $__TOOLRUNTIME_DIR; fi echo "Running: $__scriptpath/init-tools.sh" > $__init_tools_log if [ ! -e $__DOTNET_PATH ]; then echo "Installing dotnet cli..." - __DOTNET_LOCATION="https://dotnetcli.blob.core.windows.net/dotnet/beta/Binaries/${__DOTNET_TOOLS_VERSION}/${__DOTNET_PKG}.${__DOTNET_TOOLS_VERSION}.tar.gz" + __DOTNET_LOCATION="https://dotnetcli.blob.core.windows.net/dotnet/Sdk/${__DOTNET_TOOLS_VERSION}/${__DOTNET_PKG}.${__DOTNET_TOOLS_VERSION}.tar.gz" # curl has HTTPS CA trust-issues less often than wget, so lets try that first. echo "Installing '${__DOTNET_LOCATION}' to '$__DOTNET_PATH/dotnet.tar'" >> $__init_tools_log which curl > /dev/null 2> /dev/null @@ -60,12 +102,6 @@ if [ ! -e $__INIT_TOOLS_DONE_MARKER ]; then fi cd $__DOTNET_PATH tar -xf $__DOTNET_PATH/dotnet.tar - if [ -n "$BUILDTOOLS_OVERRIDE_RUNTIME" ]; then - find $__DOTNET_PATH -name *.ni.* | xargs rm 2>/dev/null - cp -R $BUILDTOOLS_OVERRIDE_RUNTIME/* $__DOTNET_PATH/bin - cp -R $BUILDTOOLS_OVERRIDE_RUNTIME/* $__DOTNET_PATH/bin/dnx - cp -R $BUILDTOOLS_OVERRIDE_RUNTIME/* $__DOTNET_PATH/runtime/coreclr - fi cd $__scriptpath fi @@ -77,7 +113,7 @@ if [ ! -e $__INIT_TOOLS_DONE_MARKER ]; then echo "Restoring BuildTools version $__BUILD_TOOLS_PACKAGE_VERSION..." echo "Running: $__DOTNET_CMD restore \"$__PROJECT_JSON_FILE\" --no-cache --packages $__PACKAGES_DIR --source $__BUILDTOOLS_SOURCE" >> $__init_tools_log $__DOTNET_CMD restore "$__PROJECT_JSON_FILE" --no-cache --packages $__PACKAGES_DIR --source $__BUILDTOOLS_SOURCE >> $__init_tools_log - if [ ! -e "$__BUILD_TOOLS_PATH/init-tools.sh" ]; then echo "ERROR: Could not restore build tools correctly. See '$__init_tools_log' for more details."; fi + if [ ! -e "$__BUILD_TOOLS_PATH/init-tools.sh" ]; then echo "ERROR: Could not restore build tools correctly. See '$__init_tools_log' for more details."1>&2; fi fi echo "Initializing BuildTools..." diff --git a/src/BuildIntegration/Microsoft.NETCore.Native.Unix.targets b/src/BuildIntegration/Microsoft.NETCore.Native.Unix.targets new file mode 100644 index 000000000..cc4a4c2ce --- /dev/null +++ b/src/BuildIntegration/Microsoft.NETCore.Native.Unix.targets @@ -0,0 +1,72 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +*********************************************************************************************** +Microsoft.NETCore.Native.targets + +WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have + created a backup copy. Incorrect changes to this file will make it + impossible to load or build your projects from the command-line or the IDE. + +This file defines the steps in the build process specific for native AOT compilation. + +Licensed to the .NET Foundation under one or more agreements. +The .NET Foundation licenses this file to you under the MIT license. +See the LICENSE file in the project root for more information. +*********************************************************************************************** +--> +<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + + <Target Name="CppCompile" + Inputs="$(IlcCompileOutput)" + Outputs="$(NativeObject)" + DependsOnTargets="IlcCompile"> + + <ItemGroup> + <CppCompilerAndLinkerArg Include="-I $(IlcPath)/inc" /> + <CppCompilerAndLinkerArg Include="$(IlcCompileOutput)" /> + <CppCompilerAndLinkerArg Include="-o $(NativeObject)" /> + <CppCompilerAndLinkerArg Condition="'$(Configuration)' == 'Debug'" Include="-O0" /> + <CppCompilerAndLinkerArg Condition="'$(Configuration)' != 'Debug'" Include="-O2" /> + <CppCompilerAndLinkerArg Include="-c -Wno-invalid-offsetof" /> + <CppCompilerAndLinkerArg Include="$(AdditionalCppCompilerFlags)" /> + </ItemGroup> + + <Exec Command="$(CppCompilerAndLinker) @(CppCompilerAndLinkerArg, ' ')"> + </Exec> + </Target> + + <Target Name="LinkNative" + Inputs="$(NativeObject)" + Outputs="$(NativeBinary)" + DependsOnTargets="$(LinkNativeDependsOn)"> + + <ItemGroup> + <NativeLibrary Condition="$(NativeCodeGen) == ''" Include="$(IlcPath)/sdk/libbootstrapper.a" /> + <NativeLibrary Condition="$(NativeCodeGen) == ''" Include="$(IlcPath)/sdk/libRuntime.a" /> + <NativeLibrary Condition="$(NativeCodeGen) == 'cpp'" Include="$(IlcPath)/sdk/libbootstrappercpp.a" /> + <NativeLibrary Condition="$(NativeCodeGen) == 'cpp'" Include="$(IlcPath)/sdk/libPortableRuntime.a" /> + <NativeLibrary Include="$(IlcPath)/sdk/libSystem.Private.CoreLib.Native.a" /> + <NativeLibrary Include="$(IlcPath)/framework/System.Native.a" /> + </ItemGroup> + + <ItemGroup> + <LinkerArg Include="$(NativeObject)" /> + <LinkerArg Include="@(NativeLibrary)" /> + <LinkerArg Include="-o $(NativeBinary)" /> + <LinkerArg Include="-g" /> + <LinkerArg Include="-pthread" /> + <LinkerArg Include="-lstdc++" /> + <LinkerArg Include="-ldl" /> + <LinkerArg Include="-lm" /> + <LinkerArg Include="-lrt" Condition="'$(TargetOS)' != 'OSX'" /> + <LinkerArg Include="-lunwind-x86_64" Condition="'$(TargetOS)' != 'OSX'" /> + </ItemGroup> + + <MakeDir Directories="$([System.IO.Path]::GetDirectoryName($(NativeBinary)))" /> + + <Exec Command="$(CppCompilerAndLinker) @(LinkerArg, ' ')"> + </Exec> + + </Target> + +</Project> diff --git a/src/BuildIntegration/Microsoft.NETCore.Native.Windows.targets b/src/BuildIntegration/Microsoft.NETCore.Native.Windows.targets new file mode 100644 index 000000000..67ce56a2c --- /dev/null +++ b/src/BuildIntegration/Microsoft.NETCore.Native.Windows.targets @@ -0,0 +1,96 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +*********************************************************************************************** +Microsoft.NETCore.Native.Windows.targets + +WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have + created a backup copy. Incorrect changes to this file will make it + impossible to load or build your projects from the command-line or the IDE. + +This file defines Windows-specific steps in the build process for native AOT compilation. + +Licensed to the .NET Foundation under one or more agreements. +The .NET Foundation licenses this file to you under the MIT license. +See the LICENSE file in the project root for more information. +*********************************************************************************************** +--> +<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + + <Target Name="CppCompile" + Inputs="$(IlcCompileOutput)" + Outputs="$(NativeObject)" + DependsOnTargets="IlcCompile"> + + <ItemGroup> + <CppCompilerAndLinkerArg Include="/I$(IlcPath)\inc" /> + <CppCompilerAndLinkerArg Include="$(IlcCompileOutput)" /> + <CppCompilerAndLinkerArg Include="/Fo$(NativeObject)" /> + <CppCompilerAndLinkerArg Condition="'$(Configuration)' == 'Debug'" Include="/Od" /> + <CppCompilerAndLinkerArg Condition="'$(Configuration)' != 'Debug'" Include="/O2" /> + <CppCompilerAndLinkerArg Include="/c /nologo /W3 /GS /DCPPCODEGEN /EHs /MT /Zi" /> + <CppCompilerAndLinkerArg Include="$(AdditionalCppCompilerFlags)" /> + </ItemGroup> + + <MakeDir Directories="$(NativeIntermediateOutputPath)" /> + <WriteLinesToFile File="$(NativeIntermediateOutputPath)cl.rsp" Lines="@(CppCompilerAndLinkerArg)" Overwrite="true" /> + + <Exec Command="cl @"$(NativeIntermediateOutputPath)cl.rsp""> + </Exec> + </Target> + + <Target Name="LinkNative" + Inputs="$(NativeObject)" + Outputs="$(NativeBinary)" + DependsOnTargets="$(LinkNativeDependsOn)"> + + <ItemGroup> + <NativeLibrary Condition="$(NativeCodeGen) == ''" Include="$(IlcPath)\sdk\bootstrapper.lib" /> + <NativeLibrary Condition="$(NativeCodeGen) == ''" Include="$(IlcPath)\sdk\Runtime.lib" /> + <NativeLibrary Condition="$(NativeCodeGen) == 'cpp'" Include="$(IlcPath)\sdk\bootstrappercpp.lib" /> + <NativeLibrary Condition="$(NativeCodeGen) == 'cpp'" Include="$(IlcPath)\sdk\PortableRuntime.lib" /> + </ItemGroup> + + <ItemGroup> + <DefaultLibrary Include="kernel32.lib" /> + <DefaultLibrary Include="user32.lib" /> + <DefaultLibrary Include="gdi32.lib" /> + <DefaultLibrary Include="winspool.lib" /> + <DefaultLibrary Include="comdlg32.lib" /> + <DefaultLibrary Include="advapi32.lib" /> + <DefaultLibrary Include="shell32.lib" /> + <DefaultLibrary Include="ole32.lib" /> + <DefaultLibrary Include="oleaut32.lib" /> + <DefaultLibrary Include="uuid.lib" /> + <DefaultLibrary Include="odbc32.lib" /> + <DefaultLibrary Include="odbccp32.lib" /> + </ItemGroup> + + <ItemGroup> + <LinkerArg Include="$(NativeObject)" /> + <LinkerArg Include="@(NativeLibrary)" /> + <LinkerArg Include="@(DefaultLibrary)" /> + <LinkerArg Include="/OUT:$(NativeBinary)" /> + <LinkerArg Include="/NOLOGO /DEBUG /MANIFEST:NO" /> + </ItemGroup> + + <ItemGroup> + <!-- TODO <LinkerArg Include="/MACHINE:X64" /> --> + </ItemGroup> + + <ItemGroup Condition="'$(Configuration)' != 'Debug'"> + <LinkerArg Include="/INCREMENTAL:NO" /> + <LinkerArg Include="/OPT:REF" /> + <LinkerArg Include="/OPT:ICF" /> + </ItemGroup> + + <MakeDir Directories="$(NativeIntermediateOutputPath)" /> + <WriteLinesToFile File="$(NativeIntermediateOutputPath)link.rsp" Lines="@(LinkerArg)" Overwrite="true" /> + + <MakeDir Directories="$([System.IO.Path]::GetDirectoryName($(NativeBinary)))" /> + + <Exec Command="link @"$(NativeIntermediateOutputPath)link.rsp""> + </Exec> + + </Target> + +</Project> diff --git a/src/BuildIntegration/Microsoft.NETCore.Native.targets b/src/BuildIntegration/Microsoft.NETCore.Native.targets new file mode 100644 index 000000000..37ccbcdea --- /dev/null +++ b/src/BuildIntegration/Microsoft.NETCore.Native.targets @@ -0,0 +1,84 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +*********************************************************************************************** +Microsoft.NETCore.Native.targets + +WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have + created a backup copy. Incorrect changes to this file will make it + impossible to load or build your projects from the command-line or the IDE. + +This file defines the steps in the build process for native AOT compilation. + +Licensed to the .NET Foundation under one or more agreements. +The .NET Foundation licenses this file to you under the MIT license. +See the LICENSE file in the project root for more information. +*********************************************************************************************** +--> +<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + + <!-- Set defaults for unspecified properties --> + <PropertyGroup> + <NativeIntermediateOutputPath Condition="'$(NativeIntermediateOutputPath)' == ''">$(IntermediateOutputPath)native\</NativeIntermediateOutputPath> + <NativeOutputPath Condition="'$(NativeOutputPath)' == ''">$(OutputPath)native\</NativeOutputPath> + <TargetOS Condition="'$(TargetOS)' == ''">$(OS)</TargetOS> + </PropertyGroup> + + <PropertyGroup> + <NativeObjectExt Condition="'$(TargetOS)' == 'Windows_NT'">.obj</NativeObjectExt> + <NativeObjectExt Condition="'$(TargetOS)' != 'Windows_NT'">.o</NativeObjectExt> + + <NativeBinaryExt Condition="'$(OutputType)' == 'Exe' and '$(TargetOS)' == 'Windows_NT'">.exe</NativeBinaryExt> + <NativeBinaryExt Condition="'$(OutputType)' == 'Exe' and '$(TargetOS)' != 'Windows_NT'"></NativeBinaryExt> + <NativeBinaryExt Condition="'$(OutputType)' != 'Exe' and '$(TargetOS)' == 'Windows_NT'">.dll</NativeBinaryExt> + <NativeBinaryExt Condition="'$(OutputType)' != 'Exe' and '$(TargetOS)' == 'OSX'">.dylib</NativeBinaryExt> + <NativeBinaryExt Condition="'$(OutputType)' != 'Exe' and '$(TargetOS)' != 'Windows_NT' and '$(TargetOS)' != 'OSX'">.so</NativeBinaryExt> + + <ManagedBinary>$(IntermediateOutputPath)$(TargetName)$(TargetExt)</ManagedBinary> + <NativeObject>$(NativeIntermediateOutputPath)$(TargetName)$(NativeObjectExt)</NativeObject> + <NativeBinary>$(NativeOutputPath)$(TargetName)$(NativeBinaryExt)</NativeBinary> + + <IlcCompileOutput Condition="$(NativeCodeGen) == ''">$(NativeObject)</IlcCompileOutput> + <IlcCompileOutput Condition="$(NativeCodeGen) == 'cpp'">$(NativeIntermediateOutputPath)$(TargetName).cpp</IlcCompileOutput> + <LinkNativeDependsOn Condition="$(NativeCodeGen) == ''">IlcCompile</LinkNativeDependsOn> + <LinkNativeDependsOn Condition="$(NativeCodeGen) == 'cpp'">CppCompile</LinkNativeDependsOn> + + <CppCompilerAndLinker Condition="'$(CppCompilerAndLinker)' == '' and '$(TargetOS)' == 'OSX'">clang</CppCompilerAndLinker> + <CppCompilerAndLinker Condition="'$(CppCompilerAndLinker)' == ''">clang-3.5</CppCompilerAndLinker> + </PropertyGroup> + + <Target Name="IlcCompile" + Inputs="$(ManagedBinary)" + Outputs="$(IlcCompileOutput)" + DependsOnTargets="Compile"> + + <ItemGroup> + <IlcReference Include="$(IlcPath)\sdk\*.dll" /> + <IlcReference Include="$(IlcPath)\framework\*.dll" /> + </ItemGroup> + + <ItemGroup> + <IlcArg Include="$(ManagedBinary)" /> + <IlcArg Include="-o:$(IlcCompileOutput)" /> + <IlcArg Include="@(IlcReference->'-r:%(Identity)')" /> + <IlcArg Condition="$(NativeCodeGen) != ''" Include="--$(NativeCodeGen)" /> + </ItemGroup> + + <MakeDir Directories="$(NativeIntermediateOutputPath)" /> + <WriteLinesToFile File="$(NativeIntermediateOutputPath)ilc.rsp" Lines="@(IlcArg)" Overwrite="true" /> + + <MakeDir Directories="$([System.IO.Path]::GetDirectoryName($(NativeObject)))" /> + + <PropertyGroup> + <TestHost Condition="'$(OS)' == 'Windows_NT'">CoreRun.exe</TestHost> + <TestHost Condition="'$(OS)' != 'Windows_NT'">corerun</TestHost> + </PropertyGroup> + + <Exec Command=""$(IlcPath)\$(TestHost)" "$(IlcPath)\ilc.exe" @"$(NativeIntermediateOutputPath)ilc.rsp""> + </Exec> + + </Target> + + <Import Project="Microsoft.NETCore.Native.Windows.targets" Condition="'$(TargetOS)' == 'Windows_NT'" /> + <Import Project="Microsoft.NETCore.Native.Unix.targets" Condition="'$(TargetOS)' != 'Windows_NT'" /> + +</Project> diff --git a/src/Common/src/TypeSystem/Common/ArrayType.cs b/src/Common/src/TypeSystem/Common/ArrayType.cs index 3dbd00b85..384e487d2 100644 --- a/src/Common/src/TypeSystem/Common/ArrayType.cs +++ b/src/Common/src/TypeSystem/Common/ArrayType.cs @@ -118,8 +118,12 @@ namespace Internal.TypeSystem public override TypeDesc InstantiateSignature(Instantiation typeInstantiation, Instantiation methodInstantiation) { - TypeDesc instantiatedElementType = this.ElementType.InstantiateSignature(typeInstantiation, methodInstantiation); - return instantiatedElementType.Context.GetArrayType(instantiatedElementType, _rank); + TypeDesc elementType = this.ElementType; + TypeDesc instantiatedElementType = elementType.InstantiateSignature(typeInstantiation, methodInstantiation); + if (instantiatedElementType != elementType) + return Context.GetArrayType(instantiatedElementType, _rank); + + return this; } protected override TypeFlags ComputeTypeFlags(TypeFlags mask) diff --git a/src/Common/src/TypeSystem/Common/ByRefType.cs b/src/Common/src/TypeSystem/Common/ByRefType.cs index 55aa33f44..7fb07fb5f 100644 --- a/src/Common/src/TypeSystem/Common/ByRefType.cs +++ b/src/Common/src/TypeSystem/Common/ByRefType.cs @@ -21,8 +21,12 @@ namespace Internal.TypeSystem public override TypeDesc InstantiateSignature(Instantiation typeInstantiation, Instantiation methodInstantiation) { - TypeDesc instantiatedParameterType = this.ParameterType.InstantiateSignature(typeInstantiation, methodInstantiation); - return instantiatedParameterType.MakeByRefType(); + TypeDesc parameterType = this.ParameterType; + TypeDesc instantiatedParameterType = parameterType.InstantiateSignature(typeInstantiation, methodInstantiation); + if (instantiatedParameterType != parameterType) + return Context.GetByRefType(instantiatedParameterType); + + return this; } protected override TypeFlags ComputeTypeFlags(TypeFlags mask) diff --git a/src/Common/src/TypeSystem/Common/FieldDesc.cs b/src/Common/src/TypeSystem/Common/FieldDesc.cs index e7478d7e7..ce491302d 100644 --- a/src/Common/src/TypeSystem/Common/FieldDesc.cs +++ b/src/Common/src/TypeSystem/Common/FieldDesc.cs @@ -9,7 +9,7 @@ using Debug = System.Diagnostics.Debug; namespace Internal.TypeSystem { - public abstract partial class FieldDesc + public abstract partial class FieldDesc : TypeSystemEntity { public readonly static FieldDesc[] EmptyFields = new FieldDesc[0]; @@ -34,11 +34,6 @@ namespace Internal.TypeSystem } } - public abstract TypeSystemContext Context - { - get; - } - public abstract DefType OwningType { get; diff --git a/src/Common/src/TypeSystem/Common/InstantiatedMethod.cs b/src/Common/src/TypeSystem/Common/InstantiatedMethod.cs index dd00ff20b..a163319f2 100644 --- a/src/Common/src/TypeSystem/Common/InstantiatedMethod.cs +++ b/src/Common/src/TypeSystem/Common/InstantiatedMethod.cs @@ -147,8 +147,7 @@ namespace Internal.TypeSystem { var sb = new StringBuilder(_methodDef.ToString()); sb.Append('<'); - for (int i = 0; i < _instantiation.Length; i++) - sb.Append(_instantiation[i].ToString()); + sb.Append(_instantiation.ToString()); sb.Append('>'); return sb.ToString(); } diff --git a/src/Common/src/TypeSystem/Common/InstantiatedType.cs b/src/Common/src/TypeSystem/Common/InstantiatedType.cs index ebc2c75d7..37fd2f93a 100644 --- a/src/Common/src/TypeSystem/Common/InstantiatedType.cs +++ b/src/Common/src/TypeSystem/Common/InstantiatedType.cs @@ -263,8 +263,7 @@ namespace Internal.TypeSystem { var sb = new StringBuilder(_typeDef.ToString()); sb.Append('<'); - for (int i = 0; i < _instantiation.Length; i++) - sb.Append(_instantiation[i].ToString()); + sb.Append(_instantiation.ToString()); sb.Append('>'); return sb.ToString(); } diff --git a/src/Common/src/TypeSystem/Common/Instantiation.cs b/src/Common/src/TypeSystem/Common/Instantiation.cs index d1c7f053c..11038a6a3 100644 --- a/src/Common/src/TypeSystem/Common/Instantiation.cs +++ b/src/Common/src/TypeSystem/Common/Instantiation.cs @@ -2,7 +2,9 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System; using System.Runtime.CompilerServices; +using System.Text; namespace Internal.TypeSystem { @@ -60,6 +62,21 @@ namespace Internal.TypeSystem return new Enumerator(_genericParameters); } + public override string ToString() + { + if (_genericParameters == null) + return String.Empty; + + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < _genericParameters.Length; i++) + { + if (i > 0) + sb.Append(", "); + sb.Append(_genericParameters[i]); + } + return sb.ToString(); + } + /// <summary> /// Enumerator for iterating over the types in an instantiation /// </summary> diff --git a/src/Common/src/TypeSystem/Common/MethodDesc.cs b/src/Common/src/TypeSystem/Common/MethodDesc.cs index 7dff64b57..d732de343 100644 --- a/src/Common/src/TypeSystem/Common/MethodDesc.cs +++ b/src/Common/src/TypeSystem/Common/MethodDesc.cs @@ -209,7 +209,7 @@ namespace Internal.TypeSystem /// <summary> /// Represents the fundamental base type for all methods within the type system. /// </summary> - public abstract partial class MethodDesc + public abstract partial class MethodDesc : TypeSystemEntity { public readonly static MethodDesc[] EmptyMethods = new MethodDesc[0]; @@ -261,14 +261,6 @@ namespace Internal.TypeSystem } /// <summary> - /// Gets the type system context this method belongs to. - /// </summary> - public abstract TypeSystemContext Context - { - get; - } - - /// <summary> /// Gets the type that owns this method. This will be a <see cref="DefType"/> or /// an <see cref="ArrayType"/>. /// </summary> diff --git a/src/Common/src/TypeSystem/Common/ModuleDesc.cs b/src/Common/src/TypeSystem/Common/ModuleDesc.cs index 78b9f0a32..4d06abb7a 100644 --- a/src/Common/src/TypeSystem/Common/ModuleDesc.cs +++ b/src/Common/src/TypeSystem/Common/ModuleDesc.cs @@ -6,15 +6,11 @@ using System.Collections.Generic; namespace Internal.TypeSystem { - public abstract partial class ModuleDesc + public abstract partial class ModuleDesc : TypeSystemEntity { - /// <summary> - /// Gets the type system context the module belongs to. - /// </summary> - public TypeSystemContext Context + public override TypeSystemContext Context { get; - private set; } public ModuleDesc(TypeSystemContext context) diff --git a/src/Common/src/TypeSystem/Common/PointerType.cs b/src/Common/src/TypeSystem/Common/PointerType.cs index 468c2e227..dd1751823 100644 --- a/src/Common/src/TypeSystem/Common/PointerType.cs +++ b/src/Common/src/TypeSystem/Common/PointerType.cs @@ -21,8 +21,12 @@ namespace Internal.TypeSystem public override TypeDesc InstantiateSignature(Instantiation typeInstantiation, Instantiation methodInstantiation) { - TypeDesc instantiatedParameterType = this.ParameterType.InstantiateSignature(typeInstantiation, methodInstantiation); - return instantiatedParameterType.Context.GetPointerType(instantiatedParameterType); + TypeDesc parameterType = this.ParameterType; + TypeDesc instantiatedParameterType = parameterType.InstantiateSignature(typeInstantiation, methodInstantiation); + if (instantiatedParameterType != parameterType) + return Context.GetPointerType(instantiatedParameterType); + + return this; } protected override TypeFlags ComputeTypeFlags(TypeFlags mask) diff --git a/src/Common/src/TypeSystem/Common/TypeDesc.cs b/src/Common/src/TypeSystem/Common/TypeDesc.cs index aaafd8080..42c5e5781 100644 --- a/src/Common/src/TypeSystem/Common/TypeDesc.cs +++ b/src/Common/src/TypeSystem/Common/TypeDesc.cs @@ -12,7 +12,7 @@ namespace Internal.TypeSystem /// <summary> /// Represents the fundamental base type of all types within the type system. /// </summary> - public abstract partial class TypeDesc + public abstract partial class TypeDesc : TypeSystemEntity { public static readonly TypeDesc[] EmptyTypes = new TypeDesc[0]; @@ -47,14 +47,6 @@ namespace Internal.TypeSystem private TypeFlags _typeFlags; /// <summary> - /// Gets the type system context this type belongs to. - /// </summary> - public abstract TypeSystemContext Context - { - get; - } - - /// <summary> /// Gets the generic instantiation information of this type. /// For generic definitions, retrieves the generic parameters of the type. /// For generic instantiation, retrieves the generic arguments of the type. diff --git a/src/Common/src/TypeSystem/Common/TypeSystemEntity.cs b/src/Common/src/TypeSystem/Common/TypeSystemEntity.cs new file mode 100644 index 000000000..ad3d3739d --- /dev/null +++ b/src/Common/src/TypeSystem/Common/TypeSystemEntity.cs @@ -0,0 +1,14 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Internal.TypeSystem +{ + public abstract class TypeSystemEntity + { + /// <summary> + /// Gets the type system context this entity belongs to. + /// </summary> + public abstract TypeSystemContext Context { get; } + } +} diff --git a/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/CppCodegenNodeFactory.cs b/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/CppCodegenNodeFactory.cs index 46189b1d3..be94a5ad4 100644 --- a/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/CppCodegenNodeFactory.cs +++ b/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/CppCodegenNodeFactory.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System; - +using ILCompiler.DependencyAnalysisFramework; using Internal.TypeSystem; namespace ILCompiler.DependencyAnalysis @@ -15,6 +15,12 @@ namespace ILCompiler.DependencyAnalysis { } + public override void AttachToDependencyGraph(DependencyAnalysisFramework.DependencyAnalyzerBase<NodeFactory> graph) + { + AddWellKnownTypes(graph); + base.AttachToDependencyGraph(graph); + } + protected override IMethodNode CreateMethodEntrypointNode(MethodDesc method) { if (CompilationModuleGroup.ContainsMethod(method)) @@ -38,5 +44,33 @@ namespace ILCompiler.DependencyAnalysis // TODO: this is wrong: this returns an assembly stub node return new ReadyToRunHelperNode(helperCall.Item1, helperCall.Item2); } + + private void AddWellKnownType(WellKnownType wellKnownType, DependencyAnalysisFramework.DependencyAnalyzerBase<NodeFactory> graph) + { + var type = TypeSystemContext.GetWellKnownType(wellKnownType); + var typeNode = ConstructedTypeSymbol(type); + graph.AddRoot(typeNode, "Enables CPP codegen"); + } + private void AddWellKnownTypes(DependencyAnalysisFramework.DependencyAnalyzerBase<NodeFactory> graph) + { + + AddWellKnownType(WellKnownType.Void, graph); + AddWellKnownType(WellKnownType.Boolean, graph); + AddWellKnownType(WellKnownType.Char, graph); + AddWellKnownType(WellKnownType.SByte, graph); + AddWellKnownType(WellKnownType.Byte, graph); + AddWellKnownType(WellKnownType.Int16, graph); + AddWellKnownType(WellKnownType.UInt16, graph); + AddWellKnownType(WellKnownType.Int32, graph); + AddWellKnownType(WellKnownType.UInt32, graph); + AddWellKnownType(WellKnownType.Int64, graph); + AddWellKnownType(WellKnownType.UInt64, graph); + AddWellKnownType(WellKnownType.IntPtr, graph); + AddWellKnownType(WellKnownType.UIntPtr, graph); + AddWellKnownType(WellKnownType.Single, graph); + AddWellKnownType(WellKnownType.Double, graph); + + } + } } diff --git a/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/NodeFactory.cs b/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/NodeFactory.cs index 499edfbfb..b0dadc2d2 100644 --- a/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/NodeFactory.cs +++ b/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/NodeFactory.cs @@ -567,7 +567,7 @@ namespace ILCompiler.DependencyAnalysis public static NameMangler NameMangler; public static string CompilationUnitPrefix; - public void AttachToDependencyGraph(DependencyAnalysisFramework.DependencyAnalyzerBase<NodeFactory> graph) + public virtual void AttachToDependencyGraph(DependencyAnalysisFramework.DependencyAnalyzerBase<NodeFactory> graph) { ReadyToRunHeader = new ReadyToRunHeaderNode(Target); diff --git a/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/ObjectWriter.cs b/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/ObjectWriter.cs index 5a5592403..4d185f6fe 100644 --- a/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/ObjectWriter.cs +++ b/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/ObjectWriter.cs @@ -692,6 +692,8 @@ namespace ILCompiler.DependencyAnalysis if (node == null) continue; + // TODO: Remove the need for the skip check + // https://github.com/dotnet/corert/issues/1826 if (node.ShouldSkipEmittingObjectNode(factory)) continue; diff --git a/src/ILCompiler.Compiler/src/CppCodeGen/CppWriter.cs b/src/ILCompiler.Compiler/src/CppCodeGen/CppWriter.cs index ca91471b4..a0528138e 100644 --- a/src/ILCompiler.Compiler/src/CppCodeGen/CppWriter.cs +++ b/src/ILCompiler.Compiler/src/CppCodeGen/CppWriter.cs @@ -27,7 +27,6 @@ namespace ILCompiler.CppCodeGen { var type = _compilation.TypeSystemContext.GetWellKnownType(wellKnownType); var typeNode = _compilation.NodeFactory.ConstructedTypeSymbol(type); - AddWellKnownType(typeNode); _cppSignatureNames.Add(type, mangledSignatureName); } @@ -38,6 +37,8 @@ namespace ILCompiler.CppCodeGen _out = new StreamWriter(new FileStream(compilation.Options.OutputFilePath, FileMode.Create, FileAccess.Write, FileShare.Read, 4096, false)); + + // Unify this list with the one in CppCodegenNodeFactory SetWellKnownTypeSignatureName(WellKnownType.Void, "void"); SetWellKnownTypeSignatureName(WellKnownType.Boolean, "uint8_t"); SetWellKnownTypeSignatureName(WellKnownType.Char, "uint16_t"); @@ -79,17 +80,6 @@ namespace ILCompiler.CppCodeGen return mangledName; } - private List<IEETypeNode> _wellKnownTypeNodes; - - public void AddWellKnownType(IEETypeNode node) - { - if (_wellKnownTypeNodes == null) - { - _wellKnownTypeNodes = new List<IEETypeNode>(); - } - _wellKnownTypeNodes.Add(node); - } - // extern "C" methods are sometimes referenced via different signatures. // _externCSignatureMap contains the canonical signature of the extern "C" import. References // via other signatures are required to use casts. @@ -493,50 +483,6 @@ namespace ILCompiler.CppCodeGen } } - private void ExpandTypes() - { - _emittedTypes = new HashSet<TypeDesc>(); - foreach (var t in _cppSignatureNames.Keys.ToArray()) - { - ExpandType(t); - } - _emittedTypes = null; - } - - private void ExpandType(TypeDesc type) - { - if (_emittedTypes.Contains(type)) - return; - _emittedTypes.Add(type); - - GetCppSignatureTypeName(type); - var baseType = type.BaseType; - if (baseType != null) - { - ExpandType(baseType); - } - - foreach (var field in type.GetFields()) - { - ExpandType(GetFieldTypeOrPlaceholder(field)); - } - - if (type.IsDelegate) - { - MethodDesc method = type.GetKnownMethod("Invoke", null); - - var sig = method.Signature; - ExpandType(sig.ReturnType); - for (int i = 0; i < sig.Length; i++) - ExpandType(sig[i]); - } - - if (type.IsArray) - { - ExpandType(((ArrayType)type).ElementType); - } - } - private void OutputTypeFields(CppGenerationBuffer sb, TypeDesc t) { bool explicitLayout = false; @@ -618,6 +564,12 @@ namespace ILCompiler.CppCodeGen } } + private void OutputMethodDecl(CppGenerationBuffer sb, MethodDesc m) + { + sb.AppendLine(); + sb.Append(GetCppMethodDeclaration(m, false)); + } + private void AppendSlotTypeDef(CppGenerationBuffer sb, MethodDesc method) { MethodSignature methodSignature = method.Signature; @@ -664,7 +616,6 @@ namespace ILCompiler.CppCodeGen sb.Append(");"); } - private String GetCodeForDelegate(TypeDesc delegateType) { var sb = new CppGenerationBuffer(); @@ -698,28 +649,52 @@ namespace ILCompiler.CppCodeGen private String GetCodeForVirtualMethod(MethodDesc method, int slot) { var sb = new CppGenerationBuffer(); + sb.Indent(); - AppendSlotTypeDef(sb, method); + if (method.OwningType.IsInterface) + { - sb.AppendLine(); - sb.Append("static __slot__"); - sb.Append(GetCppMethodName(method)); - sb.Append(" __getslot__"); - sb.Append(GetCppMethodName(method)); - sb.Append("(void * pThis)"); - sb.AppendLine(); - sb.Append("{"); - sb.Indent(); - sb.AppendLine(); - sb.Append(" return (__slot__"); - sb.Append(GetCppMethodName(method)); - sb.Append(")*((void **)(*((RawEEType **)pThis) + 1) + "); - sb.Append(slot.ToStringInvariant()); - sb.Append(");"); + AppendSlotTypeDef(sb, method); + sb.Indent(); + sb.AppendLine(); + sb.Append("static uint16_t"); + sb.Append(" __getslot__"); + sb.Append(GetCppMethodName(method)); + sb.Append("(void * pThis)"); + sb.AppendLine(); + sb.Append("{"); + sb.Indent(); + sb.AppendLine(); + sb.Append("return "); + sb.Append(slot); + sb.Append(";"); + sb.AppendLine(); + } + else + { + AppendSlotTypeDef(sb, method); + sb.Indent(); + sb.AppendLine(); + sb.Append("static __slot__"); + sb.Append(GetCppMethodName(method)); + sb.Append(" __getslot__"); + sb.Append(GetCppMethodName(method)); + sb.Append("(void * pThis)"); + sb.AppendLine(); + sb.Append("{"); + sb.Indent(); + sb.AppendLine(); + sb.Append(" return (__slot__"); + sb.Append(GetCppMethodName(method)); + sb.Append(")*((void **)(*((RawEEType **)pThis) + 1) + "); + sb.Append(slot.ToStringInvariant()); + sb.Append(");"); + + } sb.Exdent(); sb.AppendLine(); sb.Append("};"); - + sb.Exdent(); return sb.ToString(); } @@ -787,8 +762,8 @@ namespace ILCompiler.CppCodeGen } } } - - nodeCode.Append("MethodTable * "); + string pointerType = node is EETypeNode ? "MethodTable * " : "void* "; + nodeCode.Append(pointerType); if (node is EETypeNode) { nodeCode.Append(GetCppMethodDeclarationName((node as EETypeNode).Type, "__getMethodTable")); @@ -809,65 +784,81 @@ namespace ILCompiler.CppCodeGen nodeCode.AppendLine(); nodeCode.Append("} mt = {"); - nodeCode.Append(GetCodeForNodeData(nodeDataSections, relocs, nodeData.Data, node, offset)); + nodeCode.Append(GetCodeForNodeData(nodeDataSections, relocs, nodeData.Data, node, offset, factory)); nodeCode.Append("};"); nodeCode.AppendLine(); - nodeCode.Append("return (MethodTable *)&mt;"); + nodeCode.Append("return ( "); + nodeCode.Append(pointerType); + nodeCode.Append(")&mt;"); nodeCode.Exdent(); nodeCode.AppendLine(); nodeCode.Append("}"); - + nodeCode.AppendLine(); return nodeCode.ToString(); } - - private String GetCodeForNodeData(List<NodeDataSection> nodeDataSections, Relocation[] relocs, byte[] byteData, DependencyNode node, int offset) + private String GetCodeForNodeData(List<NodeDataSection> nodeDataSections, Relocation[] relocs, byte[] byteData, DependencyNode node, int offset, NodeFactory factory) { CppGenerationBuffer nodeDataDecl = new CppGenerationBuffer(); int relocCounter = 0; int divisionStartIndex = offset; nodeDataDecl.Indent(); + nodeDataDecl.Indent(); nodeDataDecl.AppendLine(); for (int i = 0; i < nodeDataSections.Count; i++) { - nodeDataDecl.Indent(); - if (nodeDataSections[i].SectionType == NodeDataSectionType.Relocation) { Relocation reloc = relocs[relocCounter]; - if (reloc.Target is CppMethodCodeNode) - { - var method = reloc.Target as CppMethodCodeNode; - - nodeDataDecl.Append("(void*)&"); - nodeDataDecl.Append(GetCppMethodDeclarationName(method.Method.OwningType, GetCppMethodName(method.Method))); - nodeDataDecl.Append(","); - } - else if (reloc.Target is EETypeNode && node is EETypeNode && _emittedTypes.Contains((reloc.Target as EETypeNode).Type)) - { - nodeDataDecl.Append(GetCppMethodDeclarationName((reloc.Target as EETypeNode).Type, "__getMethodTable")); - nodeDataDecl.Append("(),"); - } - else - { - // TODO Add support for other relocs - nodeDataDecl.Append("NULL,"); - } + nodeDataDecl.Append(GetCodeForReloc(reloc, node, factory)); + nodeDataDecl.Append(","); relocCounter++; } else { - AppendFormattedByteArray(nodeDataDecl, byteData, divisionStartIndex, divisionStartIndex + nodeDataSections[i].SectionSize); + AppendFormattedByteArray(byteData, divisionStartIndex, divisionStartIndex + nodeDataSections[i].SectionSize, nodeDataDecl); nodeDataDecl.Append(","); } divisionStartIndex += nodeDataSections[i].SectionSize; nodeDataDecl.AppendLine(); - nodeDataDecl.Exdent(); } return nodeDataDecl.ToString(); } + private String GetCodeForReloc(Relocation reloc, DependencyNode node, NodeFactory factory) + { + CppGenerationBuffer relocCode = new CppGenerationBuffer(); + if (reloc.Target is CppMethodCodeNode) + { + var method = reloc.Target as CppMethodCodeNode; + + relocCode.Append("(void*)&"); + relocCode.Append(GetCppMethodDeclarationName(method.Method.OwningType, GetCppMethodName(method.Method))); + } + else if (reloc.Target is EETypeNode && node is EETypeNode && (reloc.Target as EETypeNode).Marked) + { + relocCode.Append(GetCppMethodDeclarationName((reloc.Target as EETypeNode).Type, "__getMethodTable")); + relocCode.Append("()"); + } + // Node is either an non-emitted type or a generic composition - both are ignored for CPP codegen + else if ((reloc.Target is ModuleManagerIndirectionNode || reloc.Target is InterfaceDispatchMapNode || reloc.Target is EETypeOptionalFieldsNode) && !(reloc.Target as ObjectNode).ShouldSkipEmittingObjectNode(factory)) + { + relocCode.Append(reloc.Target.MangledName); + relocCode.Append("()"); + } + else if (reloc.Target is ObjectAndOffsetSymbolNode && (reloc.Target as ObjectAndOffsetSymbolNode).GetName().Contains("DispatchMap")) + { + relocCode.Append("dispatchMapModule"); + } + else + { + relocCode.Append("NULL"); + + } + return relocCode.ToString(); + } + private String GetCodeForNodeStruct(List<NodeDataSection> nodeDataDivs, DependencyNode node) { CppGenerationBuffer nodeStructDecl = new CppGenerationBuffer(); @@ -900,7 +891,7 @@ namespace ILCompiler.CppCodeGen return nodeStructDecl.ToString(); } - private void AppendFormattedByteArray(CppGenerationBuffer sb, byte[] array, int startIndex, int endIndex) + private static void AppendFormattedByteArray(byte[] array, int startIndex, int endIndex, CppGenerationBuffer sb) { sb.Append("{"); sb.Append("0x"); @@ -952,37 +943,69 @@ namespace ILCompiler.CppCodeGen /// <param name="nodes">A set of dependency nodes</param> /// <param name="entrypoint">Code entrypoint</param> /// <param name="factory">Associated NodeFactory instance</param> - private void OutputNodes(IEnumerable<DependencyNode> nodes, NodeFactory factory) + /// <param name="definitions">Text buffer in which the type and method definitions will be written</param> + /// <param name="implementation">Text buffer in which the method implementations will be written</param> + public void OutputNodes(IEnumerable<DependencyNode> nodes, NodeFactory factory) { + CppGenerationBuffer dispatchPointers = new CppGenerationBuffer(); CppGenerationBuffer forwardDefinitions = new CppGenerationBuffer(); CppGenerationBuffer typeDefinitions = new CppGenerationBuffer(); CppGenerationBuffer methodTables = new CppGenerationBuffer(); - CppGenerationBuffer optionalFields = new CppGenerationBuffer(); - DependencyNodeIterator nodeIterator = new DependencyNodeIterator(nodes, factory); + CppGenerationBuffer rtrHeaderData = new CppGenerationBuffer(); + DependencyNodeIterator nodeIterator = new DependencyNodeIterator(nodes); - // Output well-known types to avoid build errors - if (_wellKnownTypeNodes != null) - { - foreach (var wellKnownTypeNode in _wellKnownTypeNodes) - { - OutputTypeNode(wellKnownTypeNode, factory, forwardDefinitions, typeDefinitions, methodTables); - } - } + // Number of InterfaceDispatchMapNodes needs to be declared explicitly for Ubuntu and OSX + int dispatchMapCount = 0; + dispatchPointers.AppendLine(); + dispatchPointers.Indent(); + + //RTR header needs to be declared after all modules have already been output + string rtrHeader = string.Empty; // Iterate through nodes foreach (var node in nodeIterator.GetNodes()) { - if (node is EETypeNode && !_emittedTypes.Contains(((EETypeNode)node).Type)) + if (node is EETypeNode) OutputTypeNode(node as EETypeNode, factory, forwardDefinitions, typeDefinitions, methodTables); + else if ((node is EETypeOptionalFieldsNode || node is ModuleManagerIndirectionNode) && !(node as ObjectNode).ShouldSkipEmittingObjectNode(factory)) + rtrHeaderData.Append(GetCodeForObjectNode(node as ObjectNode, factory)); + else if (node is InterfaceDispatchMapNode) + { + dispatchPointers.Append("(void *)"); + dispatchPointers.Append(node.GetName()); + dispatchPointers.Append("(),"); + dispatchPointers.AppendLine(); + dispatchMapCount++; + rtrHeaderData.Append(GetCodeForObjectNode(node as ObjectNode, factory)); - else if (node is EETypeOptionalFieldsNode) - optionalFields.Append(GetCodeForObjectNode(node as EETypeOptionalFieldsNode, factory)); + } + else if (node is ReadyToRunHeaderNode) + rtrHeader = GetCodeForReadyToRunHeader(node as ReadyToRunHeaderNode, factory); } + dispatchPointers.AppendLine(); + dispatchPointers.Exdent(); + Out.Write(forwardDefinitions.ToString()); + Out.Write(typeDefinitions.ToString()); + + Out.Write(rtrHeaderData.ToString()); + Out.Write(methodTables.ToString()); - Out.Write(optionalFields.ToString()); + + + + // Emit pointers to dispatch map nodes, to be used in interface dispatch + Out.Write("void * dispatchMapModule["); + Out.Write(dispatchMapCount); + Out.Write("] = {"); + Out.Write(dispatchPointers.ToString()); + Out.Write("};"); + + Out.Write(rtrHeader); + + } /// <summary> @@ -999,7 +1022,6 @@ namespace ILCompiler.CppCodeGen if (alternateName != null) { CppGenerationBuffer sb = new CppGenerationBuffer(); - sb.AppendLine(); sb.Append(GetCppMethodDeclaration(methodCodeNode.Method, true, alternateName)); sb.AppendLine(); @@ -1021,14 +1043,12 @@ namespace ILCompiler.CppCodeGen Out.Write(sb.ToString()); } } - private void OutputTypeNode(IEETypeNode typeNode, NodeFactory factory, CppGenerationBuffer forwardDefinitions, CppGenerationBuffer typeDefinitions, CppGenerationBuffer methodTable) { if (_emittedTypes == null) { _emittedTypes = new HashSet<TypeDesc>(); } - TypeDesc nodeType = typeNode.Type; if (nodeType.IsPointer || nodeType.IsByRef || _emittedTypes.Contains(nodeType)) return; @@ -1067,7 +1087,8 @@ namespace ILCompiler.CppCodeGen typeDefinitions.Append("class " + mangledName.Substring(current)); if (!nodeType.IsValueType) { - if (nodeType.BaseType != null) + // Don't emit inheritance if base type has not been marked for emission + if (nodeType.BaseType != null && _emittedTypes.Contains(nodeType.BaseType)) { typeDefinitions.Append(" : public " + GetCppTypeName(nodeType.BaseType)); } @@ -1086,6 +1107,8 @@ namespace ILCompiler.CppCodeGen } if (typeNode is ConstructedEETypeNode) { + OutputTypeFields(typeDefinitions, nodeType); + IReadOnlyList<MethodDesc> virtualSlots = _compilation.NodeFactory.VTable(nodeType).Slots; int baseSlots = 0; @@ -1111,25 +1134,22 @@ namespace ILCompiler.CppCodeGen typeDefinitions.Append(GetCodeForDelegate(nodeType)); } - OutputTypeFields(typeDefinitions, nodeType); if (nodeType.HasStaticConstructor) { _statics.AppendLine(); _statics.Append("bool __cctor_" + GetCppTypeName(nodeType).Replace("::", "__") + ";"); } - } - List<MethodDesc> methodList; - if (_methodLists.TryGetValue(nodeType, out methodList)) - { - foreach (var m in methodList) + List<MethodDesc> methodList; + if (_methodLists.TryGetValue(nodeType, out methodList)) { - typeDefinitions.AppendLine(); - typeDefinitions.Append(GetCppMethodDeclaration(m, false)); + foreach (var m in methodList) + { + OutputMethodDecl(typeDefinitions, m); + } } } - typeDefinitions.AppendEmptyLine(); typeDefinitions.Append("};"); typeDefinitions.AppendEmptyLine(); @@ -1151,11 +1171,48 @@ namespace ILCompiler.CppCodeGen methodTable.AppendEmptyLine(); } } + private String GetCodeForReadyToRunHeader(ReadyToRunHeaderNode headerNode, NodeFactory factory) + { + CppGenerationBuffer rtrHeader = new CppGenerationBuffer(); + rtrHeader.Append(GetCodeForObjectNode(headerNode, factory)); + rtrHeader.AppendLine(); + rtrHeader.Append("void* RtRHeaderWrapper() {"); + rtrHeader.Indent(); + rtrHeader.AppendLine(); + rtrHeader.Append("static struct {"); + rtrHeader.AppendLine(); + rtrHeader.Append("unsigned char leftPadding[8];"); + rtrHeader.AppendLine(); + rtrHeader.Append("void* rtrHeader;"); + rtrHeader.AppendLine(); + rtrHeader.Append("unsigned char rightPadding[8];"); + rtrHeader.AppendLine(); + rtrHeader.Append("} rtrHeaderWrapper = {"); + rtrHeader.Indent(); + rtrHeader.AppendLine(); + rtrHeader.Append("{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },"); + rtrHeader.AppendLine(); + rtrHeader.Append("(void*)"); + rtrHeader.Append(headerNode.GetName()); + rtrHeader.Append("(),"); + rtrHeader.AppendLine(); + rtrHeader.Append("{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }"); + rtrHeader.AppendLine(); + rtrHeader.Append("};"); + rtrHeader.Exdent(); + rtrHeader.AppendLine(); + rtrHeader.Append("return (void *)&rtrHeaderWrapper;"); + rtrHeader.Exdent(); + rtrHeader.AppendLine(); + rtrHeader.Append("}"); + rtrHeader.AppendLine(); + + return rtrHeader.ToString(); + } private void OutputExternCSignatures() { var sb = new CppGenerationBuffer(); - foreach (var externC in _externCSignatureMap) { string importName = externC.Key; @@ -1174,7 +1231,6 @@ namespace ILCompiler.CppCodeGen { var sb = new CppGenerationBuffer(); - // Stub for main method sb.AppendLine(); if (_compilation.TypeSystemContext.Target.OperatingSystem == TargetOS.Windows) { @@ -1200,6 +1256,8 @@ namespace ILCompiler.CppCodeGen sb.AppendEmptyLine(); sb.AppendLine(); + sb.Append("::System_Private_CoreLib::Internal::Runtime::CompilerHelpers::StartupCodeHelpers::InitializeModules((intptr_t)RtRHeaderWrapper(), 2);"); + sb.AppendLine(); sb.Append("int ret = "); sb.Append(GetCppMethodDeclarationName(entrypoint.OwningType, GetCppMethodName(entrypoint))); sb.Append("(argc, (intptr_t)argv);"); @@ -1215,7 +1273,6 @@ namespace ILCompiler.CppCodeGen sb.Exdent(); sb.AppendLine(); sb.Append("}"); - Out.Write(sb.ToString()); } @@ -1223,12 +1280,11 @@ namespace ILCompiler.CppCodeGen { BuildMethodLists(nodes); - ExpandTypes(); - Out.WriteLine("#include \"common.h\""); Out.WriteLine("#include \"CppCodeGen.h\""); Out.WriteLine(); + _statics = new CppGenerationBuffer(); _statics.Indent(); _gcStatics = new CppGenerationBuffer(); @@ -1263,9 +1319,9 @@ namespace ILCompiler.CppCodeGen if (entrypoint != null) { OutputMainMethodStub(entrypoint); - } + } Out.Dispose(); } } -} +}
\ No newline at end of file diff --git a/src/ILCompiler.Compiler/src/CppCodeGen/DependencyNodeIterator.cs b/src/ILCompiler.Compiler/src/CppCodeGen/DependencyNodeIterator.cs index d07aa878c..950398295 100644 --- a/src/ILCompiler.Compiler/src/CppCodeGen/DependencyNodeIterator.cs +++ b/src/ILCompiler.Compiler/src/CppCodeGen/DependencyNodeIterator.cs @@ -18,7 +18,7 @@ namespace ILCompiler.Compiler.CppCodeGen private HashSet<DependencyNode> _visited; private Dictionary<TypeDesc, EETypeNode> _typeToNodeMap; - public DependencyNodeIterator(IEnumerable<DependencyNode> nodes, NodeFactory factory) + public DependencyNodeIterator(IEnumerable<DependencyNode> nodes) { _nodes = new List<DependencyNode>(); _typeToNodeMap = new Dictionary<TypeDesc, EETypeNode>(); @@ -28,23 +28,11 @@ namespace ILCompiler.Compiler.CppCodeGen if (node is EETypeNode) { var typeNode = node as EETypeNode; - if (!_typeToNodeMap.ContainsKey(typeNode.Type)) _typeToNodeMap[typeNode.Type] = typeNode; else if (typeNode is ConstructedEETypeNode) _typeToNodeMap[typeNode.Type] = typeNode; } - else - if (node is CppMethodCodeNode) - { - // TODO: Remove once the type depedencies are tracked properly - // Ensure that there is going to be a forward type definition for the method containing type - var methodNode = node as CppMethodCodeNode; - - var methodType = methodNode.Method.OwningType; - if (!_typeToNodeMap.ContainsKey(methodType)) - _typeToNodeMap[methodType] = (EETypeNode)factory.NecessaryTypeSymbol(methodType); - } // Assume ordering doesn't matter else _nodes.Add(node); } diff --git a/src/ILCompiler.Compiler/src/CppCodeGen/ILToCppImporter.cs b/src/ILCompiler.Compiler/src/CppCodeGen/ILToCppImporter.cs index de2cb4d51..df7a96159 100644 --- a/src/ILCompiler.Compiler/src/CppCodeGen/ILToCppImporter.cs +++ b/src/ILCompiler.Compiler/src/CppCodeGen/ILToCppImporter.cs @@ -389,6 +389,15 @@ namespace Internal.IL } /// <summary> + /// Append the typedef of the method to assist in function pointer conversion + /// </summary> + /// <param name="method">Method typedef</param> + private void AppendInterfaceCallTypeDef(MethodDesc method, string name) + { + _writer.AppendSignatureTypeDef(_builder, name, method.Signature, method.Signature.ReturnType); + } + + /// <summary> /// Increase level of indentation by one in <see cref="_builder"/>. /// </summary> public void Indent() @@ -491,14 +500,9 @@ namespace Internal.IL AddTypeReference(returnType, true); } var owningType = methodCodeNodeNeedingCode.Method.OwningType; - if (methodCodeNodeNeedingCode.Method.IsNativeCallable || methodCodeNodeNeedingCode.Method.IsRuntimeExport || methodCodeNodeNeedingCode.Method.IsRuntimeImplemented) - { - AddTypeReference(owningType, true); - } - if (methodCodeNodeNeedingCode.Method.Signature.IsStatic) - { - AddTypeReference(owningType, true); - } + + AddTypeReference(owningType, true); + ImportBasicBlocks(); if (_sequencePoints != null && _sequencePoints[0].Document != null) @@ -860,6 +864,7 @@ namespace Internal.IL { bool callViaSlot = false; bool delegateInvoke = false; + bool callViaInterfaceDispatch = false; DelegateCreationInfo delegateInfo = null; MethodDesc method = (MethodDesc)_methodIL.GetObject(token); @@ -936,17 +941,18 @@ namespace Internal.IL if (!method.IsNewSlot) throw new NotImplementedException(); - // TODO: Interface calls if (method.OwningType.IsInterface) - throw new NotImplementedException(); + callViaInterfaceDispatch = true; + + else + callViaSlot = true; _dependencies.Add(_nodeFactory.VirtualMethodUse(method)); - callViaSlot = true; } } - if (!callViaSlot && !delegateInvoke) + if (!callViaSlot && !delegateInvoke && !callViaInterfaceDispatch) AddMethodReference(method); if (opcode == ILOpcode.newobj) @@ -961,6 +967,55 @@ namespace Internal.IL StackValueKind retKind = StackValueKind.Unknown; var needNewLine = false; + if (callViaInterfaceDispatch) + { + _dependencies.Add(_nodeFactory.ReadyToRunHelper(ReadyToRunHelperId.InterfaceDispatch, method)); + ExpressionEntry v = (ExpressionEntry)_stack[_stack.Top - (methodSignature.Length + 1)]; + + string typeDefName = _writer.GetCppMethodName(method); + _writer.AppendSignatureTypeDef(_builder, typeDefName, method.Signature, method.OwningType); + + string functionPtr = NewTempName(); + AppendEmptyLine(); + + Append("void*"); + Append(functionPtr); + Append(" = (void*) (("); + Append(typeDefName); + // Call method to find implementation address + Append(") System_Private_CoreLib::System::Runtime::DispatchResolve::FindInterfaceMethodImplementationTarget("); + + // Get EEType of current object (interface implementation) + Append("::System_Private_CoreLib::System::Object::get_EEType((::System_Private_CoreLib::System::Object*)"); + Append(v.Name); + Append(")"); + + Append(", "); + + // Get EEType of interface + Append("((::System_Private_CoreLib::Internal::Runtime::EEType *)("); + Append(_writer.GetCppTypeName(method.OwningType)); + Append("::__getMethodTable()))"); + + Append(", "); + + // Get slot of implementation + Append("(uint16_t)"); + Append("("); + Append(_writer.GetCppTypeName(method.OwningType)); + Append("::"); + Append("__getslot__"); + Append(_writer.GetCppMethodName(method)); + Append("("); + Append(v.Name); + Append("))"); + + Append("));"); + + PushExpression(StackValueKind.ByRef, functionPtr); + + } + if (!retType.IsVoid) { retKind = GetStackValueKind(retType); @@ -1048,6 +1103,15 @@ namespace Internal.IL v.Name + ")->m_firstParameter"; } } + else if (callViaInterfaceDispatch) + { + Append("(("); + Append(_writer.GetCppMethodName(method)); + Append(")"); + ExpressionEntry v = (ExpressionEntry)_stack.Pop(); + Append(v); + Append(")"); + } else { Append(_writer.GetCppTypeName(method.OwningType)); diff --git a/src/ILCompiler.Compiler/src/project.json b/src/ILCompiler.Compiler/src/project.json index 0e57fbe18..7d127b2aa 100644 --- a/src/ILCompiler.Compiler/src/project.json +++ b/src/ILCompiler.Compiler/src/project.json @@ -1,10 +1,9 @@ { "dependencies": { - "NETStandard.Library": "1.5.0-rc2-23911", - "System.IO.MemoryMappedFiles": "4.0.0-rc2-23911", - "System.Reflection.Metadata": "1.3.0-rc3-24102-00", - "System.Runtime.CompilerServices.Unsafe": "4.0.0-rc3-24102-00", - "System.Runtime.InteropServices": "4.1.0-rc3-24102-00" + "NETStandard.Library": "1.6.0", + "System.IO.MemoryMappedFiles": "4.0.0", + "System.Reflection.Metadata": "1.4.1-beta-24227-04", + "System.Runtime.CompilerServices.Unsafe": "4.0.0" }, "frameworks": { "netstandard1.3": {} diff --git a/src/ILCompiler.DependencyAnalysisFramework/src/project.json b/src/ILCompiler.DependencyAnalysisFramework/src/project.json index ebb55ba63..2b8ab126a 100644 --- a/src/ILCompiler.DependencyAnalysisFramework/src/project.json +++ b/src/ILCompiler.DependencyAnalysisFramework/src/project.json @@ -1,7 +1,8 @@ { "dependencies": { - "NETStandard.Library": "1.5.0-rc2-23911", - "System.Collections.Immutable": "1.2.0-rc2-23911" + "NETStandard.Library": "1.6.0", + "System.Xml.ReaderWriter": "4.0.11", + "System.Collections.Immutable": "1.2.0" }, "frameworks": { "netstandard1.3": {} diff --git a/src/ILCompiler.DependencyAnalysisFramework/tests/project.json b/src/ILCompiler.DependencyAnalysisFramework/tests/project.json index d6a59cc88..baa52a133 100644 --- a/src/ILCompiler.DependencyAnalysisFramework/tests/project.json +++ b/src/ILCompiler.DependencyAnalysisFramework/tests/project.json @@ -1,7 +1,7 @@ { "dependencies": { - "NETStandard.Library": "1.5.0-rc2-23911", - "System.Collections.Immutable": "1.2.0-rc2-23911", + "NETStandard.Library": "1.6.0", + "System.Collections.Immutable": "1.2.0", "xunit": "2.1.0", "test-runtime": { "target": "project", @@ -10,7 +10,10 @@ }, "frameworks": { "dnxcore50": { - "imports": "portable-net451+win8" + "imports": [ + "netstandard1.6", + "portable-net45+win8" + ] } }, "runtimes": { diff --git a/src/ILCompiler.MetadataTransform/src/project.json b/src/ILCompiler.MetadataTransform/src/project.json index 0cb1973fa..721bce5b4 100644 --- a/src/ILCompiler.MetadataTransform/src/project.json +++ b/src/ILCompiler.MetadataTransform/src/project.json @@ -1,7 +1,7 @@ { "dependencies": { - "NETStandard.Library": "1.5.0-rc2-23911", - "System.Reflection.Metadata": "1.3.0-rc3-24102-00" + "NETStandard.Library": "1.6.0", + "System.Reflection.Metadata": "1.4.1-beta-24227-04" }, "frameworks": { "netstandard1.3": {} diff --git a/src/ILCompiler.MetadataTransform/tests/project.json b/src/ILCompiler.MetadataTransform/tests/project.json index b46e3b8c1..645afdaaf 100644 --- a/src/ILCompiler.MetadataTransform/tests/project.json +++ b/src/ILCompiler.MetadataTransform/tests/project.json @@ -1,7 +1,7 @@ { "dependencies": { - "NETStandard.Library": "1.5.0-rc2-23911", - "System.Reflection.Metadata": "1.3.0-rc3-24102-00", + "NETStandard.Library": "1.6.0", + "System.Reflection.Metadata": "1.4.1-beta-24227-04", "xunit": "2.1.0", "test-runtime": { "target": "project", @@ -10,7 +10,10 @@ }, "frameworks": { "dnxcore50": { - "imports": "portable-net451+win8" + "imports": [ + "netstandard1.6", + "portable-net45+win8" + ] } }, "runtimes": { diff --git a/src/ILCompiler.MetadataWriter/src/project.json b/src/ILCompiler.MetadataWriter/src/project.json index 6f3e8fc80..e8c7d8ff7 100644 --- a/src/ILCompiler.MetadataWriter/src/project.json +++ b/src/ILCompiler.MetadataWriter/src/project.json @@ -1,6 +1,6 @@ { "dependencies": { - "NETStandard.Library": "1.5.0-rc2-23911" + "NETStandard.Library": "1.6.0" }, "frameworks": { "netstandard1.3": {} diff --git a/src/ILCompiler.TypeSystem/src/ILCompiler.TypeSystem.csproj b/src/ILCompiler.TypeSystem/src/ILCompiler.TypeSystem.csproj index 9e4b9a66b..66d960978 100644 --- a/src/ILCompiler.TypeSystem/src/ILCompiler.TypeSystem.csproj +++ b/src/ILCompiler.TypeSystem/src/ILCompiler.TypeSystem.csproj @@ -92,6 +92,9 @@ <Compile Include="..\..\Common\src\TypeSystem\Common\ModuleDesc.cs"> <Link>TypeSystem\Common\ModuleDesc.cs</Link> </Compile> + <Compile Include="..\..\Common\src\TypeSystem\Common\TypeSystemEntity.cs"> + <Link>TypeSystem\Common\TypeSystemEntity.cs</Link> + </Compile> <Compile Include="..\..\Common\src\TypeSystem\Common\Utilities\CustomAttributeTypeNameParser.cs"> <Link>Utilities\CustomAttributeTypeNameParser.cs</Link> </Compile> diff --git a/src/ILCompiler.TypeSystem/src/project.json b/src/ILCompiler.TypeSystem/src/project.json index d9c26bcee..e7a4be069 100644 --- a/src/ILCompiler.TypeSystem/src/project.json +++ b/src/ILCompiler.TypeSystem/src/project.json @@ -1,9 +1,9 @@ { "dependencies": { - "NETStandard.Library": "1.5.0-rc2-23911", - "System.IO.MemoryMappedFiles": "4.0.0-rc2-23911", - "System.Reflection.Metadata": "1.3.0-rc3-24102-00", - "Microsoft.DiaSymReader": "1.0.8-rc2-60325" + "NETStandard.Library": "1.6.0", + "System.IO.MemoryMappedFiles": "4.0.0", + "System.Reflection.Metadata": "1.4.1-beta-24227-04", + "Microsoft.DiaSymReader": "1.0.8" }, "frameworks": { "netstandard1.3": {} diff --git a/src/ILCompiler.TypeSystem/tests/project.json b/src/ILCompiler.TypeSystem/tests/project.json index d98647b09..34705dc8e 100644 --- a/src/ILCompiler.TypeSystem/tests/project.json +++ b/src/ILCompiler.TypeSystem/tests/project.json @@ -1,9 +1,9 @@ { "dependencies": { - "NETStandard.Library": "1.5.0-rc2-23911", - "System.Reflection.Metadata": "1.3.0-rc3-24102-00", + "NETStandard.Library": "1.6.0", + "System.Reflection.Metadata": "1.4.1-beta-24227-04", "xunit": "2.1.0", - "xunit.netcore.extensions": "1.0.0-prerelease-00231-07", + "xunit.netcore.extensions": "1.0.0-prerelease-00312-04", "test-runtime": { "target": "project", "exclude": "compile" @@ -11,7 +11,10 @@ }, "frameworks": { "dnxcore50": { - "imports": "portable-net451+win8" + "imports": [ + "netstandard1.6", + "portable-net45+win8" + ] } }, "runtimes": { diff --git a/src/ILCompiler/desktop/App.config b/src/ILCompiler/desktop/App.config deleted file mode 100644 index fbce4b6bc..000000000 --- a/src/ILCompiler/desktop/App.config +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<configuration> - <runtime> - <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> - <dependentAssembly> - <assemblyIdentity name="System.IO.UnmanagedMemoryStream" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> - <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /> - </dependentAssembly> - </assemblyBinding> - <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> - <dependentAssembly> - <assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> - <bindingRedirect oldVersion="0.0.0.0-1.2.0.0" newVersion="1.2.0.0" /> - </dependentAssembly> - </assemblyBinding> - <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> - <dependentAssembly> - <assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> - <bindingRedirect oldVersion="0.0.0.0-1.2.0.0" newVersion="1.2.0.0" /> - </dependentAssembly> - </assemblyBinding> - <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> - <dependentAssembly> - <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> - <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" /> - </dependentAssembly> - </assemblyBinding> - <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> - <dependentAssembly> - <assemblyIdentity name="System.IO.FileSystem" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> - <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" /> - </dependentAssembly> - </assemblyBinding> - </runtime> -</configuration>
\ No newline at end of file diff --git a/src/ILCompiler/desktop/desktop.csproj b/src/ILCompiler/desktop/desktop.csproj index af78d3394..a721c0ed7 100644 --- a/src/ILCompiler/desktop/desktop.csproj +++ b/src/ILCompiler/desktop/desktop.csproj @@ -52,7 +52,6 @@ </ProjectReference> </ItemGroup> <ItemGroup> - <None Include="App.config" /> <None Include="project.json" /> </ItemGroup> <ItemGroup> @@ -67,7 +66,7 @@ <Content Include="..\..\..\bin\Product\Windows_NT.$(Platform).$(Configuration)\packaging\publish1\objwriter.dll"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> - <Content Include="..\..\..\bin\Product\Windows_NT.$(Platform).$(Configuration)\packaging\publish1\clrjit.dll"> + <Content Include="..\..\..\bin\Product\Windows_NT.$(Platform).$(Configuration)\packaging\publish1\clrjitilc.dll"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> </ItemGroup> diff --git a/src/ILCompiler/desktop/project.json b/src/ILCompiler/desktop/project.json index 09cb009de..973eefdc7 100644 --- a/src/ILCompiler/desktop/project.json +++ b/src/ILCompiler/desktop/project.json @@ -1,11 +1,11 @@ { "dependencies": { - "NETStandard.Library": "1.5.0-rc2-23911", - "System.IO.MemoryMappedFiles": "4.0.0-rc2-23911", - "System.Reflection.Metadata": "1.3.0-rc3-24102-00", - "System.Runtime.CompilerServices.Unsafe": "4.0.0-rc3-24102-00", - "Microsoft.DiaSymReader": "1.0.8-rc2-60325", - "System.CommandLine": "0.1.0-e160514-1" + "NETStandard.Library": "1.6.0", + "System.IO.MemoryMappedFiles": "4.0.0", + "System.Reflection.Metadata": "1.4.1-beta-24227-04", + "System.Runtime.CompilerServices.Unsafe": "4.0.0", + "Microsoft.DiaSymReader": "1.0.8", + "System.CommandLine": "0.1.0-e160909-1" }, "frameworks": { "net46": {} diff --git a/src/ILCompiler/repro/project.json b/src/ILCompiler/repro/project.json index 271875a54..0d0563883 100644 --- a/src/ILCompiler/repro/project.json +++ b/src/ILCompiler/repro/project.json @@ -1,20 +1,8 @@ { - "version": "1.0.0-*", - "compilationOptions": { - "emitEntryPoint": true - }, - - "dependencies": { - "NETStandard.Library": "1.0.0-rc2-23819" - }, - - "frameworks": { - "dnxcore50": { } - }, - - "runtimes": { - "win7-x64": { }, - "osx.10.10-x64": { }, - "ubuntu.14.04-x64": { } - } + "dependencies": { + "NETStandard.Library": "1.6.0", + }, + "frameworks": { + "netstandard1.3": {} + } } diff --git a/src/ILCompiler/repro/repro.csproj b/src/ILCompiler/repro/repro.csproj index e70f8aeaf..23a532f20 100644 --- a/src/ILCompiler/repro/repro.csproj +++ b/src/ILCompiler/repro/repro.csproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="12.0" DefaultTargets="Build;CopyForRspFile" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> @@ -15,12 +15,12 @@ <ExcludeResourcesImport>true</ExcludeResourcesImport> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> - <OutputPath>bin\Debug\dnxcore50</OutputPath> + <OutputPath>bin\Debug</OutputPath> <ErrorReport>prompt</ErrorReport> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> - <OutputPath>bin\Release\dnxcore50</OutputPath> + <OutputPath>bin\Release</OutputPath> <ErrorReport>prompt</ErrorReport> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> </PropertyGroup> @@ -34,9 +34,5 @@ <None Include="project.json" /> </ItemGroup> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> - <Target Name="CopyForRspFile"> - <Copy - SourceFiles="bin\$(Configuration)\dnxcore50\repro.exe" - DestinationFiles="bin\$(Configuration)\dnxcore50\repro.dll" /> - </Target> + <Import Project="$(MSBuildThisFileDirectory)\..\..\BuildIntegration\Microsoft.NETCore.Native.targets" /> </Project> diff --git a/src/ILCompiler/reproNative/reproNative.vcxproj b/src/ILCompiler/reproNative/reproNative.vcxproj index 62229d93e..30801c28b 100644 --- a/src/ILCompiler/reproNative/reproNative.vcxproj +++ b/src/ILCompiler/reproNative/reproNative.vcxproj @@ -60,7 +60,7 @@ <Link> <SubSystem>Console</SubSystem> <GenerateDebugInformation>true</GenerateDebugInformation> - <AdditionalDependencies>..\repro\obj\Debug\dnxcore50\native\repro.obj;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);..\..\..\bin\Product\Windows_NT.x64.Debug\lib\Runtime.lib</AdditionalDependencies> + <AdditionalDependencies>..\..\..\bin\obj\Windows_NT.x64.Debug\repro\native\repro.obj;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);..\..\..\bin\Product\Windows_NT.x64.Debug\lib\Runtime.lib</AdditionalDependencies> </Link> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> @@ -82,7 +82,7 @@ <GenerateDebugInformation>true</GenerateDebugInformation> <EnableCOMDATFolding>true</EnableCOMDATFolding> <OptimizeReferences>true</OptimizeReferences> - <AdditionalDependencies>..\repro\obj\Release\dnxcore50\native\repro.obj;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);..\..\..\bin\Product\Windows_NT.x64.Release\lib\Runtime.lib</AdditionalDependencies> + <AdditionalDependencies>..\..\..\bin\obj\Windows_NT.x64.Release\repro\native\repro.obj;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);..\..\..\bin\Product\Windows_NT.x64.Release\lib\Runtime.lib</AdditionalDependencies> </Link> </ItemDefinitionGroup> <ItemGroup> diff --git a/src/ILCompiler/reproNative/reproNativeCpp.vcxproj b/src/ILCompiler/reproNative/reproNativeCpp.vcxproj index 2e6366140..71850dcd8 100644 --- a/src/ILCompiler/reproNative/reproNativeCpp.vcxproj +++ b/src/ILCompiler/reproNative/reproNativeCpp.vcxproj @@ -97,7 +97,7 @@ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader> </ClCompile> <ClCompile Include="..\..\Native\Bootstrap\main.cpp" /> - <ClCompile Include="..\repro\obj\Debug\dnxcore50\native\repro.cpp" /> + <ClCompile Include="..\..\..\bin\obj\Windows_NT.x64.Debug\repro\native\repro.cpp" /> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> diff --git a/src/ILCompiler/src/project.json b/src/ILCompiler/src/project.json index f9a16c881..2eee0ca7c 100644 --- a/src/ILCompiler/src/project.json +++ b/src/ILCompiler/src/project.json @@ -1,20 +1,9 @@ { "dependencies": { - "NETStandard.Library": "1.5.0-rc2-23911", - "System.CommandLine": "0.1.0-e160514-1", - "Microsoft.NETCore.Jit": "1.0.4-beta-24411-03", - "Microsoft.DotNet.ObjectWriter": "1.0.13-prerelease-00001" + "NETStandard.Library": "1.6.0", + "System.CommandLine": "0.1.0-e160909-1" }, "frameworks": { - "netstandard1.3": {} - }, - "runtimes": { - "win7-x86": {}, - "win7-x64": {}, - "ubuntu.14.04-x64": {}, - "osx.10.10-x64": {}, - "centos.7-x64": {}, - "rhel.7-x64": {}, - "debian.8.2-x64": {} + "netstandard1.6": {} } } diff --git a/src/JitInterface/src/CorInfoImpl.cs b/src/JitInterface/src/CorInfoImpl.cs index a0b9460b1..9b44180a2 100644 --- a/src/JitInterface/src/CorInfoImpl.cs +++ b/src/JitInterface/src/CorInfoImpl.cs @@ -29,10 +29,10 @@ namespace Internal.JitInterface private IntPtr _unmanagedCallbacks; // array of pointers to JIT-EE interface callbacks private Object _keepAlive; // Keeps delegates for the callbacks alive - [DllImport("clrjit")] + [DllImport("clrjitilc")] private extern static IntPtr jitStartup(IntPtr host); - [DllImport("clrjit")] + [DllImport("clrjitilc")] private extern static IntPtr getJit(); [DllImport("jitinterface")] @@ -2269,6 +2269,8 @@ namespace Internal.JitInterface // TODO: Generics // pResult.instParamLookup + + pResult._secureDelegateInvoke = 0; } [return: MarshalAs(UnmanagedType.Bool)] diff --git a/src/JitInterface/src/CorInfoTypes.cs b/src/JitInterface/src/CorInfoTypes.cs index 870467925..6a4778744 100644 --- a/src/JitInterface/src/CorInfoTypes.cs +++ b/src/JitInterface/src/CorInfoTypes.cs @@ -883,6 +883,9 @@ namespace Internal.JitInterface public uint offsetOfDelegateInstance; public uint offsetOfDelegateFirstTarget; + // Secure delegate offsets + public uint offsetOfSecureDelegateIndirectCell; + // Remoting offsets public uint offsetOfTransparentProxyRP; public uint offsetOfRealProxyServer; @@ -1037,11 +1040,13 @@ namespace Internal.JitInterface public CORINFO_THIS_TRANSFORM thisTransform; public CORINFO_CALL_KIND kind; + public uint _nullInstanceCheck; public bool nullInstanceCheck { get { return _nullInstanceCheck != 0; } set { _nullInstanceCheck = value ? (byte)1 : (byte)0; } } // Context for inlining and hidden arg public CORINFO_CONTEXT_STRUCT* contextHandle; + public uint _exactContextNeedsRuntimeLookup; // Set if contextHandle is approx handle. Runtime lookup is required to get the exact handle. public bool exactContextNeedsRuntimeLookup { get { return _exactContextNeedsRuntimeLookup != 0; } set { _exactContextNeedsRuntimeLookup = value ? (byte)1 : (byte)0; } } @@ -1051,6 +1056,9 @@ namespace Internal.JitInterface // Used by Ready-to-Run public CORINFO_CONST_LOOKUP instParamLookup; + + public uint _secureDelegateInvoke; + public bool secureDelegateInvoke { get { return _secureDelegateInvoke != 0; } set { _secureDelegateInvoke = value ? (byte)1 : (byte)0; } } } diff --git a/src/JitInterface/src/ThunkGenerator/corinfo.h b/src/JitInterface/src/ThunkGenerator/corinfo.h index 7302f4a5e..6e41d8e03 100644 --- a/src/JitInterface/src/ThunkGenerator/corinfo.h +++ b/src/JitInterface/src/ThunkGenerator/corinfo.h @@ -231,11 +231,11 @@ TODO: Talk about initializing strutures before use #if COR_JIT_EE_VERSION > 460 // Update this one -SELECTANY const GUID JITEEVersionIdentifier = { /* 718c4238-2a85-45de-88ad-9b1fed806547 */ - 0x718c4238, - 0x2a85, - 0x45de, - { 0x88, 0xad, 0x9b, 0x1f, 0xed, 0x80, 0x65, 0x47 } +SELECTANY const GUID JITEEVersionIdentifier = { /* 0b17dfeb-1ead-4e06-b025-d60d3a493b53 */ + 0x0b17dfeb, + 0x1ead, + 0x4e06, + { 0xb0, 0x25, 0xd6, 0x0d, 0x3a, 0x49, 0x3b, 0x53 } }; #else @@ -1686,6 +1686,8 @@ struct CORINFO_CALL_INFO }; CORINFO_CONST_LOOKUP instParamLookup; // Used by Ready-to-Run + + BOOL secureDelegateInvoke; }; //---------------------------------------------------------------------------- @@ -1808,6 +1810,9 @@ struct CORINFO_EE_INFO unsigned offsetOfDelegateInstance; unsigned offsetOfDelegateFirstTarget; + // Secure delegate offsets + unsigned offsetOfSecureDelegateIndirectCell; + // Remoting offsets unsigned offsetOfTransparentProxyRP; unsigned offsetOfRealProxyServer; diff --git a/src/Native/Runtime/amd64/ExceptionHandling.S b/src/Native/Runtime/amd64/ExceptionHandling.S index 3e6a689b1..3c0f62595 100644 --- a/src/Native/Runtime/amd64/ExceptionHandling.S +++ b/src/Native/Runtime/amd64/ExceptionHandling.S @@ -23,6 +23,9 @@ NESTED_ENTRY RhpThrowHwEx, _TEXT, NoHandler mov rax, rsp // save the faulting RSP + // Align the stack towards zero + and rsp, -16 + add rsi, 1 // 'faulting IP' += 1, we do this because everywhere else we treat the faulting IP as // a return-address and optionally subtract one when doing EH-related things (but not // subtracting 1 when doing GC-related things). The fault IP here will be the start @@ -32,7 +35,6 @@ NESTED_ENTRY RhpThrowHwEx, _TEXT, NoHandler // don't need to be precise here because the fault location isn't a GC safe point xor rdx, rdx - push_register rdx // padding // struct PAL_LIMITED_CONTEXT // { diff --git a/src/Native/Runtime/unix/UnixContext.cpp b/src/Native/Runtime/unix/UnixContext.cpp index ac47ad1c2..4812a1ec7 100644 --- a/src/Native/Runtime/unix/UnixContext.cpp +++ b/src/Native/Runtime/unix/UnixContext.cpp @@ -24,12 +24,6 @@ #include "UnixContext.h" #ifdef __APPLE__ -// TODO: remove this define and all related #ifdefs after we can link shared libunwind -// during the build. -#define CAN_LINK_SHARED_LIBUNWIND -#endif // __APPLE__ - -#ifdef __APPLE__ #define MCREG_Rip(mc) ((mc)->__ss.__rip) #define MCREG_Rsp(mc) ((mc)->__ss.__rsp) @@ -221,7 +215,7 @@ ASSIGN_REG_PTR(R15, R15) #elif defined(_ARM64_) #define ASSIGN_UNWIND_REGS \ - ASSIGN_REG(Pc, IP) + ASSIGN_REG(Pc, IP) // ASSIGN_REG(Sp, SP) \ // ASSIGN_REG_PTR(Fp, FP) \ // ASSIGN_REG_PTR(Lr, LR) \ @@ -260,7 +254,7 @@ static void RegDisplayToUnwindContext(REGDISPLAY* regDisplay, unw_context_t *unw // Update unw_context_t from REGDISPLAY static void RegDisplayToUnwindContext(REGDISPLAY* regDisplay, unw_context_t *unwContext) { -#if defined(_ARM_) +#if defined(_ARM_) // Assuming that unw_set_reg() on cursor will point the cursor to the // supposed stack frame is dangerous for libunwind-arm in Linux. // It is because libunwind's unw_cursor_t has other data structure @@ -289,12 +283,11 @@ static void RegDisplayToUnwindContext(REGDISPLAY* regDisplay, unw_context_t *unw #undef ASSIGN_REG #undef ASSIGN_REG_PTR #endif // _ARM_ -} +} // Update unw_cursor_t from REGDISPLAY static void RegDisplayToUnwindCursor(REGDISPLAY* regDisplay, unw_cursor_t *cursor) { -#ifdef CAN_LINK_SHARED_LIBUNWIND #if defined(_AMD64_) #define ASSIGN_REG(regName1, regName2) \ unw_set_reg(cursor, regName1, regDisplay->regName2); @@ -315,17 +308,13 @@ static void RegDisplayToUnwindCursor(REGDISPLAY* regDisplay, unw_cursor_t *curso #undef ASSIGN_REG #undef ASSIGN_REG_PTR #endif // _AMD64_ -#endif // CAN_LINK_SHARED_LIBUNWIND } #endif // UNWIND_CONTEXT_IS_UCONTEXT_T // Initialize unw_cursor_t and unw_context_t from REGDISPLAY bool InitializeUnwindContextAndCursor(REGDISPLAY* regDisplay, unw_cursor_t* cursor, unw_context_t* unwContext) { -#ifndef CAN_LINK_SHARED_LIBUNWIND - return false; -#else // CAN_LINK_SHARED_LIBUNWIND - int st; + int st; #if !UNWIND_CONTEXT_IS_UCONTEXT_T st = unw_getcontext(unwContext); @@ -349,19 +338,18 @@ bool InitializeUnwindContextAndCursor(REGDISPLAY* regDisplay, unw_cursor_t* curs #endif return true; -#endif // CAN_LINK_SHARED_LIBUNWIND } -// Update context pointer for a register from the unw_cursor_t. +// Update context pointer for a register from the unw_cursor_t. static void GetContextPointer(unw_cursor_t *cursor, unw_context_t *unwContext, int reg, PTR_UIntNative *contextPointer) { -#if defined(HAVE_UNW_GET_SAVE_LOC) && defined(CAN_LINK_SHARED_LIBUNWIND) +#if defined(HAVE_UNW_GET_SAVE_LOC) unw_save_loc_t saveLoc; unw_get_save_loc(cursor, reg, &saveLoc); if (saveLoc.type == UNW_SLT_MEMORY) { PTR_UIntNative pLoc = (PTR_UIntNative)saveLoc.u.addr; - // Filter out fake save locations that point to unwContext + // Filter out fake save locations that point to unwContext if (unwContext == NULL || (pLoc < (PTR_UIntNative)unwContext) || ((PTR_UIntNative)(unwContext + 1) <= pLoc)) *contextPointer = (PTR_UIntNative)saveLoc.u.addr; } @@ -373,34 +361,34 @@ static void GetContextPointer(unw_cursor_t *cursor, unw_context_t *unwContext, i #if defined(_AMD64_) #define GET_CONTEXT_POINTERS \ - GET_CONTEXT_POINTER(UNW_X86_64_RBP, Rbp) \ - GET_CONTEXT_POINTER(UNW_X86_64_RBX, Rbx) \ - GET_CONTEXT_POINTER(UNW_X86_64_R12, R12) \ - GET_CONTEXT_POINTER(UNW_X86_64_R13, R13) \ - GET_CONTEXT_POINTER(UNW_X86_64_R14, R14) \ - GET_CONTEXT_POINTER(UNW_X86_64_R15, R15) + GET_CONTEXT_POINTER(UNW_X86_64_RBP, Rbp) \ + GET_CONTEXT_POINTER(UNW_X86_64_RBX, Rbx) \ + GET_CONTEXT_POINTER(UNW_X86_64_R12, R12) \ + GET_CONTEXT_POINTER(UNW_X86_64_R13, R13) \ + GET_CONTEXT_POINTER(UNW_X86_64_R14, R14) \ + GET_CONTEXT_POINTER(UNW_X86_64_R15, R15) #elif defined(_ARM_) #define GET_CONTEXT_POINTERS \ - GET_CONTEXT_POINTER(UNW_ARM_R4, R4) \ - GET_CONTEXT_POINTER(UNW_ARM_R5, R5) \ - GET_CONTEXT_POINTER(UNW_ARM_R6, R6) \ - GET_CONTEXT_POINTER(UNW_ARM_R7, R7) \ - GET_CONTEXT_POINTER(UNW_ARM_R8, R8) \ - GET_CONTEXT_POINTER(UNW_ARM_R9, R9) \ - GET_CONTEXT_POINTER(UNW_ARM_R10, R10) \ - GET_CONTEXT_POINTER(UNW_ARM_R11, R11) + GET_CONTEXT_POINTER(UNW_ARM_R4, R4) \ + GET_CONTEXT_POINTER(UNW_ARM_R5, R5) \ + GET_CONTEXT_POINTER(UNW_ARM_R6, R6) \ + GET_CONTEXT_POINTER(UNW_ARM_R7, R7) \ + GET_CONTEXT_POINTER(UNW_ARM_R8, R8) \ + GET_CONTEXT_POINTER(UNW_ARM_R9, R9) \ + GET_CONTEXT_POINTER(UNW_ARM_R10, R10) \ + GET_CONTEXT_POINTER(UNW_ARM_R11, R11) #elif defined(_ARM64_) #define GET_CONTEXT_POINTERS \ - GET_CONTEXT_POINTER(UNW_AARCH64_X19, 19) \ - GET_CONTEXT_POINTER(UNW_AARCH64_X20, 20) \ - GET_CONTEXT_POINTER(UNW_AARCH64_X21, 21) \ - GET_CONTEXT_POINTER(UNW_AARCH64_X22, 22) \ - GET_CONTEXT_POINTER(UNW_AARCH64_X23, 23) \ - GET_CONTEXT_POINTER(UNW_AARCH64_X24, 24) \ - GET_CONTEXT_POINTER(UNW_AARCH64_X25, 25) \ - GET_CONTEXT_POINTER(UNW_AARCH64_X26, 26) \ - GET_CONTEXT_POINTER(UNW_AARCH64_X27, 27) \ - GET_CONTEXT_POINTER(UNW_AARCH64_X28, 28) + GET_CONTEXT_POINTER(UNW_AARCH64_X19, 19) \ + GET_CONTEXT_POINTER(UNW_AARCH64_X20, 20) \ + GET_CONTEXT_POINTER(UNW_AARCH64_X21, 21) \ + GET_CONTEXT_POINTER(UNW_AARCH64_X22, 22) \ + GET_CONTEXT_POINTER(UNW_AARCH64_X23, 23) \ + GET_CONTEXT_POINTER(UNW_AARCH64_X24, 24) \ + GET_CONTEXT_POINTER(UNW_AARCH64_X25, 25) \ + GET_CONTEXT_POINTER(UNW_AARCH64_X26, 26) \ + GET_CONTEXT_POINTER(UNW_AARCH64_X27, 27) \ + GET_CONTEXT_POINTER(UNW_AARCH64_X28, 28) #else #error unsupported architecture #endif @@ -409,13 +397,11 @@ static void GetContextPointer(unw_cursor_t *cursor, unw_context_t *unwContext, i void UnwindCursorToRegDisplay(unw_cursor_t *cursor, unw_context_t *unwContext, REGDISPLAY *regDisplay) { #define GET_CONTEXT_POINTER(unwReg, rdReg) GetContextPointer(cursor, unwContext, unwReg, ®Display->p##rdReg); - GET_CONTEXT_POINTERS + GET_CONTEXT_POINTERS #undef GET_CONTEXT_POINTER -#ifdef CAN_LINK_SHARED_LIBUNWIND unw_get_reg(cursor, UNW_REG_IP, (unw_word_t *) ®Display->IP); unw_get_reg(cursor, UNW_REG_SP, (unw_word_t *) ®Display->SP); -#endif // CAN_LINK_SHARED_LIBUNWIND #if defined(_ARM_) || defined(_ARM64_) regDisplay->IP |= 1; @@ -424,45 +410,45 @@ void UnwindCursorToRegDisplay(unw_cursor_t *cursor, unw_context_t *unwContext, R #if defined(_AMD64_) #define ASSIGN_CONTROL_REGS \ - ASSIGN_REG(Rip, IP) \ - ASSIGN_REG(Rsp, Rsp) + ASSIGN_REG(Rip, IP) \ + ASSIGN_REG(Rsp, Rsp) #define ASSIGN_INTEGER_REGS \ - ASSIGN_REG(Rbx, Rbx) \ - ASSIGN_REG(Rbp, Rbp) \ - ASSIGN_REG(R12, R12) \ - ASSIGN_REG(R13, R13) \ - ASSIGN_REG(R14, R14) \ - ASSIGN_REG(R15, R15) + ASSIGN_REG(Rbx, Rbx) \ + ASSIGN_REG(Rbp, Rbp) \ + ASSIGN_REG(R12, R12) \ + ASSIGN_REG(R13, R13) \ + ASSIGN_REG(R14, R14) \ + ASSIGN_REG(R15, R15) #define ASSIGN_TWO_ARGUMENT_REGS(arg0Reg, arg1Reg) \ - MCREG_Rdi(nativeContext->uc_mcontext) = arg0Reg; \ - MCREG_Rsi(nativeContext->uc_mcontext) = arg1Reg; + MCREG_Rdi(nativeContext->uc_mcontext) = arg0Reg; \ + MCREG_Rsi(nativeContext->uc_mcontext) = arg1Reg; #elif defined(_ARM_) #define ASSIGN_CONTROL_REGS \ - ASSIGN_REG(Pc, IP) \ - ASSIGN_REG(Sp, SP) \ - ASSIGN_REG(Lr, LR) + ASSIGN_REG(Pc, IP) \ + ASSIGN_REG(Sp, SP) \ + ASSIGN_REG(Lr, LR) #define ASSIGN_INTEGER_REGS \ - ASSIGN_REG(R4, R4) \ - ASSIGN_REG(R5, R5) \ - ASSIGN_REG(R6, R6) \ - ASSIGN_REG(R7, R7) \ - ASSIGN_REG(R8, R8) \ - ASSIGN_REG(R9, R9) \ - ASSIGN_REG(R10, R10) \ - ASSIGN_REG(R11, R11) + ASSIGN_REG(R4, R4) \ + ASSIGN_REG(R5, R5) \ + ASSIGN_REG(R6, R6) \ + ASSIGN_REG(R7, R7) \ + ASSIGN_REG(R8, R8) \ + ASSIGN_REG(R9, R9) \ + ASSIGN_REG(R10, R10) \ + ASSIGN_REG(R11, R11) #define ASSIGN_TWO_ARGUMENT_REGS(arg0Reg, arg1Reg) \ - MCREG_R0(nativeContext->uc_mcontext) = arg0Reg; \ - MCREG_R1(nativeContext->uc_mcontext) = arg1Reg; + MCREG_R0(nativeContext->uc_mcontext) = arg0Reg; \ + MCREG_R1(nativeContext->uc_mcontext) = arg1Reg; #elif defined(_ARM64_) #define ASSIGN_CONTROL_REGS \ - ASSIGN_REG(Pc, IP) + ASSIGN_REG(Pc, IP) // ASSIGN_REG(Sp, SP) \ // ASSIGN_REG(Fp, FP) \ // ASSIGN_REG(Lr, LR) \ @@ -480,8 +466,8 @@ void UnwindCursorToRegDisplay(unw_cursor_t *cursor, unw_context_t *unwContext, R // ASSIGN_REG(X28, X28) #define ASSIGN_TWO_ARGUMENT_REGS - // MCREG_X0(nativeContext->uc_mcontext) = arg0Reg; \ - // MCREG_X1(nativeContext->uc_mcontext) = arg1Reg; + // MCREG_X0(nativeContext->uc_mcontext) = arg0Reg; \ + // MCREG_X1(nativeContext->uc_mcontext) = arg1Reg; #else #error unsupported architecture @@ -490,7 +476,7 @@ void UnwindCursorToRegDisplay(unw_cursor_t *cursor, unw_context_t *unwContext, R // Convert Unix native context to PAL_LIMITED_CONTEXT void NativeContextToPalContext(const void* context, PAL_LIMITED_CONTEXT* palContext) { - ucontext_t *nativeContext = (ucontext_t*)context; + ucontext_t *nativeContext = (ucontext_t*)context; #define ASSIGN_REG(regNative, regPal) palContext->regPal = MCREG_##regNative(nativeContext->uc_mcontext); ASSIGN_CONTROL_REGS ASSIGN_INTEGER_REGS @@ -500,7 +486,7 @@ void NativeContextToPalContext(const void* context, PAL_LIMITED_CONTEXT* palCont // Redirect Unix native context to the PAL_LIMITED_CONTEXT and also set the first two argument registers void RedirectNativeContext(void* context, const PAL_LIMITED_CONTEXT* palContext, UIntNative arg0Reg, UIntNative arg1Reg) { - ucontext_t *nativeContext = (ucontext_t*)context; + ucontext_t *nativeContext = (ucontext_t*)context; #define ASSIGN_REG(regNative, regPal) MCREG_##regNative(nativeContext->uc_mcontext) = palContext->regPal; ASSIGN_CONTROL_REGS @@ -572,9 +558,6 @@ uint64_t GetPC(void* context) // Find LSDA and start address for a function at address controlPC bool FindProcInfo(UIntNative controlPC, UIntNative* startAddress, UIntNative* lsda) { -#ifndef CAN_LINK_SHARED_LIBUNWIND - return false; -#else // CAN_LINK_SHARED_LIBUNWIND unw_context_t unwContext; unw_cursor_t cursor; REGDISPLAY regDisplay; @@ -600,15 +583,11 @@ bool FindProcInfo(UIntNative controlPC, UIntNative* startAddress, UIntNative* ls *startAddress = procInfo.start_ip; return true; -#endif // CAN_LINK_SHARED_LIBUNWIND } // Virtually unwind stack to the caller of the context specified by the REGDISPLAY bool VirtualUnwind(REGDISPLAY* pRegisterSet) { -#ifndef CAN_LINK_SHARED_LIBUNWIND - return false; -#else // CAN_LINK_SHARED_LIBUNWIND unw_context_t unwContext; unw_cursor_t cursor; @@ -647,5 +626,4 @@ bool VirtualUnwind(REGDISPLAY* pRegisterSet) #endif return true; -#endif // CAN_LINK_SHARED_LIBUNWIND } diff --git a/src/Native/jitinterface/jitwrapper.cpp b/src/Native/jitinterface/jitwrapper.cpp index 0c1f85db2..3edc918e4 100644 --- a/src/Native/jitinterface/jitwrapper.cpp +++ b/src/Native/jitinterface/jitwrapper.cpp @@ -16,11 +16,11 @@ typedef struct _GUID { unsigned char Data4[8]; } GUID; -static const GUID JITEEVersionIdentifier = { /* 718c4238-2a85-45de-88ad-9b1fed806547 */ - 0x718c4238, - 0x2a85, - 0x45de, - { 0x88, 0xad, 0x9b, 0x1f, 0xed, 0x80, 0x65, 0x47 } +static const GUID JITEEVersionIdentifier = { /* 0b17dfeb-1ead-4e06-b025-d60d3a493b53 */ + 0x0b17dfeb, + 0x1ead, + 0x4e06, + { 0xb0, 0x25, 0xd6, 0x0d, 0x3a, 0x49, 0x3b, 0x53 } }; class Jit diff --git a/src/System.Private.CoreLib/src/System/Array.cs b/src/System.Private.CoreLib/src/System/Array.cs index 65a33a332..0915c926b 100644 --- a/src/System.Private.CoreLib/src/System/Array.cs +++ b/src/System.Private.CoreLib/src/System/Array.cs @@ -1745,6 +1745,35 @@ namespace System } } + public static void Reverse<T>(T[] array) + { + if (array == null) + throw new ArgumentNullException("array"); + + Reverse(array, 0, array.Length); + } + + public static void Reverse<T>(T[] array, int index, int length) + { + if (array == null) + throw new ArgumentNullException("array"); + if (index < 0 || length < 0) + throw new ArgumentOutOfRangeException((index < 0 ? "index" : "length"), SR.ArgumentOutOfRange_NeedNonNegNum); + if (array.Length - index < length) + throw new ArgumentException(SR.Argument_InvalidOffLen); + + int i = index; + int j = index + length - 1; + while (i < j) + { + T temp = array[i]; + array[i] = array[j]; + array[j] = temp; + i++; + j--; + } + } + // Sorts the elements of an array. The sort compares the elements to each // other using the IComparable interface, which must be implemented // by all elements of the array. diff --git a/src/System.Private.CoreLib/src/System/IO/Stream.cs b/src/System.Private.CoreLib/src/System/IO/Stream.cs index 13545cf99..42fd2cb6a 100644 --- a/src/System.Private.CoreLib/src/System/IO/Stream.cs +++ b/src/System.Private.CoreLib/src/System/IO/Stream.cs @@ -148,9 +148,10 @@ namespace System.IO Debug.Assert(destination.CanWrite); byte[] buffer = new byte[bufferSize]; - int bytesRead; - while ((bytesRead = await ReadAsync(buffer, 0, buffer.Length, cancellationToken).ConfigureAwait(false)) != 0) + while (true) { + int bytesRead = await ReadAsync(buffer, 0, buffer.Length, cancellationToken).ConfigureAwait(false); + if (bytesRead == 0) break; await destination.WriteAsync(buffer, 0, bytesRead, cancellationToken).ConfigureAwait(false); } } diff --git a/src/System.Private.CoreLib/src/System/Random.cs b/src/System.Private.CoreLib/src/System/Random.cs index a55b870d8..3bacbea3d 100644 --- a/src/System.Private.CoreLib/src/System/Random.cs +++ b/src/System.Private.CoreLib/src/System/Random.cs @@ -56,7 +56,7 @@ namespace System public Random(int Seed) { - int ii; + int ii = 0; int mj, mk; //Initialize our Seed array. @@ -66,7 +66,7 @@ namespace System mk = 1; for (int i = 1; i < 55; i++) { //Apparently the range [1..55] is special (Knuth) and so we're wasting the 0'th position. - ii = (21 * i) % 55; + if ((ii += 21) >= 55) ii -= 55; SeedArray[ii] = mk; mk = mj - mk; if (mk < 0) mk += MBIG; @@ -76,7 +76,9 @@ namespace System { for (int i = 1; i < 56; i++) { - SeedArray[i] -= SeedArray[1 + (i + 30) % 55]; + int n = i + 30; + if (n >= 55) n -= 55; + SeedArray[i] -= SeedArray[1 + n]; if (SeedArray[i] < 0) SeedArray[i] += MBIG; } } diff --git a/src/System.Private.CoreLib/src/System/String.Manipulation.cs b/src/System.Private.CoreLib/src/System/String.Manipulation.cs index f273cc4c5..ea56c69a7 100644 --- a/src/System.Private.CoreLib/src/System/String.Manipulation.cs +++ b/src/System.Private.CoreLib/src/System/String.Manipulation.cs @@ -911,6 +911,16 @@ namespace System } } + public String[] Split(char separator, StringSplitOptions options = StringSplitOptions.None) + { + return SplitInternal(separator, Int32.MaxValue, options); + } + + public String[] Split(char separator, int count, StringSplitOptions options = StringSplitOptions.None) + { + return SplitInternal(separator, count, options); + } + // Creates an array of strings by splitting this string at each // occurrence of a separator. The separator is searched for, and if found, // the substring preceding the occurrence is stored as the first element in @@ -922,7 +932,7 @@ namespace System // public String[] Split(params char[] separator) { - return Split(separator, Int32.MaxValue, StringSplitOptions.None); + return SplitInternal(separator, Int32.MaxValue, StringSplitOptions.None); } // Creates an array of strings by splitting this string at each @@ -938,16 +948,37 @@ namespace System // public string[] Split(char[] separator, int count) { - return Split(separator, count, StringSplitOptions.None); + return SplitInternal(separator, count, StringSplitOptions.None); } public String[] Split(char[] separator, StringSplitOptions options) { - return Split(separator, Int32.MaxValue, options); + return SplitInternal(separator, Int32.MaxValue, options); } public String[] Split(char[] separator, int count, StringSplitOptions options) { + return SplitInternal(separator, count, options); + } + + private unsafe String[] SplitInternal(char separator, int count, StringSplitOptions options) + { + char* pSeparators = stackalloc char[1]; + pSeparators[0] = separator; + return SplitInternal(pSeparators, /*separatorsLength*/ 1, count, options); + } + + private unsafe String[] SplitInternal(char[] separator, int count, StringSplitOptions options) + { + fixed (char* pSeparators = separator) + { + int separatorsLength = separator == null ? 0 : separator.Length; + return SplitInternal(pSeparators, separatorsLength, count, options); + } + } + + private unsafe String[] SplitInternal(char* separators, int separatorsLength, int count, StringSplitOptions options) + { if (count < 0) throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_NegativeCount); @@ -968,7 +999,7 @@ namespace System } int[] sepList = new int[Length]; - int numReplaces = MakeSeparatorList(separator, sepList); + int numReplaces = MakeSeparatorList(separators, separatorsLength, sepList); // Handle the special case of no replaces. if (0 == numReplaces) @@ -978,21 +1009,36 @@ namespace System if (omitEmptyEntries) { - return SplitOmitEmptyEntries(sepList, null, numReplaces, count); + return SplitOmitEmptyEntries(sepList, null, 1, numReplaces, count); } else { - return SplitKeepEmptyEntries(sepList, null, numReplaces, count); + return SplitKeepEmptyEntries(sepList, null, 1, numReplaces, count); } } + public String[] Split(String separator, StringSplitOptions options = StringSplitOptions.None) + { + return SplitInternal(separator ?? String.Empty, null, Int32.MaxValue, options); + } + + public String[] Split(String separator, Int32 count, StringSplitOptions options = StringSplitOptions.None) + { + return SplitInternal(separator ?? String.Empty, null, count, options); + } + public String[] Split(String[] separator, StringSplitOptions options) { - return Split(separator, Int32.MaxValue, options); + return SplitInternal(null, separator, Int32.MaxValue, options); } public String[] Split(String[] separator, Int32 count, StringSplitOptions options) { + return SplitInternal(null, separator, count, options); + } + + private String[] SplitInternal(String separator, String[] separators, Int32 count, StringSplitOptions options) + { if (count < 0) { throw new ArgumentOutOfRangeException("count", @@ -1006,9 +1052,11 @@ namespace System bool omitEmptyEntries = (options == StringSplitOptions.RemoveEmptyEntries); - if (separator == null || separator.Length == 0) + bool singleSeparator = separator != null; + + if (!singleSeparator && (separators == null || separators.Length == 0)) { - return Split((char[])null, count, options); + return SplitInternal((char[])null, count, options); } if ((count == 0) || (omitEmptyEntries && this.Length == 0)) @@ -1016,16 +1064,30 @@ namespace System return Array.Empty<String>(); } - if (count == 1) + if (count == 1 || (singleSeparator && separator.Length == 0)) { return new String[] { this }; } int[] sepList = new int[Length]; - int[] lengthList = new int[Length]; - int numReplaces = MakeSeparatorList(separator, sepList, lengthList); + int[] lengthList; + int defaultLength; + int numReplaces; + + if (singleSeparator) + { + lengthList = null; + defaultLength = separator.Length; + numReplaces = MakeSeparatorList(separator, sepList); + } + else + { + lengthList = new int[Length]; + defaultLength = 0; + numReplaces = MakeSeparatorList(separators, sepList, lengthList); + } - //Handle the special case of no replaces. + // Handle the special case of no replaces. if (0 == numReplaces) { return new String[] { this }; @@ -1033,11 +1095,11 @@ namespace System if (omitEmptyEntries) { - return SplitOmitEmptyEntries(sepList, lengthList, numReplaces, count); + return SplitOmitEmptyEntries(sepList, lengthList, defaultLength, numReplaces, count); } else { - return SplitKeepEmptyEntries(sepList, lengthList, numReplaces, count); + return SplitKeepEmptyEntries(sepList, lengthList, defaultLength, numReplaces, count); } } @@ -1046,8 +1108,11 @@ namespace System // the original string will be returned regardless of the count. // - private String[] SplitKeepEmptyEntries(Int32[] sepList, Int32[] lengthList, Int32 numReplaces, int count) + private String[] SplitKeepEmptyEntries(Int32[] sepList, Int32[] lengthList, Int32 defaultLength, Int32 numReplaces, int count) { + Debug.Assert(numReplaces >= 0); + Debug.Assert(count >= 2); + int currIndex = 0; int arrIndex = 0; @@ -1061,7 +1126,7 @@ namespace System for (int i = 0; i < numActualReplaces && currIndex < Length; i++) { splitStrings[arrIndex++] = Substring(currIndex, sepList[i] - currIndex); - currIndex = sepList[i] + ((lengthList == null) ? 1 : lengthList[i]); + currIndex = sepList[i] + ((lengthList == null) ? defaultLength : lengthList[i]); } //Handle the last string at the end of the array if there is one. @@ -1081,8 +1146,11 @@ namespace System // This function will not keep the Empty String - private String[] SplitOmitEmptyEntries(Int32[] sepList, Int32[] lengthList, Int32 numReplaces, int count) + private String[] SplitOmitEmptyEntries(Int32[] sepList, Int32[] lengthList, Int32 defaultLength, Int32 numReplaces, int count) { + Debug.Assert(numReplaces >= 0); + Debug.Assert(count >= 2); + // Allocate array to hold items. This array may not be // filled completely in this function, we will create a // new array and copy string references to that new array. @@ -1099,18 +1167,21 @@ namespace System { splitStrings[arrIndex++] = Substring(currIndex, sepList[i] - currIndex); } - currIndex = sepList[i] + ((lengthList == null) ? 1 : lengthList[i]); + currIndex = sepList[i] + ((lengthList == null) ? defaultLength : lengthList[i]); if (arrIndex == count - 1) { // If all the remaining entries at the end are empty, skip them while (i < numReplaces - 1 && currIndex == sepList[++i]) { - currIndex += ((lengthList == null) ? 1 : lengthList[i]); + currIndex += ((lengthList == null) ? defaultLength : lengthList[i]); } break; } } + // we must have at least one slot left to fill in the last string. + Debug.Assert(arrIndex < maxItems); + //Handle the last string at the end of the array if there is one. if (currIndex < Length) { @@ -1135,11 +1206,13 @@ namespace System // Args: separator -- A string containing all of the split characters. // sepList -- an array of ints for split char indicies. //-------------------------------------------------------------------- - private unsafe int MakeSeparatorList(char[] separator, int[] sepList) + private unsafe int MakeSeparatorList(char* separators, int separatorsLength, int[] sepList) { + Debug.Assert(separatorsLength >= 0, "separatorsLength >= 0"); + int foundCount = 0; - if (separator == null || separator.Length == 0) + if (separators == null || separatorsLength == 0) { fixed (char* pwzChars = &_firstChar) { @@ -1156,14 +1229,13 @@ namespace System else { int sepListCount = sepList.Length; - int sepCount = separator.Length; //If they passed in a string of chars, actually look for those chars. - fixed (char* pwzChars = &_firstChar, pSepChars = separator) + fixed (char* pwzChars = &_firstChar) { for (int i = 0; i < Length && foundCount < sepListCount; i++) { - char* pSep = pSepChars; - for (int j = 0; j < sepCount; j++, pSep++) + char* pSep = separators; + for (int j = 0; j < separatorsLength; j++, pSep++) { if (pwzChars[i] == *pSep) { @@ -1177,6 +1249,39 @@ namespace System return foundCount; } + //-------------------------------------------------------------------- + // This function returns number of the places within baseString where + // instances of the separator string occurs. + // Args: separator -- the separator + // sepList -- an array of ints for split string indicies. + //-------------------------------------------------------------------- + private unsafe int MakeSeparatorList(string separator, int[] sepList) + { + Debug.Assert(!string.IsNullOrEmpty(separator), "!string.IsNullOrEmpty(separator)"); + + int foundCount = 0; + int sepListCount = sepList.Length; + int currentSepLength = separator.Length; + + fixed (char* pwzChars = &_firstChar) + { + for (int i = 0; i < Length && foundCount < sepListCount; i++) + { + if (pwzChars[i] == separator[0] && currentSepLength <= Length - i) + { + if (currentSepLength == 1 + || String.CompareOrdinal(this, i, separator, 0, currentSepLength) == 0) + { + sepList[foundCount] = i; + foundCount++; + i += currentSepLength - 1; + } + } + } + } + return foundCount; + } + //-------------------------------------------------------------------- // This function returns the number of the places within this instance where // instances of separator strings occur. @@ -1186,6 +1291,8 @@ namespace System //-------------------------------------------------------------------- private unsafe int MakeSeparatorList(String[] separators, int[] sepList, int[] lengthList) { + Debug.Assert(separators != null && separators.Length > 0, "separators != null && separators.Length > 0"); + int foundCount = 0; int sepListCount = sepList.Length; int sepCount = separators.Length; diff --git a/src/System.Private.CoreLib/src/System/Version.cs b/src/System.Private.CoreLib/src/System/Version.cs index c3cba9490..4ee305018 100644 --- a/src/System.Private.CoreLib/src/System/Version.cs +++ b/src/System.Private.CoreLib/src/System/Version.cs @@ -18,10 +18,10 @@ namespace System public sealed class Version : IComparable, IComparable<Version>, IEquatable<Version>, ICloneable { // AssemblyName depends on the order staying the same - private int _Major; - private int _Minor; - private int _Build = -1; - private int _Revision = -1; + private readonly int _Major; + private readonly int _Minor; + private readonly int _Build = -1; + private readonly int _Revision = -1; public Version(int major, int minor, int build, int revision) { @@ -84,9 +84,19 @@ namespace System _Revision = v.Revision; } + private Version(Version version) + { + Debug.Assert(version != null); + + _Major = version._Major; + _Minor = version._Minor; + _Build = version._Build; + _Revision = version._Revision; + } + public object Clone() { - return new Version(_Major, _Minor, _Build, _Revision); + return new Version(this); } // Properties for setting and getting version numbers @@ -133,94 +143,34 @@ namespace System throw new ArgumentException(SR.Arg_MustBeVersion); } - if (_Major != v._Major) - if (_Major > v._Major) - return 1; - else - return -1; - - if (_Minor != v._Minor) - if (_Minor > v._Minor) - return 1; - else - return -1; - - if (_Build != v._Build) - if (_Build > v._Build) - return 1; - else - return -1; - - if (_Revision != v._Revision) - if (_Revision > v._Revision) - return 1; - else - return -1; - - return 0; + return CompareTo(v); } public int CompareTo(Version value) { - if (value == null) - return 1; - - if (_Major != value._Major) - if (_Major > value._Major) - return 1; - else - return -1; - - if (_Minor != value._Minor) - if (_Minor > value._Minor) - return 1; - else - return -1; - - if (_Build != value._Build) - if (_Build > value._Build) - return 1; - else - return -1; - - if (_Revision != value._Revision) - if (_Revision > value._Revision) - return 1; - else - return -1; - - return 0; + return + object.ReferenceEquals(value, this) ? 0 : + object.ReferenceEquals(value, null) ? 1 : + _Major != value._Major ? (_Major > value._Major ? 1 : -1) : + _Minor != value._Minor ? (_Minor > value._Minor ? 1 : -1) : + _Build != value._Build ? (_Build > value._Build ? 1 : -1) : + _Revision != value._Revision ? (_Revision > value._Revision ? 1 : -1) : + 0; } public override bool Equals(Object obj) { - Version v = obj as Version; - if (v == null) - return false; - - // check that major, minor, build & revision numbers match - if ((_Major != v._Major) || - (_Minor != v._Minor) || - (_Build != v._Build) || - (_Revision != v._Revision)) - return false; - - return true; + return Equals(obj as Version); } public bool Equals(Version obj) { - if (obj == null) - return false; - - // check that major, minor, build & revision numbers match - if ((_Major != obj._Major) || - (_Minor != obj._Minor) || - (_Build != obj._Build) || - (_Revision != obj._Revision)) - return false; - - return true; + return object.ReferenceEquals(obj, this) || + (!object.ReferenceEquals(obj, null) && + _Major == obj._Major && + _Minor == obj._Minor && + _Build == obj._Build && + _Revision == obj._Revision); } public override int GetHashCode() diff --git a/src/System.Private.Reflection.Metadata/tests/project.json b/src/System.Private.Reflection.Metadata/tests/project.json index 3c63115ec..f2301f514 100644 --- a/src/System.Private.Reflection.Metadata/tests/project.json +++ b/src/System.Private.Reflection.Metadata/tests/project.json @@ -1,6 +1,6 @@ { "dependencies": { - "NETStandard.Library": "1.5.0-rc2-23911", + "NETStandard.Library": "1.6.0", "xunit": "2.1.0", "test-runtime": { "target": "project", @@ -9,7 +9,10 @@ }, "frameworks": { "dnxcore50": { - "imports": "portable-net451+win8" + "imports": [ + "netstandard1.6", + "portable-net45+win8" + ] } }, "runtimes": { diff --git a/src/packaging/buildtools/test-runtime/project.json b/src/packaging/buildtools/test-runtime/project.json index 4b0fe3c78..24474a8d7 100644 --- a/src/packaging/buildtools/test-runtime/project.json +++ b/src/packaging/buildtools/test-runtime/project.json @@ -1,29 +1,32 @@ { - "dependencies": { - "NETStandard.Library": "1.5.0-rc2-23911", - "Microsoft.NETCore.TestHost": "1.0.0-rc2-23911", - "Microsoft.NETCore.Console": "1.0.0-rc2-23911", - "System.IO.Compression": "4.1.0-rc2-23911", - "coveralls.io": "1.4", - "OpenCover": "4.6.166", - "ReportGenerator": "2.3.1", + "dependencies": { + "NETStandard.Library": "1.6.0", + "Microsoft.NETCore.Runtime.CoreCLR": "1.0.4", + "Microsoft.NETCore.TestHost": "1.0.0", - "Microsoft.DotNet.xunit.performance.analysis": "1.0.0-alpha-build0023", - "Microsoft.DotNet.xunit.performance.runner.Windows": "1.0.0-alpha-build0023", + "coveralls.io": "1.4", + "OpenCover": "4.6.519", + "ReportGenerator": "2.4.3", - "xunit": "2.1.0", - "xunit.console.netcore": "1.0.2-prerelease-00101", - "xunit.runner.utility": "2.1.0" - }, - "frameworks": { - "dnxcore50": { - "imports": "portable-net45+win8" - } - }, - "runtimes": { - "win7-x64": { }, - "win7-x86": { }, - "ubuntu.14.04-x64": {}, - "osx.10.10-x64": {} + "Microsoft.DotNet.xunit.performance.analysis": "1.0.0-alpha-build0040", + "Microsoft.DotNet.xunit.performance.runner.Windows": "1.0.0-alpha-build0040", + + "xunit": "2.1.0", + "xunit.console.netcore": "1.0.2-prerelease-00101", + "xunit.runner.utility": "2.1.0" + }, + "frameworks": { + "dnxcore50": { + "imports": [ + "netstandard1.6", + "portable-net45+win8" + ] } + }, + "runtimes": { + "win7-x64": { }, + "win7-x86": { }, + "ubuntu.14.04-x64": {}, + "osx.10.10-x64": {} + } } diff --git a/src/packaging/clrjit/project.json b/src/packaging/clrjit/project.json new file mode 100644 index 000000000..1b6fe2d4d --- /dev/null +++ b/src/packaging/clrjit/project.json @@ -0,0 +1,13 @@ +{ + "dependencies": { + "Microsoft.NETCore.Jit": "1.1.0-preview1-24512-01" + }, + "frameworks": { + "dnxcore50": { } + }, + "runtimes": { + "win7-x64": { }, + "osx.10.10-x64": { }, + "ubuntu.14.04-x64": { } + } +} diff --git a/src/packaging/packages.targets b/src/packaging/packages.targets index f3b17213e..c7cca40ea 100644 --- a/src/packaging/packages.targets +++ b/src/packaging/packages.targets @@ -22,6 +22,8 @@ <LibPrefix Condition="'$(OsEnvironment)'!='Windows_NT'">lib</LibPrefix> <StaticLibExt Condition="'$(OsEnvironment)'=='Windows_NT'">lib</StaticLibExt> <StaticLibExt Condition="'$(OsEnvironment)'!='Windows_NT'">a</StaticLibExt> + + <JitPackageVersion>1.1.0-preview1-24512-01</JitPackageVersion> </PropertyGroup> <ItemGroup> <!-- IL.Compiler target files --> @@ -42,6 +44,22 @@ <Text><![CDATA[ <file src="$(RelativeProductBinDir)/%(Identity)" target="runtimes/$(NuPkgRid)/native/%(Identity)" /> ]]></Text> </ILCompilerBinPlace> + <!-- Repackage the JIT dynamic library used for AOT compilation with ilc suffix to avoid colliding with the one used to run the toolchain --> + <!-- TODO: Publish the JIT dynamic library in a sub-directory under the original name instead? --> + <ILCompilerRepackageJitFiles Include="clrjit.dll" Condition="'$(OSGroup)'=='Windows_NT'" /> + <ILCompilerRepackageJitFiles Include="libclrjit.so" Condition="'$(OSGroup)'=='Linux'" /> + <ILCompilerRepackageJitFiles Include="libclrjit.dylib" Condition="'$(OSGroup)'=='OSX'" /> + <ILCompilerBinPlace Include="@(ILCompilerRepackageJitFiles)"> + <Text><![CDATA[ <file src="packages/runtime.$(NuPkgRid).Microsoft.NETCore.Jit/$(JitPackageVersion)/runtimes/$(NuPkgRid)/native/%(Identity)" target="runtimes/$(NuPkgRid)/native/%(Filename)ilc%(Extension)" /> ]]></Text> + </ILCompilerBinPlace> + + <ILCompilerContentFiles Include="BuildIntegration/Microsoft.NETCore.Native.targets" /> + <ILCompilerContentFiles Include="BuildIntegration/Microsoft.NETCore.Native.Windows.targets" /> + <ILCompilerContentFiles Include="BuildIntegration/Microsoft.NETCore.Native.Unix.targets" /> + <ILCompilerBinPlace Include="@(ILCompilerContentFiles)"> + <Text><![CDATA[ <file src="src/%(Identity)" target="runtimes/$(NuPkgRid)/native/%(Filename)%(Extension)" /> ]]></Text> + </ILCompilerBinPlace> + <!-- IL.Compiler.SDK target files --> <ILCompilerSdkFiles Include="Runtime" /> <ILCompilerSdkFiles Include="PortableRuntime" /> @@ -64,8 +82,6 @@ <ILCompilerSdkFilesManaged Include="System.Private.Threading" /> <ILCompilerSdkFilesManaged Include="System.Private.TypeLoader" /> - <ILCompilerSdkContentFiles Include="scripts/linkerscript" /> - <ILCompilerSdkBinPlace Include="@(ILCompilerSdkFiles)"> <Text><![CDATA[ <file src="$(RelativeProductBinDir)/lib/$(LibPrefix)%(Identity).$(StaticLibExt)" target="runtimes/$(NuPkgRid)/native/sdk/$(LibPrefix)%(Identity).$(StaticLibExt)" /> ]]></Text> </ILCompilerSdkBinPlace> @@ -79,8 +95,64 @@ <ILCompilerSdkBinPlace Include="@(ILCompilerSdkCppCodegenFiles)"> <Text><![CDATA[ <file src="src/%(Identity)" target="runtimes/$(NuPkgRid)/native/inc/%(Filename)%(Extension)" /> ]]></Text> </ILCompilerSdkBinPlace> - <ILCompilerSdkBinPlace Include="@(ILCompilerSdkContentFiles)"> - <Text><![CDATA[ <file src="src/%(Identity)" target="runtimes/$(NuPkgRid)/native/sdk/%(Filename)%(Extension)" /> ]]></Text> + + <!-- Repackage the framework used for AOT compilation --> + <!-- TODO: Obtain this via nuget once the framework is properly packaged --> + <ILCompilerAOTFrameworkFiles Include="System.Globalization" /> + <ILCompilerAOTFrameworkFiles Include="System.IO" /> + <ILCompilerAOTFrameworkFiles Include="System.Reflection" /> + <ILCompilerAOTFrameworkFiles Include="System.Reflection.Extensions" /> + <ILCompilerAOTFrameworkFiles Include="System.Reflection.Primitives" /> + <ILCompilerAOTFrameworkFiles Include="System.Runtime" /> + <ILCompilerAOTFrameworkFiles Include="System.Runtime.Handles" /> + <ILCompilerAOTFrameworkFiles Include="System.Runtime.InteropServices" /> + <ILCompilerAOTFrameworkFiles Include="System.Text.Encoding" /> + <ILCompilerAOTFrameworkFiles Include="System.Text.Encoding.Extensions" /> + <ILCompilerAOTFrameworkFiles Include="System.Threading.Tasks" /> + <ILCompilerAOTFrameworkFiles Include="System.Collections" /> + <ILCompilerAOTFrameworkFiles Include="System.Diagnostics.Tools" /> + <ILCompilerAOTFrameworkFiles Include="System.Diagnostics.Tracing" /> + <ILCompilerAOTFrameworkFiles Include="System.Globalization.Calendars" /> + <ILCompilerAOTFrameworkFiles Include="System.Threading.Timer" /> + <ILCompilerSdkBinPlace Include="@(ILCompilerAOTFrameworkFiles)"> + <Text><![CDATA[ <file src="packages/runtime.aot.%(Identity)/4.3.0-beta-devapi-24514-04/runtimes/aot/lib/netcore50/%(Identity).dll" target="runtimes/$(NuPkgRid)/native/framework/%(Identity).dll" /> ]]></Text> + </ILCompilerSdkBinPlace> + + <ILCompilerFrameworkFiles Include="System.Reflection.TypeExtensions/4.1.0/runtimes/aot/lib/netcore50/System.Reflection.TypeExtensions.dll" /> + + <ILCompilerFrameworkFiles Include="Microsoft.NETCore.Portable.Compatibility/1.0.2/runtimes/aot/lib/netcore50/mscorlib.dll" /> + <ILCompilerFrameworkFiles Include="toolchain.$(NuPkgRid).Microsoft.DotNet.AppDep/1.0.6-prerelease-00004/System.Resources.ResourceManager.dll" /> + + <ILCompilerFrameworkFiles Include="runtime.win.System.Runtime.Extensions/4.1.0/runtimes/win/lib/netstandard1.5/System.Runtime.Extensions.dll" Condition="'$(OsEnvironment)'=='Windows_NT'" /> + <ILCompilerFrameworkFiles Include="runtime.unix.System.Runtime.Extensions/4.1.0/runtimes/unix/lib/netstandard1.5/System.Runtime.Extensions.dll" Condition="'$(OsEnvironment)'!='Windows_NT'" /> + + <ILCompilerFrameworkFiles Include="runtime.win.System.Console/4.0.0/runtimes/win/lib/netstandard1.3/System.Console.dll" Condition="'$(OsEnvironment)'=='Windows_NT'" /> + <ILCompilerFrameworkFiles Include="runtime.unix.System.Console/4.0.0/runtimes/unix/lib/netstandard1.3/System.Console.dll" Condition="'$(OsEnvironment)'!='Windows_NT'" /> + <ILCompilerFrameworkFiles Include="runtime.win.System.Diagnostics.Debug/4.0.11/runtimes/win/lib/netstandard1.3/System.Diagnostics.Debug.dll" Condition="'$(OsEnvironment)'=='Windows_NT'" /> + <ILCompilerFrameworkFiles Include="runtime.unix.System.Diagnostics.Debug/4.0.11/runtimes/unix/lib/netstandard1.3/System.Diagnostics.Debug.dll" Condition="'$(OsEnvironment)'!='Windows_NT'" /> + <ILCompilerFrameworkFiles Include="runtime.win.Microsoft.Win32.Primitives/4.0.1/runtimes/win/lib/netstandard1.3/Microsoft.Win32.Primitives.dll" Condition="'$(OsEnvironment)'=='Windows_NT'" /> + <ILCompilerFrameworkFiles Include="runtime.unix.Microsoft.Win32.Primitives/4.0.1/runtimes/unix/lib/netstandard1.3/Microsoft.Win32.Primitives.dll" Condition="'$(OsEnvironment)'!='Windows_NT'" /> + <ILCompilerFrameworkFiles Include="runtime.win.System.IO.FileSystem/4.0.1/runtimes/win/lib/netstandard1.3/System.IO.FileSystem.dll" Condition="'$(OsEnvironment)'=='Windows_NT'" /> + <ILCompilerFrameworkFiles Include="runtime.unix.System.IO.FileSystem/4.0.1/runtimes/unix/lib/netstandard1.3/System.IO.FileSystem.dll" Condition="'$(OsEnvironment)'!='Windows_NT'" /> + <ILCompilerFrameworkFiles Include="runtime.win7.System.Private.Uri/4.0.1/runtimes/win/lib/netstandard1.0/System.Private.Uri.dll" Condition="'$(OsEnvironment)'=='Windows_NT'" /> + <ILCompilerFrameworkFiles Include="runtime.unix.System.Private.Uri/4.0.1/runtimes/unix/lib/netstandard1.0/System.Private.Uri.dll" Condition="'$(OsEnvironment)'!='Windows_NT'" /> + + <ILCompilerFrameworkFiles Include="System.Runtime.InteropServices.RuntimeInformation/4.0.0/runtimes/win/lib/netstandard1.1/System.Runtime.InteropServices.RuntimeInformation.dll" Condition="'$(OsEnvironment)'=='Windows_NT'" /> + <ILCompilerFrameworkFiles Include="System.Runtime.InteropServices.RuntimeInformation/4.0.0/runtimes/unix/lib/netstandard1.1/System.Runtime.InteropServices.RuntimeInformation.dll" Condition="'$(OsEnvironment)'=='Windows_NT'" /> + + <ILCompilerFrameworkFiles Include="System.Buffers/4.0.0/lib/netstandard1.1/System.Buffers.dll" /> + <ILCompilerFrameworkFiles Include="System.Collections.Concurrent/4.0.12/lib/netcore50/System.Collections.Concurrent.dll" /> + <ILCompilerFrameworkFiles Include="System.Collections.NonGeneric/4.0.1/lib/netstandard1.3/System.Collections.NonGeneric.dll" /> + <ILCompilerFrameworkFiles Include="System.IO.FileSystem.Primitives/4.0.1/lib/netstandard1.3/System.IO.FileSystem.Primitives.dll" /> + <ILCompilerFrameworkFiles Include="System.Linq/4.1.0/lib/netcore50/System.Linq.dll" /> + <ILCompilerFrameworkFiles Include="System.Runtime.Numerics/4.0.1/lib/netcore50/System.Runtime.Numerics.dll" /> + <ILCompilerFrameworkFiles Include="System.Security.Principal/4.0.1/lib/netcore50/System.Security.Principal.dll" /> + <ILCompilerFrameworkFiles Include="System.Threading/4.0.11/lib/netstandard1.3/System.Threading.dll" /> + + <ILCompilerFrameworkFiles Include="runtime.$(NuPkgRid).runtime.native.System/1.0.1/runtimes/$(NuPkgRid)/native/System.Native.a" Condition="'$(OsEnvironment)'!='Windows_NT'" /> + + <ILCompilerSdkBinPlace Include="@(ILCompilerFrameworkFiles)"> + <Text><![CDATA[ <file src="packages/%(Identity)" target="runtimes/$(NuPkgRid)/native/framework/%(Filename)%(Extension)" /> ]]></Text> </ILCompilerSdkBinPlace> <!-- ILCompiler nuspec file --> @@ -93,15 +165,14 @@ <!-- TODO: Obtain this from project.lock.json --> <Dependencies><![CDATA[ <dependency id="Microsoft.DotNet.ObjectWriter" version="1.0.13-prerelease-00001" /> - <dependency id="Microsoft.NETCore.Jit" version="1.0.4-beta-24411-03" /> - <dependency id="NETStandard.Library" version="1.5.0-rc2-23911" /> - <dependency id="System.Collections.Immutable" version="1.2.0-rc2-23911" /> - <dependency id="System.IO.MemoryMappedFiles" version="4.0.0-rc2-23911" /> - <dependency id="System.Reflection.Metadata" version="1.3.0-rc3-24102-00" /> - <dependency id="System.Runtime.CompilerServices.Unsafe" version="4.0.0-rc3-24102-00" /> - <dependency id="System.Xml.ReaderWriter" version="4.0.0" /> - <dependency id="Microsoft.DiaSymReader" version="1.0.8-rc2-60325" /> - <dependency id="System.CommandLine" version="0.1.0-e160514-1" /> + <dependency id="NETStandard.Library" version="1.6.0" /> + <dependency id="System.Collections.Immutable" version="1.2.0" /> + <dependency id="System.IO.MemoryMappedFiles" version="4.0.0" /> + <dependency id="System.Reflection.Metadata" version="1.4.1-beta-24227-04" /> + <dependency id="System.Runtime.CompilerServices.Unsafe" version="4.0.0" /> + <dependency id="System.Xml.ReaderWriter" version="4.0.11" /> + <dependency id="Microsoft.DiaSymReader" version="1.0.8" /> + <dependency id="System.CommandLine" version="0.1.0-e160909-1" /> ]]></Dependencies> </NuSpecFile> @@ -220,19 +291,20 @@ <Stage1ProjectJsonLines><![CDATA[ { "version": "1.0.0-*", - "compilationOptions": { - "emitEntryPoint": true, - }, "dependencies": { - "NETStandard.Library": "1.5.0-rc2-23911", - "Microsoft.NETCore.TestHost": "1.0.0-beta-23504", + "NETStandard.Library": "1.6.0", + "Microsoft.NETCore.Runtime.CoreCLR": "1.0.4", + "Microsoft.NETCore.TestHost": "1.0.0", "toolchain.$(NuPkgRid).$(RuntimeSdkPackageName)": "$(RuntimeSdkVersion)", }, "frameworks": { "dnxcore50": { - "imports": "portable-net451+win8" + "imports": [ + "netstandard1.6", + "portable-net45+win8" + ] } }, @@ -245,7 +317,7 @@ <MakeDir Directories="$(Stage1ProjectDir)" Condition="!Exists('$(Stage1ProjectDir)')" /> <WriteLinesToFile File="$(Stage1ProjectJsonFile)" Lines="$(Stage1ProjectJsonLines)" Overwrite="true" /> <WriteLinesToFile File="$(Stage1ProjectDir)/Program.cs" Lines="class Program { public static void Main() { } }" Overwrite="true" /> - <Exec Command=""$(DnuToolPath)" restore --quiet -s "$(ProductPackageDir)" $(DnuRestoreSource) "$(Stage1ProjectDir)"" /> + <Exec Command=""$(DnuToolPath)" restore -s "$(ProductPackageDir)" $(DnuRestoreSource) "$(Stage1ProjectDir)"" /> <Exec Command=""$(DnuToolPath)" publish "$(Stage1ProjectDir)" --native-subdirectory -o "$(Stage1PublishDir)" -f "dnxcore50" --runtime "$(NuPkgRid)"" /> </Target> diff --git a/src/packaging/uap/project.json b/src/packaging/uap/project.json new file mode 100644 index 000000000..17928b1ac --- /dev/null +++ b/src/packaging/uap/project.json @@ -0,0 +1,20 @@ +{ + "frameworks": { + "uap10.1": { + "dependencies": { + "Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2", + "System.Diagnostics.StackTrace": "4.0.3-beta-24415-01", + "System.IO.Compression": "4.1.2-beta-24415-01", + "System.IO": "4.3.0-beta-devapi-24512-01", + "System.Reflection.Primitives": "4.3.0-beta-devapi-24512-01", + "System.Runtime": "4.3.0-beta-devapi-24512-01", + "System.Runtime.Serialization.Primitives": "4.3.0-beta-devapi-24512-01" + } + } + }, + + "runtimes": { + "win10-aot": {}, + "win8-aot": {} + } +} diff --git a/src/scripts/linkerscript b/src/scripts/linkerscript deleted file mode 100644 index f7e9c6595..000000000 --- a/src/scripts/linkerscript +++ /dev/null @@ -1,15 +0,0 @@ -/* -Licensed to the .NET Foundation under one or more agreements. -The .NET Foundation licenses this file to you under the MIT license. -See the LICENSE file in the project root for more information. -*/ - -SECTIONS -{ - .data : ALIGN(8) - { - *(.modules$A) - KEEP(*(.modules$I)) - *(.modules$Z) - } -} diff --git a/tests/.gitignore b/tests/.gitignore deleted file mode 100644 index 900941011..000000000 --- a/tests/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -**/*.S -**/*.compiled.exe -**/*.obj -**/*.exe.cpp -**/*.idb -**/*.pdb diff --git a/tests/ilc.cmd b/tests/ilc.cmd deleted file mode 100644 index c7860ee9b..000000000 --- a/tests/ilc.cmd +++ /dev/null @@ -1,89 +0,0 @@ -@echo off - -setlocal - -REM ** Validate args -set "__SourceFolder=%1" & shift -set "__SourceFile=%__SourceFolder%\%1" & shift - -set __ExeParams= -:Loop - if [%1]==[] goto :DoneArgs - set __ExeParams=%__ExeParams% %1 - shift -goto :Loop - -:DoneArgs - -if "%CoreRT_TestCompileMode%"=="" ((call :Fail "Test compile mode not set in CoreRT_TestCompileMode: Specify cpp/ryujit") & exit /b -1) -set __RSPTemplate="%CoreRT_RspTemplateDir%\%CoreRT_TestCompileMode%.rsp" -if not exist %__RSPTemplate% ((call :Fail "RSP template not found (%__RSPTemplate%)") & exit /b -1) - -set __RSPFile=%__SourceFile%.rsp - -rem Copy the relevant lines from the template RSP file -findstr /B /C:"-r:" %__RSPTemplate% > %__RSPFile% - -echo %__SourceFile% >> %__RSPFile% -if exist "%__SourceFolder%\*.dll" ( - echo -r:%__SourceFolder%\*.dll >> %__RSPFile% -) - -REM Initialize environment to invoke native tools -call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" amd64 - -set __ExeFile=%__SourceFile%.compiled.exe -if exist %__ExeFile% del %__ExeFile% - -REM ** Set CORE_ROOT to empty so, ILCompiler's corerun doesn't load dependencies from there. -set CORE_ROOT= - -if /i "%CoreRT_TestCompileMode%" == "cpp" goto :ModeCPP -if /i "%CoreRT_TestCompileMode%" == "ryujit" goto :ModeRyuJIT -echo Unrecognized compile mode: %CoreRT_TestCompileMode% -exit /b -1 - -:ModeRyuJIT -set __ObjFile=%__SourceFile%.obj -if exist %__ObjFile% del %__ObjFile% - -echo -o:%__ObjFile% >> %__RSPFile% - -%CoreRT_ToolchainDir%\corerun.exe %CoreRT_ToolchainDir%\ilc.exe @%__RSPFile% -if %ERRORLEVEL% NEQ 0 ((call :Fail "Unable to generate object file") & exit /b -1) - -link %__ObjFile% %CoreRT_ToolchainDir%\sdk\bootstrapper.lib %CoreRT_ToolchainDir%\sdk\runtime.lib ole32.lib OleAut32.lib kernel32.lib /out:%__ExeFile% /debug:full -if %ERRORLEVEL% NEQ 0 ((call :Fail "Linking failed") & exit /b -1) - -goto :Run - -:ModeCPP -call :Fail "ModeCPP Not Yet Implemented" -exit /b -1 - -:Run -REM ** Fail if we did not generate obj file -if exist "%__ExeFile%" ( - REM ** Should run the tests? - if "%CoreRT_TestRun%"=="false" (exit /b 100) - - REM ** Run the test - "%__ExeFile%" %__ExeParams% - - exit /b !ErrorLevel! -) else ( - echo "ILCompiler failed to generate exe, exiting..." - exit /b -1 -) - -endlocal - -:Fail -echo. -powershell -Command Write-Host %1 -foreground "red" -exit /b -1 - -:InvalidArgs -echo. -echo Usage: %0 ^<exe-dir^> ^<exe-name^> ^<exe-args^> -exit /b -3 diff --git a/tests/runtest.cmd b/tests/runtest.cmd index 9e7ce9354..f4fcab5e7 100644 --- a/tests/runtest.cmd +++ b/tests/runtest.cmd @@ -47,9 +47,6 @@ set __BuildStr=%CoreRT_BuildOS%.%CoreRT_BuildArch%.%CoreRT_BuildType% set __CoreRTTestBinDir=%CoreRT_TestRoot%..\bin\tests set __LogDir=%CoreRT_TestRoot%\..\bin\Logs\%__BuildStr%\tests -REM ** Validate the paths needed to run tests -if not exist "%CoreRT_AppDepSdkDir%" ((call :Fail "AppDep SDK not installed at %CoreRT_AppDepSdkDir%") & exit /b -1) - if not "%CoreRT_TestExtRepo%"=="" goto :TestExtRepo if /i "%__BuildType%"=="Debug" ( @@ -68,8 +65,7 @@ for /f "delims=" %%a in ('dir /s /aD /b src\*') do ( set __SourceFolder=%%a set __SourceFileName=%%~na set __RelativePath=!__SourceFolder:%CoreRT_TestRoot%=! - if exist "!__SourceFolder!\project.json" ( - %CoreRT_CliDir%\dotnet restore --quiet --source "https://dotnet.myget.org/F/dotnet-core" "!__SourceFolder!" + if exist "!__SourceFolder!\!__SourceFileName!.csproj" ( set __Mode=Jit call :CompileFile !__SourceFolder! !__SourceFileName! %__LogDir%\!__RelativePath! @@ -77,7 +73,7 @@ for /f "delims=" %%a in ('dir /s /aD /b src\*') do ( if not exist "!__SourceFolder!\no_cpp" ( set __Mode=Cpp - call :CompileFile !__SourceFolder! !__SourceFileName! %__LogDir%\!__RelativePath! --cpp + call :CompileFile !__SourceFolder! !__SourceFileName! %__LogDir%\!__RelativePath! set /a __CppTotalTests=!__CppTotalTests!+1 ) ) @@ -127,8 +123,10 @@ goto :eof set __SourceFolder=%~1 set __SourceFileName=%~2 set __CompileLogPath=%~3 - set __ExtraCompileArgs=%~4 - echo Compiling directory !__SourceFolder! !__ExtraCompileArgs! + + echo Compiling directory !__SourceFolder! !__Mode! + echo. + if not exist "!__CompileLogPath!" (mkdir !__CompileLogPath!) set __SourceFile=!__SourceFolder!\!__SourceFileName! @@ -136,12 +134,19 @@ goto :eof if exist "!__SourceFolder!\obj" rmdir /s /q !__SourceFolder!\obj setlocal - set additionalCompilerFlags= - if /i "%CoreRT_BuildType%" == "debug" ( - if /i "%__Mode%" == "cpp" set additionalCompilerFlags=--cppcompilerflags /MTd + set extraArgs= + if /i "%__Mode%" == "cpp" ( + set extraArgs=!extraArgs! /p:NativeCodeGen=cpp + if /i "%CoreRT_BuildType%" == "debug" ( + set extraArgs=!extraArgs! /p:AdditionalCppCompilerFlags=/MTd + ) ) + call "!VS140COMNTOOLS!\..\..\VC\vcvarsall.bat" %CoreRT_BuildArch% - "%CoreRT_CliDir%\dotnet" build --native --runtime "win7-x64" --ilcpath "%CoreRT_ToolchainDir%" --appdepsdkpath "%CoreRT_AppDepSdkDir%" !__ExtraCompileArgs! !__SourceFolder! -c %CoreRT_BuildType% %additionalCompilerFlags% + + echo msbuild "/p:IlcPath=%CoreRT_ToolchainDir%" "/p:Configuration=%CoreRT_BuildType%" !extraArgs! !__SourceFile!.csproj + echo. + msbuild "/p:IlcPath=%CoreRT_ToolchainDir%" "/p:Configuration=%CoreRT_BuildType%" !extraArgs! !__SourceFile!.csproj endlocal set __SavedErrorLevel=%ErrorLevel% @@ -150,7 +155,7 @@ goto :eof if "%__SavedErrorLevel%"=="0" ( echo. echo Running test !__SourceFileName! - call !__SourceFile!.cmd !__SourceFolder!\bin\%CoreRT_BuildType%\dnxcore50\win7-x64\native !__SourceFileName!.exe + call !__SourceFile!.cmd !__SourceFolder!\bin\%CoreRT_BuildType%\native !__SourceFileName!.exe set __SavedErrorLevel=!ErrorLevel! ) diff --git a/tests/runtest.sh b/tests/runtest.sh index 11c720264..43d401ba4 100755 --- a/tests/runtest.sh +++ b/tests/runtest.sh @@ -16,37 +16,27 @@ runtest() __SourceFolder=$1 __SourceFileName=$2 __SourceFile=${__SourceFolder}/${__SourceFileName} - ${__SourceFile}.sh $1/bin/${CoreRT_BuildType}/dnxcore50/${__BuildRid}/native $2 + ${__SourceFile}.sh $1/bin/${CoreRT_BuildType}/native $2 return $? } -restore() -{ - ${CoreRT_CliBinDir}/dotnet restore --quiet $1 --source "https://dotnet.myget.org/F/dotnet-core" -} - -compiletest() -{ - echo "Compiling dir $1 with dotnet build $2" - rm -rf $1/bin $1/obj - ${CoreRT_CliBinDir}/dotnet build --runtime ${__BuildRid} --native -c ${CoreRT_BuildType} --ilcpath ${CoreRT_ToolchainDir} --appdepsdkpath ${CoreRT_AppDepSdkDir} $1 $2 -} - run_test_dir() { local __test_dir=$1 - local __restore=$2 - local __mode=$3 + local __mode=$2 local __dir_path=`dirname ${__test_dir}` local __filename=`basename ${__dir_path}` - if [ ${__restore} == 1 ]; then - restore ${__dir_path} - fi - local __compile_args="" + local __extra_args="" if [ "${__mode}" = "Cpp" ]; then - __compile_args="--cpp" + __extra_args="${__extra_args} /p:NativeCodeGen=cpp" fi - compiletest ${__dir_path} ${__compile_args} + + rm -rf ${__dir_path}/bin ${__dir_path}/obj + + local __msbuild_dir=${CoreRT_TestRoot}/../Tools + echo ${__msbuild_dir}/corerun ${__msbuild_dir}/MSBuild.exe /p:IlcPath=${CoreRT_ToolchainDir} /p:Configuration=${CoreRT_BuildType} ${__extra_args} ${__dir_path}/${__filename}.csproj + ${__msbuild_dir}/corerun ${__msbuild_dir}/MSBuild.exe /p:IlcPath=${CoreRT_ToolchainDir} /p:Configuration=${CoreRT_BuildType} ${__extra_args} ${__dir_path}/${__filename}.csproj + runtest ${__dir_path} ${__filename} local __exitcode=$? if [ ${__exitcode} == 0 ]; then @@ -133,11 +123,6 @@ else __BuildRid=osx.10.10-${CoreRT_BuildArch} fi -if [ ! -d ${CoreRT_AppDepSdkDir} ]; then - echo "AppDep SDK not installed at ${CoreRT_AppDepSdkDir}" - exit -1 -fi - if [ ! -d ${CoreRT_ToolchainDir} ]; then echo "Toolchain not found in ${CoreRT_ToolchainDir}" exit -1 @@ -152,14 +137,12 @@ echo > ${__CoreRTTestBinDir}/testResults.tmp __BuildOsLowcase=$(echo "${CoreRT_BuildOS}" | tr '[:upper:]' '[:lower:]') -for json in $(find src -iname 'project.json') +for csproj in $(find src -name "*.csproj") do - if [ ! -e `dirname ${json}`/no_unix ]; then - __restore=1 - run_test_dir ${json} ${__restore} "Jit" - __restore=0 - if [ ! -e `dirname ${json}`/no_cpp ]; then - run_test_dir ${json} ${__restore} "Cpp" + if [ ! -e `dirname ${csproj}`/no_unix ]; then + run_test_dir ${csproj} "Jit" + if [ ! -e `dirname ${csproj}`/no_cpp ]; then + run_test_dir ${csproj} "Cpp" fi fi done diff --git a/tests/src/Simple/Add1/Add1.csproj b/tests/src/Simple/Add1/Add1.csproj new file mode 100644 index 000000000..0948ddf81 --- /dev/null +++ b/tests/src/Simple/Add1/Add1.csproj @@ -0,0 +1,7 @@ +<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Compile Include="*.cs" /> + </ItemGroup> + + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), SimpleTest.targets))\SimpleTest.targets" /> +</Project> diff --git a/tests/src/Simple/Add1/project.json b/tests/src/Simple/Add1/project.json deleted file mode 100644 index 271875a54..000000000 --- a/tests/src/Simple/Add1/project.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "version": "1.0.0-*", - "compilationOptions": { - "emitEntryPoint": true - }, - - "dependencies": { - "NETStandard.Library": "1.0.0-rc2-23819" - }, - - "frameworks": { - "dnxcore50": { } - }, - - "runtimes": { - "win7-x64": { }, - "osx.10.10-x64": { }, - "ubuntu.14.04-x64": { } - } -} diff --git a/tests/src/Simple/Delegates/Delegates.csproj b/tests/src/Simple/Delegates/Delegates.csproj new file mode 100644 index 000000000..0948ddf81 --- /dev/null +++ b/tests/src/Simple/Delegates/Delegates.csproj @@ -0,0 +1,7 @@ +<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Compile Include="*.cs" /> + </ItemGroup> + + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), SimpleTest.targets))\SimpleTest.targets" /> +</Project> diff --git a/tests/src/Simple/Delegates/project.json b/tests/src/Simple/Delegates/project.json deleted file mode 100644 index 170ac38a6..000000000 --- a/tests/src/Simple/Delegates/project.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "version": "1.0.0-*", - "compilationOptions": { - "emitEntryPoint": true, - "allowUnsafe": true - }, - - "dependencies": { - "NETStandard.Library": "1.0.0-rc2-23819" - }, - - "frameworks": { - "dnxcore50": { } - }, - - "runtimes": { - "win7-x64": { }, - "osx.10.10-x64": { }, - "ubuntu.14.04-x64": { } - } -} diff --git a/tests/src/Simple/Exceptions/Exceptions.csproj b/tests/src/Simple/Exceptions/Exceptions.csproj new file mode 100644 index 000000000..0948ddf81 --- /dev/null +++ b/tests/src/Simple/Exceptions/Exceptions.csproj @@ -0,0 +1,7 @@ +<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Compile Include="*.cs" /> + </ItemGroup> + + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), SimpleTest.targets))\SimpleTest.targets" /> +</Project> diff --git a/tests/src/Simple/Exceptions/no_unix b/tests/src/Simple/Exceptions/no_unix deleted file mode 100644 index 9db98903a..000000000 --- a/tests/src/Simple/Exceptions/no_unix +++ /dev/null @@ -1 +0,0 @@ -Skip this test on unix diff --git a/tests/src/Simple/Exceptions/project.json b/tests/src/Simple/Exceptions/project.json deleted file mode 100644 index 271875a54..000000000 --- a/tests/src/Simple/Exceptions/project.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "version": "1.0.0-*", - "compilationOptions": { - "emitEntryPoint": true - }, - - "dependencies": { - "NETStandard.Library": "1.0.0-rc2-23819" - }, - - "frameworks": { - "dnxcore50": { } - }, - - "runtimes": { - "win7-x64": { }, - "osx.10.10-x64": { }, - "ubuntu.14.04-x64": { } - } -} diff --git a/tests/src/Simple/Formatting/Formatting.csproj b/tests/src/Simple/Formatting/Formatting.csproj new file mode 100644 index 000000000..0948ddf81 --- /dev/null +++ b/tests/src/Simple/Formatting/Formatting.csproj @@ -0,0 +1,7 @@ +<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Compile Include="*.cs" /> + </ItemGroup> + + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), SimpleTest.targets))\SimpleTest.targets" /> +</Project> diff --git a/tests/src/Simple/Formatting/project.json b/tests/src/Simple/Formatting/project.json deleted file mode 100644 index 271875a54..000000000 --- a/tests/src/Simple/Formatting/project.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "version": "1.0.0-*", - "compilationOptions": { - "emitEntryPoint": true - }, - - "dependencies": { - "NETStandard.Library": "1.0.0-rc2-23819" - }, - - "frameworks": { - "dnxcore50": { } - }, - - "runtimes": { - "win7-x64": { }, - "osx.10.10-x64": { }, - "ubuntu.14.04-x64": { } - } -} diff --git a/tests/src/Simple/Hello/Hello.csproj b/tests/src/Simple/Hello/Hello.csproj new file mode 100644 index 000000000..0948ddf81 --- /dev/null +++ b/tests/src/Simple/Hello/Hello.csproj @@ -0,0 +1,7 @@ +<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Compile Include="*.cs" /> + </ItemGroup> + + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), SimpleTest.targets))\SimpleTest.targets" /> +</Project> diff --git a/tests/src/Simple/Hello/project.json b/tests/src/Simple/Hello/project.json deleted file mode 100644 index 271875a54..000000000 --- a/tests/src/Simple/Hello/project.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "version": "1.0.0-*", - "compilationOptions": { - "emitEntryPoint": true - }, - - "dependencies": { - "NETStandard.Library": "1.0.0-rc2-23819" - }, - - "frameworks": { - "dnxcore50": { } - }, - - "runtimes": { - "win7-x64": { }, - "osx.10.10-x64": { }, - "ubuntu.14.04-x64": { } - } -} diff --git a/tests/src/Simple/Interfaces/Interfaces.csproj b/tests/src/Simple/Interfaces/Interfaces.csproj new file mode 100644 index 000000000..0948ddf81 --- /dev/null +++ b/tests/src/Simple/Interfaces/Interfaces.csproj @@ -0,0 +1,7 @@ +<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Compile Include="*.cs" /> + </ItemGroup> + + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), SimpleTest.targets))\SimpleTest.targets" /> +</Project> diff --git a/tests/src/Simple/Interfaces/project.json b/tests/src/Simple/Interfaces/project.json deleted file mode 100644 index 271875a54..000000000 --- a/tests/src/Simple/Interfaces/project.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "version": "1.0.0-*", - "compilationOptions": { - "emitEntryPoint": true - }, - - "dependencies": { - "NETStandard.Library": "1.0.0-rc2-23819" - }, - - "frameworks": { - "dnxcore50": { } - }, - - "runtimes": { - "win7-x64": { }, - "osx.10.10-x64": { }, - "ubuntu.14.04-x64": { } - } -} diff --git a/tests/src/Simple/Reflection/Reflection.csproj b/tests/src/Simple/Reflection/Reflection.csproj new file mode 100644 index 000000000..0948ddf81 --- /dev/null +++ b/tests/src/Simple/Reflection/Reflection.csproj @@ -0,0 +1,7 @@ +<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Compile Include="*.cs" /> + </ItemGroup> + + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), SimpleTest.targets))\SimpleTest.targets" /> +</Project> diff --git a/tests/src/Simple/Reflection/project.json b/tests/src/Simple/Reflection/project.json deleted file mode 100644 index 271875a54..000000000 --- a/tests/src/Simple/Reflection/project.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "version": "1.0.0-*", - "compilationOptions": { - "emitEntryPoint": true - }, - - "dependencies": { - "NETStandard.Library": "1.0.0-rc2-23819" - }, - - "frameworks": { - "dnxcore50": { } - }, - - "runtimes": { - "win7-x64": { }, - "osx.10.10-x64": { }, - "ubuntu.14.04-x64": { } - } -} diff --git a/tests/src/Simple/SimpleTest.targets b/tests/src/Simple/SimpleTest.targets new file mode 100644 index 000000000..572e6982a --- /dev/null +++ b/tests/src/Simple/SimpleTest.targets @@ -0,0 +1,23 @@ +<Project ToolsVersion="14.0" DefaultTargets="LinkNative" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + + <PropertyGroup> + <OutputType>Exe</OutputType> + <OutputPath>$(MSBuildProjectDirectory)\bin\$(Configuration)\</OutputPath> + <IntermediateOutputPath>$(MSBuildProjectDirectory)\obj\$(Configuration)\</IntermediateOutputPath> + </PropertyGroup> + + <PropertyGroup> + <ProjectJson>$(MSBuildThisFileDirectory)\project.json</ProjectJson> + <ProjectLockJson>$(MSBuildThisFileDirectory)\project.lock.json</ProjectLockJson> + <CopyNuGetImplementations>false</CopyNuGetImplementations> + <GenerateAssemblyInfo>false</GenerateAssemblyInfo> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + </PropertyGroup> + + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + + <!-- Use the source primary copy for development convenience --> + <Import Project="$(MSBuildThisFileDirectory)\..\..\..\src\BuildIntegration\Microsoft.NETCore.Native.targets" /> + <!-- <Import Project="$(IlcPath)\Microsoft.NETCore.Native.targets" /> --> +</Project>
\ No newline at end of file diff --git a/tests/src/Simple/project.json b/tests/src/Simple/project.json new file mode 100644 index 000000000..0d0563883 --- /dev/null +++ b/tests/src/Simple/project.json @@ -0,0 +1,8 @@ +{ + "dependencies": { + "NETStandard.Library": "1.6.0", + }, + "frameworks": { + "netstandard1.3": {} + } +} diff --git a/tests/testenv.cmd b/tests/testenv.cmd index cea27cf72..dd797b893 100644 --- a/tests/testenv.cmd +++ b/tests/testenv.cmd @@ -16,11 +16,7 @@ if /i "%1" == "release" (set CoreRT_BuildType=Release&shift&goto Arg_Loop) set CoreRT_BuildOS=Windows_NT -set CoreRT_AppDepSdkPkg=toolchain.win7-%CoreRT_BuildArch%.Microsoft.DotNet.AppDep -set CoreRT_AppDepSdkVer=1.0.6-prerelease-00004 - set CoreRT_ToolchainDir=%~dp0\..\bin\Product\%CoreRT_BuildOS%.%CoreRT_BuildArch%.%CoreRT_BuildType%\packaging\publish1 -set CoreRT_AppDepSdkDir=%~dp0\..\packages\%CoreRT_AppDepSdkPkg%\%CoreRT_AppDepSdkVer% exit /b 0 diff --git a/tests/testenv.sh b/tests/testenv.sh index 1c77f879a..7fed24e48 100755 --- a/tests/testenv.sh +++ b/tests/testenv.sh @@ -89,10 +89,6 @@ else __BuildRid=osx.10.10-${CoreRT_BuildArch} fi -export CoreRT_AppDepSdkPkg=toolchain.${__BuildRid}.Microsoft.DotNet.AppDep -export CoreRT_AppDepSdkVer=1.0.6-prerelease-00004 - __ScriptDir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) export CoreRT_ToolchainDir=${__ScriptDir}/../bin/Product/${CoreRT_BuildOS}.${CoreRT_BuildArch}.${CoreRT_BuildType}/packaging/publish1 -export CoreRT_AppDepSdkDir=${__ScriptDir}/../packages/${CoreRT_AppDepSdkPkg}/${CoreRT_AppDepSdkVer} |