Skip to content

Commit d09ac72

Browse files
committed
[CI] Fixed linux-arm64 CrossCompile
1 parent a78fb9d commit d09ac72

File tree

1 file changed

+35
-6
lines changed

1 file changed

+35
-6
lines changed

.github/workflows/native-api-build.yaml

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,49 @@ jobs:
4848
RUNTIME_IDENTIFIER: ${{ matrix.rid }}
4949

5050
steps:
51-
- name: Install Linux Dependencies
52-
if: matrix.os == 'ubuntu-latest'
53-
run: sudo apt-get update && sudo apt-get install -y clang zlib1g-dev
51+
- name: Checkout code
52+
uses: actions/checkout@v4
5453

5554
- name: Setup .NET SDK
5655
uses: actions/setup-dotnet@v4
5756
with:
5857
dotnet-version: '9.0.x'
5958

60-
- name: Checkout code
61-
uses: actions/checkout@v4
59+
- name: Install Linux Dependencies
60+
if: matrix.os == 'ubuntu-latest'
61+
run: |
62+
sudo apt-get update
63+
sudo apt-get install -y clang zlib1g-dev
64+
65+
# Install additional dependencies for ARM64 builds
66+
if [ "${{ matrix.rid }}" == "linux-arm64" ]; then
67+
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu
68+
fi
6269
6370
- name: Publish with Native AOT
64-
run: dotnet publish Lagrange.Core.NativeAPI -c Release -r ${{ matrix.rid }}
71+
shell: bash
72+
run: |
73+
if [ "${{ matrix.rid }}" == "linux-arm64" ] && [ "${{ matrix.os }}" == "ubuntu-latest" ]; then
74+
# Set up cross-compilation for ARM64 on Ubuntu
75+
export OBJCOPY=aarch64-linux-gnu-objcopy
76+
77+
dotnet publish Lagrange.Core.NativeAPI -c Release -r linux-arm64 \
78+
/p:CppCompilerAndLinker=clang \
79+
/p:CrossHostArch=x64 \
80+
/p:CrossHostCompilerPath=/usr/bin \
81+
/p:IlcDisableObjCopy=true
82+
83+
# Process the generated shared library
84+
cd Lagrange.Core.NativeAPI/bin/Release/net9.0/linux-arm64/publish/
85+
if [ -f "Lagrange.Core.NativeAPI.so" ]; then
86+
aarch64-linux-gnu-objcopy --only-keep-debug Lagrange.Core.NativeAPI.so Lagrange.Core.NativeAPI.so.dbg
87+
aarch64-linux-gnu-objcopy --strip-debug Lagrange.Core.NativeAPI.so
88+
aarch64-linux-gnu-objcopy --add-gnu-debuglink=Lagrange.Core.NativeAPI.so.dbg Lagrange.Core.NativeAPI.so
89+
fi
90+
cd -
91+
else
92+
dotnet publish Lagrange.Core.NativeAPI -c Release -r ${{ matrix.rid }}
93+
fi
6594
6695
- name: Upload artifacts
6796
if: github.event_name != 'pull_request'

0 commit comments

Comments
 (0)