-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Add reproZero NativeAOT compiler project #131686
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jtschuster
wants to merge
3
commits into
dotnet:main
Choose a base branch
from
jtschuster:extract-repro-zero
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+194
−0
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,5 +52,6 @@ | |
|
|
||
| <ItemGroup> | ||
| <Compile Remove="repro\*" /> | ||
| <Compile Remove="reproZero\*" /> | ||
| </ItemGroup> | ||
| </Project> | ||
64 changes: 64 additions & 0 deletions
64
src/coreclr/tools/aot/ILCompiler/reproZero/reproZero.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <!-- | ||
| This project builds a runtime-less .NET project that can be compiled with ilcompiler with the generated .rsp | ||
| and then linked with native libs to create a very barebones executable. Based off zerosharp. Helpful during | ||
| platform bringup, like ongoing wasm work, to be able to perform some validation before a runtime and CoreLib are buildable. | ||
| --> | ||
| <PropertyGroup> | ||
| <TargetFramework>$(NetCoreAppToolCurrent)</TargetFramework> | ||
| <OutputType>Exe</OutputType> | ||
| <Platforms>x64;x86;wasm</Platforms> | ||
| <PlatformTarget>AnyCPU</PlatformTarget> | ||
| <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> | ||
| <AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath> | ||
| <Configurations>Debug;Release;Checked</Configurations> | ||
| <AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
| <RunAnalyzers>false</RunAnalyzers> | ||
| <NoStdLib>true</NoStdLib> | ||
| <DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences> | ||
| <GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute> | ||
| <GenerateAssemblyInfo>false</GenerateAssemblyInfo> | ||
| <AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects> | ||
| <RuntimeMetadataVersion>v4.0.30319</RuntimeMetadataVersion> | ||
| <UseAppHost>false</UseAppHost> | ||
| </PropertyGroup> | ||
|
|
||
| <!-- Strip every resolved reference so csc compiles zerosharp.cs against no metadata at all. --> | ||
| <Target Name="RemoveAllReferences" BeforeTargets="CoreCompile"> | ||
| <ItemGroup> | ||
| <ReferencePathWithRefAssemblies Remove="@(ReferencePathWithRefAssemblies)" /> | ||
| <ReferencePath Remove="@(ReferencePath)" /> | ||
| <Reference Remove="@(Reference)" /> | ||
| </ItemGroup> | ||
| </Target> | ||
|
|
||
| <Target Name="GenerateReproProjectResponseFile" | ||
| AfterTargets="Build" | ||
| Condition="'$(BuildingInsideVisualStudio)' != 'true'"> | ||
|
|
||
| <ItemGroup> | ||
| <ReproResponseLines Include="$(OutputPath)$(AssemblyName)$(TargetExt)" /> | ||
| <ReproResponseLines Include="--targetarch:$(Platform)" /> | ||
| <ReproResponseLines Include="-o:$(OutputPath)$(AssemblyName).obj" /> | ||
| <!-- <ReproResponseLines Include="-g" /> --> | ||
| <ReproResponseLines Include="-O" Condition="'$(Optimize)' == 'true'" /> | ||
| <ReproResponseLines Include="--systemmodule:reproZero" /> | ||
| <ReproResponseLines Include="--dehydrate" /> | ||
| <ReproResponseLines Include="--stacktracedata:lines" /> | ||
| <ReproResponseLines Include="--scanreflection" /> | ||
| <ReproResponseLines Include="--feature:System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization=false" /> | ||
| <ReproResponseLines Include="--feature:System.Diagnostics.Tracing.EventSource.IsSupported=false" /> | ||
| <ReproResponseLines Include="--feature:System.Resources.ResourceManager.AllowCustomResourceTypes=false" /> | ||
| <ReproResponseLines Include="--feature:System.Linq.Expressions.CanEmitObjectArrayDelegate=false" /> | ||
| <ReproResponseLines Include="--feature:System.Runtime.CompilerServices.RuntimeFeature.IsDynamicCodeSupported=false" /> | ||
| <ReproResponseLines Include="--feature:System.Globalization.Invariant=true" /> | ||
| <ReproResponseLines Include="--feature:System.Diagnostics.Debugger.IsSupported=false" /> | ||
| <ReproResponseLines Include="--feature:System.StartupHookProvider.IsSupported=false" /> | ||
| </ItemGroup> | ||
|
|
||
| <WriteLinesToFile File="$(OutputPath)compile-with-$(LibrariesConfiguration)-libs.rsp" | ||
| Lines="@(ReproResponseLines)" | ||
| Overwrite="true" | ||
| WriteOnlyWhenDifferent="true" /> | ||
| </Target> | ||
| </Project> | ||
129 changes: 129 additions & 0 deletions
129
src/coreclr/tools/aot/ILCompiler/reproZero/zerosharp.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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<T> 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<T> : 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; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.