Skip to content
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

Improve WASM build #661

Closed
wants to merge 3 commits into from
Closed

Conversation

tcharding
Copy link
Member

@tcharding tcharding commented Oct 31, 2023

Currently we are getting a bunch of warnings when building for WASM, this fixes a few of them leaving just the ones described in #660.

I can't figure out #660 so far.

Fix: #434

In `lib.rs` unit tests we are getting build warnings because of how we
are importing things, just import with `super::*` unconditionally and be
done with it.
We currently use the `cc::Build::flag_if_supported` function to pass in
`-Wno-unused-function` however when building for wasm the flag is
ignored.

Using plain old `flag` seems to work, found by trial and error, I did no
further investigation as to why it works and the other does not.

Resolves: rust-bitcoin#434
`libc v0.2.149` for the `wasm-unknown-unknown` target does not include
the struct `max_align_t`. Feature gate the test that uses it so it
doesn't get built in for WASM builds.
@@ -19,7 +19,7 @@ fn main() {
base_config.include("depend/secp256k1/")
.include("depend/secp256k1/include")
.include("depend/secp256k1/src")
.flag_if_supported("-Wno-unused-function") // some ecmult stuff is defined but not used upstream
.flag("-Wno-unused-function") // some ecmult stuff is defined but not used upstream
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like this needs bug report against cc (but we should check with the newest version first).

Copy link
Member

Choose a reason for hiding this comment

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

Agreed. This change seems pretty sketchy.

use std::mem;
use std::os::raw;
use crate::{types, AlignedType};
#[cfg(not(target_arch = "wasm32"))]
use crate::AlignedType;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't we redefine the type to be something else on wasm?

apoelstra added a commit that referenced this pull request Nov 3, 2023
dd6bf7c Fix unit test import statements (Tobin C. Harding)

Pull request description:

  In `lib.rs` unit tests we are getting build warnings because of how we are importing things, just import with `super::*` unconditionally and be done with it.

  This patch is the only good one out of #661.

ACKs for top commit:
  apoelstra:
    ACK dd6bf7c
  Kixunil:
    ACK dd6bf7c

Tree-SHA512: 3970f4c1374ec6de4798bfb52b561e9ac4611ec3a3885edc79639566f777e1fbb502cb36fa7abd015f3fd4a9ca4b6a4931b4ecb2e629e967b4e49391db97a97f
@tcharding tcharding closed this Nov 8, 2023
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.

[wasm] unused-function warnings are not silenced
3 participants