Skip to content

Fix wasm build #421

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 1 commit into from
Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions secp256k1-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ fn main() {
#[cfg(feature = "recovery")]
base_config.define("ENABLE_MODULE_RECOVERY", Some("1"));

// Header files. WASM only.
// WASM headers and size/align defines.
if env::var("CARGO_CFG_TARGET_ARCH").unwrap() == "wasm32" {
base_config.include("wasm-sysroot");
base_config.include("wasm/wasm-sysroot")
.file("wasm/wasm.c");
}

// secp256k1
Expand Down
17 changes: 0 additions & 17 deletions secp256k1-sys/wasm-sysroot/stdio.h

This file was deleted.

Empty file.
17 changes: 17 additions & 0 deletions secp256k1-sys/wasm/wasm.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <stddef.h>
#define alignof(type) offsetof (struct { char c; type member; }, member)

const unsigned char WASM32_INT_SIZE = sizeof(int);
const unsigned char WASM32_INT_ALIGN = alignof(int);

const unsigned char WASM32_UNSIGNED_INT_SIZE = sizeof(unsigned int);
const unsigned char WASM32_UNSIGNED_INT_ALIGN = alignof(unsigned int);

const unsigned char WASM32_SIZE_T_SIZE = sizeof(size_t);
const unsigned char WASM32_SIZE_T_ALIGN = alignof(size_t);

const unsigned char WASM32_UNSIGNED_CHAR_SIZE = sizeof(unsigned char);
const unsigned char WASM32_UNSIGNED_CHAR_ALIGN = alignof(unsigned char);

const unsigned char WASM32_PTR_SIZE = sizeof(void*);
const unsigned char WASM32_PTR_ALIGN = alignof(void*);