-
Notifications
You must be signed in to change notification settings - Fork 263
C# macos support #1576
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
base: main
Are you sure you want to change the base?
C# macos support #1576
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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: | ||
|
|
@@ -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 | ||
|
|
@@ -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/ | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting, something must be missing in the runtimelab build to make this necessary. Not saying anything needs changing, just if we want to push this to runtimelab, we will have to make the build copy these files. |
||
| 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 \ | ||
|
|
||
| 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; | ||
|
|
||
|
|
@@ -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}" /> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might be a problem for arm64 on windows as we don't have that either. |
||
| </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 --> | ||
|
|
@@ -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>"# | ||
| ), | ||
| )?; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to fix a commit?