Skip to content

Commit

Permalink
wasm32: Make wasm32_c the default and only mode; remove the "wasm32…
Browse files Browse the repository at this point in the history
…_c" feature.

Always require a C compilare for wasm32, instead of trying to provide a subset
of the functionality.
  • Loading branch information
briansmith committed Oct 6, 2021
1 parent fe23432 commit d97ae1f
Show file tree
Hide file tree
Showing 10 changed files with 5 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ jobs:
matrix:
features:
- # Default
- --features=wasm32_c

host_os:
- ubuntu-18.04
mode:
Expand Down
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ dev_urandom_fallback = ["once_cell"]
slow_tests = []
std = ["alloc"]
test_logging = []
wasm32_c = []

# XXX: debug = false because of https://github.com/rust-lang/rust/issues/34122

Expand Down
7 changes: 0 additions & 7 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,13 +427,6 @@ fn build_c_code(
) {
println!("cargo:rustc-env=RING_CORE_PREFIX={}", ring_core_prefix);

#[cfg(not(feature = "wasm32_c"))]
{
if &target.arch == "wasm32" {
return;
}
}

let asm_target = ASM_TARGETS.iter().find(|asm_target| {
asm_target.arch == target.arch && asm_target.oss.contains(&target.os.as_ref())
});
Expand Down
8 changes: 1 addition & 7 deletions mk/install-build-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,7 @@ case $target in
# The version of wasm-bindgen-cli must match the wasm-bindgen version.
wasm_bindgen_version=$(cargo metadata --format-version 1 | jq -r '.packages | map(select( .name == "wasm-bindgen")) | map(.version) | .[0]')
cargo install wasm-bindgen-cli --vers "$wasm_bindgen_version" --bin wasm-bindgen-test-runner
case ${features-} in
*wasm32_c*)
use_clang=1
;;
*)
;;
esac
use_clang=1
;;
--target=*)
;;
Expand Down
11 changes: 1 addition & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,7 @@
//! <tr><td><code>std</code>
//! <td>Enable features that use libstd, in particular
//! <code>std::error::Error</code> integration. Implies `alloc`.
//! <tr><td><code>wasm32_c</code>
//! <td>Enables features that require a C compiler on wasm32 targets, such as
//! the <code>constant_time</code> module, HMAC verification, and PBKDF2
//! verification. Without this feature, only a subset of functionality
//! is provided to wasm32 targets so that a C compiler isn't needed. A
//! typical invocation would be:
//! <code>TARGET_CC=clang-10 TARGET_AR=llvm-ar-10 cargo test --target=wasm32-unknown-unknown --features=wasm32_c</code>
//! with <code>llvm-ar-10</code> and <code>clang-10</code> in <code>$PATH</code>.
//! (Going forward more functionality should be enabled by default, without
//! requiring these hacks, and without requiring a C compiler.)
//!
//! </table>
// When running mk/package.sh, don't actually build any code.
Expand Down
2 changes: 0 additions & 2 deletions tests/aead_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

#![cfg(any(not(target_arch = "wasm32"), feature = "wasm32_c"))]

#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::{wasm_bindgen_test as test, wasm_bindgen_test_configure};

Expand Down
1 change: 0 additions & 1 deletion tests/constant_time_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

#![cfg(any(not(target_arch = "wasm32"), feature = "wasm32_c"))]
use ring::{constant_time, error, rand};

#[cfg(target_arch = "wasm32")]
Expand Down
2 changes: 0 additions & 2 deletions tests/hmac_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ fn hmac_test_case_inner(
{
let signature = hmac::sign(&key, input);
assert_eq!(is_ok, signature.as_ref() == output);

#[cfg(any(not(target_arch = "wasm32"), feature = "wasm32_c"))]
assert_eq!(is_ok, hmac::verify(&key, input, output).is_ok());
}

Expand Down
1 change: 0 additions & 1 deletion tests/pbkdf2_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ pub fn pbkdf2_tests() {
assert_eq!(dk == out, verify_expected_result.is_ok() || dk.is_empty());
}

#[cfg(any(not(target_arch = "wasm32"), feature = "wasm32_c"))]
assert_eq!(
pbkdf2::verify(algorithm, iterations, &salt, &secret, &dk),
verify_expected_result
Expand Down
4 changes: 2 additions & 2 deletions tests/rsa_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ use ring::{
};
use std::convert::TryFrom;

#[cfg(all(target_arch = "wasm32", feature = "wasm32_c"))]
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::{wasm_bindgen_test as test, wasm_bindgen_test_configure};

#[cfg(all(target_arch = "wasm32", feature = "wasm32_c"))]
#[cfg(target_arch = "wasm32")]
wasm_bindgen_test_configure!(run_in_browser);

#[test]
Expand Down

0 comments on commit d97ae1f

Please sign in to comment.