diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml
index 2804aa2..6e02093 100644
--- a/.github/workflows/cicd.yml
+++ b/.github/workflows/cicd.yml
@@ -25,7 +25,7 @@ jobs:
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
- dotnet-version: '8.0.x'
+ dotnet-version: '10.0.x'
dotnet-quality: 'preview'
- name: Ask Github to please let us use the package registry
run: |
@@ -73,42 +73,42 @@ jobs:
tar -C layouts/linux-glibc-arm64/ -czvf layouts/linux-glibc-arm64.tar.gz .
tar -C layouts/obj/linux-glibc-arm64/ -czvf layouts/linux-glibc-arm64-symbols.tar.gz bflat.dwo
- name: Archive windows-x64 hosted compiler
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v4
with:
name: bflat-windows-x64.zip
path: layouts/windows-x64.zip
- name: Archive windows-x64 hosted compiler symbols
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v4
with:
name: debugsymbols-bflat-windows-x64.zip
path: layouts/windows-x64-symbols.zip
- name: Archive windows-arm64 hosted compiler
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v4
with:
name: bflat-windows-arm64.zip
path: layouts/windows-arm64.zip
- name: Archive windows-arm64 hosted compiler symbols
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v4
with:
name: debugsymbols-bflat-windows-arm64.zip
path: layouts/windows-arm64-symbols.zip
- name: Archive linux-glibc-x64 hosted compiler
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v4
with:
name: bflat-linux-glibc-x64.zip
path: layouts/linux-glibc-x64.tar.gz
- name: Archive linux-glibc-x64 hosted compiler symbols
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v4
with:
name: debugsymbols-bflat-linux-glibc-x64.zip
path: layouts/linux-glibc-x64-symbols.tar.gz
- name: Archive linux-glibc-arm64 hosted compiler
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v4
with:
name: bflat-linux-glibc-arm64.zip
path: layouts/linux-glibc-arm64.tar.gz
- name: Archive linux-glibc-arm64 hosted compiler symbols
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v4
with:
name: debugsymbols-bflat-linux-glibc-arm64.zip
path: layouts/linux-glibc-arm64-symbols.tar.gz
diff --git a/src/bflat.Tests/bflat.Tests.csproj b/src/bflat.Tests/bflat.Tests.csproj
index 011bd72..d27cc7e 100644
--- a/src/bflat.Tests/bflat.Tests.csproj
+++ b/src/bflat.Tests/bflat.Tests.csproj
@@ -1,7 +1,7 @@
- net6.0
+ net10.0
diff --git a/src/bflat/BuildCommand.cs b/src/bflat/BuildCommand.cs
index ca9d4ff..e13514e 100644
--- a/src/bflat/BuildCommand.cs
+++ b/src/bflat/BuildCommand.cs
@@ -32,6 +32,7 @@
using Microsoft.CodeAnalysis;
using ILCompiler;
+using ILCompiler.Dataflow;
using Internal.TypeSystem;
using Internal.IL;
@@ -210,9 +211,12 @@ public override int Handle(ParseResult result)
userSpecificedOutputFileName != null ? Path.GetFileNameWithoutExtension(userSpecificedOutputFileName) :
CommonOptions.GetOutputFileNameWithoutSuffix(userSpecifiedInputFiles);
+ bool disableCompilerGenerateHeuristics = false;
+
ILProvider ilProvider = new NativeAotILProvider();
bool verbose = result.GetValueForOption(CommonOptions.VerbosityOption);
- var logger = new Logger(Console.Out, ilProvider, verbose, Array.Empty(), singleWarn: false, Array.Empty(), Array.Empty(), Array.Empty());
+ var logger = new Logger(Console.Out, ilProvider, verbose, Array.Empty(), singleWarn: false, Array.Empty(), Array.Empty(), Array.Empty(),
+ false, new Dictionary(), disableCompilerGenerateHeuristics);
BuildTargetType buildTargetType = result.GetValueForOption(CommonOptions.TargetOption);
string compiledModuleName = Path.GetFileName(outputNameWithoutSuffix);
@@ -316,11 +320,12 @@ public override int Handle(ParseResult result)
if (stdlib != StandardLibType.DotNet)
{
+ SettingsTunnel.ZerolibLike = true;
SettingsTunnel.EmitGCInfo = false;
SettingsTunnel.EmitEHInfo = false;
SettingsTunnel.EmitGSCookies = false;
- if (debugInfoFormat == 0)
- SettingsTunnel.EmitUnwindInfo = false;
+ //if (debugInfoFormat == 0)
+ // SettingsTunnel.EmitUnwindInfo = false;
}
bool supportsReflection = !disableReflection && systemModuleName == DefaultSystemModule;
@@ -408,21 +413,22 @@ public override int Handle(ParseResult result)
typeSystemContext.SetSystemModule(typeSystemContext.GetModuleForSimpleName(systemModuleName));
EcmaModule compiledAssembly = typeSystemContext.GetModuleForSimpleName(compiledModuleName);
+ ilProvider = new HardwareIntrinsicILProvider(
+ instructionSetSupport,
+ new ExternSymbolMappedField(typeSystemContext.GetWellKnownType(WellKnownType.Int32), "g_cpuFeatures"),
+ ilProvider);
+
//
// Initialize compilation group and compilation roots
//
List initAssemblies = new List { "System.Private.CoreLib" };
- if (!disableReflection || !disableStackTraceData)
+ if (!disableReflection && !disableStackTraceData)
initAssemblies.Add("System.Private.StackTraceMetadata");
initAssemblies.Add("System.Private.TypeLoader");
-
- if (!disableReflection)
- initAssemblies.Add("System.Private.Reflection.Execution");
- else
- initAssemblies.Add("System.Private.DisabledReflection");
+ initAssemblies.Add("System.Private.Reflection.Execution");
// Build a list of assemblies that have an initializer that needs to run before
// any user code runs.
@@ -442,6 +448,7 @@ public override int Handle(ParseResult result)
CompilationModuleGroup compilationGroup;
List compilationRoots = new List();
+ TypeMapManager typeMapManager = new UsageBasedTypeMapManager(TypeMapMetadata.CreateFromAssembly((EcmaAssembly)compiledAssembly, typeSystemContext));
compilationRoots.Add(new UnmanagedEntryPointsRootProvider(compiledAssembly));
@@ -453,7 +460,7 @@ public override int Handle(ParseResult result)
}
else
{
- compilationRoots.Add(new GenericRootProvider
diff --git a/src/zerolib/System/Math.cs b/src/zerolib/System/Math.cs
new file mode 100644
index 0000000..34b5c5d
--- /dev/null
+++ b/src/zerolib/System/Math.cs
@@ -0,0 +1,47 @@
+// bflat minimal runtime library
+// Copyright (C) 2021-2022 Michal Strehovsky
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published
+// by the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+using System.Runtime.CompilerServices;
+
+namespace System
+{
+ public static class Math
+ {
+ internal static int ConvertToInt32Checked(double value)
+ {
+ Environment.FailFast(null);
+ return 0;
+ }
+
+ internal static uint ConvertToUInt32Checked(double value)
+ {
+ Environment.FailFast(null);
+ return 0;
+ }
+
+ internal static long ConvertToInt64Checked(double value)
+ {
+ Environment.FailFast(null);
+ return 0;
+ }
+
+ internal static ulong ConvertToUInt64Checked(double value)
+ {
+ Environment.FailFast(null);
+ return 0;
+ }
+ }
+}
diff --git a/src/zerolib/System/Runtime/CompilerServices/Unsafe.cs b/src/zerolib/System/Runtime/CompilerServices/Unsafe.cs
index 6b13ca8..5e3055f 100644
--- a/src/zerolib/System/Runtime/CompilerServices/Unsafe.cs
+++ b/src/zerolib/System/Runtime/CompilerServices/Unsafe.cs
@@ -32,5 +32,8 @@ public static unsafe partial class Unsafe
public static extern void* AsPointer(ref T value);
[Intrinsic]
public static extern ref T AsRef(void* source);
+ [Intrinsic]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static extern IntPtr ByteOffset(ref readonly T origin, ref readonly T target);
}
}
diff --git a/src/zerolib/System/SpanHelpers.cs b/src/zerolib/System/SpanHelpers.cs
new file mode 100644
index 0000000..0ffb6c1
--- /dev/null
+++ b/src/zerolib/System/SpanHelpers.cs
@@ -0,0 +1,47 @@
+// bflat minimal runtime library
+// Copyright (C) 2021-2022 Michal Strehovsky
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published
+// by the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+using System.Runtime.CompilerServices;
+
+namespace System
+{
+ internal static class SpanHelpers
+ {
+ [Intrinsic]
+ public static unsafe void ClearWithoutReferences(ref byte dest, nuint len)
+ {
+ Fill(ref dest, 0, len);
+ }
+
+ [Intrinsic]
+ internal static unsafe void Memmove(ref byte dest, ref byte src, nuint len)
+ {
+ if ((nuint)(nint)Unsafe.ByteOffset(ref src, ref dest) >= len)
+ for (nuint i = 0; i < len; i++)
+ Unsafe.Add(ref dest, (nint)i) = Unsafe.Add(ref src, (nint)i);
+ else
+ for (nuint i = len; i > 0; i--)
+ Unsafe.Add(ref dest, (nint)(i - 1)) = Unsafe.Add(ref src, (nint)(i - 1));
+ }
+
+
+ internal static void Fill(ref byte dest, byte value, nuint len)
+ {
+ for (nuint i = 0; i < len; i++)
+ Unsafe.Add(ref dest, (nint)i) = value;
+ }
+ }
+}