diff --git a/.github/workflows/cross.yml b/.github/workflows/cross.yml index fb92c84d7..84c8e894f 100644 --- a/.github/workflows/cross.yml +++ b/.github/workflows/cross.yml @@ -53,4 +53,4 @@ jobs: - name: install cross run: cargo install cross - name: run cross test - run: cross test --target ${{ matrix.arch }} + run: cross test --target ${{ matrix.arch }} --verbose diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index f435fdda7..bbe07b19d 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -46,6 +46,8 @@ jobs: uses: dtolnay/rust-toolchain@nightly - name: Install src run: rustup component add rust-src + - name: Install xargo + run: cargo install xargo - name: Running test script env: DO_FMT: true diff --git a/Cargo.toml b/Cargo.toml index a1958d945..7a3403864 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -54,6 +54,8 @@ bincode = "1.3.3" wasm-bindgen-test = "0.3" getrandom = { version = "0.2", features = ["js"] } +[lints.rust] +unexpected_cfgs = { level = "deny", check-cfg = ['cfg(bench)', 'cfg(secp256k1_fuzz)', 'cfg(rust_secp_no_symbol_renaming)'] } [[example]] name = "sign_verify_recovery" diff --git a/Cross.toml b/Cross.toml new file mode 100644 index 000000000..cc9bc4cfb --- /dev/null +++ b/Cross.toml @@ -0,0 +1,2 @@ +[target.x86_64-pc-windows-gnu] +image = "ghcr.io/cross-rs/x86_64-pc-windows-gnu:main" diff --git a/contrib/_test.sh b/contrib/_test.sh index e18b23146..d415b5689 100755 --- a/contrib/_test.sh +++ b/contrib/_test.sh @@ -101,8 +101,10 @@ if [ "$DO_ASAN" = true ]; then RUSTFLAGS='-Zsanitizer=memory -Zsanitizer-memory-track-origins -Cforce-frame-pointers=yes -Cllvm-args=-msan-eager-checks=0' \ cargo test --lib --all --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu - cargo run --release --manifest-path=./no_std_test/Cargo.toml | grep -q "Verified Successfully" - cargo run --release --features=alloc --manifest-path=./no_std_test/Cargo.toml | grep -q "Verified alloc Successfully" + cd no_std_test + xargo run --release --target=x86_64-unknown-linux-gnu | grep -q "Verified Successfully" + xargo run --release --target=x86_64-unknown-linux-gnu --features=alloc | grep -q "Verified alloc Successfully" + cd - fi # Run formatter if told to. diff --git a/no_std_test/Cargo.toml b/no_std_test/Cargo.toml index d36523550..31ce5c17e 100644 --- a/no_std_test/Cargo.toml +++ b/no_std_test/Cargo.toml @@ -2,6 +2,7 @@ name = "no_std_test" version = "0.1.0" authors = ["Elichai Turkel "] +edition = "2021" [features] alloc = ["secp256k1/alloc", "wee_alloc"] diff --git a/no_std_test/Xargo.toml b/no_std_test/Xargo.toml new file mode 100644 index 000000000..de8cec3df --- /dev/null +++ b/no_std_test/Xargo.toml @@ -0,0 +1,2 @@ +[dependencies] +alloc = {} diff --git a/no_std_test/src/main.rs b/no_std_test/src/main.rs index eb3871f47..53898873a 100644 --- a/no_std_test/src/main.rs +++ b/no_std_test/src/main.rs @@ -28,8 +28,6 @@ //! #![feature(start)] -#![feature(core_intrinsics)] -#![feature(panic_info_message)] #![feature(alloc_error_handler)] #![no_std] extern crate libc; @@ -48,8 +46,7 @@ extern crate wee_alloc; #[global_allocator] static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; -use core::fmt::{self, write, Write}; -use core::intrinsics; +use core::fmt::{self, Write}; use core::panic::PanicInfo; use secp256k1::ecdh::{self, SharedSecret}; @@ -62,6 +59,10 @@ use serde_cbor::de; use serde_cbor::ser::SliceWrite; use serde_cbor::Serializer; +fn abort() -> ! { + unsafe { libc::abort() } +} + struct FakeRng; impl RngCore for FakeRng { fn next_u32(&mut self) -> u32 { @@ -158,7 +159,7 @@ impl Write for Print { if curr + s.len() > MAX_PRINT { unsafe { libc::printf("overflow\n\0".as_ptr() as _); - intrinsics::abort(); + abort(); } } self.loc += s.len(); @@ -170,15 +171,15 @@ impl Write for Print { #[panic_handler] fn panic(info: &PanicInfo) -> ! { unsafe { libc::printf("shi1\n\0".as_ptr() as _) }; - let msg = info.message().unwrap(); + let msg = info.message(); let mut buf = Print::new(); - write(&mut buf, *msg).unwrap(); + write!(&mut buf, "{}", msg).unwrap(); buf.print(); - intrinsics::abort() + abort() } #[alloc_error_handler] fn alloc_error(_layout: Layout) -> ! { unsafe { libc::printf("alloc shi1\n\0".as_ptr() as _) }; - intrinsics::abort() + abort() } diff --git a/secp256k1-sys/Cargo.toml b/secp256k1-sys/Cargo.toml index 5d591ffcb..1ca432045 100644 --- a/secp256k1-sys/Cargo.toml +++ b/secp256k1-sys/Cargo.toml @@ -32,3 +32,6 @@ recovery = [] lowmemory = [] std = ["alloc"] alloc = [] + +[lints.rust] +unexpected_cfgs = { level = "deny", check-cfg = ['cfg(bench)', 'cfg(secp256k1_fuzz)', 'cfg(rust_secp_no_symbol_renaming)'] } diff --git a/src/key.rs b/src/key.rs index 012f09d36..9a868980d 100644 --- a/src/key.rs +++ b/src/key.rs @@ -638,10 +638,9 @@ impl PublicKey { /// # } /// ``` pub fn combine_keys(keys: &[&PublicKey]) -> Result { - use core::i32::MAX; use core::mem::transmute; - if keys.is_empty() || keys.len() > MAX as usize { + if keys.is_empty() || keys.len() > i32::MAX as usize { return Err(InvalidPublicKeySum); }