added wasm64 support

This commit is contained in:
Jorijn van der Graaf 2024-12-29 03:30:22 +01:00
commit 98a73c0443
2 changed files with 7 additions and 2 deletions

View file

@ -161,13 +161,18 @@ void Project::Build(Configuration config, std::string outputDir) {
pcmDir = config.buildDir; pcmDir = config.buildDir;
} }
std::string clangDir; std::string clangDir;
if(config.target == "wasm32-unknown-wasi"){ if(config.target == "wasm32-unknown-wasi" || config.target == "wasm64-unknown-wasi"){
clangDir = "${WASI_SDK_PATH}/bin/clang++ --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot"; clangDir = "${WASI_SDK_PATH}/bin/clang++ --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot";
name+=".wasm"; name+=".wasm";
} else{ } else{
clangDir = "clang++"; clangDir = "clang++";
} }
if(config.target == "wasm32" || config.target == "wasm64") {
clangDir = "${WASI_SDK_PATH}/bin/clang++ --no-standard-libraries -Wl,--no-entry -Wl,--export-all -Wno-unused-command-line-argument";
name+=".wasm";
}
for(const std::string& moduleFile : config.moduleFiles){ for(const std::string& moduleFile : config.moduleFiles){
system(std::format("{} -std={} {}.cppm --precompile -fprebuilt-module-path={} -o {}/{}.pcm {}", clangDir, config.standard, moduleFile, pcmDir, pcmDir, moduleFile, target).c_str()); system(std::format("{} -std={} {}.cppm --precompile -fprebuilt-module-path={} -o {}/{}.pcm {}", clangDir, config.standard, moduleFile, pcmDir, pcmDir, moduleFile, target).c_str());
} }

View file

@ -86,7 +86,7 @@ Save and close, then run ``crafter-build -c debug``. Now you can run the ``hello
``target`` Clang triplet this configuration uses, please refer to the [relevant clang documentation](https://clang.llvm.org/docs/CrossCompilation.html#target-triple). ``target`` Clang triplet this configuration uses, please refer to the [relevant clang documentation](https://clang.llvm.org/docs/CrossCompilation.html#target-triple).
Note: the WASI SDK needs to be installed to use the ``wasm32-unknown-wasi`` to compile to webassmbly, and ``$WASI_SDK_PATH`` needs to be set, please refer to the [wasi-sdk installation guide](https://github.com/WebAssembly/wasi-sdk?tab=readme-ov-file#install). Note: the WASI SDK needs to be installed to compile to webassmbly, and ``$WASI_SDK_PATH`` needs to be set, please refer to the [wasi-sdk installation guide](https://github.com/WebAssembly/wasi-sdk?tab=readme-ov-file#install).