Skip to content

Commit

Permalink
Put aarch64 simd feature behind nightly feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
rubdos committed May 1, 2021
1 parent 87f205e commit df0ca72
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 9 deletions.
3 changes: 3 additions & 0 deletions rust/bridge/ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ license = "AGPL-3.0-only"
name = "signal_ffi"
crate-type = ["staticlib"]

[features]
nightly = ["signal-crypto/nightly", "libsignal-protocol/nightly"]

[dependencies]
libsignal-protocol = { path = "../../protocol" }
device-transfer = { path = "../../device-transfer" }
Expand Down
3 changes: 3 additions & 0 deletions rust/bridge/jni/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ license = "AGPL-3.0-only"
name = "signal_jni"
crate-type = ["cdylib"]

[features]
nightly = ["libsignal-protocol/nightly", "signal-crypto/nightly"]

[dependencies]
libsignal-protocol = { path = "../../protocol" }
signal-crypto = { path = "../../crypto" }
Expand Down
3 changes: 3 additions & 0 deletions rust/bridge/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ edition = "2018"
name = "signal_node"
crate-type = ["cdylib"]

[features]
nightly = ["libsignal-protocol/nightly", "libsignal-bridge/nightly"]

[dependencies]
libsignal-protocol = { path = "../../protocol" }
libsignal-bridge = { path = "../shared", features = ["node"] }
Expand Down
1 change: 1 addition & 0 deletions rust/bridge/shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ signal-neon-futures = { path = "../node/futures", optional = true }
ffi = ["libc", "libsignal-bridge-macros/ffi"]
jni = ["jni_crate", "libsignal-bridge-macros/jni"]
node = ["neon", "linkme", "signal-neon-futures", "libsignal-bridge-macros/node"]
nightly = ["signal-crypto/nightly", "libsignal-protocol/nightly"]
3 changes: 3 additions & 0 deletions rust/crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ rand = "0.7.3"
sha-1 = "0.9"
sha2 = "0.9"

[features]
nightly = []

[target.'cfg(all(target_arch = "aarch64", any(target_os = "linux")))'.dependencies]
libc = "0.2" # for getauxval

Expand Down
7 changes: 5 additions & 2 deletions rust/crypto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
// SPDX-License-Identifier: AGPL-3.0-only
//

#![cfg_attr(target_arch = "aarch64", feature(stdsimd))]
#![cfg_attr(target_arch = "aarch64", feature(aarch64_target_feature))]
#![cfg_attr(all(target_arch = "aarch64", feature = "nightly"), feature(stdsimd))]
#![cfg_attr(
all(target_arch = "aarch64", feature = "nightly"),
feature(aarch64_target_feature)
)]
#![deny(clippy::unwrap_used)]

mod error;
Expand Down
12 changes: 6 additions & 6 deletions rust/crypto/src/polyval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ mod polyval_soft;
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
mod polyval_clmul;

#[cfg(target_arch = "aarch64")]
#[cfg(all(target_arch = "aarch64", feature = "nightly"))]
mod polyval_pmul;

#[derive(Clone)]
pub enum Polyval {
Soft(polyval_soft::PolyvalSoft),
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
Clmul(polyval_clmul::PolyvalClmul),
#[cfg(target_arch = "aarch64")]
#[cfg(all(target_arch = "aarch64", feature = "nightly"))]
Pmul(polyval_pmul::PolyvalPmul),
}

Expand All @@ -35,7 +35,7 @@ impl Polyval {
}
}

#[cfg(target_arch = "aarch64")]
#[cfg(all(target_arch = "aarch64", feature = "nightly"))]
{
if crate::cpuid::has_armv8_crypto() {
return Ok(Polyval::Pmul(polyval_pmul::PolyvalPmul::new(key)?));
Expand All @@ -54,7 +54,7 @@ impl Polyval {
Polyval::Soft(polyval) => polyval.update(data),
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
Polyval::Clmul(polyval) => polyval.update(data),
#[cfg(target_arch = "aarch64")]
#[cfg(all(target_arch = "aarch64", feature = "nightly"))]
Polyval::Pmul(polyval) => polyval.update(data),
}
}
Expand All @@ -64,7 +64,7 @@ impl Polyval {
Polyval::Soft(polyval) => polyval.update_padded(data),
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
Polyval::Clmul(polyval) => polyval.update_padded(data),
#[cfg(target_arch = "aarch64")]
#[cfg(all(target_arch = "aarch64", feature = "nightly"))]
Polyval::Pmul(polyval) => polyval.update_padded(data),
}
}
Expand All @@ -74,7 +74,7 @@ impl Polyval {
Polyval::Soft(polyval) => polyval.finalize(),
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
Polyval::Clmul(polyval) => polyval.finalize(),
#[cfg(target_arch = "aarch64")]
#[cfg(all(target_arch = "aarch64", feature = "nightly"))]
Polyval::Pmul(polyval) => polyval.finalize(),
}
}
Expand Down
2 changes: 1 addition & 1 deletion rust/protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ default = ["u64_backend"]
u32_backend = ["curve25519-dalek/u32_backend"]
u64_backend = ["curve25519-dalek/u64_backend"]
simd_backend = ["curve25519-dalek/simd_backend"]
nightly = ["curve25519-dalek/nightly"]
nightly = ["curve25519-dalek/nightly", "signal-crypto/nightly"]

[dev-dependencies]
criterion = "0.3"
Expand Down

0 comments on commit df0ca72

Please sign in to comment.