Skip to content

Commit

Permalink
Add linux-musl-arm target for net9.0 (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
fallenwood authored Jan 14, 2025
1 parent 68934b5 commit e0d8dfc
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,22 @@ jobs:
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Setup dotnet
- name: Setup dotnet 8.0
uses: actions/setup-dotnet@v2
with:
dotnet-version: '8.0.x'
- name: Setup dotnet 9.0
uses: actions/setup-dotnet@v2
with:
dotnet-version: '9.0.x'
- name: Setup zig
uses: goto-bus-stop/setup-zig@v2
- name: Build (CI)
run: |
dotnet build -c Release -t:Pack src/Fallenwood.PublishAotCross.nuproj
dotnet publish -r linux-musl-arm64 -c Release test/Hello.csproj -p:StripSymbols=false
dotnet publish -r linux-musl-x64 -c Release test/Hello.csproj -p:StripSymbols=false -o output-linux-musl-x64
dotnet publish -r linux-musl-arm -c Release test/Hello9.csproj -p:StripSymbols=false -o output-linux-musl-arm
build:
strategy:
Expand Down Expand Up @@ -86,7 +92,7 @@ jobs:
- name: Setup dotnet
uses: actions/setup-dotnet@v2
with:
dotnet-version: '8.0.x'
dotnet-version: '9.0.x'
- name: Build (CD)
if: ${{ github.event.inputs.version != '' }}
run: dotnet build -c Release -t:Pack src/Fallenwood.PublishAotCross.nuproj -p:Version=${{ github.event.inputs.version }}
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ This nuget package allows using [Zig](https://ziglang.org/) as the linker/sysroo
* `dotnet publish -r linux-arm64`
* `dotnet publish -r linux-musl-x64`
* `dotnet publish -r linux-musl-arm64`
* `dotnet publish -r linux-musl-arm` (Only works for net >= 9.0)

If you skipped the second optional step to download llvm-objcopy, you must also pass `/p:StripSymbols=false` to the publish command, or you'll see an error instructing you to do that.

Expand All @@ -49,5 +50,7 @@ dotnet publish -r linux-x64 /p:PublishAot=true /p:AotPreferZig=true
|Linux GNU arm64 |O |O |O |N/A |N/A |
|Linux MUSL x64 |O |O |O |N/A |N/A |
|Linux MUSL arm64 |O |O |O |N/A |N/A |
|Linux MUSL arm |N/A |O |N/A |N/A |N/A |

Notes: `N/A` means it's might work but not tested.

Notes: `N/A` means it's might work but not tested.
4 changes: 4 additions & 0 deletions src/Crosscompile.targets
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
buildenv += "-x64";
} else if (RuntimeInformation.OSArchitecture == Architecture.Arm64) {
buildenv += "-arm64";
} else if (RuntimeInformation.OSArchitecture == Architecture.Arm) {
buildenv += "-arm";
}
if (buildenv != RuntimeIdentifier || AotPreferZig) {
Expand Down Expand Up @@ -90,10 +92,12 @@
<CrossCompileArch />
<CrossCompileArch Condition="$(CrossCompileRid.EndsWith('-x64'))">x86_64</CrossCompileArch>
<CrossCompileArch Condition="$(CrossCompileRid.EndsWith('-arm64'))">aarch64</CrossCompileArch>
<CrossCompileArch Condition="$(CrossCompileRid.EndsWith('-arm'))">arm</CrossCompileArch>

<TargetTriple />
<TargetTriple Condition="'$(CrossCompileArch)' != '' and $(CrossCompileRid.StartsWith('linux'))">$(CrossCompileArch)-linux-gnu</TargetTriple>
<TargetTriple Condition="'$(CrossCompileArch)' != '' and ($(CrossCompileRid.StartsWith('linux-musl')) or $(CrossCompileRid.StartsWith('alpine')))">$(CrossCompileArch)-linux-musl</TargetTriple>
<TargetTriple Condition="'$(CrossCompileArch)' == 'arm' and $(CrossCompileRid.StartsWith('linux-musl'))">thumb-linux-musleabihf</TargetTriple>
</PropertyGroup>

<ItemGroup>
Expand Down
13 changes: 13 additions & 0 deletions test/Hello9.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<PublishAot>true</PublishAot>
</PropertyGroup>

<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />

<Import Project="../src/Fallenwood.PublishAotCross.targets" />
</Project>

0 comments on commit e0d8dfc

Please sign in to comment.