Add support for aarch64-apple-darwin.

Change the static CPU feature detection logic to assume all aarch64-apple-* targets
have the same capabilities as far as the features we use are concerned.

Use the "ios64" PerlAsm flavour for aarch64-apple-darwin, like OpenSSL upstream does.

Add (build-only) cross-compilation jobs to GitHub Actions.
This commit is contained in:
Brian Smith 2020-11-17 15:46:35 -08:00
parent f19c4f626b
commit f26bae0a6a
3 changed files with 39 additions and 17 deletions

View File

@ -88,6 +88,7 @@ jobs:
target:
- aarch64-apple-ios
- aarch64-apple-darwin
- aarch64-linux-android
- aarch64-unknown-linux-gnu
- arm-unknown-linux-gnueabihf
@ -110,10 +111,25 @@ jobs:
- beta
- nightly
exclude:
# The stable channel doesn't have aarch64-apple-darwin support yet.
- target: aarch64-apple-darwin
rust_channel: stable
# The beta channel doesn't have aarch64-apple-darwin support yet.
- target: aarch64-apple-darwin
rust_channel: beta
include:
- target: aarch64-apple-darwin
# macos-latest didn't work.
host_os: macos-11.0
# GitHub Actions doesn't have a way to run this target yet.
cargo_options: --no-run
- target: aarch64-apple-ios
host_os: macos-latest
# GitHub Actions doesn't have a way to run aarch64-apple-ios.
# GitHub Actions doesn't have a way to run this target yet.
cargo_options: --no-run
- target: aarch64-linux-android
@ -173,6 +189,9 @@ jobs:
target: ${{ matrix.target }}
toolchain: ${{ matrix.rust_channel }}
- if: ${{ matrix.target == 'aarch64-apple-darwin' }}
run: echo "DEVELOPER_DIR=/Applications/Xcode_12.2.app/Contents/Developer" >> $GITHUB_ENV
- if: ${{ !contains(matrix.host_os, 'windows') }}
run: |
mk/cargo.sh test -vv --target=${{ matrix.target }} ${{ matrix.cargo_options }} ${{ matrix.features }} ${{ matrix.mode }}

View File

@ -236,6 +236,7 @@ const ASM_TARGETS: &[(&str, Option<&str>, Option<&str>)] = &[
("x86_64", Some(WINDOWS), Some("nasm")),
("x86_64", None, Some("elf")),
("aarch64", Some("ios"), Some("ios64")),
("aarch64", Some("macos"), Some("ios64")),
("aarch64", None, Some("linux64")),
("x86", Some(WINDOWS), Some("win32n")),
("x86", Some("ios"), Some("macosx")),

View File

@ -24,9 +24,8 @@ pub(crate) struct Features(());
#[inline(always)]
pub(crate) fn features() -> Features {
// We don't do runtime feature detection on aarch64-apple-ios as all
// AAarch64 features we use are available on every device since the first
// device.
// We don't do runtime feature detection on aarch64-apple-* as all AAarch64
// features we use are available on every device since the first devices.
#[cfg(any(
target_arch = "x86",
target_arch = "x86_64",
@ -170,13 +169,13 @@ pub(crate) mod arm {
mask: $mask:expr,
/// Should we assume that the feature is always available
/// for aarch64-apple-ios targets? The first AArch64 iOS
/// for aarch64-apple-* targets? The first AArch64 iOS
/// device used the Apple A7 chip.
// TODO: When we can use `if` in const expressions:
// ```
// aarch64_ios: $aarch64_ios,
// aarch64_apple: $aarch64_apple,
// ```
aarch64_ios: true,
aarch64_apple: true,
}
),+
, // trailing comma is required.
@ -192,9 +191,9 @@ pub(crate) mod arm {
// ```
// const ARMCAP_STATIC: u32 = 0
// $(
// | ( if $aarch64_ios &&
// | ( if $aarch64_apple &&
// cfg!(all(target_arch = "aarch64",
// target_os = "ios")) {
// target_vendor = "apple")) {
// $name.mask
// } else {
// 0
@ -206,14 +205,14 @@ pub(crate) mod arm {
// TODO: Add static feature detection to other targets.
// TODO: Combine static feature detection with runtime feature
// detection.
#[cfg(all(target_arch = "aarch64", target_os = "ios"))]
#[cfg(all(target_arch = "aarch64", target_vendor = "apple"))]
const ARMCAP_STATIC: u32 = 0
$( | $name.mask
)+;
#[cfg(not(all(target_arch = "aarch64", target_os = "ios")))]
#[cfg(not(all(target_arch = "aarch64", target_vendor = "apple")))]
const ARMCAP_STATIC: u32 = 0;
#[cfg(all(target_arch = "aarch64", target_os = "ios"))]
#[cfg(all(target_arch = "aarch64", target_vendor = "apple"))]
#[test]
fn test_armcap_static_available() {
let features = crate::cpu::features();
@ -255,25 +254,25 @@ pub(crate) mod arm {
// Keep in sync with `ARMV7_NEON`.
NEON {
mask: 1 << 0,
aarch64_ios: true,
aarch64_apple: true,
},
// Keep in sync with `ARMV8_AES`.
AES {
mask: 1 << 2,
aarch64_ios: true,
aarch64_apple: true,
},
// Keep in sync with `ARMV8_SHA256`.
SHA256 {
mask: 1 << 4,
aarch64_ios: true,
aarch64_apple: true,
},
// Keep in sync with `ARMV8_PMULL`.
PMULL {
mask: 1 << 5,
aarch64_ios: true,
aarch64_apple: true,
},
}
@ -288,7 +287,10 @@ pub(crate) mod arm {
#[no_mangle]
static mut GFp_armcap_P: u32 = ARMCAP_STATIC;
#[cfg(all(any(target_arch = "arm", target_arch = "aarch64"), target_os = "ios"))]
#[cfg(all(
any(target_arch = "arm", target_arch = "aarch64"),
target_vendor = "apple"
))]
#[test]
fn test_armcap_static_matches_armcap_dynamic() {
assert_eq!(ARMCAP_STATIC, 1 | 4 | 16 | 32);