Skip to content

Commit fde6ead

Browse files
authored
Support for arm-unknown-linux-musleabi(hf) (#638)
* Cross.toml cleanup * Add CI for arm-unknown-linux-muslabi(hf) * Allow disable slow tests * Add BINDGEN_EXTRA_CLANG_ARGS, sort lines * PR feedback
1 parent 4bb6b69 commit fde6ead

File tree

10 files changed

+163
-89
lines changed

10 files changed

+163
-89
lines changed

.github/workflows/cross.yml

Lines changed: 53 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ name: cross
33
on:
44
push:
55
branches:
6-
- '*'
7-
- '!generate/aws-lc-*'
6+
- "*"
7+
- "!generate/aws-lc-*"
88
pull_request:
99
branches:
10-
- '*'
10+
- "*"
1111
concurrency:
1212
group: ${{ github.workflow }}-${{ github.ref_name }}
1313
cancel-in-progress: true
@@ -21,62 +21,67 @@ env:
2121
jobs:
2222
aws-lc-rs-cross-test:
2323
if: github.repository_owner == 'aws'
24-
name: cross tests ${{ matrix.target }}
24+
name: cross tests ${{ matrix.target[0] }}
2525
runs-on: ubuntu-22.04
2626
strategy:
2727
fail-fast: false
2828
matrix:
2929
target:
30-
- aarch64-linux-android
31-
- aarch64-unknown-linux-gnu
32-
- aarch64-unknown-linux-musl
33-
- arm-linux-androideabi
34-
- arm-unknown-linux-gnueabihf
35-
- armv7-linux-androideabi
36-
- armv7-unknown-linux-gnueabihf
37-
- i686-unknown-linux-gnu
38-
- powerpc-unknown-linux-gnu
39-
- powerpc64-unknown-linux-gnu
40-
- powerpc64le-unknown-linux-gnu
41-
- riscv64gc-unknown-linux-gnu
42-
- s390x-unknown-linux-gnu
43-
- x86_64-pc-windows-gnu
44-
- x86_64-unknown-linux-musl
30+
- [aarch64-linux-android, 0]
31+
- [aarch64-unknown-linux-gnu, 1]
32+
- [aarch64-unknown-linux-musl, 1]
33+
- [arm-linux-androideabi, 0]
34+
- [arm-unknown-linux-gnueabihf, 0]
35+
- [arm-unknown-linux-musleabi, 1]
36+
- [arm-unknown-linux-musleabihf, 1]
37+
- [armv7-linux-androideabi, 0]
38+
- [armv7-unknown-linux-gnueabihf, 0]
39+
- [i686-unknown-linux-gnu, 0]
40+
- [powerpc-unknown-linux-gnu, 1]
41+
- [powerpc64-unknown-linux-gnu, 1]
42+
- [powerpc64le-unknown-linux-gnu, 1]
43+
- [riscv64gc-unknown-linux-gnu, 0]
44+
- [s390x-unknown-linux-gnu, 0]
45+
- [x86_64-pc-windows-gnu, 0]
46+
- [x86_64-unknown-linux-musl, 0]
4547
steps:
4648
- uses: actions/checkout@v3
4749
with:
48-
submodules: 'recursive'
50+
submodules: "recursive"
4951
- uses: dtolnay/rust-toolchain@master
5052
with:
51-
toolchain: 'stable'
53+
toolchain: "stable"
5254
- name: Install cross
5355
run: cargo install cross --git https://github.com/cross-rs/cross
5456
- uses: dtolnay/rust-toolchain@master
5557
id: toolchain
5658
with:
57-
toolchain: 'stable'
58-
target: ${{ matrix.target }}
59+
toolchain: "stable"
60+
target: ${{ matrix.target[0] }}
5961
- name: Set Rust toolchain override
6062
run: rustup override set ${{ steps.toolchain.outputs.name }}
6163
# The flag below is set to avoid the following error with GCC 11.4.0 on the riscv64 platform:
6264
# /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]
6365
# 707 | if (strncmp(buf, "-----END ", 9) == 0) {
6466
# | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
65-
- if: ${{ matrix.target == 'riscv64gc-unknown-linux-gnu' }}
67+
- if: ${{ matrix.target[0] == 'riscv64gc-unknown-linux-gnu' }}
6668
run: |
6769
echo 'AWS_LC_SYS_CFLAGS="-Wno-string-compare"' >> "$GITHUB_ENV"
68-
- name: Cross-compilation (build debug)
69-
run: cross build -p aws-lc-rs --features unstable --target ${{ matrix.target }}
70+
- if: ${{ !startsWith(matrix.target[0], 'x86_64') }}
71+
run: |
72+
echo 'AWS_LC_RS_DISABLE_SLOW_TESTS=1' >> "$GITHUB_ENV"
7073
- name: Cross-compilation (test release)
71-
run: cross test -p aws-lc-rs --release --features unstable --target ${{ matrix.target }}
72-
74+
run: cross test -p aws-lc-rs --release --features unstable --target ${{ matrix.target[0] }}
75+
- if: ${{ matrix.target[1] == 1 }}
76+
name: Cross-compilation (test FIPS release)
77+
run: cross test -p aws-lc-rs --release --no-default-features --features fips --target ${{ matrix.target[0] }}
7378

7479
aws-lc-rs-cross-0_2_5-test:
7580
if: github.repository_owner == 'aws'
7681
name: cross tests ${{ matrix.target }}
7782
runs-on: ubuntu-latest
7883
env:
79-
CROSS_CONFIG: './Cross.toml.x86_64-unknown-linux-gnu'
84+
CROSS_CONFIG: "./Cross.toml.x86_64-unknown-linux-gnu"
8085
strategy:
8186
fail-fast: false
8287
matrix:
@@ -85,16 +90,16 @@ jobs:
8590
steps:
8691
- uses: actions/checkout@v3
8792
with:
88-
submodules: 'recursive'
93+
submodules: "recursive"
8994
- uses: dtolnay/rust-toolchain@master
9095
with:
91-
toolchain: 'stable'
96+
toolchain: "stable"
9297
- name: Install cross
9398
run: cargo install cross --locked --version 0.2.5
9499
- uses: dtolnay/rust-toolchain@master
95100
id: toolchain
96101
with:
97-
toolchain: 'stable'
102+
toolchain: "stable"
98103
target: ${{ matrix.target }}
99104
- name: Set Rust toolchain override
100105
run: rustup override set ${{ steps.toolchain.outputs.name }}
@@ -110,7 +115,7 @@ jobs:
110115
steps:
111116
- uses: actions/checkout@v3
112117
with:
113-
submodules: 'recursive'
118+
submodules: "recursive"
114119
- run: |
115120
brew install llvm
116121
echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"'
@@ -132,7 +137,7 @@ jobs:
132137
steps:
133138
- uses: actions/checkout@v3
134139
with:
135-
submodules: 'recursive'
140+
submodules: "recursive"
136141
- run: |
137142
brew install llvm
138143
echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"'
@@ -147,7 +152,6 @@ jobs:
147152
- name: Release build for `x86_64-apple-ios`
148153
run: cargo build -p aws-lc-rs --release --target x86_64-apple-ios --features bindgen
149154

150-
151155
cargo-xwin:
152156
if: github.repository_owner == 'aws'
153157
runs-on: ubuntu-latest
@@ -158,7 +162,7 @@ jobs:
158162
sudo apt-get update && sudo apt-get install --assume-yes nasm clang ninja-build llvm
159163
- uses: actions/checkout@v3
160164
with:
161-
submodules: 'recursive'
165+
submodules: "recursive"
162166
- uses: dtolnay/rust-toolchain@master
163167
with:
164168
toolchain: stable
@@ -182,13 +186,13 @@ jobs:
182186
fail-fast: false
183187
matrix:
184188
target:
185-
- 'x86_64-pc-windows-gnu'
186-
- 'i686-pc-windows-gnu'
189+
- "x86_64-pc-windows-gnu"
190+
- "i686-pc-windows-gnu"
187191
steps:
188192
- uses: ilammy/setup-nasm@v1
189193
- uses: actions/checkout@v4
190194
with:
191-
submodules: 'recursive'
195+
submodules: "recursive"
192196
- uses: dtolnay/rust-toolchain@master
193197
id: toolchain
194198
with:
@@ -212,19 +216,19 @@ jobs:
212216
fail-fast: false
213217
matrix:
214218
target:
215-
- 'x86_64-pc-windows-msvc'
216-
- 'i686-pc-windows-msvc'
217-
- 'aarch64-pc-windows-msvc'
219+
- "x86_64-pc-windows-msvc"
220+
- "i686-pc-windows-msvc"
221+
- "aarch64-pc-windows-msvc"
218222
crt_static:
219-
- '0'
220-
- '1'
223+
- "0"
224+
- "1"
221225
steps:
222226
- name: Install NASM
223227
if: ${{ matrix.target == 'x86_64-pc-windows-msvc' || matrix.target == 'i686-pc-windows-msvc' }}
224228
uses: ilammy/setup-nasm@v1
225229
- uses: actions/checkout@v4
226230
with:
227-
submodules: 'recursive'
231+
submodules: "recursive"
228232
- uses: dtolnay/rust-toolchain@master
229233
id: toolchain
230234
with:
@@ -255,11 +259,11 @@ jobs:
255259
strategy:
256260
fail-fast: false
257261
matrix:
258-
target: [ 13.4, 14.1 ]
262+
target: [13.4, 14.1]
259263
steps:
260264
- uses: actions/checkout@v4
261265
with:
262-
submodules: 'recursive'
266+
submodules: "recursive"
263267
- name: Prepare VM
264268
uses: vmactions/freebsd-vm@v1
265269
with:
@@ -280,11 +284,11 @@ jobs:
280284
steps:
281285
- uses: actions/checkout@v4
282286
with:
283-
submodules: 'recursive'
287+
submodules: "recursive"
284288
- uses: dtolnay/rust-toolchain@stable
285289
id: toolchain
286290
with:
287-
toolchain: 'stable'
291+
toolchain: "stable"
288292
target: x86_64-pc-windows-gnu
289293
- name: Install mingw
290294
run: sudo apt-get update && sudo apt-get install --assume-yes mingw-w64

Cross.toml

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,8 @@
1-
[build]
2-
dockerfile = "./docker/linux-cross/Dockerfile"
3-
pre-build = [
4-
"curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain stable",
5-
". $HOME/.cargo/env",
6-
"cargo install --force --locked bindgen-cli && mv $HOME/.cargo/bin/bindgen /usr/bin",
7-
"rm -rf $HOME/.cargo"
8-
]
9-
1+
[build.dockerfile]
2+
file = "./docker/linux-cross/Dockerfile"
103

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

2312
[build.env]
2413
passthrough = [
25-
"AWS_LC_SYS_NO_PREFIX", "AWS_LC_FIPS_SYS_NO_PREFIX",
26-
"AWS_LC_SYS_PREGENERATING_BINDINGS", "AWS_LC_FIPS_SYS_PREGENERATING_BINDINGS",
27-
"AWS_LC_SYS_EXTERNAL_BINDGEN", "AWS_LC_FIPS_SYS_EXTERNAL_BINDGEN",
28-
"AWS_LC_SYS_STATIC", "AWS_LC_FIPS_SYS_STATIC",
29-
"AWS_LC_SYS_CMAKE_BUILDER", "AWS_LC_SYS_CC_SRC_COLLECTOR",
30-
"GOPROXY", "AWS_LC_SYS_CFLAGS"
14+
"AWS_LC_FIPS_SYS_EXTERNAL_BINDGEN",
15+
"AWS_LC_FIPS_SYS_NO_PREFIX",
16+
"AWS_LC_FIPS_SYS_PREGENERATING_BINDINGS",
17+
"AWS_LC_FIPS_SYS_STATIC",
18+
"AWS_LC_RS_DISABLE_SLOW_TESTS",
19+
"AWS_LC_SYS_CC_SRC_COLLECTOR",
20+
"AWS_LC_SYS_CFLAGS",
21+
"AWS_LC_SYS_CMAKE_BUILDER",
22+
"AWS_LC_SYS_EXTERNAL_BINDGEN",
23+
"AWS_LC_SYS_NO_PREFIX",
24+
"AWS_LC_SYS_PREGENERATING_BINDINGS",
25+
"AWS_LC_SYS_STATIC",
26+
"BINDGEN_EXTRA_CLANG_ARGS",
27+
"GOPROXY",
3128
]

aws-lc-rs/Cross.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ dockerfile = "../docker/linux-cross/Dockerfile"
55
passthrough = [
66
"CROSS_CMAKE_SYSTEM_PROCESSOR",
77
"RUST_BACKTRACE",
8-
"RUST_LOG"
8+
"RUST_LOG",
9+
"AWS_LC_RS_DISABLE_SLOW_TESTS",
910
]

aws-lc-rs/build.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0 OR ISC
33

4+
use std::env;
5+
46
fn main() {
57
let has_mutually_exclusive_features = cfg!(feature = "non-fips") && cfg!(feature = "fips");
68
assert!(
79
!has_mutually_exclusive_features,
810
"`fips` and `non-fips` are mutually exclusive crate features."
911
);
1012

13+
println!("cargo:rustc-check-cfg=cfg(disable_slow_tests)");
14+
if let Ok(disable) = env::var("AWS_LC_RS_DISABLE_SLOW_TESTS") {
15+
if disable == "1" {
16+
println!("cargo:warning=### Slow tests will be disabled! ###");
17+
println!("cargo:rustc-cfg=disable_slow_tests");
18+
} else {
19+
println!("cargo:warning=### Slow tests are enabled: {disable}! ###");
20+
}
21+
}
22+
1123
// This appears asymmetric, but it reflects the `cfg` statements in lib.rs that
1224
// require `aws-lc-sys` to be present when "fips" is not enabled.
1325
// if `fips` is enabled, then use that

aws-lc-rs/src/agreement/ephemeral.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ mod tests {
154154
// The spec gives a test vector for 1,000,000 iterations but it takes
155155
// too long to do 1,000,000 iterations by default right now. This
156156
// 10,000 iteration vector is self-computed.
157+
#[cfg(not(disable_slow_tests))]
157158
expect_iterated_x25519(
158159
"2c125a20f639d504a7703d2e223c79a79de48c4ee8c23379aa19a62ecd211815",
159160
1_000..10_000,

aws-lc-rs/src/rsa/tests/fips.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,26 +78,40 @@ macro_rules! generate_key {
7878
}
7979

8080
generate_key!(rsa2048_signing_generate_key, KeyPair, KeySize::Rsa2048);
81+
// Key generation for large RSA keys is very slow
82+
#[cfg(not(disable_slow_tests))]
8183
generate_key!(rsa3072_signing_generate_key, KeyPair, KeySize::Rsa3072);
84+
// Key generation for large RSA keys is very slow
85+
#[cfg(not(disable_slow_tests))]
8286
generate_key!(rsa4096_signing_generate_key, KeyPair, KeySize::Rsa4096);
83-
87+
// Key generation for large RSA keys is very slow
88+
#[cfg(not(disable_slow_tests))]
8489
generate_key!(rsa8192_signing_generate_key, KeyPair, KeySize::Rsa8192);
8590

8691
generate_key!(
8792
rsa2048_encryption_generate_key,
8893
PrivateDecryptingKey,
8994
KeySize::Rsa2048
9095
);
96+
97+
// Key generation for large RSA keys is very slow
98+
#[cfg(not(disable_slow_tests))]
9199
generate_key!(
92100
rsa3072_encryption_generate_key,
93101
PrivateDecryptingKey,
94102
KeySize::Rsa3072
95103
);
104+
105+
// Key generation for large RSA keys is very slow
106+
#[cfg(not(disable_slow_tests))]
96107
generate_key!(
97108
rsa4096_encryption_signing_generate_key,
98109
PrivateDecryptingKey,
99110
KeySize::Rsa4096
100111
);
112+
113+
// Key generation for large RSA keys is very slow
114+
#[cfg(not(disable_slow_tests))]
101115
generate_key!(
102116
rsa8192_encryption_generate_key,
103117
PrivateDecryptingKey,

aws-lc-rs/tests/aead_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ fn test_aead<Seal, Open>(
190190
// test a smaller subset.
191191

192192
let mut more_comprehensive_in_prefix_lengths = vec![0; 4096].into_boxed_slice();
193-
let in_prefix_lengths = if cfg!(debug_assertions) {
193+
let in_prefix_lengths = if cfg!(any(debug_assertions, disable_slow_tests)) {
194194
&MINIMAL_IN_PREFIX_LENS[..]
195195
} else {
196196
#[allow(clippy::needless_range_loop)]

aws-lc-rs/tests/digest_test.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ mod digest_shavs {
243243
macro_rules! test_i_u_f {
244244
( $test_name:ident, $alg:expr) => {
245245
#[cfg(not(debug_assertions))]
246+
#[cfg(not(disable_slow_tests))]
246247
// TODO: Get this working on WebAssembly
247248
#[cfg(not(target_arch = "wasm32"))]
248249
#[test]
@@ -308,6 +309,7 @@ macro_rules! test_large_digest {
308309
( $test_name:ident, $alg:expr, $len:expr, $expected:expr) => {
309310
// TODO: get this working on WebAssembly.
310311
#[cfg(not(debug_assertions))]
312+
#[cfg(not(disable_slow_tests))]
311313
#[cfg(not(target_arch = "wasm32"))]
312314
#[test]
313315
fn $test_name() {

0 commit comments

Comments
 (0)