Skip to content

Add tests for no-std #173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 5, 2019
Merged

Conversation

elichai
Copy link
Member

@elichai elichai commented Oct 24, 2019

This will not compile if std is somehow involved.
You can see yourself by removing default-features = false from the Cargo.toml and you'll get:

error[E0152]: duplicate lang item found: `eh_personality`.
  --> src/main.rs:37:1
   |
37 | pub extern "C" fn rust_eh_personality() {}
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: first defined in crate `panic_unwind` (which `std` depends on).

error[E0152]: duplicate lang item found: `panic_impl`.
  --> src/main.rs:83:1
   |
83 | / fn panic(info: &PanicInfo) -> ! {
84 | |     unsafe { libc::printf("shi1\n\0".as_ptr() as _) };
85 | |     let msg = info.message().unwrap();
86 | |     let mut buf = Print::new();
...  |
89 | |     unsafe { intrinsics::abort() }
90 | | }
   | |_^
   |
   = note: first defined in crate `std` (which `secp256k1` depends on).

error: aborting due to 2 previous errors

This currently only runs in release mode due to a bug that debug mode always tries to link to libunwind (which isn't available) even when we use abort instead of panic.

@elichai elichai force-pushed the 2019-10-no-std-tests branch from 0b6345a to e5e22ee Compare October 24, 2019 18:10
@apoelstra
Copy link
Member

Can you clarify the motivation for this PR?

@elichai
Copy link
Member Author

elichai commented Oct 28, 2019

@apoelstra Yes, #172.
This PR made me doubt our no-std support for a second so I wanted to write my own simple check to make sure that I'm not missing anything

Copy link
Collaborator

@jonasnick jonasnick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very nice. Approach ACK. I think it would be helpful to add a few sentences of documention (by adding a header main.rs?) mentioning what this is (a minimal nostd example that exercises some secp functions and features) and the kinds of error messages expected when something accidentally pulls in std.

@elichai elichai force-pushed the 2019-10-no-std-tests branch from cdf538f to 49391d6 Compare November 3, 2019 14:32
Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK. Looks great.

@apoelstra apoelstra merged commit c883a98 into rust-bitcoin:master Nov 5, 2019
@elichai elichai deleted the 2019-10-no-std-tests branch January 23, 2020 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants