diff --git a/src/coreclr/tools/aot/ILCompiler/ILCompiler.props b/src/coreclr/tools/aot/ILCompiler/ILCompiler.props index e901d56df167fb..84855fc2f189ad 100644 --- a/src/coreclr/tools/aot/ILCompiler/ILCompiler.props +++ b/src/coreclr/tools/aot/ILCompiler/ILCompiler.props @@ -52,5 +52,6 @@ + diff --git a/src/coreclr/tools/aot/ILCompiler/reproZero/reproZero.csproj b/src/coreclr/tools/aot/ILCompiler/reproZero/reproZero.csproj new file mode 100644 index 00000000000000..9a501e553cfbcd --- /dev/null +++ b/src/coreclr/tools/aot/ILCompiler/reproZero/reproZero.csproj @@ -0,0 +1,64 @@ + + + + $(NetCoreAppToolCurrent) + Exe + x64;x86;wasm + AnyCPU + false + false + Debug;Release;Checked + true + false + true + true + false + false + false + v4.0.30319 + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/coreclr/tools/aot/ILCompiler/reproZero/zerosharp.cs b/src/coreclr/tools/aot/ILCompiler/reproZero/zerosharp.cs new file mode 100644 index 00000000000000..14ee6552bbbc51 --- /dev/null +++ b/src/coreclr/tools/aot/ILCompiler/reproZero/zerosharp.cs @@ -0,0 +1,129 @@ + // Licensed to the .NET Foundation under one or more agreements. + // The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Runtime; +using System.Runtime.InteropServices; + +#region A couple very basic things +namespace System +{ + public class Object + { +#pragma warning disable 169 + // The layout of object is a contract with the compiler. + private IntPtr m_pMethodTable; +#pragma warning restore 169 + } + public struct Void { } + + // The layout of primitive types is special cased because it would be recursive. + // These really don't need any fields to work. + public struct Boolean { } + public struct Char { } + public struct SByte { } + public struct Byte { } + public struct Int16 { } + public struct UInt16 { } + public struct Int32 { } + public struct UInt32 { } + public struct Int64 { } + public struct UInt64 { } + public struct IntPtr { } + public struct UIntPtr { } + public struct Single { } + public struct Double { } + + public abstract class ValueType { } + public abstract class Enum : ValueType { } + + public struct Nullable where T : struct { } + + public sealed class String { public readonly int Length; } + public abstract class Array { } + public abstract class Delegate { } + public abstract class MulticastDelegate : Delegate { } + + public struct RuntimeTypeHandle { } + public struct RuntimeMethodHandle { } + public struct RuntimeFieldHandle { } + + public class Attribute { } + + public enum AttributeTargets { } + + public sealed class AttributeUsageAttribute : Attribute + { + public AttributeUsageAttribute(AttributeTargets validOn) { } + public bool AllowMultiple { get; set; } + public bool Inherited { get; set; } + } + + public class AppContext + { + public static void SetData(string s, object o) { } + } + + namespace Runtime.CompilerServices + { + public class RuntimeHelpers + { + public static unsafe int OffsetToStringData => sizeof(IntPtr) + sizeof(int); + } + } +} +namespace System.Runtime.InteropServices +{ + public sealed class DllImportAttribute : Attribute + { + public DllImportAttribute(string dllName) { } + } +} +#endregion + +#region Things needed by ILC +namespace System +{ + namespace Runtime + { + internal sealed class RuntimeExportAttribute : Attribute + { + public RuntimeExportAttribute(string entry) { } + } + } + + class Array : Array { } +} + +namespace Internal.Runtime.CompilerHelpers +{ + // A class that the compiler looks for that has helpers to initialize the + // process. The compiler can gracefully handle the helpers not being present, + // but the class itself being absent is unhandled. Let's add an empty class. + class StartupCodeHelpers + { + // A couple symbols the generated code will need we park them in this class + // for no particular reason. These aid in transitioning to/from managed code. + // Since we don't have a GC, the transition is a no-op. + [RuntimeExport("RhpReversePInvoke")] + static void RhpReversePInvoke(IntPtr frame) { } + [RuntimeExport("RhpReversePInvokeReturn")] + static void RhpReversePInvokeReturn(IntPtr frame) { } + [RuntimeExport("RhpPInvoke")] + static void RhpPInvoke(IntPtr frame) { } + [RuntimeExport("RhpPInvokeReturn")] + static void RhpPInvokeReturn(IntPtr frame) { } + + [RuntimeExport("RhpFallbackFailFast")] + static void RhpFallbackFailFast() { while (true) ; } + } +} +#endregion + +unsafe class Program +{ + static int Main() + { + return 42; + } +}