Skip to content

Commit

Permalink
Merge #705: Fix ci
Browse files Browse the repository at this point in the history
33a1893 Upgrade cross image for windows (Martin Habovstiak)
24e81ee Run cross with --verbose flag (Martin Habovstiak)
742c69f Compile `no_std` test using xargo (Martin Habovstiak)
2572fb6 Migrate `no_std_test` to edition 2021 (Martin Habovstiak)
df0523a Use `libc::abort` instead of `intrinsics::abort` (Martin Habovstiak)
924ba38 Update panic message handling (Martin Habovstiak)
614fe81 Whitelist known cfgs (Martin Habovstiak)
05a4e39 Don't use `core::i32::MAX` (Martin Habovstiak)

Pull request description:

  Updated deprecated item and fixed cfg lints.

ACKs for top commit:
  apoelstra:
    ACK 33a1893

Tree-SHA512: 8b66f1f404d44916b2a18dbbe829b31ec1915d3fd084164127aa6e5f98ee5de3ea988f5b1ed05e9532c026890a769b4c54e175508fe472beaea5898a477d5c76
  • Loading branch information
apoelstra committed Jul 5, 2024
2 parents 6648126 + 33a1893 commit 30dda2c
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cross.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions Cross.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[target.x86_64-pc-windows-gnu]
image = "ghcr.io/cross-rs/x86_64-pc-windows-gnu:main"
6 changes: 4 additions & 2 deletions contrib/_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions no_std_test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "no_std_test"
version = "0.1.0"
authors = ["Elichai Turkel <[email protected]>"]
edition = "2021"

[features]
alloc = ["secp256k1/alloc", "wee_alloc"]
Expand Down
2 changes: 2 additions & 0 deletions no_std_test/Xargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[dependencies]
alloc = {}
19 changes: 10 additions & 9 deletions no_std_test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
//!

#![feature(start)]
#![feature(core_intrinsics)]
#![feature(panic_info_message)]
#![feature(alloc_error_handler)]
#![no_std]
extern crate libc;
Expand All @@ -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};
Expand All @@ -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 {
Expand Down Expand Up @@ -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();
Expand All @@ -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()
}
3 changes: 3 additions & 0 deletions secp256k1-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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)'] }
3 changes: 1 addition & 2 deletions src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -638,10 +638,9 @@ impl PublicKey {
/// # }
/// ```
pub fn combine_keys(keys: &[&PublicKey]) -> Result<PublicKey, Error> {
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);
}

Expand Down

0 comments on commit 30dda2c

Please sign in to comment.