Skip to content
This repository was archived by the owner on Feb 19, 2025. It is now read-only.

Commit

Permalink
Try using workaround from cacticouncil/lilypad
Browse files Browse the repository at this point in the history
  • Loading branch information
noClaps committed Jan 4, 2025
1 parent f6397e1 commit 71dc214
Show file tree
Hide file tree
Showing 12 changed files with 88 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/build-wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
export CXX=clang++
- run: cargo install wasm-pack
- run: |
mkdir dist
export CFLAGS_wasm32_unknown_unknown := `echo "-I$(pwd)/wasm-sysroot -Wbad-function-cast -Wcast-function-type -fno-builtin"`
wasm-pack build --release -d ./dist
- uses: actions/upload-artifact@v4
with:
Expand Down
4 changes: 4 additions & 0 deletions wasm-sysroot/assert.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#pragma once

#define assert(ignore) ((void)0)
#define static_assert(cnd, msg) assert(cnd && msg)
3 changes: 3 additions & 0 deletions wasm-sysroot/ctype.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

int isprint(int c);
3 changes: 3 additions & 0 deletions wasm-sysroot/inttypes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

#define PRId32 "d"
5 changes: 5 additions & 0 deletions wasm-sysroot/stdbool.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

#define bool _Bool
#define true 1
#define false 0
19 changes: 19 additions & 0 deletions wasm-sysroot/stdint.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once

typedef signed char int8_t;
typedef short int16_t;
typedef long int32_t;
typedef long long int64_t;

typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned long uint32_t;
typedef unsigned long long uint64_t;

typedef unsigned long size_t;

typedef unsigned int uintptr_t;

#define UINT8_MAX 0xff
#define UINT16_MAX 0xffff
#define UINT32_MAX 0xffffffff
19 changes: 19 additions & 0 deletions wasm-sysroot/stdio.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once

// just some filler type
#define FILE void

#define stdin NULL
#define stdout NULL
#define stderr NULL

int fprintf(FILE *__restrict__, const char *__restrict__, ...);
int fputs(const char *__restrict, FILE *__restrict);
int fputc(int, FILE *);
FILE *fdopen(int, const char *);
int fclose(FILE *);

int vsnprintf(char *s, unsigned long n, const char *format, ...);

#define sprintf(str, ...) 0
#define snprintf(str, len, ...) 0
12 changes: 12 additions & 0 deletions wasm-sysroot/stdlib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once

#include <stdint.h>

#define NULL ((void*)0)

void* malloc(size_t size);
void* calloc(size_t nmemb, size_t size);
void free(void* ptr);
void* realloc(void* ptr, size_t size);

void abort(void);
7 changes: 7 additions & 0 deletions wasm-sysroot/string.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

void *memcpy(void *dest, const void *src, unsigned long n);
void *memmove(void *dest, const void *src, unsigned long n);
void *memset(void *s, int c, unsigned long n);
int memcmp(const void *ptr1, const void *ptr2, unsigned long n);
int strncmp(const char *s1, const char *s2, unsigned long n);
5 changes: 5 additions & 0 deletions wasm-sysroot/time.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

typedef unsigned long clock_t;
#define CLOCKS_PER_SEC ((clock_t)1000000)
clock_t clock(void);
3 changes: 3 additions & 0 deletions wasm-sysroot/unistd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

int dup(int);
7 changes: 7 additions & 0 deletions wasm-sysroot/wctype.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

typedef __WCHAR_TYPE__ wchar_t;
typedef __WINT_TYPE__ wint_t;

int iswspace(wchar_t ch);
int iswalnum(wint_t _wc);

0 comments on commit 71dc214

Please sign in to comment.