Skip to content

Commit 69c724e

Browse files
authored
Updates to support LTSC (#298)
Many changes depend on support of `by-ref like` type parameters for generics, which is runtime specific and only supported in .NET 9 or later. These are all confined by pre-processor tests for `NET9_0_OR_GREATER`. Once .NET 10 is available then the library should multi-target to support both active LTSC versions of the runtime * Updates to support LTSC * Added Ubiquity.NET.TextUX for text based (console) app use * Updated scripting to use string (constant) as the TFM for testing sample apps * Updated path formation to make it OS independent. * While this is not a requirement at this point it was in the same area and sets the stage for true platform independence, which is a longer term goal. * Updated SLNX to reference correct test script
1 parent 25b3ccc commit 69c724e

File tree

93 files changed

+1630
-886
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+1630
-886
lines changed

Directory.Packages.props

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
-->
1919
<ItemGroup>
2020
<!-- Roslyn Analyzers ***MUST*** target older framework -->
21+
<PackageVersion Include="AnsiCodes" Version="0.2.1" />
2122
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="4.14.0" />
2223
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0" />
2324
<PackageVersion Include="Microsoft.CodeAnalysis" Version="4.14.0" />
@@ -31,7 +32,7 @@
3132
<PackageVersion Include="System.Formats.Asn1" Version="9.0.7" />
3233
<!-- Common packages for solution -->
3334
<PackageVersion Include="System.Linq.Async" Version="6.0.3" />
34-
<PackageVersion Include="Ubiquity.NET.Versioning" Version="6.0.1" />
35+
<PackageVersion Include="Ubiquity.NET.Versioning" Version="6.0.2-beta" />
3536
<PackageVersion Include="Antlr4BuildTasks" Version="12.10.0" />
3637
<PackageVersion Include="Antlr4.Runtime.Standard" Version="4.13.1" />
3738
<PackageVersion Include="OpenSoftware.DgmlBuilder" Version="2.1.0" />
@@ -44,4 +45,4 @@
4445
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing" Version="1.1.2" />
4546
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeRefactoring.Testing" Version="1.1.2" />
4647
</ItemGroup>
47-
</Project>
48+
</Project>

Invoke-Tests.ps1

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,20 @@ try
4747

4848
# ensure the samples run - output not validated but they need to compile and run without crashing
4949
Write-Information 'Running sample apps for .NET Core'
50-
Push-Location (Join-path $buildInfo['BuildOutputPath'] 'bin\CodeGenWithDebugInfo\Release\net9.0')
50+
$sampleTFM = "net8.0"
51+
Push-Location (Join-path $buildInfo['BuildOutputPath'] 'bin' 'CodeGenWithDebugInfo' 'Release' $sampleTFM)
5152
try
5253
{
5354
$testGenOutputPath = Join-Path $buildInfo['TestResultsPath'] 'M3'
54-
Write-Information "CodeGenWithDebugInfo M3 'Support Files\test.c' $testGenOutputPath"
55-
Invoke-External dotnet CodeGenWithDebugInfo.dll M3 'Support Files\test.c' $testGenOutputPath
55+
$testFileRelativePath = Join-Path 'Support Files' 'test.c'
56+
Write-Information "CodeGenWithDebugInfo M3 '$testFileRelativePath' $testGenOutputPath"
57+
Invoke-External dotnet CodeGenWithDebugInfo.dll M3 $testFileRelativePath $testGenOutputPath
5658

5759
$testGenOutputPath = Join-Path $buildInfo['TestResultsPath'] 'X64'
58-
Write-Information "CodeGenWithDebugInfo X64 'Support Files\test.c' $testGenOutputPath"
59-
Invoke-External dotnet CodeGenWithDebugInfo.dll X64 'Support Files\test.c' $testGenOutputPath
60+
Write-Information "CodeGenWithDebugInfo X64 '$testFileRelativePath' $testGenOutputPath"
61+
Invoke-External dotnet CodeGenWithDebugInfo.dll X64 $testFileRelativePath $testGenOutputPath
6062

61-
Set-Location (Join-path $buildInfo['BuildOutputPath'] 'bin\OrcV2VeryLazy\Release\net9.0')
63+
Set-Location (Join-path $buildInfo['BuildOutputPath'] 'bin' 'OrcV2VeryLazy' 'Release' $sampleTFM)
6264
Invoke-External dotnet OrcV2VeryLazy.dll
6365
}
6466
finally

src/Interop/InteropTests/ArchitectureExtensionsTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ public void GetLibLLVMTargetTest( )
2121
Assert.AreEqual( LibLLVMCodeGenTarget.CodeGenTarget_ARM, Architecture.Armv6.AsLLVMTarget() );
2222
Assert.AreEqual( LibLLVMCodeGenTarget.CodeGenTarget_LoongArch, Architecture.LoongArch64.AsLLVMTarget() );
2323
Assert.AreEqual( LibLLVMCodeGenTarget.CodeGenTarget_PowerPC, Architecture.Ppc64le.AsLLVMTarget() );
24+
#if NET9_0_OR_GREATER
2425
Assert.AreEqual( LibLLVMCodeGenTarget.CodeGenTarget_RISCV, Architecture.RiscV64.AsLLVMTarget() );
26+
#endif
2527
Assert.AreEqual( LibLLVMCodeGenTarget.CodeGenTarget_SystemZ, Architecture.S390x.AsLLVMTarget() );
2628
Assert.AreEqual( LibLLVMCodeGenTarget.CodeGenTarget_WebAssembly, Architecture.Wasm.AsLLVMTarget() );
2729
Assert.AreEqual( LibLLVMCodeGenTarget.CodeGenTarget_X86, Architecture.X64.AsLLVMTarget() );
Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
<PropertyGroup>
3-
<TargetFramework>net9.0</TargetFramework>
4-
<IsPackable>false</IsPackable>
5-
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
6-
</PropertyGroup>
7-
<ItemGroup>
8-
<ProjectReference Include="..\..\Ubiquity.NET.InteropHelpers\Ubiquity.NET.InteropHelpers.csproj" />
9-
<ProjectReference Include="..\Ubiquity.NET.Llvm.Interop\Ubiquity.NET.Llvm.Interop.csproj">
10-
<Name>Ubiquity.NET.Llvm.Interop</Name>
11-
<Private>true</Private>
12-
</ProjectReference>
13-
</ItemGroup>
14-
<ItemGroup>
15-
<PackageReference Include="Microsoft.NET.Test.Sdk" />
16-
<PackageReference Include="MSTest.TestFramework" />
17-
<PackageReference Include="MSTest.TestAdapter" />
18-
<PackageReference Include="Tmds.ExecFunction" />
19-
<PackageReference Include="Ubiquity.NET.Versioning" />
20-
</ItemGroup>
21-
<ItemGroup>
22-
<PackageVersion Update="EnvDTE" Version="17.14.40260" />
23-
</ItemGroup>
2+
<PropertyGroup>
3+
<TargetFramework>net8.0</TargetFramework>
4+
<LangVersion>13</LangVersion>
5+
<IsPackable>false</IsPackable>
6+
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
7+
</PropertyGroup>
8+
<ItemGroup>
9+
<ProjectReference Include="..\..\Ubiquity.NET.InteropHelpers\Ubiquity.NET.InteropHelpers.csproj" />
10+
<ProjectReference Include="..\Ubiquity.NET.Llvm.Interop\Ubiquity.NET.Llvm.Interop.csproj">
11+
<Name>Ubiquity.NET.Llvm.Interop</Name>
12+
<Private>true</Private>
13+
</ProjectReference>
14+
</ItemGroup>
15+
<ItemGroup>
16+
<PackageReference Include="Microsoft.NET.Test.Sdk" />
17+
<PackageReference Include="MSTest.TestFramework" />
18+
<PackageReference Include="MSTest.TestAdapter" />
19+
<PackageReference Include="Tmds.ExecFunction" />
20+
<PackageReference Include="Ubiquity.NET.Versioning" />
21+
</ItemGroup>
22+
<ItemGroup>
23+
<PackageVersion Update="EnvDTE" Version="17.14.40260" />
24+
</ItemGroup>
2425
</Project>

src/Interop/Ubiquity.NET.Llvm.Interop/ArchitectureExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ Architecture.Arm or
2222
Architecture.Wasm => LibLLVMCodeGenTarget.CodeGenTarget_WebAssembly,
2323
Architecture.LoongArch64 => LibLLVMCodeGenTarget.CodeGenTarget_LoongArch,
2424
Architecture.Ppc64le => LibLLVMCodeGenTarget.CodeGenTarget_PowerPC,
25+
#if NET9_0_OR_GREATER
2526
Architecture.RiscV64 => LibLLVMCodeGenTarget.CodeGenTarget_RISCV, // 64 vs 32 bit distinction is a CPU/Feature of the target
27+
#endif
2628
Architecture.S390x => LibLLVMCodeGenTarget.CodeGenTarget_SystemZ,
2729
_ => throw new NotSupportedException( "Native code gen target is unknown" )
2830
};

src/Interop/Ubiquity.NET.Llvm.Interop/Library.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ public static ILibLlvm InitializeLLVM( )
5656

5757
// Verify the version of LibLLVM.
5858
var libVersion = SemVer.Parse(LibLLVMGetVersion()?.ToString() ?? string.Empty, SemVerFormatProvider.CaseInsensitive);
59+
if( libVersion is CSemVerCI semVerCI)
60+
{
61+
libVersion = semVerCI.BaseBuild;
62+
}
63+
5964
if( libVersion.Major != SupportedVersion.Major
6065
|| libVersion.Minor != SupportedVersion.Minor
6166
|| libVersion.Patch != SupportedVersion.Patch

src/Interop/Ubiquity.NET.Llvm.Interop/NativeLibraryResolver.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,17 @@ internal static bool Apply( )
1919
// has the module and the address of the symbol it replaces the P/Invoke in the same way that
2020
// native code replaces the thunk for a dllimport. That is, once the address of the exported symbol
2121
// is known, no further resolution is used.
22+
#if NET9_0_OR_GREATER
2223
if(Interlocked.CompareExchange( ref ResolverApplied, true, false ))
2324
{
2425
return false;
2526
}
26-
27+
#else
28+
if(Interlocked.CompareExchange( ref ResolverAppliedObject, 1, 0 ) == 1)
29+
{
30+
return false;
31+
}
32+
#endif
2733
NativeLibrary.SetDllImportResolver( Assembly.GetExecutingAssembly(), NativeLibResolver );
2834
return true;
2935
}
@@ -74,6 +80,14 @@ internal static nint NativeLibResolver( string libraryName, Assembly assembly, D
7480
}
7581

7682
private static NativeLibraryHandle NativeLibHandle = new();
77-
private static bool ResolverApplied = false;
83+
84+
// .NET 9 adds support for Interlocked.CompareExchange() for a bool
85+
#if NET9_0_OR_GREATER
86+
private static bool ResolverApplied;
87+
#else
88+
private static bool ResolverApplied => ResolverAppliedObject != 0;
89+
90+
private static int ResolverAppliedObject = 0;
91+
#endif
7892
}
7993
}
Lines changed: 56 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,62 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
<PropertyGroup>
3-
<TargetFramework>net9.0</TargetFramework>
4-
<RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
5-
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
6-
<DebugType>portable</DebugType>
7-
<DebugSymbols>true</DebugSymbols>
8-
<SignAssembly>False</SignAssembly>
9-
<GenerateDocumentationFile>False</GenerateDocumentationFile>
10-
<DocumentationFile>$(BaseIntermediateOutputPath)$(MSBuildProjectName).xml</DocumentationFile>
11-
<IsAotCompatible>True</IsAotCompatible>
2+
<PropertyGroup>
3+
<TargetFramework>net8.0</TargetFramework>
4+
<LangVersion>13</LangVersion>
5+
<RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
6+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
7+
<DebugType>portable</DebugType>
8+
<DebugSymbols>true</DebugSymbols>
9+
<SignAssembly>False</SignAssembly>
10+
<GenerateDocumentationFile>False</GenerateDocumentationFile>
11+
<DocumentationFile>$(BaseIntermediateOutputPath)$(MSBuildProjectName).xml</DocumentationFile>
12+
<IsAotCompatible>True</IsAotCompatible>
1213

13-
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
14-
<MinClientVersion>4.9.0</MinClientVersion>
15-
<Authors>.NET Foundation,LLVM.org,Ubiquity.NET</Authors>
16-
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
17-
<Description>.NET Low Level Interop Bindings for Ubiquity.LibLLVM [$(LlvmVersion)]. Direct use of this low level API is **STRONGLY** discouraged, instead you should use the Ubiquity.NET.Llvm package, which provides a full C# object model projection of the LLVM APIs on top of this library.</Description>
18-
<PackageTags>LLVM,Compiler,JIT,Ubiquity.NET</PackageTags>
19-
<PackageProjectUrl>https://github.com/UbiquityDotNET/Llvm.NET</PackageProjectUrl>
20-
<RepositoryUrl>https://github.com/UbiquityDotNET/Llvm.NET.git</RepositoryUrl>
21-
<RepositoryType>git</RepositoryType>
22-
<PackageLicenseExpression>Apache-2.0 WITH LLVM-exception</PackageLicenseExpression>
23-
<IncludeSymbols Condition="'$(Configuration)'=='Release'">true</IncludeSymbols>
24-
<EmbedUntrackedSources>false</EmbedUntrackedSources>
25-
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
26-
<!-- This is an internal undocumented package ignore the analysis that complains about a missing ReadMe -->
27-
<NoPackageAnalysis>true</NoPackageAnalysis>
14+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
15+
<MinClientVersion>4.9.0</MinClientVersion>
16+
<Authors>.NET Foundation,LLVM.org,Ubiquity.NET</Authors>
17+
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
18+
<Description>.NET Low Level Interop Bindings for Ubiquity.LibLLVM [$(LlvmVersion)]. Direct use of this low level API is **STRONGLY** discouraged, instead you should use the Ubiquity.NET.Llvm package, which provides a full C# object model projection of the LLVM APIs on top of this library.</Description>
19+
<PackageTags>LLVM,Compiler,JIT,Ubiquity.NET</PackageTags>
20+
<PackageProjectUrl>https://github.com/UbiquityDotNET/Llvm.NET</PackageProjectUrl>
21+
<RepositoryUrl>https://github.com/UbiquityDotNET/Llvm.NET.git</RepositoryUrl>
22+
<RepositoryType>git</RepositoryType>
23+
<PackageLicenseExpression>Apache-2.0 WITH LLVM-exception</PackageLicenseExpression>
24+
<IncludeSymbols Condition="'$(Configuration)'=='Release'">true</IncludeSymbols>
25+
<EmbedUntrackedSources>false</EmbedUntrackedSources>
26+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
2827

29-
<!--
30-
workaround: https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3882
31-
Only known solution to prevent complier Null check issues is to disable the rule
32-
-->
33-
<NoWarn>$(NoWarn);SA1135</NoWarn>
28+
<!-- This is an internal undocumented package ignore the analysis that complains about a missing ReadMe -->
29+
<NoPackageAnalysis>true</NoPackageAnalysis>
3430

35-
</PropertyGroup>
36-
<ItemGroup>
37-
<!-- Sadly, the version range syntax doesn't work for Directory.Package.props so it must be provided here-->
38-
<PackageReference Include="Ubiquity.NET.LibLLVM" VersionOverride="20.1.*-*" />
39-
<PackageReference Include="Ubiquity.NET.Llvm.Interop.Handles" VersionOverride="20.1.*-*" />
40-
<PackageReference Include="Ubiquity.NET.Versioning" />
41-
</ItemGroup>
42-
<ItemGroup>
43-
<Compile Update="Properties\Resources.Designer.cs">
44-
<DesignTime>True</DesignTime>
45-
<AutoGen>True</AutoGen>
46-
<DependentUpon>Resources.resx</DependentUpon>
47-
</Compile>
48-
</ItemGroup>
49-
<ItemGroup>
50-
<EmbeddedResource Update="Properties\Resources.resx">
51-
<Generator>ResXFileCodeGenerator</Generator>
52-
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
53-
</EmbeddedResource>
54-
</ItemGroup>
31+
<!--
32+
workaround: https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3882
33+
Only known solution to prevent complier Null check issues is to disable the rule
34+
-->
35+
<NoWarn>$(NoWarn);SA1135</NoWarn>
5536

56-
<ItemGroup>
57-
<ProjectReference Include="..\..\Ubiquity.NET.Extensions\Ubiquity.NET.Extensions.csproj" />
58-
<ProjectReference Include="..\..\Ubiquity.NET.InteropHelpers\Ubiquity.NET.InteropHelpers.csproj" />
59-
</ItemGroup>
37+
</PropertyGroup>
38+
<ItemGroup>
39+
<!-- Sadly, the version range syntax doesn't work for Directory.Package.props so it must be provided here-->
40+
<PackageReference Include="Ubiquity.NET.LibLLVM" VersionOverride="20.1.*-*" />
41+
<PackageReference Include="Ubiquity.NET.Llvm.Interop.Handles" VersionOverride="20.1.*-*" />
42+
<PackageReference Include="Ubiquity.NET.Versioning" />
43+
</ItemGroup>
44+
<ItemGroup>
45+
<Compile Update="Properties\Resources.Designer.cs">
46+
<DesignTime>True</DesignTime>
47+
<AutoGen>True</AutoGen>
48+
<DependentUpon>Resources.resx</DependentUpon>
49+
</Compile>
50+
</ItemGroup>
51+
<ItemGroup>
52+
<EmbeddedResource Update="Properties\Resources.resx">
53+
<Generator>ResXFileCodeGenerator</Generator>
54+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
55+
</EmbeddedResource>
56+
</ItemGroup>
57+
58+
<ItemGroup>
59+
<ProjectReference Include="..\..\Ubiquity.NET.Extensions\Ubiquity.NET.Extensions.csproj" />
60+
<ProjectReference Include="..\..\Ubiquity.NET.InteropHelpers\Ubiquity.NET.InteropHelpers.csproj" />
61+
</ItemGroup>
6062
</Project>

src/Samples/CodeGenWithDebugInfo/CodeGenWithDebugInfo.csproj

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project Sdk="Microsoft.NET.Sdk">
3-
<PropertyGroup>
4-
<AssemblyVersion>20.1.0.0</AssemblyVersion>
5-
<TargetFramework>net9.0</TargetFramework>
6-
<OutputType>exe</OutputType>
7-
<OutputTypeEx>exe</OutputTypeEx>
8-
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
9-
<PublishAot>True</PublishAot>
10-
</PropertyGroup>
11-
<ItemGroup>
12-
<None Include="Support Files\ClangCompile.cmd">
13-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
14-
</None>
15-
<None Include="Support Files\test.c">
16-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
17-
</None>
18-
</ItemGroup>
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<LangVersion>13</LangVersion>
6+
<OutputType>exe</OutputType>
7+
<OutputTypeEx>exe</OutputTypeEx>
8+
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
9+
<PublishAot>True</PublishAot>
10+
</PropertyGroup>
11+
<ItemGroup>
12+
<None Include="Support Files\ClangCompile.cmd">
13+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
14+
</None>
15+
<None Include="Support Files\test.c">
16+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
17+
</None>
18+
</ItemGroup>
1919
<ItemGroup>
2020
<ProjectReference Include="$(BuildRootDir)src\Ubiquity.NET.Llvm\Ubiquity.NET.Llvm.csproj">
2121
<Name>Llvm.NET</Name>
Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
<PropertyGroup>
3-
<OutputType>Exe</OutputType>
4-
<TargetFramework>net9.0</TargetFramework>
5-
<AssemblyName>kls2</AssemblyName>
6-
<RootNamespace>Kaleidoscope</RootNamespace>
7-
<PlatformTarget>AnyCPU</PlatformTarget>
8-
<PublishAot>True</PublishAot>
9-
</PropertyGroup>
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<LangVersion>13</LangVersion>
6+
<AssemblyName>kls2</AssemblyName>
7+
<RootNamespace>Kaleidoscope</RootNamespace>
8+
<PlatformTarget>AnyCPU</PlatformTarget>
9+
<PublishAot>True</PublishAot>
10+
</PropertyGroup>
1011

11-
<ItemGroup>
12-
<ProjectReference Include="..\Kaleidoscope.Grammar\Kaleidoscope.Grammar.csproj" />
13-
<ProjectReference Include="..\Kaleidoscope.Runtime\Kaleidoscope.Runtime.csproj" />
14-
</ItemGroup>
12+
<ItemGroup>
13+
<ProjectReference Include="..\Kaleidoscope.Grammar\Kaleidoscope.Grammar.csproj" />
14+
<ProjectReference Include="..\Kaleidoscope.Runtime\Kaleidoscope.Runtime.csproj" />
15+
</ItemGroup>
1516

1617
</Project>

0 commit comments

Comments
 (0)