Add partial support for cross-compiling on Linux ARM runners
Until https://github.com/cross-rs/cross/issues/1628 is resolved, running cross on Linux ARM also requires the user to provide a custom Docker image, so this is only sort of usable.
This commit is contained in:
parent
601d02e82d
commit
83dc934d7f
26
.github/workflows/test.yml
vendored
26
.github/workflows/test.yml
vendored
@ -103,6 +103,32 @@ jobs:
|
||||
expect-stripped: ""
|
||||
can-execute: true
|
||||
|
||||
- platform_name: Linux-aarch64 with arm64 host
|
||||
runs-on: ubuntu-24.04-arm
|
||||
target: aarch64-unknown-linux-gnu
|
||||
cache-cross-binary: true
|
||||
expect-file-re: "aarch64"
|
||||
expect-cross: ""
|
||||
expect-stripped: "--expect-stripped"
|
||||
can-execute: true
|
||||
|
||||
# This fails because of some sort of weird bug in cross. See
|
||||
# https://github.com/cross-rs/cross/issues/1628 for more details. Until that's fixed
|
||||
# cross-compiling on Linux ARM won't work without a custom Docker image, which I don't
|
||||
# want to do just for the sake of testing this.
|
||||
#
|
||||
# - platform_name: Linux-aarch64 with arm64 host compile to x86-64
|
||||
# runs-on: ubuntu-24.04-arm
|
||||
# target: x86_64-unknown-linux-gnu
|
||||
# # Until cross produces arm64 binary releases we _have_ to set this when running on
|
||||
# # arm64.
|
||||
# cross-version: "c7dee4d"
|
||||
# cache-cross-binary: true
|
||||
# expect-file-re: "ELF.+x86-64"
|
||||
# expect-cross: "--expect-cross"
|
||||
# expect-stripped: ""
|
||||
# can-execute: true
|
||||
|
||||
- platform_name: Linux-arm
|
||||
runs-on: ubuntu-24.04
|
||||
target: arm-unknown-linux-gnueabi
|
||||
|
||||
@ -1,3 +1,9 @@
|
||||
## 1.0.3
|
||||
|
||||
- Fixed a bug when running with an ARM Linux host where the action would use a cached `cross`
|
||||
download for x86-64 Linux (or vice versa). Now the cache key for the `cross` binary includes both
|
||||
the runner's architecture in addition to its OS.
|
||||
|
||||
## 1.0.2 - 2025-02-16
|
||||
|
||||
- Added a new `force-use-cross` input, which does what it says. It will force the use of `cross`
|
||||
|
||||
13
README.md
13
README.md
@ -163,6 +163,19 @@ you can avoid this issue by structuring your workflow as follows:
|
||||
|
||||
When structured this way, it does not matter if the output of crate A is deleted in step 3.
|
||||
|
||||
## Cross-Compiling from Linux ARM Runners
|
||||
|
||||
In theory, this should work, and this action does implement some of the necessary work for this.
|
||||
However, there are a couple issues with this:
|
||||
|
||||
1. As of 2025-02-17, the `cross` project does not publish Linux ARM binary releases. That means that
|
||||
in order to use `cross` on a Linux ARM runner as part of this action, you must set
|
||||
`cross-version` to a more recent commit from the `cross` repo.
|
||||
2. There is
|
||||
[a bug in `cross` that means you must use a custom Docker image](https://github.com/cross-rs/cross/issues/1628)
|
||||
when cross-compiling from a Linux ARM runner. See
|
||||
[this other `cross` issue](https://github.com/cross-rs/cross/issues/751) for more details.
|
||||
|
||||
## Linting and Tidying this Code
|
||||
|
||||
The code in this repo is linted and tidied with
|
||||
|
||||
11
action.yml
11
action.yml
@ -107,6 +107,15 @@ runs:
|
||||
targets: ${{ inputs.target }}
|
||||
toolchain: ${{ inputs.toolchain }}
|
||||
|
||||
- name: Install qemu-user emulator binaries if cross-compiling on arm64 host
|
||||
shell: bash
|
||||
run: |
|
||||
set -e
|
||||
set -x
|
||||
|
||||
docker run --privileged --rm tonistiigi/binfmt --install all
|
||||
if: steps.determine-cross-compile.outputs.needs-cross == 'true' && runner.os == 'Linux' && contains(runner.arch, 'ARM')
|
||||
|
||||
- name: Determine cross version
|
||||
id: determine-cross-version
|
||||
shell: bash
|
||||
@ -128,7 +137,7 @@ runs:
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ${{ steps.set-cross-dir.outputs.cross-dir }}/cross
|
||||
key: ${{ runner.os }}-${{ steps.determine-cross-version.outputs.cross-version }}
|
||||
key: ${{ runner.os }}-${{ runner.arch }}-${{ steps.determine-cross-version.outputs.cross-version }}
|
||||
if: steps.determine-cross-compile.outputs.needs-cross == 'true' && inputs.cache-cross-binary == 'true'
|
||||
|
||||
- name: Install cross if cross-compiling (*nix)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user