Skip to content

Commit 353566c

Browse files
committed
Add CI step that cross-compiles from Linux to macOS/iOS
1 parent 9a9c248 commit 353566c

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

.github/workflows/main.yml

+35
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,16 @@ jobs:
8686
rust: stable
8787
target: x86_64-apple-ios-macabi
8888
no_run: --no-run # FIXME(madsmtm): Fix running tests
89+
- build: cross-macos-aarch64
90+
os: ubuntu-latest
91+
rust: stable
92+
target: aarch64-apple-darwin
93+
no_run: --no-run
94+
- build: cross-ios-aarch64
95+
os: ubuntu-latest
96+
rust: stable
97+
target: aarch64-apple-ios
98+
no_run: --no-run
8999
- build: windows-aarch64
90100
os: windows-latest
91101
rust: stable
@@ -155,6 +165,31 @@ jobs:
155165
env:
156166
CC: ${{ matrix.CC }}
157167
CXX: ${{ matrix.CXX }}
168+
- name: Install llvm tools (for llvm-ar)
169+
if: startsWith(matrix.build, 'cross-macos') || startsWith(matrix.build, 'cross-ios')
170+
run: sudo apt-get install llvm
171+
- name: Download macOS SDK
172+
if: startsWith(matrix.build, 'cross-macos')
173+
run: |
174+
wget https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX11.3.sdk.tar.xz
175+
tar -xf MacOSX11.3.sdk.tar.xz
176+
echo "SDKROOT=$(pwd)/MacOSX11.3.sdk" >> $GITHUB_ENV
177+
- name: Download iOS SDK
178+
if: startsWith(matrix.build, 'cross-ios')
179+
run: |
180+
wget https://github.com/xybp888/iOS-SDKs/releases/download/iOS18.1-SDKs/iPhoneOS18.1.sdk.zip
181+
unzip iPhoneOS18.1.sdk.zip
182+
echo "SDKROOT=$(pwd)/iPhoneOS18.1.sdk" >> $GITHUB_ENV
183+
- name: Set up Apple cross-compilation
184+
if: startsWith(matrix.build, 'cross-macos') || startsWith(matrix.build, 'cross-ios')
185+
run: |
186+
# Test with clang/llvm for now, has better cross-compilation support (GCC requires downloading a different toolchain)
187+
echo "CC=clang" >> $GITHUB_ENV
188+
echo "CXX=clang++" >> $GITHUB_ENV
189+
echo "AR=llvm-ar" >> $GITHUB_ENV
190+
# Link with rust-lld
191+
UPPERCASE_TARGET_NAME=$(echo "${{ matrix.target }}" | tr '[:lower:]-' '[:upper:]_')
192+
echo "CARGO_TARGET_${UPPERCASE_TARGET_NAME}_LINKER=rust-lld" >> $GITHUB_ENV
158193
- name: setup dev environment
159194
uses: ilammy/msvc-dev-cmd@v1
160195
if: startsWith(matrix.build, 'windows-clang')

0 commit comments

Comments
 (0)