Skip to content

Commit

Permalink
Support for arm-unknown-linux-musleabi(hf) (#638)
Browse files Browse the repository at this point in the history
* Cross.toml cleanup

* Add CI for arm-unknown-linux-muslabi(hf)

* Allow disable slow tests

* Add BINDGEN_EXTRA_CLANG_ARGS, sort lines

* PR feedback
  • Loading branch information
justsmth authored Dec 30, 2024
1 parent 4bb6b69 commit fde6ead
Show file tree
Hide file tree
Showing 10 changed files with 163 additions and 89 deletions.
102 changes: 53 additions & 49 deletions .github/workflows/cross.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ name: cross
on:
push:
branches:
- '*'
- '!generate/aws-lc-*'
- "*"
- "!generate/aws-lc-*"
pull_request:
branches:
- '*'
- "*"
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
Expand All @@ -21,62 +21,67 @@ env:
jobs:
aws-lc-rs-cross-test:
if: github.repository_owner == 'aws'
name: cross tests ${{ matrix.target }}
name: cross tests ${{ matrix.target[0] }}
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
target:
- aarch64-linux-android
- aarch64-unknown-linux-gnu
- aarch64-unknown-linux-musl
- arm-linux-androideabi
- arm-unknown-linux-gnueabihf
- armv7-linux-androideabi
- armv7-unknown-linux-gnueabihf
- i686-unknown-linux-gnu
- powerpc-unknown-linux-gnu
- powerpc64-unknown-linux-gnu
- powerpc64le-unknown-linux-gnu
- riscv64gc-unknown-linux-gnu
- s390x-unknown-linux-gnu
- x86_64-pc-windows-gnu
- x86_64-unknown-linux-musl
- [aarch64-linux-android, 0]
- [aarch64-unknown-linux-gnu, 1]
- [aarch64-unknown-linux-musl, 1]
- [arm-linux-androideabi, 0]
- [arm-unknown-linux-gnueabihf, 0]
- [arm-unknown-linux-musleabi, 1]
- [arm-unknown-linux-musleabihf, 1]
- [armv7-linux-androideabi, 0]
- [armv7-unknown-linux-gnueabihf, 0]
- [i686-unknown-linux-gnu, 0]
- [powerpc-unknown-linux-gnu, 1]
- [powerpc64-unknown-linux-gnu, 1]
- [powerpc64le-unknown-linux-gnu, 1]
- [riscv64gc-unknown-linux-gnu, 0]
- [s390x-unknown-linux-gnu, 0]
- [x86_64-pc-windows-gnu, 0]
- [x86_64-unknown-linux-musl, 0]
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
submodules: "recursive"
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 'stable'
toolchain: "stable"
- name: Install cross
run: cargo install cross --git https://github.com/cross-rs/cross
- uses: dtolnay/rust-toolchain@master
id: toolchain
with:
toolchain: 'stable'
target: ${{ matrix.target }}
toolchain: "stable"
target: ${{ matrix.target[0] }}
- name: Set Rust toolchain override
run: rustup override set ${{ steps.toolchain.outputs.name }}
# The flag below is set to avoid the following error with GCC 11.4.0 on the riscv64 platform:
# /home/runner/work/aws-lc-rs/aws-lc-rs/aws-lc-sys/aws-lc/crypto/pem/pem_lib.c:707:11: error: 'strncmp' of strings of length 1 and 9 and bound of 9 evaluates to nonzero [-Werror=string-compare]
# 707 | if (strncmp(buf, "-----END ", 9) == 0) {
# | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
- if: ${{ matrix.target == 'riscv64gc-unknown-linux-gnu' }}
- if: ${{ matrix.target[0] == 'riscv64gc-unknown-linux-gnu' }}
run: |
echo 'AWS_LC_SYS_CFLAGS="-Wno-string-compare"' >> "$GITHUB_ENV"
- name: Cross-compilation (build debug)
run: cross build -p aws-lc-rs --features unstable --target ${{ matrix.target }}
- if: ${{ !startsWith(matrix.target[0], 'x86_64') }}
run: |
echo 'AWS_LC_RS_DISABLE_SLOW_TESTS=1' >> "$GITHUB_ENV"
- name: Cross-compilation (test release)
run: cross test -p aws-lc-rs --release --features unstable --target ${{ matrix.target }}

run: cross test -p aws-lc-rs --release --features unstable --target ${{ matrix.target[0] }}
- if: ${{ matrix.target[1] == 1 }}
name: Cross-compilation (test FIPS release)
run: cross test -p aws-lc-rs --release --no-default-features --features fips --target ${{ matrix.target[0] }}

aws-lc-rs-cross-0_2_5-test:
if: github.repository_owner == 'aws'
name: cross tests ${{ matrix.target }}
runs-on: ubuntu-latest
env:
CROSS_CONFIG: './Cross.toml.x86_64-unknown-linux-gnu'
CROSS_CONFIG: "./Cross.toml.x86_64-unknown-linux-gnu"
strategy:
fail-fast: false
matrix:
Expand All @@ -85,16 +90,16 @@ jobs:
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
submodules: "recursive"
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 'stable'
toolchain: "stable"
- name: Install cross
run: cargo install cross --locked --version 0.2.5
- uses: dtolnay/rust-toolchain@master
id: toolchain
with:
toolchain: 'stable'
toolchain: "stable"
target: ${{ matrix.target }}
- name: Set Rust toolchain override
run: rustup override set ${{ steps.toolchain.outputs.name }}
Expand All @@ -110,7 +115,7 @@ jobs:
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
submodules: "recursive"
- run: |
brew install llvm
echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"'
Expand All @@ -132,7 +137,7 @@ jobs:
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
submodules: "recursive"
- run: |
brew install llvm
echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"'
Expand All @@ -147,7 +152,6 @@ jobs:
- name: Release build for `x86_64-apple-ios`
run: cargo build -p aws-lc-rs --release --target x86_64-apple-ios --features bindgen


cargo-xwin:
if: github.repository_owner == 'aws'
runs-on: ubuntu-latest
Expand All @@ -158,7 +162,7 @@ jobs:
sudo apt-get update && sudo apt-get install --assume-yes nasm clang ninja-build llvm
- uses: actions/checkout@v3
with:
submodules: 'recursive'
submodules: "recursive"
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
Expand All @@ -182,13 +186,13 @@ jobs:
fail-fast: false
matrix:
target:
- 'x86_64-pc-windows-gnu'
- 'i686-pc-windows-gnu'
- "x86_64-pc-windows-gnu"
- "i686-pc-windows-gnu"
steps:
- uses: ilammy/setup-nasm@v1
- uses: actions/checkout@v4
with:
submodules: 'recursive'
submodules: "recursive"
- uses: dtolnay/rust-toolchain@master
id: toolchain
with:
Expand All @@ -212,19 +216,19 @@ jobs:
fail-fast: false
matrix:
target:
- 'x86_64-pc-windows-msvc'
- 'i686-pc-windows-msvc'
- 'aarch64-pc-windows-msvc'
- "x86_64-pc-windows-msvc"
- "i686-pc-windows-msvc"
- "aarch64-pc-windows-msvc"
crt_static:
- '0'
- '1'
- "0"
- "1"
steps:
- name: Install NASM
if: ${{ matrix.target == 'x86_64-pc-windows-msvc' || matrix.target == 'i686-pc-windows-msvc' }}
uses: ilammy/setup-nasm@v1
- uses: actions/checkout@v4
with:
submodules: 'recursive'
submodules: "recursive"
- uses: dtolnay/rust-toolchain@master
id: toolchain
with:
Expand Down Expand Up @@ -255,11 +259,11 @@ jobs:
strategy:
fail-fast: false
matrix:
target: [ 13.4, 14.1 ]
target: [13.4, 14.1]
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
submodules: "recursive"
- name: Prepare VM
uses: vmactions/freebsd-vm@v1
with:
Expand All @@ -280,11 +284,11 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
submodules: "recursive"
- uses: dtolnay/rust-toolchain@stable
id: toolchain
with:
toolchain: 'stable'
toolchain: "stable"
target: x86_64-pc-windows-gnu
- name: Install mingw
run: sudo apt-get update && sudo apt-get install --assume-yes mingw-w64
Expand Down
35 changes: 16 additions & 19 deletions Cross.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
[build]
dockerfile = "./docker/linux-cross/Dockerfile"
pre-build = [
"curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain stable",
". $HOME/.cargo/env",
"cargo install --force --locked bindgen-cli && mv $HOME/.cargo/bin/bindgen /usr/bin",
"rm -rf $HOME/.cargo"
]

[build.dockerfile]
file = "./docker/linux-cross/Dockerfile"

[target.x86_64-pc-windows-gnu]
pre-build = [
"curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain stable",
". $HOME/.cargo/env",
"cargo install --force --locked bindgen-cli && mv $HOME/.cargo/bin/bindgen /usr/bin",
"rm -rf $HOME/.cargo",
"apt-get update && apt-get install --assume-yes nasm wget",
"mkdir -pm755 /etc/apt/keyrings",
"wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/jammy/winehq-jammy.sources",
Expand All @@ -22,10 +11,18 @@ pre-build = [

[build.env]
passthrough = [
"AWS_LC_SYS_NO_PREFIX", "AWS_LC_FIPS_SYS_NO_PREFIX",
"AWS_LC_SYS_PREGENERATING_BINDINGS", "AWS_LC_FIPS_SYS_PREGENERATING_BINDINGS",
"AWS_LC_SYS_EXTERNAL_BINDGEN", "AWS_LC_FIPS_SYS_EXTERNAL_BINDGEN",
"AWS_LC_SYS_STATIC", "AWS_LC_FIPS_SYS_STATIC",
"AWS_LC_SYS_CMAKE_BUILDER", "AWS_LC_SYS_CC_SRC_COLLECTOR",
"GOPROXY", "AWS_LC_SYS_CFLAGS"
"AWS_LC_FIPS_SYS_EXTERNAL_BINDGEN",
"AWS_LC_FIPS_SYS_NO_PREFIX",
"AWS_LC_FIPS_SYS_PREGENERATING_BINDINGS",
"AWS_LC_FIPS_SYS_STATIC",
"AWS_LC_RS_DISABLE_SLOW_TESTS",
"AWS_LC_SYS_CC_SRC_COLLECTOR",
"AWS_LC_SYS_CFLAGS",
"AWS_LC_SYS_CMAKE_BUILDER",
"AWS_LC_SYS_EXTERNAL_BINDGEN",
"AWS_LC_SYS_NO_PREFIX",
"AWS_LC_SYS_PREGENERATING_BINDINGS",
"AWS_LC_SYS_STATIC",
"BINDGEN_EXTRA_CLANG_ARGS",
"GOPROXY",
]
3 changes: 2 additions & 1 deletion aws-lc-rs/Cross.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ dockerfile = "../docker/linux-cross/Dockerfile"
passthrough = [
"CROSS_CMAKE_SYSTEM_PROCESSOR",
"RUST_BACKTRACE",
"RUST_LOG"
"RUST_LOG",
"AWS_LC_RS_DISABLE_SLOW_TESTS",
]
12 changes: 12 additions & 0 deletions aws-lc-rs/build.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0 OR ISC

use std::env;

fn main() {
let has_mutually_exclusive_features = cfg!(feature = "non-fips") && cfg!(feature = "fips");
assert!(
!has_mutually_exclusive_features,
"`fips` and `non-fips` are mutually exclusive crate features."
);

println!("cargo:rustc-check-cfg=cfg(disable_slow_tests)");
if let Ok(disable) = env::var("AWS_LC_RS_DISABLE_SLOW_TESTS") {
if disable == "1" {
println!("cargo:warning=### Slow tests will be disabled! ###");
println!("cargo:rustc-cfg=disable_slow_tests");
} else {
println!("cargo:warning=### Slow tests are enabled: {disable}! ###");
}
}

// This appears asymmetric, but it reflects the `cfg` statements in lib.rs that
// require `aws-lc-sys` to be present when "fips" is not enabled.
// if `fips` is enabled, then use that
Expand Down
1 change: 1 addition & 0 deletions aws-lc-rs/src/agreement/ephemeral.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ mod tests {
// The spec gives a test vector for 1,000,000 iterations but it takes
// too long to do 1,000,000 iterations by default right now. This
// 10,000 iteration vector is self-computed.
#[cfg(not(disable_slow_tests))]
expect_iterated_x25519(
"2c125a20f639d504a7703d2e223c79a79de48c4ee8c23379aa19a62ecd211815",
1_000..10_000,
Expand Down
16 changes: 15 additions & 1 deletion aws-lc-rs/src/rsa/tests/fips.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,40 @@ macro_rules! generate_key {
}

generate_key!(rsa2048_signing_generate_key, KeyPair, KeySize::Rsa2048);
// Key generation for large RSA keys is very slow
#[cfg(not(disable_slow_tests))]
generate_key!(rsa3072_signing_generate_key, KeyPair, KeySize::Rsa3072);
// Key generation for large RSA keys is very slow
#[cfg(not(disable_slow_tests))]
generate_key!(rsa4096_signing_generate_key, KeyPair, KeySize::Rsa4096);

// Key generation for large RSA keys is very slow
#[cfg(not(disable_slow_tests))]
generate_key!(rsa8192_signing_generate_key, KeyPair, KeySize::Rsa8192);

generate_key!(
rsa2048_encryption_generate_key,
PrivateDecryptingKey,
KeySize::Rsa2048
);

// Key generation for large RSA keys is very slow
#[cfg(not(disable_slow_tests))]
generate_key!(
rsa3072_encryption_generate_key,
PrivateDecryptingKey,
KeySize::Rsa3072
);

// Key generation for large RSA keys is very slow
#[cfg(not(disable_slow_tests))]
generate_key!(
rsa4096_encryption_signing_generate_key,
PrivateDecryptingKey,
KeySize::Rsa4096
);

// Key generation for large RSA keys is very slow
#[cfg(not(disable_slow_tests))]
generate_key!(
rsa8192_encryption_generate_key,
PrivateDecryptingKey,
Expand Down
2 changes: 1 addition & 1 deletion aws-lc-rs/tests/aead_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ fn test_aead<Seal, Open>(
// test a smaller subset.

let mut more_comprehensive_in_prefix_lengths = vec![0; 4096].into_boxed_slice();
let in_prefix_lengths = if cfg!(debug_assertions) {
let in_prefix_lengths = if cfg!(any(debug_assertions, disable_slow_tests)) {
&MINIMAL_IN_PREFIX_LENS[..]
} else {
#[allow(clippy::needless_range_loop)]
Expand Down
2 changes: 2 additions & 0 deletions aws-lc-rs/tests/digest_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ mod digest_shavs {
macro_rules! test_i_u_f {
( $test_name:ident, $alg:expr) => {
#[cfg(not(debug_assertions))]
#[cfg(not(disable_slow_tests))]
// TODO: Get this working on WebAssembly
#[cfg(not(target_arch = "wasm32"))]
#[test]
Expand Down Expand Up @@ -308,6 +309,7 @@ macro_rules! test_large_digest {
( $test_name:ident, $alg:expr, $len:expr, $expected:expr) => {
// TODO: get this working on WebAssembly.
#[cfg(not(debug_assertions))]
#[cfg(not(disable_slow_tests))]
#[cfg(not(target_arch = "wasm32"))]
#[test]
fn $test_name() {
Expand Down
Loading

0 comments on commit fde6ead

Please sign in to comment.