From d97ae1fd080da06de13a7ae92648e84da457ba85 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Wed, 6 Oct 2021 08:57:10 -0700 Subject: [PATCH] wasm32: Make `wasm32_c` the default and only mode; remove the "wasm32_c" feature. Always require a C compilare for wasm32, instead of trying to provide a subset of the functionality. --- .github/workflows/ci.yml | 2 +- Cargo.toml | 1 - build.rs | 7 ------- mk/install-build-tools.sh | 8 +------- src/lib.rs | 11 +---------- tests/aead_tests.rs | 2 -- tests/constant_time_tests.rs | 1 - tests/hmac_tests.rs | 2 -- tests/pbkdf2_tests.rs | 1 - tests/rsa_tests.rs | 4 ++-- 10 files changed, 5 insertions(+), 34 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ca26a12398..df74d2f259 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -430,7 +430,7 @@ jobs: matrix: features: - # Default - - --features=wasm32_c + host_os: - ubuntu-18.04 mode: diff --git a/Cargo.toml b/Cargo.toml index 736bd9f06b..f6c11567ac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 diff --git a/build.rs b/build.rs index 3087ba7b5d..b50128a37f 100644 --- a/build.rs +++ b/build.rs @@ -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()) }); diff --git a/mk/install-build-tools.sh b/mk/install-build-tools.sh index db50246e8d..5379fc14f7 100755 --- a/mk/install-build-tools.sh +++ b/mk/install-build-tools.sh @@ -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=*) ;; diff --git a/src/lib.rs b/src/lib.rs index 2f40ecec1b..ff5c94f6a4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -33,16 +33,7 @@ //! std //! Enable features that use libstd, in particular //! std::error::Error integration. Implies `alloc`. -//! wasm32_c -//! Enables features that require a C compiler on wasm32 targets, such as -//! the constant_time 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: -//! TARGET_CC=clang-10 TARGET_AR=llvm-ar-10 cargo test --target=wasm32-unknown-unknown --features=wasm32_c -//! with llvm-ar-10 and clang-10 in $PATH. -//! (Going forward more functionality should be enabled by default, without -//! requiring these hacks, and without requiring a C compiler.) +//! //! // When running mk/package.sh, don't actually build any code. diff --git a/tests/aead_tests.rs b/tests/aead_tests.rs index a542b54051..74db661715 100644 --- a/tests/aead_tests.rs +++ b/tests/aead_tests.rs @@ -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}; diff --git a/tests/constant_time_tests.rs b/tests/constant_time_tests.rs index 359e8b2547..ea2de3c326 100644 --- a/tests/constant_time_tests.rs +++ b/tests/constant_time_tests.rs @@ -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")] diff --git a/tests/hmac_tests.rs b/tests/hmac_tests.rs index 2f305da85f..0da0db5f40 100644 --- a/tests/hmac_tests.rs +++ b/tests/hmac_tests.rs @@ -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()); } diff --git a/tests/pbkdf2_tests.rs b/tests/pbkdf2_tests.rs index dda2224fa8..d3fe6ee0e9 100644 --- a/tests/pbkdf2_tests.rs +++ b/tests/pbkdf2_tests.rs @@ -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 diff --git a/tests/rsa_tests.rs b/tests/rsa_tests.rs index 99cc02ca39..2935c6fcfc 100644 --- a/tests/rsa_tests.rs +++ b/tests/rsa_tests.rs @@ -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]