Skip to content

Commit 910c4d8

Browse files
committed
Add wasi support
cmake -B build -DCMAKE_BUILD_TYPE=Release \ --toolchain ${wasi_sdk}/share/cmake/wasi-sdk.cmake \ -DNCNN_RUNTIME_CPU=OFF \ -DNCNN_DISABLE_EXCEPTION=ON \ -DNCNN_THREADS=OFF cmake --build build After build, you can run benchncnn on cmdline with wasmtime: wasmtime --dir . benchncnn
1 parent 95c86a5 commit 910c4d8

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ else()
559559
unset(CMAKE_REQUIRED_FLAGS)
560560
endif()
561561

562-
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten" AND NCNN_COMPILER_SUPPORT_X86_AVX)
562+
if(NOT CMAKE_SYSTEM_NAME MATCHES "Emscripten|WASI" AND NCNN_COMPILER_SUPPORT_X86_AVX)
563563
option(NCNN_AVX "optimize x86 platform with avx extension" ON)
564564
if(NCNN_COMPILER_SUPPORT_X86_FMA)
565565
if(NCNN_AVX)

src/CMakeLists.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -395,9 +395,10 @@ if(NCNN_TARGET_ARCH STREQUAL "x86")
395395
endif()
396396
target_compile_options(ncnn PRIVATE /D__SSE2__)
397397
else()
398-
target_compile_options(ncnn PRIVATE -msse2 -msse)
399-
if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
398+
if(CMAKE_SYSTEM_NAME MATCHES "Emscripten|WASI")
400399
target_compile_options(ncnn PRIVATE -msimd128)
400+
else()
401+
target_compile_options(ncnn PRIVATE -msse2 -msse)
401402
endif()
402403
endif()
403404
endif()

src/cpu.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
#include "platform.h"
1818

1919
#include <limits.h>
20+
#ifndef __wasi__
2021
#include <setjmp.h>
2122
#include <signal.h>
23+
#endif // __wasi__
2224
#include <stdio.h>
2325
#include <string.h>
2426

0 commit comments

Comments
 (0)