Skip to content

Commit 18259fd

Browse files
committed
Fix no-std raw test, after removal of lang items
1 parent b2edf15 commit 18259fd

File tree

1 file changed

+7
-20
lines changed

1 file changed

+7
-20
lines changed

no_std_test/src/main.rs

+7-20
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414

1515
//! # secp256k1 no-std test.
1616
//! This binary is a short smallest rust code to produce a working binary *without libstd*.
17-
//! This gives us 2 things:
17+
//! This gives us 2 things:
1818
//! 1. Test that the parts of the code that should work in a no-std enviroment actually work.
1919
//! 2. Test that we don't accidentally import libstd into `secp256k1`.
20-
//!
20+
//!
2121
//! The first is tested using the following command `cargo run --release | grep -q "Verified Successfully"`.
2222
//! (Making sure that it successfully printed that. i.e. it didn't abort before that).
23-
//!
23+
//!
2424
//! The second is tested by the fact that it compiles. if we accidentally link against libstd we should see the following error:
2525
//! `error[E0152]: duplicate lang item found`.
2626
//! Example:
@@ -33,11 +33,11 @@
3333
//! |
3434
//! = note: first defined in crate `panic_unwind` (which `std` depends on).
3535
//! ```
36-
//!
37-
//! Notes:
36+
//!
37+
//! Notes:
3838
//! * Requires `panic=abort` and `--release` to not depend on libunwind(which is provided usually by libstd) https://github.com/rust-lang/rust/issues/47493
3939
//! * Requires linking with `libc` for calling `printf`.
40-
//!
40+
//!
4141
4242
#![feature(lang_items)]
4343
#![feature(start)]
@@ -52,10 +52,10 @@ use core::fmt::{self, write, Write};
5252
use core::intrinsics;
5353
use core::panic::PanicInfo;
5454

55+
use secp256k1::ecdh::SharedSecret;
5556
use secp256k1::rand::{self, RngCore};
5657
use secp256k1::serde::Serialize;
5758
use secp256k1::*;
58-
use secp256k1::ecdh::SharedSecret;
5959

6060
use serde_cbor::de;
6161
use serde_cbor::ser::SliceWrite;
@@ -111,24 +111,11 @@ fn start(_argc: isize, _argv: *const *const u8) -> isize {
111111
})}.unwrap();
112112
assert_ne!(x_arr, [0u8; 32]);
113113
assert_ne!(&y_arr[..], &[0u8; 32][..]);
114-
115114

116115
unsafe { libc::printf("Verified Successfully!\n\0".as_ptr() as _) };
117116
0
118117
}
119118

120-
// These functions are used by the compiler, but not
121-
// for a bare-bones hello world. These are normally
122-
// provided by libstd.
123-
#[lang = "eh_personality"]
124-
#[no_mangle]
125-
pub extern "C" fn rust_eh_personality() {}
126-
127-
// This function may be needed based on the compilation target.
128-
#[lang = "eh_unwind_resume"]
129-
#[no_mangle]
130-
pub extern "C" fn rust_eh_unwind_resume() {}
131-
132119
const MAX_PRINT: usize = 511;
133120
struct Print {
134121
loc: usize,

0 commit comments

Comments
 (0)