Skip to content

Commit f7cae46

Browse files
committed
Merge #421: Fix wasm build
bfd88db Move WASM const definitions to a source file (Tobin Harding) Pull request description: Total re-write ... again :) Currently we are defining the WASM integer size and alignments in the `stdio.h` header file, this is wrong because this file is included in the build by way of `build.rs` as well as by upstream `libsecp256k1`. Move WASM integer definitions to a `C` source file and build the file into the binary if target is WASM. Fixes the first part of #419 (#422 does the second part). ### Note to reviewers I'm not exactly sure why the directory `was-sysroot` is named as it is or if the name is significant to `cargo` , please review carefully the directory tree changes. ``` cd secp256k1-sys tree wasm wasm ├── wasm.c └── wasm-sysroot ├── stdio.h ├── stdlib.h └── string.h ``` ACKs for top commit: thomaseizinger: ACK bfd88db apoelstra: ACK bfd88db Tree-SHA512: ba822b764fb5f74dfd22cc797f7e3f70440dbaabfe34e0475c796e0e5d88f2086bedb00a1ec765cce91bde6bb45130b9abe5d9289317d6c20f692c6ed711969e
2 parents 2ce67d9 + bfd88db commit f7cae46

File tree

6 files changed

+20
-19
lines changed

6 files changed

+20
-19
lines changed

secp256k1-sys/build.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ fn main() {
5252
#[cfg(feature = "recovery")]
5353
base_config.define("ENABLE_MODULE_RECOVERY", Some("1"));
5454

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

6061
// secp256k1

secp256k1-sys/wasm-sysroot/stdio.h

-17
This file was deleted.

secp256k1-sys/wasm/wasm-sysroot/stdlib.h

Whitespace-only changes.

secp256k1-sys/wasm/wasm.c

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include <stddef.h>
2+
#define alignof(type) offsetof (struct { char c; type member; }, member)
3+
4+
const unsigned char WASM32_INT_SIZE = sizeof(int);
5+
const unsigned char WASM32_INT_ALIGN = alignof(int);
6+
7+
const unsigned char WASM32_UNSIGNED_INT_SIZE = sizeof(unsigned int);
8+
const unsigned char WASM32_UNSIGNED_INT_ALIGN = alignof(unsigned int);
9+
10+
const unsigned char WASM32_SIZE_T_SIZE = sizeof(size_t);
11+
const unsigned char WASM32_SIZE_T_ALIGN = alignof(size_t);
12+
13+
const unsigned char WASM32_UNSIGNED_CHAR_SIZE = sizeof(unsigned char);
14+
const unsigned char WASM32_UNSIGNED_CHAR_ALIGN = alignof(unsigned char);
15+
16+
const unsigned char WASM32_PTR_SIZE = sizeof(void*);
17+
const unsigned char WASM32_PTR_ALIGN = alignof(void*);

0 commit comments

Comments
 (0)