-
Notifications
You must be signed in to change notification settings - Fork 480
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] Use
--cfg
attributes to select backends
Crate features are intended to be additive, whereas only 1-of-N possible backends can be selected. Features can also be activated by transitive dependencies, which leads to a problem of different dependences selecting conflicting backends. Using `--cfg` instead moves all backend selection control to the toplevel executable. This commit switches to the following RUSTFLAGS to enable backends: - `--cfg curve25519_dalek_backend="fiat"`: uses `fiat-crypto` - `--cfg curve25519_dalek_backend="simd"`: uses nightly-only SIMD
- Loading branch information
Showing
11 changed files
with
40 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,9 @@ jobs: | |
- run: rustup target add ${{ matrix.target }} | ||
- run: ${{ matrix.deps }} | ||
- run: cargo test --target ${{ matrix.target }} | ||
- run: cargo test --target ${{ matrix.target }} --features fiat_backend | ||
- env: | ||
RUSTFLAGS: '--cfg curve25519_dalek_backend="fiat" -D warnings' | ||
run: cargo test --target ${{ matrix.target }} | ||
|
||
build-simd: | ||
name: Build simd backend (nightly) | ||
|
@@ -37,11 +39,11 @@ jobs: | |
- uses: dtolnay/rust-toolchain@nightly | ||
# Build with AVX2 features, then with AVX512 features | ||
- env: | ||
RUSTFLAGS: "-C target_feature=+avx2" | ||
run: cargo build --target x86_64-unknown-linux-gnu --features simd_backend | ||
RUSTFLAGS: '--cfg curve25519_dalek_backend="simd" -C target_feature=+avx2 -D warnings' | ||
run: cargo build --target x86_64-unknown-linux-gnu | ||
- env: | ||
RUSTFLAGS: "-C target_feature=+avx512ifma" | ||
run: cargo build --target x86_64-unknown-linux-gnu --features simd_backend | ||
RUSTFLAGS: '--cfg curve25519_dalek_backend="simd" -C target_feature=+avx512ifma -D warnings' | ||
run: cargo build --target x86_64-unknown-linux-gnu | ||
|
||
test-defaults-serde: | ||
name: Test default feature selection and serde | ||
|
@@ -78,11 +80,11 @@ jobs: | |
with: | ||
components: clippy | ||
- env: | ||
RUSTFLAGS: "-C target_feature=+avx2" | ||
run: cargo clippy --target x86_64-unknown-linux-gnu --features simd_backend -- -D warnings | ||
RUSTFLAGS: '--cfg curve25519_dalek_backend="simd" -C target_feature=+avx2 -D warnings' | ||
run: cargo clippy --target x86_64-unknown-linux-gnu | ||
- env: | ||
RUSTFLAGS: "-C target_feature=+avx512ifma" | ||
run: cargo clippy --target x86_64-unknown-linux-gnu --features simd_backend -- -D warnings | ||
RUSTFLAGS: '--cfg curve25519_dalek_backend="simd" -C target_feature=+avx512ifma -D warnings' | ||
run: cargo clippy --target x86_64-unknown-linux-gnu | ||
|
||
rustfmt: | ||
name: Check formatting | ||
|
@@ -102,11 +104,11 @@ jobs: | |
# First run `cargo +nightly -Z minimal-verisons check` in order to get a | ||
# Cargo.lock with the oldest possible deps | ||
- uses: dtolnay/rust-toolchain@nightly | ||
- run: cargo -Z minimal-versions check --no-default-features --features fiat_backend,serde | ||
- run: cargo -Z minimal-versions check --no-default-features --features serde | ||
# Now check that `cargo build` works with respect to the oldest possible | ||
# deps and the stated MSRV | ||
- uses: dtolnay/[email protected] | ||
- run: cargo build --no-default-features --features fiat_backend,serde | ||
- run: cargo build --no-default-features --features serde | ||
|
||
bench: | ||
name: Check that benchmarks compile | ||
|
@@ -115,8 +117,12 @@ jobs: | |
- uses: actions/checkout@v3 | ||
- uses: dtolnay/rust-toolchain@stable | ||
- name: Build u32 bench | ||
run: env RUSTFLAGS="--cfg curve25519_dalek_bits=\"32\"" cargo build --benches | ||
env: | ||
RUSTFLAGS: '--cfg curve25519_dalek_bits="32" -D warnings' | ||
run: cargo build --benches | ||
- name: Build u64 bench | ||
run: env RUSTFLAGS="--cfg curve25519_dalek_bits=\"64\"" cargo build --benches | ||
env: | ||
RUSTFLAGS: '--cfg curve25519_dalek_bits="64" -D warnings' | ||
run: cargo build --benches | ||
- name: Build default (host native) bench | ||
run: cargo build --benches |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
// - Henry de Valence <[email protected]> | ||
|
||
#![no_std] | ||
#![cfg_attr(feature = "simd_backend", feature(stdsimd))] | ||
#![cfg_attr(curve25519_dalek_backend = "simd", feature(stdsimd))] | ||
#![cfg_attr(docsrs, feature(doc_auto_cfg, doc_cfg, doc_cfg_hide))] | ||
#![cfg_attr(docsrs, doc(cfg_hide(docsrs)))] | ||
//------------------------------------------------------------------------ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters