Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sunxfancy committed Jul 17, 2024
1 parent 414d04f commit 67fdc6b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -297,21 +297,21 @@ upstream/wasi: .target/upstream/wasi
.target/upstream/wasi:
@echo "Downloading WASI..."
@mkdir -p upstream
@cd upstream && wget -c https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-23/wasi-sysroot-23.0.tar.gz \
&& tar -xvf wasi-sysroot-23.0.tar.gz \
&& rm -f wasi-sysroot-23.0.tar.gz
@cd upstream && wget -c https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-23/libclang_rt.builtins-wasm32-wasi-23.0.tar.gz \
&& tar -xvf libclang_rt.builtins-wasm32-wasi-23.0.tar.gz \
&& rm -f libclang_rt.builtins-wasm32-wasi-23.0.tar.gz
@cd upstream && wget -c https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-23/wasi-sdk-23.0-linux.tar.gz \
&& tar -xvf wasi-sdk-23.0-linux.tar.gz \
&& rm -f wasi-sdk-23.0-linux.tar.gz
@mkdir -p .target/upstream && touch .target/upstream/wasi


pack/wasi: .target/pack/wasi
.target/pack/wasi: .target/upstream/wasi .target/build/wasm-package
@echo "Packing WASI..."
@mkdir -p out
@cd upstream && ../out/wasm-package pack ../out/wasi.pack ./wasi-sysroot ./lib
@out/brotli -q 11 -o out/wasi.pack.br out/wasi.pack
@rm -rf out/lib/ out/wasi-sysroot/
@cp -r upstream/wasi-sdk-23.0/share/wasi-sysroot out/wasi-sysroot
@cp -r upstream/wasi-sdk-23.0/lib out/lib
@cd out && rm -rf ../out/wasi.pack && ../out/wasm-package pack ../out/wasi.pack ./wasi-sysroot ./lib
@rm -rf out/wasi.pack.br && out/brotli -q 11 -o out/wasi.pack.br out/wasi.pack
@mkdir -p .target/pack && touch .target/pack/wasi

endif
10 changes: 6 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
<script type="module">
const example =
`
extern "C" int printf(const char *format, ...);
#include <iostream>
int main() {
printf("Hello, world!\\n");
std::cout << "Hello C++!" << std::endl;
return 0;
}
`;
Expand Down Expand Up @@ -97,7 +97,7 @@
"generic",
"-fvisibility=hidden",
"-resource-dir",
"/",
"/lib/clang/18",
"-isysroot",
"/wasi-sysroot",
"-internal-isystem",
Expand All @@ -110,6 +110,8 @@
"/wasi-sysroot/include/wasm32-wasi",
"-internal-isystem",
"/wasi-sysroot/include",
"-internal-isystem",
"/lib/clang/18/include",
"-fdeprecated-macro",
"-ferror-limit",
"19",
Expand All @@ -133,7 +135,7 @@
"-lc++",
"-lc++abi",
"-lc",
"/lib/wasi/libclang_rt.builtins-wasm32.a",
"/lib/clang/18/lib/wasi/libclang_rt.builtins-wasm32.a",
"--export-all",
"--threads=1",
"-o",
Expand Down
4 changes: 4 additions & 0 deletions src/ClangProcess.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import EmProcess from "./EmProcess.mjs";

export default class ClangProcess extends EmProcess {
constructor(opts) {
ClangModule["wasmMemory"] = new WebAssembly.Memory({
"initial" : 128,
"maximum" : 25600
});
super(ClangModule, { ...opts });
}
};
Expand Down

0 comments on commit 67fdc6b

Please sign in to comment.