Git Product home page Git Product logo

dotnet / corert Goto Github PK

View Code? Open in Web Editor NEW
2.9K 311.0 511.0 49.51 MB

This repo contains CoreRT, an experimental .NET Core runtime optimized for AOT (ahead of time compilation) scenarios, with the accompanying compiler toolchain.

Home Page: http://dot.net

License: MIT License

CMake 0.24% C++ 13.98% C 2.29% Shell 0.27% C# 79.28% Batchfile 0.21% PowerShell 0.07% Assembly 3.26% Python 0.34% Dockerfile 0.01% Visual Basic .NET 0.01% JavaScript 0.04%

corert's Introduction

.NET Core Runtime (CoreRT)

This project is superseded by NativeAOT experiment in dotnet/runtimelab repo.

This repo contains the .NET Core runtime optimized for ahead of time compilation. The CoreRT compiler can compile a managed .NET Core application into a native (architecture specific) single-file executable that is easy to deploy. It can also produce standalone dynamic or static libraries that can be consumed by applications written in other programming languages. To learn more about CoreRT, see the intro document.

Try Our Samples

If you would like to give CoreRT a try, we publish daily snapshots of CoreRT to a NuGet feed. Using CoreRT is as simple as adding a new package reference to your .NET Core project and publishing it. Check out one of our samples: a "Hello World" console app, a simple ASP.NET Core app, a MonoGame game or a native library. The README.md file in each sample's directory will guide you through the process step by step.

Platforms

How to Engage, Contribute and Provide Feedback

Some of the best ways to contribute are to try things out, file bugs, and join in design conversations.

Looking for something to work on? The up for grabs issues are a great place to start. Take a look at our documentation to find out about the architecture and learn how to build and test the repo.

This project follows the .NET Core Contribution Guidelines.

Join the chat at https://gitter.im/dotnet/corert

.NET Native for UWP Support

Use https://developercommunity.visualstudio.com/ to report problems and suggestions related to .NET Native for UWP.

Reporting security issues and security bugs

Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) [email protected]. You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Further information, including the MSRC PGP key, can be found in the Security TechCenter.

License

The CoreRT Repo is licensed under the MIT license.

.NET Foundation

CoreRT is a .NET Foundation project.

This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community. For more information, see the .NET Foundation Code of Conduct.

Related Projects

There are many .NET related projects on GitHub.

corert's People

Contributors

a-and avatar adityamandaleeka avatar ahsonkhan avatar anipik avatar antonlapounov avatar atsushikan avatar benaadams avatar bredpet avatar cshung avatar davidwrighton avatar dotnet-bot avatar filipnavara avatar gkhanna79 avatar grabyourpitchforks avatar janvorli avatar jkotas avatar luqunl avatar marek-safar avatar michalstrehovsky avatar morganbr avatar nattress avatar sergign60 avatar sergiy-k avatar shrah avatar stephentoub avatar swgillespie avatar tannergooding avatar tarekgh avatar trylek avatar yowl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

corert's Issues

Namespace and .dll name collisions (CppCodeGen)

using System;

namespace WebApplication106
{
    public class Startup
    {
        public static void Main(string[] args)
        {
            var identity = new Func<int, int>(Identity);
        }

        private static int Identity(int arg)
        {
            return arg;
        }
    }
}

I get compilation errors in the generated Cpp

Infinite recursion in virtual method resolution

Paste this program into "repro" solution and compile it using ILToNative.

using System;

class Program
{
    class MyG<T>
    {
        override public string ToString()
        {
            return null;
        }
    }

    static void Main(string[] args)
    {
        new MyG<Program>().ToString();
    }
}

Remove encoding workaround

\src\System.Private.CoreLib\src\System\Environment.EnvironmentVariables.Unix.cs has a workaround to return null for LANG environment variable. This is to prevent System.Console from taking complicated code paths that we don't support yet.

The required feature is either interface calls or constrained calls (don't remember which one...).

Standardize on a style for structs with no logic

We have a bunch of structs that are just a bundle of values with no logic - we are using private fields + properties in some places, and public readonly fields in other places.

Would be nice to use readonly fields everywhere we can.

Invariant culture hardcoding has recursive nature

        private static bool Init()
        {
            if (s_InvariantCultureInfo == null)
            {
                CultureInfo temp = new CultureInfo("", false);
                temp._isReadOnly = true;
                s_InvariantCultureInfo = temp;
            }

            s_userDefaultCulture = GetUserDefaultCulture();
            return true;
        }

Notice this will call "new CultureInfo(...)" which is defined as:

        internal CultureInfo(String name, bool useUserOverride)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name",
                    SR.ArgumentNull_String);
            }

#if CORERT
            // CORERT-TODO CultureInfo
            m_cultureData = s_InvariantCultureInfo.m_cultureData;
            m_name = _sortName = _nonSortName = name;
            m_isInherited = false;
#else
            ...

The constructor is trying to access s_InvariantCultureInfo which is not yet initialized because we're in the process of initializing it.

To hit the bug, undo workaround #117 and compile hello world. Make sure you have the contents of pull request #125 or you'll hit a different bug.

Stil can't use System.Console in some cases (CppCodeGen)

When I try to use the System.Console in my ASP.NET sample I get this:

1>c:\corefxlab\src\system.buffers\src\system\buffers\bufferpool.cs(17193): error C2733: 'FormatMessageW': second C linkage of overloaded function not allowed
1>  c:\corefxlab\src\system.buffers\src\system\buffers\bufferpool.cs(7454): note: see declaration of 'FormatMessageW'
1>c:\corefxlab\src\system.buffers\src\system\buffers\bufferpool.cs(21051): error C2556: 'uint32_t GetLastError(void)': overloaded function differs only by return type from 'int32_t GetLastError(void)'
1>  c:\corefxlab\src\system.buffers\src\system\buffers\bufferpool.cs(17199): note: see declaration of 'GetLastError'
1>c:\corefxlab\src\system.buffers\src\system\buffers\bufferpool.cs(21051): error C2371: 'GetLastError': redefinition; different basic types

/cc @jkotas

Looks like the issue is with System.Buffers?

Turning off line numbers shows:

1>c:\dev\git\corert\src\iltonative\repronative\repro.cpp(30841): error C2733: 'FormatMessageW': second C linkage of overloaded function not allowed
1>  c:\dev\git\corert\src\iltonative\repronative\repro.cpp(21102): note: see declaration of 'FormatMessageW'
1>c:\dev\git\corert\src\iltonative\repronative\repro.cpp(34699): error C2556: 'uint32_t GetLastError(void)': overloaded function differs only by return type from 'int32_t GetLastError(void)'
1>  c:\dev\git\corert\src\iltonative\repronative\repro.cpp(30847): note: see declaration of 'GetLastError'
1>c:\dev\git\corert\src\iltonative\repronative\repro.cpp(34699): error C2371: 'GetLastError': redefinition; different basic types

It would help if the cpp codegen preserved (maybe in a comment) where it found the DLL exports. That would help identify the problem.

Remove or mitigate Windows dependencies

Just built CoreRT on OS X. Got error messages about installing an SDK of reference assemblies into the GAC.

/Users/rlander/git/corert/packages/Microsoft.Build.Mono.Debug.14.1.0.0-prerelease/lib/Microsoft.Common.CurrentVersion.targets(1090,5): warning MSB3644: The reference assemblies for framework ".NETPortable,Version=v4.5,Profile=Profile7" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [/Users/rlander/git/corert/src/ILToNative.DependencyAnalysisFramework/tests/ILToNative.DependencyAnalysisFramework.Tests.csproj]
/Users/rlander/git/corert/packages/Microsoft.Build.Mono.Debug.14.1.0.0-prerelease/lib/Microsoft.Common.CurrentVersion.targets(1090,5): warning MSB3644: The reference assemblies for framework ".NETPortable,Version=v4.5" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [/Users/rlander/git/corert/src/ILToNative.DependencyAnalysisFramework/tests/ILToNative.DependencyAnalysisFramework.Tests.csproj]
/Users/rlander/git/corert/packages/Microsoft.Build.Mono.Debug.14.1.0.0-prerelease/lib/Microsoft.Common.CurrentVersion.targets(1090,5): warning MSB3644: The reference assemblies for framework ".NETPortable,Version=v4.5,Profile=Profile7" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [/Users/rlander/git/corert/src/ILToNative.TypeSystem/tests/CoreTestAssembly/CoreTestAssembly.csproj]
/Users/rlander/git/corert/packages/Microsoft.Build.Mono.Debug.14.1.0.0-prerelease/lib/Microsoft.Common.CurrentVersion.targets(1090,5): warning MSB3644: The reference assemblies for framework ".NETPortable,Version=v4.5" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [/Users/rlander/git/corert/src/ILToNative.TypeSystem/tests/CoreTestAssembly/CoreTestAssembly.csproj]
CoreTestAssembly -> /Users/rlander/git/corert/bin/Product/OSX.x64.Debug/CoreTestAssembly.dll
/Users/rlander/git/corert/packages/Microsoft.Build.Mono.Debug.14.1.0.0-prerelease/lib/Microsoft.Common.CurrentVersion.targets(1090,5): warning MSB3644: The reference assemblies for framework ".NETPortable,Version=v4.5,Profile=Profile7" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [/Users/rlander/git/corert/src/ILToNative.TypeSystem/tests/TypeSystem.Tests.csproj]
/Users/rlander/git/corert/packages/Microsoft.Build.Mono.Debug.14.1.0.0-prerelease/lib/Microsoft.Common.CurrentVersion.targets(1090,5): warning MSB3644: The reference assemblies for framework ".NETPortable,Version=v4.5" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [/Users/rlander/git/corert/src/ILToNative.TypeSystem/tests/TypeSystem.Tests.csproj]

Assertion Failed: node.StaticDependenciesAreComputed

Compile "hello world" using JIT codegen:

at ILToNative.DependencyAnalysisFramework.DependencyAnalyzer`2.ComputeMarkedNodes() in C:\corert\src\ILToNative.DependencyAnalysisFramework\src\DependencyAnalyzer.cs:line 254

Implement error/warning infrastructure in the type system

Good warnings and error reporting are of great help to tool developers or general developers alike.

The warning system should not be a burden in environments where warnings are undesired/unactionable - it should get out of the way without impacting perf. At the same time we want the warning system be flexible enough to enable PEVerify-like scenarios (dotnet/coreclr/#295) for the type system in the future.

The error system should be based on standardized exceptions that provide context with programmatic access (e.g. having an object-typed Pertinent property that points to a type system object associated with the exception).

Fix Mac OSX build Breaks

Mac build fails with the following error:

In file included from /Users/gkhanna/Github/gkhanna79/corert/src/Native/Runtime/EHHelpers.cpp:26:
/Users/gkhanna/Github/gkhanna79/corert/src/Native/Runtime/stressLog.h:377:9: error: unused typedef 'C_ASSERT' [-Werror,-Wunused-local-typedef]

This happens on Apple Clang 7+ (part of XCode 7+) and is no repro on Apple Clang 6.1 (part of XCode 6.1+).

Make VS projects drop to the same locations as build.cmd

#104 (it was not perfect before, but #104 made it significantly worse) regressed where the bits are dropped by VS projects. E.g

  • Building in VS drops System.Private.CoreLib.dll to C:\corert\bin\System.Private.CoreLib.dll and C:\corert\bin\System.Private.CoreLib\System.Private.CoreLib.dll
  • build.cmd drops it to C:\corert\bin\Product\Windows_NT.x64.Debug\System.Private.CoreLib.dll.

We need to get these back in sync to maintain development loop efficiency.

Implement C++ JitInterface wrapper

Implement C++ JIT interface wrapper that will catch the managed exception and re-throw it as unmanaged exception so that we can throw managed exceptions from JitInterface and not crash afterwards on Linux.

Implement error/warning infrastructure in the compiler

The compiler needs a warning/error infrastructure that provides experience developers in the 21st century got used to.

This includes:

  • Errors that can unambiguously distinguish between bad inputs and internal compiler errors. For bad inputs, they should be actionable and provide good context.
  • Warnings that have warning levels associated with them
  • Warnings that can be selectively disabled
  • Errors and warnings that are testable. We have seen diagnostics silently regressing far too often in the past

This should work together with the error/warning infrastructure in the type system (#71).

CoreLib doesn't implement Environment.GetEnvironmentVariable and friends

GetEnvironmentVariable and ExpandEnvironment are implemented like this:

public static String GetEnvironmentVariable(String variable)
{
    if (variable == null)
        throw new ArgumentNullException("variable");

    // Environment variable accessors are not approved modern API.
    // Behave as if the variable was not found in this case.
    return null;
}

We need real implementations.

Running ILToNative.exe from the command line against the .NET Framework

I'm not sure if this is my setup but I'm unable to run ILToNative.exe from the command line (although I'm pretty sure it worked last week). It fails because it wants to load the following assembly:

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
at ILToNative.Program.Run(String[] args)
at ILToNative.Program.Main(String[] args) in C:\work\Microsoft\corert\src\ILToNative\src\Program.cs:line 180

I can run it just fine using CoreCLR or from VisualStudio.

Static/instance field layout tests for non x64 architectures

We should refactor the existing static/instance field layout type system tests to be easily extensible to other platform. Currently, the expected offsets are hardcoded to a specific number and the architecture is hardcoded to x64 (aka AMD64 or x86-64).

What we want is probably a data structure that has expected field offsets for each architecture and a driver that iterates over all architectures and for each architecture tests that the computed offsets match the expected values.

I didn't do it initially because the tests are a line-by-line port from the tests for the .NET Native NUTC compiler and we don't support anything but x64 right now anyway.

Followon work for after dependency analysis checkin

  • Convert Cpp code gen to use dependency analysis
  • Use only 1 Relocation structure
  • Remove unused AsmWriter
  • Generate target in jit interface as dependency analysis nodes directly instead of having translation step

Fix InstantiatedType.GetMethods signature handling

Currently, InstantiatedType.GetMethods uninstantiates the type before doing signature comparisons with the signature passed in. This doesn't work for the case where the signature in question was instantiated since the instantiated type doesn't match the generic parameter. When fixing this, please remove the workaround in FindMatchingVirtualMethodOnTypeByNameAndSig in VirtualFunctionResolution.cs

Enable tests for Linux/Mac

Similar to how we build and run tests, as part of the product build on Windows, we need to enable the same for Linux and Mac as well.

Debug Assertion Violation: !IsStateSet(TSF_Detached)

"Hello world" crashes during shutdown with debug assertion violation:

Expression: '!IsStateSet(TSF_Detached)`

File: c:\corert\src\native\runtime\thread.cpp, Line: 951

reproNativeCpp.exe!PalDebugBreak() Line 918   C++
reproNativeCpp.exe!Assert(const char * expr, const char * file, unsigned int line_num, const char * message) Line 97  C++
reproNativeCpp.exe!Thread::SetDetached() Line 952        C++
reproNativeCpp.exe!Thread::Destroy() Line 405  C++
reproNativeCpp.exe!ThreadStore::DetachCurrentThreadIfHomeFiber() Line 247  C++
reproNativeCpp.exe!FiberDetach(void * lpFlsData) Line 267          C++

Name mangling robustness

Make name mangling to be robust against collisions with built-in C++ identifiers or our internal identifiers (see #31)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.