Skip to content

Commit

Permalink
Add ifdef guards to wasm-sysroot headers
Browse files Browse the repository at this point in the history
In typical C fashion headers should have if guards to stop them being
included multiple times in an object file.

Done in an attempt to fix the current WASM build failures e.g.,

 rust-lld: error: duplicate symbol: WASM32_INT_SIZE
 >>> defined in /home/tobin/.cache/cargo/wasm32-unknown-unknown/release/deps/libsecp256k1_sys-26edc0990a3ac6e5.rlib(precomputed_ecmult_gen.o)
 >>> defined in /home/tobin/.cache/cargo/wasm32-unknown-unknown/release/deps/libsecp256k1_sys-26edc0990a3ac6e5.rlib(precomputed_ecmult.o)

This seems valuable to have even if it does not fix the build issue.
  • Loading branch information
tcharding committed Mar 17, 2022
1 parent e9427d2 commit 53455b8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion secp256k1-sys/wasm-sysroot/stdio.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#ifndef WASM_SYSROOT_STDIO_H
#define WASM_SYSROOT_STDIO_H

#include <stddef.h>
#define alignof(type) offsetof (struct { char c; type member; }, member)

Expand All @@ -14,4 +17,6 @@ extern const unsigned char WASM32_UNSIGNED_CHAR_SIZE = sizeof(unsigned char);
extern const unsigned char WASM32_UNSIGNED_CHAR_ALIGN = alignof(unsigned char);

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

#endif /* WASM_SYSROOT_STDIO_H */
5 changes: 5 additions & 0 deletions secp256k1-sys/wasm-sysroot/string.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#ifndef WASM_SYSROOT_STRING_H
#define WASM_SYSROOT_STRING_H

#include <stddef.h>
void *memset(void *s, int c, size_t n);
void *memcpy(void *dest, const void *src, size_t n);
int memcmp(const void *s1, const void *s2, size_t n);

#endif /* WASM_SYSROOT_STRING_H */

0 comments on commit 53455b8

Please sign in to comment.