Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 61 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,9 @@ jobs:
os: [ubuntu-latest, macos-latest, windows-latest]
# moonbit removed from language matrix for now - causing CI failures
lang: [c, rust, csharp, cpp, go]
exclude:
# For now csharp doesn't work on macos, so exclude it from testing.
- os: macos-latest
lang: csharp
runs-on: ${{ matrix.os }}
env:
RUNTIMELAB_COMMIT: '4cac3ab5c8e97fda69c23dfca41ace964babc05e'
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -103,7 +101,14 @@ jobs:
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.x'
if: matrix.lang == 'csharp'
if: matrix.lang == 'csharp' && runner.os != 'macOS'

- name: Setup .NET 10 (macOS)
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.x'
dotnet-quality: 'preview'
if: matrix.lang == 'csharp' && runner.os == 'macOS'

- name: Setup Go
uses: actions/setup-go@v5
Expand All @@ -125,6 +130,57 @@ jobs:
shell: powershell
if: matrix.os == 'windows-latest' && matrix.lang == 'moonbit'

# macOS C# requires locally-built ILC packages since no osx-arm64
# packages are published on NuGet.
- name: Cache runtimelab ILC packages
id: cache-runtimelab
uses: actions/cache@v4
with:
path: runtimelab-packages
key: runtimelab-macos-arm64-${{ env.RUNTIMELAB_COMMIT }}
if: runner.os == 'macOS' && matrix.lang == 'csharp'

- name: Install LLVM 18 for runtimelab build
if: runner.os == 'macOS' && matrix.lang == 'csharp' && steps.cache-runtimelab.outputs.cache-hit != 'true'
run: brew install llvm@18

- name: Checkout runtimelab
uses: actions/checkout@v4
with:
repository: dotnet/runtimelab
ref: ${{ env.RUNTIMELAB_COMMIT }}
path: runtimelab
if: runner.os == 'macOS' && matrix.lang == 'csharp' && steps.cache-runtimelab.outputs.cache-hit != 'true'

- name: Build runtimelab ILC packages
if: runner.os == 'macOS' && matrix.lang == 'csharp' && steps.cache-runtimelab.outputs.cache-hit != 'true'
run: |
cd runtimelab
ln -sf $WASI_SDK_PATH src/mono/wasi/wasi-sdk
mkdir -p src/mono/wasi/include

# Build wasi libs and packages
./build.sh clr.aot+libs -c Release -a wasm -os wasi /p:NuGetAudit=false
./build.sh nativeaot.packages -c Release -a wasm -os wasi /p:NuGetAudit=false

# Build host compiler, libs, WASM JIT, and packages
./build.sh clr.aot -c Release /p:NuGetAudit=false
./build.sh libs -c Release /p:NuGetAudit=false
LLVM_CMAKE_CONFIG_RELEASE=$(brew --prefix llvm@18)/lib/cmake/llvm \
src/coreclr/build-runtime.sh -arm64 -release -os osx -outputrid osx-arm64 -component llvmjit
cp artifacts/bin/coreclr/osx.arm64.Release/libclrjit_universal_llvm32_arm64.dylib artifacts/bin/coreclr/osx.arm64.Release/ilc-published/
cp artifacts/bin/coreclr/osx.arm64.Release/libjitinterface_arm64.dylib artifacts/bin/coreclr/osx.arm64.Release/ilc-published/
./build.sh nativeaot.packages -c Release /p:NuGetAudit=false

mkdir -p ../runtimelab-packages
cp artifacts/packages/Release/Shipping/*.nupkg ../runtimelab-packages/

- name: Set ILC env vars for macOS C#
if: runner.os == 'macOS' && matrix.lang == 'csharp'
run: |
echo "ILC_VERSION=10.0.0-dev" >> $GITHUB_ENV
echo "ILC_PACKAGES_PATH=${{ github.workspace }}/runtimelab-packages" >> $GITHUB_ENV

# Run all codegen tests for this language
- run: |
cargo run test --languages ${{ matrix.lang }} tests/codegen \
Expand Down
28 changes: 22 additions & 6 deletions crates/csharp/src/csproj.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use anyhow::Result;
use std::{fs, path::PathBuf};
use std::{env, fs, path::PathBuf};

use heck::ToUpperCamelCase;

Expand Down Expand Up @@ -103,21 +103,36 @@ impl CSProjectLLVMBuilder {
let os = match std::env::consts::OS {
"windows" => "win",
"linux" => std::env::consts::OS,
"macos" => "osx",
other => todo!("OS {} not supported", other),
};

let arch = match std::env::consts::ARCH {
"aarch64" => "arm64",
"x86_64" => "x64",
other => todo!("ARCH {} not supported", other),
};

let ilc_version = env::var("ILC_VERSION").unwrap_or_else(|_| "10.0.0-*".to_string());

csproj.push_str(
&format!(
r#"
<ItemGroup>
<PackageReference Include="Microsoft.DotNet.ILCompiler.LLVM" Version="10.0.0-*" />
<PackageReference Include="runtime.{os}-x64.Microsoft.DotNet.ILCompiler.LLVM" Version="10.0.0-*" />
<PackageReference Include="Microsoft.DotNet.ILCompiler.LLVM" Version="{ilc_version}" />
<PackageReference Include="runtime.{os}-{arch}.Microsoft.DotNet.ILCompiler.LLVM" Version="{ilc_version}" />
</ItemGroup>"#),
);

let local_source = match env::var("ILC_PACKAGES_PATH") {
Ok(path) => format!(r#"<add key="local-ilc" value="{path}" />"#),
Err(_) => String::new(),
};

fs::write(
self.dir.join("nuget.config"),
r#"<?xml version="1.0" encoding="utf-8"?>
format!(
r#"<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<!-- Store the packages where they can be shared between tests -->
Expand All @@ -126,11 +141,12 @@ impl CSProjectLLVMBuilder {
<packageSources>
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
<clear />
{local_source}
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
<add key="dotnet-experimental" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-experimental/nuget/v3/index.json" />
<!--<add key="dotnet-experimental" value="C:\github\runtimelab\artifacts\packages\Debug\Shipping" />-->
</packageSources>
</configuration>"#,
</configuration>"#
),
)?;
}

Expand Down
1 change: 1 addition & 0 deletions crates/test/src/csharp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ impl LanguageMethods for Csharp {
let os = match std::env::consts::OS {
"windows" => "win",
"linux" => std::env::consts::OS,
"macos" => "osx",
other => todo!("OS {} not supported", other),
};

Expand Down
Loading