Skip to content

Add run wasi target#7336

Merged
waruqi merged 5 commits intoxmake-io:devfrom
luadebug:wasi
Feb 23, 2026
Merged

Add run wasi target#7336
waruqi merged 5 commits intoxmake-io:devfrom
luadebug:wasi

Conversation

@luadebug
Copy link
Member

@luadebug luadebug commented Feb 21, 2026

Issue was confirmed that it present for now.

Resolves: #7327

PS C:\issue-wasi-ar> xmake f -cvD -p wasi --sdk=C:\wasi-sdk-30.0-x86_64-windows
checking for platform ... wasi (x64)
configure
{
    ndk_stdcxx = true
    host = windows
    plat = wasi
    proxy_pac = pac.lua
    sdk = C:\wasi-sdk-30.0-x86_64-windows
    ccache = true
    arch = x64
    theme = default
    builddir = build
    target_os = linux
    clean = true
    mode = release
    network = public
    kind = static
}
PS C:\issue-wasi-ar> xmake -vD
checkinfo: cannot runv(wasm32-wasi-gcc.exe --version), No such file or directory
checking for wasm32-wasi-gcc ... no
checking for the c++ compiler (cxx: wasm32-wasi-gcc) ... no
checking for wasm32-wasi-clang ... C:\wasi-sdk-30.0-x86_64-windows\bin\wasm32-wasi-clang
checking for the c++ compiler (cxx) ... wasm32-wasi-clang
checking for C:\wasi-sdk-30.0-x86_64-windows\bin\wasm32-wasi-clang ... c:\wasi-sdk-30.0-x86_64-windows\bin\wasm32-wasi-clang.exe
checking for flags (-fPIC) ... ok
> wasm32-wasi-clang.exe "-fPIC" "-Qunused-arguments"
checking for flags (-fvisibility-inlines-hidden) ... ok
> wasm32-wasi-clang.exe "-fvisibility-inlines-hidden" "-Qunused-arguments"
checking for flags (-O3) ... ok
> wasm32-wasi-clang.exe "-O3" "-Qunused-arguments"
checking for flags (-fno-exceptions) ... ok
> wasm32-wasi-clang.exe "-fno-exceptions" "-Qunused-arguments"
checking for flags (-DNDEBUG) ... ok
> wasm32-wasi-clang.exe "-DNDEBUG" "-Qunused-arguments"
[ 23%]: cache compiling.release src\use-staticlib.cpp
C:\wasi-sdk-30.0-x86_64-windows\bin\wasm32-wasi-clang -c -Qunused-arguments -fvisibility=hidden -fvisibility-inlines-hidden -O3 -IC:\wasi-sdk-30.0-x86_64-windows\share\wasi-sysroot\include\wasm32-wasi\c++\v1 -fno-exceptions -DNDEBUG -o build\.objs\use-staticlib\wasi\x64\release\src\use-staticlib.cpp.o src\use-staticlib.cpp
checking for flags (-MMD -MF) ... ok
> wasm32-wasi-clang.exe "-MMD" "-MF" "C:\Temp\.xmake\260221\_867f27c4a798489d906651fb1378bae9" "-Qunused-arguments"
checking for flags (-fdiagnostics-color=always) ... ok
> wasm32-wasi-clang.exe "-fdiagnostics-color=always" "-Qunused-arguments"
checking for flags (-fansi-escape-codes) ... ok
> wasm32-wasi-clang.exe "-fansi-escape-codes" "-Qunused-arguments"
checking for the c++ compiler (cxx: wasm32-wasi-gcc) ... no
[ 23%]: cache compiling.release src\staticlib.cpp
C:\wasi-sdk-30.0-x86_64-windows\bin\wasm32-wasi-clang -c -Qunused-arguments -fvisibility=hidden -fvisibility-inlines-hidden -O3 -IC:\wasi-sdk-30.0-x86_64-windows\share\wasi-sysroot\include\wasm32-wasi\c++\v1 -fno-exceptions -DNDEBUG -o build\.objs\teststaticlib\wasi\x64\release\src\staticlib.cpp.o src\staticlib.cpp
checking for flags (-Wno-gnu-line-marker -Werror) ... ok
> wasm32-wasi-clang.exe "-Wno-gnu-line-marker" "-Werror" "-Qunused-arguments"
checkinfo: @programdir\core\sandbox\modules\os.lua:273: cannot runv(wasm32-wasi-gcc-ar.exe -cr C:\Temp\.xmake\260221\_6b086a868c2eff732ef8b51e9347afc1.a C:\Temp\.xmake\260221\_7e734833482b1ef2346ea0c9ad8b091e.o), No such file or directory
stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:1148]:
    [@programdir\core\sandbox\modules\os.lua:273]: in function 'runv'
    [@programdir\modules\detect\tools\find_gcc_ar.lua:33]:
    [C]: in function 'xpcall'
    [@programdir\core\base\utils.lua:258]:
    [...\core\sandbox\modules\import\lib\detect\find_program.lua:67]: in function '_do_check'
    [...\core\sandbox\modules\import\lib\detect\find_program.lua:95]: in function '_check'
    [...\core\sandbox\modules\import\lib\detect\find_program.lua:287]: in function '_find'
    [...\core\sandbox\modules\import\lib\detect\find_program.lua:352]:
    [@programdir\modules\lib\detect\find_tool.lua:32]: in function '_find_from_modules'
    [@programdir\modules\lib\detect\find_tool.lua:45]: in function '_find_tool'
    [@programdir\modules\lib\detect\find_tool.lua:94]:
    [@programdir\core\tool\toolchain.lua:545]: in function '_checktool'
    [@programdir\core\tool\toolchain.lua:267]: in function 'tool'
    [@programdir\core\tool\toolchain.lua:873]:
    [@programdir\core\tool\linker.lua:88]: in function '_load_tool'
    [@programdir\core\tool\linker.lua:135]: in function 'load'
    [...gramdir\core\sandbox\modules\import\core\tool\linker.lua:31]: in function 'load'
    [@programdir\modules\private\action\build\link_objects.lua:32]: in function '_do_link_target'
    [@programdir\modules\private\action\build\link_objects.lua:73]: in function 'job_func'
    [@programdir\modules\async\runjobs.lua:441]:
    [C]: in function 'xpcall'
    [@programdir\core\base\utils.lua:258]: in function 'trycall'
    [@programdir\core\sandbox\modules\try.lua:117]: in function 'try'
    [@programdir\modules\async\runjobs.lua:410]: in function 'cotask'
    [@programdir\core\base\scheduler.lua:514]:

checking for wasm32-wasi-gcc-ar ... no
checking for the static library archiver (ar: wasm32-wasi-gcc-ar) ... no
checkinfo: @programdir\core\sandbox\modules\os.lua:273: cannot runv(wasm32-wasi-ar.exe -cr C:\Temp\.xmake\260221\_a46b969e89fa4b32b002607c048866df.a C:\Temp\.xmake\260221\_247a7a3f591019af7b9b7df9e995dcb9.o), No such file or directory
stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:1148]:
    [@programdir\core\sandbox\modules\os.lua:273]: in function 'runv'
    [@programdir\modules\detect\tools\find_ar.lua:33]:
    [C]: in function 'xpcall'
    [@programdir\core\base\utils.lua:258]:
    [...\core\sandbox\modules\import\lib\detect\find_program.lua:67]: in function '_do_check'
    [...\core\sandbox\modules\import\lib\detect\find_program.lua:95]: in function '_check'
    [...\core\sandbox\modules\import\lib\detect\find_program.lua:287]: in function '_find'
    [...\core\sandbox\modules\import\lib\detect\find_program.lua:352]:
    [@programdir\modules\lib\detect\find_tool.lua:32]: in function '_find_from_modules'
    [@programdir\modules\lib\detect\find_tool.lua:45]: in function '_find_tool'
    [@programdir\modules\lib\detect\find_tool.lua:94]:
    [@programdir\core\tool\toolchain.lua:545]: in function '_checktool'
    [@programdir\core\tool\toolchain.lua:267]: in function 'tool'
    [@programdir\core\tool\toolchain.lua:873]:
    [@programdir\core\tool\linker.lua:88]: in function '_load_tool'
    [@programdir\core\tool\linker.lua:135]: in function 'load'
    [...gramdir\core\sandbox\modules\import\core\tool\linker.lua:31]: in function 'load'
    [@programdir\modules\private\action\build\link_objects.lua:32]: in function '_do_link_target'
    [@programdir\modules\private\action\build\link_objects.lua:73]: in function 'job_func'
    [@programdir\modules\async\runjobs.lua:441]:
    [C]: in function 'xpcall'
    [@programdir\core\base\utils.lua:258]: in function 'trycall'
    [@programdir\core\sandbox\modules\try.lua:117]: in function 'try'
    [@programdir\modules\async\runjobs.lua:410]: in function 'cotask'
    [@programdir\core\base\scheduler.lua:514]:

checking for wasm32-wasi-ar ... no
checking for the static library archiver (ar: wasm32-wasi-ar) ... no
checkinfo: @programdir\core\sandbox\modules\os.lua:273: cannot runv(wasm32-wasi-gcc-ar.exe -cr C:\Temp\.xmake\260221\_ef8257d3ab730f9074aad14b544b4510.a C:\Temp\.xmake\260221\_fd0c42fb1da821550ce1e3b00391efe0.o), No such file or directory
stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:1148]:
    [@programdir\core\sandbox\modules\os.lua:273]: in function 'runv'
    [@programdir\modules\detect\tools\find_gcc_ar.lua:33]:
    [C]: in function 'xpcall'
    [@programdir\core\base\utils.lua:258]:
    [...\core\sandbox\modules\import\lib\detect\find_program.lua:67]: in function '_do_check'
    [...\core\sandbox\modules\import\lib\detect\find_program.lua:95]: in function '_check'
    [...\core\sandbox\modules\import\lib\detect\find_program.lua:287]: in function '_find'
    [...\core\sandbox\modules\import\lib\detect\find_program.lua:352]:
    [@programdir\modules\lib\detect\find_tool.lua:32]: in function '_find_from_modules'
    [@programdir\modules\lib\detect\find_tool.lua:45]: in function '_find_tool'
    [@programdir\modules\lib\detect\find_tool.lua:94]:
    [@programdir\core\tool\toolchain.lua:545]: in function '_checktool'
    [@programdir\core\tool\toolchain.lua:267]: in function 'tool'
    [@programdir\core\tool\toolchain.lua:873]:
    [@programdir\core\tool\linker.lua:88]: in function '_load_tool'
    [@programdir\core\tool\linker.lua:135]: in function 'load'
    [...gramdir\core\sandbox\modules\import\core\tool\linker.lua:31]: in function 'load'
    [@programdir\modules\private\action\build\link_objects.lua:32]: in function '_do_link_target'
    [@programdir\modules\private\action\build\link_objects.lua:73]: in function 'job_func'
    [@programdir\modules\async\runjobs.lua:441]:
    [C]: in function 'xpcall'
    [@programdir\core\base\utils.lua:258]: in function 'trycall'
    [@programdir\core\sandbox\modules\try.lua:117]: in function 'try'
    [@programdir\modules\async\runjobs.lua:410]: in function 'cotask'
    [@programdir\core\base\scheduler.lua:514]:

checking for wasm32-wasi-gcc-ar ... no
checking for the static library archiver (ar: wasm32-wasi-gcc-ar) ... no
checkinfo: @programdir\core\sandbox\modules\os.lua:273: cannot runv(wasm32-wasi-ar.exe -cr C:\Temp\.xmake\260221\_d41c6ab5c1c5bca7dddab4ac70b28aa8.a C:\Temp\.xmake\260221\_0597886af586a8ead5b29e7807f46db8.o), No such file or directory
stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:1148]:
    [@programdir\core\sandbox\modules\os.lua:273]: in function 'runv'
    [@programdir\modules\detect\tools\find_ar.lua:33]:
    [C]: in function 'xpcall'
    [@programdir\core\base\utils.lua:258]:
    [...\core\sandbox\modules\import\lib\detect\find_program.lua:67]: in function '_do_check'
    [...\core\sandbox\modules\import\lib\detect\find_program.lua:95]: in function '_check'
    [...\core\sandbox\modules\import\lib\detect\find_program.lua:287]: in function '_find'
    [...\core\sandbox\modules\import\lib\detect\find_program.lua:352]:
    [@programdir\modules\lib\detect\find_tool.lua:32]: in function '_find_from_modules'
    [@programdir\modules\lib\detect\find_tool.lua:45]: in function '_find_tool'
    [@programdir\modules\lib\detect\find_tool.lua:94]:
    [@programdir\core\tool\toolchain.lua:545]: in function '_checktool'
    [@programdir\core\tool\toolchain.lua:267]: in function 'tool'
    [@programdir\core\tool\toolchain.lua:873]:
    [@programdir\core\tool\linker.lua:88]: in function '_load_tool'
    [@programdir\core\tool\linker.lua:135]: in function 'load'
    [...gramdir\core\sandbox\modules\import\core\tool\linker.lua:31]: in function 'load'
    [@programdir\modules\private\action\build\link_objects.lua:32]: in function '_do_link_target'
    [@programdir\modules\private\action\build\link_objects.lua:73]: in function 'job_func'
    [@programdir\modules\async\runjobs.lua:441]:
    [C]: in function 'xpcall'
    [@programdir\core\base\utils.lua:258]: in function 'trycall'
    [@programdir\core\sandbox\modules\try.lua:117]: in function 'try'
    [@programdir\modules\async\runjobs.lua:410]: in function 'cotask'
    [@programdir\core\base\scheduler.lua:514]:

checking for wasm32-wasi-ar ... no
checking for the static library archiver (ar: wasm32-wasi-ar) ... no
error: @programdir\core\main.lua:274: @programdir\actions\build\main.lua:161: @programdir\modules\async\runjobs.lua:261: ...gramdir\core\sandbox\modules\import\core\tool\linker.lua:33: cannot get program for ar
stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:1148]:
    [...gramdir\core\sandbox\modules\import\core\tool\linker.lua:33]: in function 'load'
    [@programdir\modules\private\action\build\link_objects.lua:32]: in function '_do_link_target'
    [@programdir\modules\private\action\build\link_objects.lua:73]: in function 'job_func'
    [@programdir\modules\async\runjobs.lua:441]:

stack traceback:
        [C]: in function 'error'
        @programdir\core\base\os.lua:1148: in function 'os.raiselevel'
        (...tail calls...)
        @programdir\core\main.lua:274: in upvalue 'cotask'
        @programdir\core\base\scheduler.lua:514: in function <@programdir\core\base\scheduler.lua:507>
PS C:\issue-wasi-ar>

After changes applied:

PS C:\issue-wasi-ar> $env:XMAKE_PROGRAM_DIR = "C:\Users\lin\xmake-luadebug\xmake"; & "C:\Users\lin\xmake-luadebug\core\build\xmake.exe" f -cvD -p wasi --sdk=C:\wasi-sdk-30.0-x86_64-windows
checking for platform ... wasi (wasm32)
checking for wasi-sdk directory ... C:\wasi-sdk-30.0-x86_64-windows
configure
{
    ndk_stdcxx = true
    clean = true
    theme = default
    host = windows
    ccache = true
    network = public
    plat = wasi
    arch = wasm32
    builddir = build
    mode = release
    kind = static
    proxy_pac = pac.lua
    sdk = C:\wasi-sdk-30.0-x86_64-windows
}
PS C:\issue-wasi-ar> $env:XMAKE_PROGRAM_DIR = "C:\Users\lin\xmake-luadebug\xmake"; & "C:\Users\lin\xmake-luadebug\core\build\xmake.exe" -vD
checking for clang ... C:\wasi-sdk-30.0-x86_64-windows\bin\clang
checking for the c++ compiler (cxx) ... clang
checking for C:\wasi-sdk-30.0-x86_64-windows\bin\clang ... c:\wasi-sdk-30.0-x86_64-windows\bin\clang.exe
checking for flags (-fPIC) ... ok
> clang.exe "-fPIC" "-Qunused-arguments" "--sysroot=C:\wasi-sdk-30.0-x86_64-windows\share\wasi-sysroot"
checking for flags (-fvisibility-inlines-hidden) ... ok
> clang.exe "-fvisibility-inlines-hidden" "-Qunused-arguments" "--sysroot=C:\wasi-sdk-30.0-x86_64-windows\share\wasi-sysroot"
checking for flags (-O3) ... ok
> clang.exe "-O3" "-Qunused-arguments" "--sysroot=C:\wasi-sdk-30.0-x86_64-windows\share\wasi-sysroot"
checking for flags (-fno-exceptions) ... ok
> clang.exe "-fno-exceptions" "-Qunused-arguments" "--sysroot=C:\wasi-sdk-30.0-x86_64-windows\share\wasi-sysroot"
checking for flags (-DNDEBUG) ... ok
> clang.exe "-DNDEBUG" "-Qunused-arguments" "--sysroot=C:\wasi-sdk-30.0-x86_64-windows\share\wasi-sysroot"
[ 23%]: cache compiling.release src\use-staticlib.cpp
C:\wasi-sdk-30.0-x86_64-windows\bin\clang -c -Qunused-arguments --sysroot=C:\wasi-sdk-30.0-x86_64-windows\share\wasi-sysroot -fvisibility=hidden -fvisibility-inlines-hidden -O3 -IC:\wasi-sdk-30.0-x86_64-windows\share\wasi-sysroot\include\wasm32-wasi\c++\v1 -fno-exceptions -DNDEBUG -o build\.objs\use-staticlib\wasi\wasm32\release\src\use-staticlib.cpp.o src\use-staticlib.cpp
checking for flags (-MMD -MF) ... ok
> clang.exe "-MMD" "-MF" "C:\Temp\.xmake\260221\_a497d1667ba4987adbf5f04486b1c55a" "-Qunused-arguments" "--sysroot=C:\wasi-sdk-30.0-x86_64-windows\share\wasi-sysroot"
checking for flags (-fdiagnostics-color=always) ... ok
> clang.exe "-fdiagnostics-color=always" "-Qunused-arguments" "--sysroot=C:\wasi-sdk-30.0-x86_64-windows\share\wasi-sysroot"
checking for flags (-fansi-escape-codes) ... ok
> clang.exe "-fansi-escape-codes" "-Qunused-arguments" "--sysroot=C:\wasi-sdk-30.0-x86_64-windows\share\wasi-sysroot"
checking for flags (-Wno-gnu-line-marker -Werror) ... ok
> clang.exe "-Wno-gnu-line-marker" "-Werror" "-Qunused-arguments" "--sysroot=C:\wasi-sdk-30.0-x86_64-windows\share\wasi-sysroot"
[ 23%]: cache compiling.release src\staticlib.cpp
C:\wasi-sdk-30.0-x86_64-windows\bin\clang -c -Qunused-arguments --sysroot=C:\wasi-sdk-30.0-x86_64-windows\share\wasi-sysroot -fvisibility=hidden -fvisibility-inlines-hidden -O3 -IC:\wasi-sdk-30.0-x86_64-windows\share\wasi-sysroot\include\wasm32-wasi\c++\v1 -fno-exceptions -DNDEBUG -o build\.objs\teststaticlib\wasi\wasm32\release\src\staticlib.cpp.o src\staticlib.cpp
checking for llvm-ar ... C:\wasi-sdk-30.0-x86_64-windows\bin\llvm-ar
checking for the static library archiver (ar) ... llvm-ar
[ 47%]: archiving.release libteststaticlib.a
C:\wasi-sdk-30.0-x86_64-windows\bin\llvm-ar cr build\wasi\wasm32\release\libteststaticlib.a build\.objs\teststaticlib\wasi\wasm32\release\src\staticlib.cpp.o
checking for clang++ ... C:\wasi-sdk-30.0-x86_64-windows\bin\clang++
checking for the linker (ld) ... clang++
checking for C:\wasi-sdk-30.0-x86_64-windows\bin\clang++ ... c:\wasi-sdk-30.0-x86_64-windows\bin\clang++.exe
checking for flags (-fPIC) ... ok
> clang++.exe "-fPIC" "--sysroot=C:\wasi-sdk-30.0-x86_64-windows\share\wasi-sysroot" "--sysroot=C:\wasi-sdk-30.0-x86_64-windows\share\wasi-sysroot"
[ 71%]: linking.release use-staticlib.wasm
C:\wasi-sdk-30.0-x86_64-windows\bin\clang++ -o build\wasi\wasm32\release\use-staticlib.wasm build\.objs\use-staticlib\wasi\wasm32\release\src\use-staticlib.cpp.o --sysroot=C:\wasi-sdk-30.0-x86_64-windows\share\wasi-sysroot -Lbuild\wasi\wasm32\release -s -lteststaticlib

build cache stats:
cache directory: C:\issue-wasi-ar\build\.build_cache
cache hit rate: 0%
cache hit: 0
cache hit total time: 0.000s
cache miss: 2
cache miss total time: 0.016s
new cached files: 2
remote cache hit: 0
remote new cached files: 0
preprocess failed: 0
compile fallback count: 0
compile total time: 5.609s

[100%]: build ok, spent 5.312s

PS C:\issue-wasi-ar> cd build
PS C:\issue-wasi-ar\build> dir


    Directory: C:\issue-wasi-ar\build


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----         2/21/2026   8:43 AM                .build_cache
d-----         2/21/2026   8:43 AM                .deps
d-----         2/21/2026   8:43 AM                .objs
d-----         2/21/2026   8:43 AM                wasi


PS C:\issue-wasi-ar\build> cd wasi
PS C:\issue-wasi-ar\build\wasi> dir


    Directory: C:\issue-wasi-ar\build\wasi


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----         2/21/2026   8:43 AM                wasm32


PS C:\issue-wasi-ar\build\wasi> cd wasm32
PS C:\issue-wasi-ar\build\wasi\wasm32> dir


    Directory: C:\issue-wasi-ar\build\wasi\wasm32


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----         2/21/2026   8:43 AM                release


PS C:\issue-wasi-ar\build\wasi\wasm32> cd .\release\
PS C:\issue-wasi-ar\build\wasi\wasm32\release> dir


    Directory: C:\issue-wasi-ar\build\wasi\wasm32\release


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----         2/21/2026   8:43 AM           3492 libteststaticlib.a
-a----         2/21/2026   8:43 AM         227831 use-staticlib.wasm


PS C:\issue-wasi-ar\build\wasi\wasm32\release> wasmtime .\use-staticlib.wasm
Hello from wasm staticlib!

@luadebug luadebug marked this pull request as draft February 21, 2026 16:30
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @luadebug, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly extends Xmake's capabilities by introducing comprehensive support for the WebAssembly System Interface (WASI) platform. It integrates WASI across core functionalities, including platform detection, build system configurations (CMake, Meson), package management (Conan), and Go environment settings. The changes ensure that projects targeting WASI can be built and managed effectively within the Xmake ecosystem, aligning WASI with existing WebAssembly (WASM) support where appropriate.

Highlights

  • WASI Platform Definition: A new platform definition file (xmake/platforms/wasi/xmake.lua) has been added to introduce WASI as a first-class platform, specifying its operating system, supported hosts, architectures (wasm32, wasm64), and default toolchains.
  • Expanded Platform Checks: Numerous is_plat function calls across various modules (e.g., configure, find_qt.lua, cmake.lua, meson.lua, package.lua, find_platform.lua, qt/config_static.lua, qt/load.lua) have been updated to explicitly include 'wasi' alongside 'wasm', ensuring consistent platform detection and behavior for WASI targets.
  • Conan Integration for WASI: Conan package manager configurations have been updated to recognize 'wasi' as an architecture, mapping it to 'wasm' for compatibility, and extending Emscripten SDK detection to cover WASI platforms.
  • CMake and Meson Build System Support: The CMake and Meson build tool integrations have been enhanced to correctly configure projects for WASI, including generator selection, environment flag setup, and cross-compilation file generation, by treating WASI similarly to WASM.
  • Go Environment Mappings: The Go environment detection (goenv.lua) has been extended to map the 'wasi' platform to 'wasip1' for GOOS and 'wasm32' to 'wasm' for GOARCH, facilitating Go cross-compilation for WASI.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • configure
    • Updated is_plat check to include 'wasi' for emcc toolchain detection.
  • xmake/modules/detect/sdks/find_qt.lua
    • Extended is_plat checks to include 'wasi' for Qt SDK directory detection.
    • Included 'wasi' in is_plat check for special handling of qmake on Windows.
  • xmake/modules/package/manager/conan/configurations.lua
    • Mapped 'wasi' architecture to 'wasm' in Conan configurations.
  • xmake/modules/package/manager/conan/v2/install_package.lua
    • Included 'wasi' in platform check for Emscripten SDK detection during Conan profile generation.
  • xmake/modules/package/tools/cmake.lua
    • Extended is_plat check to include 'wasi' for CMake generator selection on Windows subhosts.
    • Included 'wasi' in is_plat check for setting CMake environment flags for cross-compilation.
    • Updated is_plat check to include 'wasi' for general CMake configurations.
    • Extended is_plat check to include 'wasi' for make installation on Windows subhosts.
    • Included 'wasi' in is_plat check for determining CMake generator when using Ninja on Windows subhosts.
  • xmake/modules/package/tools/meson.lua
    • Included 'wasi' in is_plat check for Meson cross-compilation file generation, setting system to 'emscripten'.
    • Extended is_plat check to include 'wasi' when adding Meson cross-file configurations.
  • xmake/modules/private/action/require/impl/package.lua
    • Included 'wasi' in is_plat check for determining default shared library configuration.
  • xmake/modules/private/action/trybuild/cmake.lua
    • Added specific handling for 'wasi' in _get_configs_for_wasm to use cross-compilation configurations.
    • Extended is_plat check to include 'wasi' for CMake generator selection on Windows subhosts.
    • Included 'wasi' in is_plat check for general CMake configurations.
  • xmake/modules/private/action/trybuild/meson.lua
    • Included 'wasi' in is_plat check for Meson cross-file generation, setting system to 'emscripten'.
  • xmake/modules/private/detect/find_platform.lua
    • Included 'wasi' in platform check for architecture detection, setting it to 'wasm32'.
  • xmake/modules/private/tools/go/goenv.lua
    • Added 'wasi' to the GOOS mapping as 'wasip1'.
    • Added 'wasm32' to the GOARCH mapping as 'wasm'.
  • xmake/platforms/wasi/xmake.lua
    • Added a new platform definition file for WASI, specifying its OS, hosts, architectures, and build formats.
  • xmake/rules/platform/wasm/installfiles/xmake.lua
    • Extended on_load rule to include 'wasi' for installing WASM-related files.
  • xmake/rules/platform/wasm/preloadfiles/xmake.lua
    • Extended on_load rule to include 'wasi' for preloading WASM-related files.
  • xmake/rules/qt/config_static.lua
    • Included 'wasi' in target:is_plat check for Qt static configuration.
  • xmake/rules/qt/load.lua
    • Included 'wasi' in target:is_plat check for Qt loading rules.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for the WASI platform across various modules and scripts. The changes are mostly about adding wasi to platform checks alongside wasm. While most changes are correct, there are a few issues:

  • In Meson configuration files, the system is incorrectly set to emscripten for WASI, where it should be wasi.
  • Some Emscripten-specific rules for wasm (like installfiles for HTML output and preloadfiles) are incorrectly applied to the wasi platform, which has different characteristics and toolchains.

These issues should be addressed to ensure correct behavior for WASI builds.

file:print("cpu = '%s'", cpu)
file:print("endian = 'little'")
elseif package:is_plat("wasm") then
elseif package:is_plat("wasm", "wasi") then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

For Meson, the system for the WASI platform should be 'wasi', not 'emscripten'. This change incorrectly groups wasi with wasm to use 'emscripten' for both. This will lead to an incorrect cross-compilation setup for Meson-based packages targeting WASI. You should add a condition to set system = 'wasi' when the platform is wasi.

file:print("cpu = '%s'", cpu)
file:print("endian = 'little'")
elseif is_plat("wasm") then
elseif is_plat("wasm", "wasi") then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Similar to another file in this PR, this change incorrectly sets the Meson system to 'emscripten' for the WASI platform. It should be 'wasi'. This will cause issues when trying to build Meson projects for WASI. Please add logic to differentiate between wasm and wasi and set the system property accordingly.

-- copy other files generated by emcc (see https://emscripten.org/docs/tools_reference/emcc.html#emcc-o-target)
rule("platform.wasm.installfiles")
on_load("wasm", function (target)
on_load("wasm", "wasi", function (target)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This rule seems specific to Emscripten's HTML output, which is not applicable to the WASI platform. The WASI platform produces standalone .wasm binaries, not .html files with associated JavaScript. Applying this rule to wasi is likely incorrect and could lead to unexpected behavior during installation.

-- @see https://github.com/xmake-io/xmake/issues/3613
rule("platform.wasm.preloadfiles")
on_load("wasm", function (target)
on_load("wasm", "wasi", function (target)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The --preload-file flag is an Emscripten-specific feature for embedding files into a virtual filesystem. The WASI platform uses a different toolchain (wasi-sdk) and has its own filesystem APIs. Applying this rule to wasi is likely incorrect as the wasi-sdk toolchain does not support this flag.

@luadebug luadebug marked this pull request as ready for review February 21, 2026 16:44
@waruqi
Copy link
Member

waruqi commented Feb 23, 2026

I don't think we should add a separate wasi platform; the Wasm platform + the wasi toolchain is sufficient.

xmake f -p wasm --toolchain=wasi --sdk=/xxx

Adding a new platform doubles the maintenance workload, especially package management. xmake-repo requires additional maintenance support for the wasi platform.

if not python then
raise("emrun or python not found, which is required for running wasm target in browser!")
end
local url = "http://localhost:8000/" .. path.unix(path.relative(targetfile, rundir))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This thing always kept opening .js file instead of .html though not about this PR.

@luadebug
Copy link
Member Author

Alright so far this works.


… ~/issue-wasi-ar ─  v5.4.8 ╱ 16:56:38  
❯ rm -rf ./.xmake

… ~/issue-wasi-ar ─  v5.4.8 ╱ 16:56:46  
❯ rm -rf ./build

… ~/issue-wasi-ar ─  v5.4.8 ╱ 16:56:50  
❯ export XMAKE_PROGRAM_DIR=/home/lin/xmake-luadebug/xmake && xmake f -p wasm --toolchain=wasi --sdk=/home/lin/issue-wasi-ar/wasi-sdk-30.0-x86_64-linux
checking for platform ... wasm (wasm32)

… ~/issue-wasi-ar ─  v5.4.8 ╱ 16:57:15  
❯ export XMAKE_PROGRAM_DIR=/home/lin/xmake-luadebug/xmake && xmake -vD
checking for clang ... /home/lin/issue-wasi-ar/wasi-sdk-30.0-x86_64-linux/bin/clang
checking for the c++ compiler (cxx) ... clang
checking for /home/lin/issue-wasi-ar/wasi-sdk-30.0-x86_64-linux/bin/clang ... ok
checking for flags (-fPIC) ... ok
> clang "-fPIC" "-Qunused-arguments" "--sysroot=/home/lin/issue-wasi-ar/wasi-sdk-30.0-x86_64-linux/share/wasi-sysroot"
checking for flags (-fvisibility-inlines-hidden) ... ok
> clang "-fvisibility-inlines-hidden" "-Qunused-arguments" "--sysroot=/home/lin/issue-wasi-ar/wasi-sdk-30.0-x86_64-linux/share/wasi-sysroot"
checking for flags (-O3) ... ok
> clang "-O3" "-Qunused-arguments" "--sysroot=/home/lin/issue-wasi-ar/wasi-sdk-30.0-x86_64-linux/share/wasi-sysroot"
checking for flags (-fno-exceptions) ... ok
> clang "-fno-exceptions" "-Qunused-arguments" "--sysroot=/home/lin/issue-wasi-ar/wasi-sdk-30.0-x86_64-linux/share/wasi-sysroot"
checking for flags (-DNDEBUG) ... ok
> clang "-DNDEBUG" "-Qunused-arguments" "--sysroot=/home/lin/issue-wasi-ar/wasi-sdk-30.0-x86_64-linux/share/wasi-sysroot"
[ 23%]: cache compiling.release src/use-staticlib.cpp
/home/lin/issue-wasi-ar/wasi-sdk-30.0-x86_64-linux/bin/clang -c -Qunused-arguments --sysroot=/home/lin/issue-wasi-ar/wasi-sdk-30.0-x86_64-linux/share/wasi-sysroot -fvisibility=hidden -fvisibility-inlines-hidden -O3 -I/home/lin/issue-wasi-ar/wasi-sdk-30.0-x86_64-linux/share/wasi-sysroot/include/wasm32-wasi/c++/v1 -fno-exceptions -DNDEBUG -o build/.objs/use-staticlib/wasm/wasm32/release/src/use-staticlib.cpp.o src/use-staticlib.cpp
checking for flags (-MMD -MF) ... ok
> clang "-MMD" "-MF" "/dev/null" "-Qunused-arguments" "--sysroot=/home/lin/issue-wasi-ar/wasi-sdk-30.0-x86_64-linux/share/wasi-sysroot"
checking for flags (-fdiagnostics-color=always) ... ok
> clang "-fdiagnostics-color=always" "-Qunused-arguments" "--sysroot=/home/lin/issue-wasi-ar/wasi-sdk-30.0-x86_64-linux/share/wasi-sysroot"
checking for flags (-Wno-gnu-line-marker -Werror) ... ok
> clang "-Wno-gnu-line-marker" "-Werror" "-Qunused-arguments" "--sysroot=/home/lin/issue-wasi-ar/wasi-sdk-30.0-x86_64-linux/share/wasi-sysroot"
[ 23%]: cache compiling.release src/staticlib.cpp
/home/lin/issue-wasi-ar/wasi-sdk-30.0-x86_64-linux/bin/clang -c -Qunused-arguments --sysroot=/home/lin/issue-wasi-ar/wasi-sdk-30.0-x86_64-linux/share/wasi-sysroot -fvisibility=hidden -fvisibility-inlines-hidden -O3 -I/home/lin/issue-wasi-ar/wasi-sdk-30.0-x86_64-linux/share/wasi-sysroot/include/wasm32-wasi/c++/v1 -fno-exceptions -DNDEBUG -o build/.objs/teststaticlib/wasm/wasm32/release/src/staticlib.cpp.o src/staticlib.cpp
checking for llvm-ar ... /home/lin/issue-wasi-ar/wasi-sdk-30.0-x86_64-linux/bin/llvm-ar
checking for the static library archiver (ar) ... llvm-ar
[ 47%]: archiving.release libteststaticlib.a
/home/lin/issue-wasi-ar/wasi-sdk-30.0-x86_64-linux/bin/llvm-ar cr build/wasm/wasm32/release/libteststaticlib.a build/.objs/teststaticlib/wasm/wasm32/release/src/staticlib.cpp.o
checking for clang++ ... /home/lin/issue-wasi-ar/wasi-sdk-30.0-x86_64-linux/bin/clang++
checking for the linker (ld) ... clang++
checking for /home/lin/issue-wasi-ar/wasi-sdk-30.0-x86_64-linux/bin/clang++ ... ok
checking for flags (-fPIC) ... ok
> clang++ "-fPIC" "--sysroot=/home/lin/issue-wasi-ar/wasi-sdk-30.0-x86_64-linux/share/wasi-sysroot" "--sysroot=/home/lin/issue-wasi-ar/wasi-sdk-30.0-x86_64-linux/share/wasi-sysroot"
[ 71%]: linking.release use-staticlib.wasm
/home/lin/issue-wasi-ar/wasi-sdk-30.0-x86_64-linux/bin/clang++ -o build/wasm/wasm32/release/use-staticlib.wasm build/.objs/use-staticlib/wasm/wasm32/release/src/use-staticlib.cpp.o --sysroot=/home/lin/issue-wasi-ar/wasi-sdk-30.0-x86_64-linux/share/wasi-sysroot -Lbuild/wasm/wasm32/release -s -lteststaticlib

build cache stats:
cache directory: /home/lin/issue-wasi-ar/build/.build_cache
cache hit rate: 0%
cache hit: 0
cache hit total time: 0,000s
cache miss: 2
cache miss total time: 0,001s
new cached files: 2
remote cache hit: 0
remote new cached files: 0
preprocess failed: 0
compile fallback count: 0
compile total time: 3,700s

[100%]: build ok, spent 3,449s

…e-wasi-ar ─ 4s  ╱  v5.4.8 ╱ 16:57:25  
❯ export XMAKE_PROGRAM_DIR=/home/lin/xmake-luadebug/xmake && xmake run
Hello from wasm staticlib!

@luadebug luadebug changed the title Add support for WASI platform in various modules and scripts Add run wasi target Feb 23, 2026
@waruqi waruqi merged commit ea307e0 into xmake-io:dev Feb 23, 2026
37 checks passed
@waruqi waruqi added this to the v3.0.8 milestone Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wasi 工具链无法识别 AR 程序位置

2 participants