diff --git a/build/html.ts b/build/html.ts
index 5bc4851..a99db1d 100644
--- a/build/html.ts
+++ b/build/html.ts
@@ -105,7 +105,7 @@ export async function buildHTML(game: string, { production = false, portable = f
}
const resultHTML = html
- .replace('', () => `${scriptPrefix}`)
+ .replace('', `${scriptPrefix}`)
.replace('', title)
.replace('', icon)
.replace('', manifest)
diff --git a/build/wasmPlugin.ts b/build/wasmPlugin.ts
index c88ec4d..068668c 100644
--- a/build/wasmPlugin.ts
+++ b/build/wasmPlugin.ts
@@ -92,11 +92,19 @@ const wasmPlugin = ({ production, portable }: WasmLoaderConfig = {}): BunPlugin
const glob = new Bun.Glob(`${buildAssets}/lib/**/*.c`);
const stdlib = await Array.fromAsync(glob.scan());
const opt = production ? '-O3' : '-O0';
- const result = await $`clang --target=wasm32 ${opt} -flto -fno-builtin --no-standard-libraries -I ${include} -Wall -Wextra -Wpedantic -Werror -Wno-gnu-anonymous-struct -Wl,--lto-O3 -Wl,--no-entry -Wl,--import-memory -o ${wasmPath} ${args.path} ${stdlib}`;
+ const objPath = wasmPath + '.o';
+ const std = args.path.endsWith('.cpp') ? '-std=gnu++23': '-std=gnu23';
+ const compileResult = await $`clang -c --target=wasm32 ${opt} -flto -fno-builtin --no-standard-libraries -I ${include} -Wall -Wextra -Wpedantic -Werror ${std} -o ${objPath} ${args.path}`;
- if (result.exitCode !== 0) {
+ if (compileResult.exitCode !== 0) {
throw new Error('Compile failed, check output');
}
+
+ const linkResult = await $`clang --target=wasm32 ${opt} -flto -fno-builtin --no-standard-libraries -I ${include} -Wall -Wextra -Wpedantic -Werror -std=gnu23 -Wl,--lto-O3 -Wl,--no-entry -Wl,--import-memory -o ${wasmPath} ${objPath} ${stdlib}`;
+
+ if (linkResult.exitCode !== 0) {
+ throw new Error('Link failed, check output');
+ }
}
const wasmContent = await Bun.file(wasmPath).arrayBuffer();
diff --git a/compile_flags.txt b/compile_flags.txt
index e15216f..4d9cfa8 100644
--- a/compile_flags.txt
+++ b/compile_flags.txt
@@ -1,4 +1,5 @@
--target=wasm32
+-std=gnu++23
-fno-builtin
--no-standard-libraries
-I
diff --git a/src/games/playground/awoo.cpp b/src/games/playground/awoo.cpp
index a332479..b392391 100644
--- a/src/games/playground/awoo.cpp
+++ b/src/games/playground/awoo.cpp
@@ -1,7 +1,15 @@
#include
+typedef struct {
+ union {
+ int a;
+ char b;
+ };
+ const char* string;
+} awoorwa;
+
EXPORT(main) void init() {
- uint32_t result = 42;
+ awoorwa result = {.a = 42, .string = "awoo"};
printf("%d\n", result);
}
\ No newline at end of file