Skip to content

Commit

Permalink
Merge pull request #28 from kelnishi/build-settings
Browse files Browse the repository at this point in the history
Adding net8.0 support for Wacs.Console AOT build
  • Loading branch information
kelnishi authored Nov 26, 2024
2 parents 2f5cf60 + 12e16f2 commit 5217647
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 9 deletions.
8 changes: 7 additions & 1 deletion Wacs.Console/Wacs.Console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>9</LangVersion>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Exe</OutputType>

<PublishAot>true</PublishAot>
<SelfContained>true</SelfContained>
<PublishTrimmed>true</PublishTrimmed>

<AssemblyVersion>0.0.1</AssemblyVersion>
<FileVersion>0.0.1</FileVersion>
<Company>Kelvin Nishikawa</Company>
Expand All @@ -24,6 +29,7 @@
<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="JetBrains.Profiler.Api" Version="1.4.8" />
<PackageReference Include="runtime.osx-arm64.Microsoft.DotNet.ILCompiler" Version="8.0.11" />
</ItemGroup>

</Project>
24 changes: 24 additions & 0 deletions Wacs.Core/Instructions/Memory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,27 +312,51 @@ public void SetMemoryValue(ExecContext context, uint offset, Value c)
break;
case BitWidth.S16:
short cI16 = (short)c.Int32;
#if NETSTANDARD2_1
MemoryMarshal.Write(bs, ref cI16);
#else
MemoryMarshal.Write(bs, in cI16); // Assume you can change to 'in'
#endif
break;
case BitWidth.U16:
ushort cU16 = (ushort)c.UInt32;
#if NETSTANDARD2_1
MemoryMarshal.Write(bs, ref cU16);
#else
MemoryMarshal.Write(bs, in cU16);
#endif
break;
case BitWidth.S32:
int cI32 = c.Int32;
#if NETSTANDARD2_1
MemoryMarshal.Write(bs, ref cI32);
#else
MemoryMarshal.Write(bs, in cI32);
#endif
break;
case BitWidth.U32:
uint cU32 = c.UInt32;
#if NETSTANDARD2_1
MemoryMarshal.Write(bs, ref cU32);
#else
MemoryMarshal.Write(bs, in cU32);
#endif
break;
case BitWidth.U64:
ulong cU64 = c.UInt64;
#if NETSTANDARD2_1
MemoryMarshal.Write(bs, ref cU64);
#else
MemoryMarshal.Write(bs, in cU64);
#endif
break;
case BitWidth.V128:
V128 cV128 = c.V128;
#if NETSTANDARD2_1
MemoryMarshal.Write(bs, ref cV128);
#else
MemoryMarshal.Write(bs, in cV128);
#endif
break;
}
}
Expand Down
4 changes: 4 additions & 0 deletions Wacs.Core/Runtime/Types/MemoryInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ public int WriteStruct<T>(uint ptr, ref T str)
{
int size = Marshal.SizeOf<T>();
var buf = this[(int)ptr..(int)(ptr + size)];
#if NETSTANDARD2_1
MemoryMarshal.Write(buf, ref str);
#else
MemoryMarshal.Write(buf, in str);
#endif
return size;
}

Expand Down
4 changes: 2 additions & 2 deletions Wacs.Core/Wacs.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>9</LangVersion>
Expand All @@ -22,14 +21,15 @@
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<RepositoryType>git</RepositoryType>
<TargetFrameworks>netstandard2.1;net8.0</TargetFrameworks>
</PropertyGroup>

<PropertyGroup>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
<None Update="README.md">
<None Include="README.md">
<Pack>true</Pack>
<PackagePath/>
</None>
Expand Down
4 changes: 4 additions & 0 deletions Wacs.WASIp1/FsFd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,11 @@ public ErrNo FdReaddir(ExecContext ctx, fd fd, ptr bufPtr, size bufLen, dircooki
var entryTarget = window[start..delim];
var nameTarget = window[delim..end];
var dirEnt = struc;
#if NETSTANDARD2_1
MemoryMarshal.Write(entryTarget, ref dirEnt);
#else
MemoryMarshal.Write(entryTarget, in dirEnt);
#endif
name.CopyTo(nameTarget);
}

Expand Down
4 changes: 4 additions & 0 deletions Wacs.WASIp1/Types/IoVec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ public void FromWasmValue(object value)
public Value ToWasmType()
{
byte[] bytes = new byte[8];
#if NETSTANDARD2_1
MemoryMarshal.Write(bytes, ref this);
#else
MemoryMarshal.Write(bytes, in this);
#endif
return MemoryMarshal.Read<ulong>(bytes);
}
}
Expand Down
8 changes: 2 additions & 6 deletions Wacs.WASIp1/Wacs.WASIp1.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<LangVersion>9</LangVersion>
<Nullable>enable</Nullable>
<Title>Wacs WASIp1</Title>
Expand All @@ -17,21 +16,18 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>0.9.2</Version>
<RepositoryType>git</RepositoryType>
<TargetFrameworks>netstandard2.1;net8.0</TargetFrameworks>
</PropertyGroup>

<PropertyGroup>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
<None Update="README.md">
<None Include="README.md">
<Pack>true</Pack>
<PackagePath/>
</None>
<None Update="README.md">
<Pack>true</Pack>
<PackagePath></PackagePath>
</None>
</ItemGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
Expand Down

0 comments on commit 5217647

Please sign in to comment.