File tree Expand file tree Collapse file tree 7 files changed +77
-48
lines changed
Expand file tree Collapse file tree 7 files changed +77
-48
lines changed Original file line number Diff line number Diff line change @@ -329,12 +329,13 @@ jobs:
329329 cmake --build . --config Release --parallel 4
330330 working-directory : wamr-compiler
331331
332+ # cmake --build . --config Debug --parallel 4
332333 - name : Build Sample [wasi-threads]
333334 run : |
334335 cd samples/wasi-threads
335336 mkdir build && cd build
336337 cmake ..
337- cmake --build . --config Debug --parallel 4
338+ cmake --build . --config Debug --verbose
338339 ./iwasm wasm-apps/no_pthread.wasm
339340
340341 ../../../wamr-compiler/build/wamrc --size-level=0 --enable-multi-thread -o wasm-apps/no_pthread.aot wasm-apps/no_pthread.wasm
Original file line number Diff line number Diff line change @@ -229,27 +229,28 @@ jobs:
229229 cp wamrc `pwd`/../../product-mini/platforms/${{ matrix.platform }}/enclave-sample
230230 working-directory : wamr-compiler
231231
232+ # cmake --build . --config Debug --parallel 4
232233 - name : Build Sample [file]
233234 run : |
234235 cd samples/file
235236 mkdir build && cd build
236237 cmake ..
237- cmake --build . --config Debug --parallel 4
238+ cmake --build . --config Debug --verbose
238239 cp wasm-app/file.wasm `pwd`/../../../product-mini/platforms/${{ matrix.platform }}/enclave-sample
239240
240241 - name : Test Sample [file] in non-aot mode
241242 if : matrix.iwasm_make_options_run_mode != '$AOT_BUILD_OPTIONS'
242243 run : |
243244 source /opt/intel/sgxsdk/environment
244- ./iwasm --dir=. file.wasm
245+ ./iwasm -f file.wasm -d .
245246 working-directory : product-mini/platforms/${{ matrix.platform }}/enclave-sample
246247
247248 - name : Test Sample [file] in aot mode
248249 if : matrix.iwasm_make_options_run_mode == '$AOT_BUILD_OPTIONS'
249250 run : |
250251 source /opt/intel/sgxsdk/environment
251252 ./wamrc -sgx -o file.aot file.wasm
252- ./iwasm --dir=. file.aot
253+ ./iwasm -f file.aot -d .
253254 working-directory : product-mini/platforms/${{ matrix.platform }}/enclave-sample
254255
255256 spec_test_default :
Original file line number Diff line number Diff line change 1+ # Copyright (C) 2019 Intel Corporation. All rights reserved.
2+ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
4+ include (FindPackageHandleStandardArgs )
5+
6+ file (GLOB WASISDK_SEARCH_PATH "/opt/wasi-sdk-*" )
7+ find_path (WASISDK_HOME
8+ NAMES share/wasi-sysroot
9+ PATHS ${WASISDK_SEARCH_PATH}
10+ NO_DEFAULT_PATH
11+ REQUIRED
12+ )
13+
14+ string (REGEX MATCH [0-9]+\.[0-9]+\.*[0-9]* WASISDK_VERSION ${WASISDK_HOME} )
15+
16+ find_package_handle_standard_args (WASISDK REQUIRED_VARS WASISDK_HOME VERSION_VAR WASISDK_VERSION)
17+
18+ if (WASISDK_FOUND)
19+ set (WASISDK_CC_COMMAND ${WASISDK_HOME} /bin/clang)
20+ set (WASISDK_CXX_COMMAND ${WASISDK_HOME} /bin/clang++)
21+ set (WASISDK_TOOLCHAIN ${WASISDK_HOME} /share/cmake/wasi-sdk.cmake)
22+ set (WASISDK_PTHREAD_TOOLCHAIN ${WASISDK_HOME} /share/cmake/wasi-sdk-pthread.cmake)
23+ set (WASISDK_SYSROOT ${WASISDK_HOME} /share/wasi-sysroot)
24+ endif ()
25+ mark_as_advanced (WASISDK_CC_COMMAND WASISDK_CXX_COMMAND WASISDK_TOOLCHAIN WASISDK_PTHREAD_TOOLCHAIN WASISDK_SYSROOT WASISDK_HOME )
Original file line number Diff line number Diff line change @@ -6,4 +6,20 @@ project(file)
66
77################ wasm application ###############
88add_subdirectory (src )
9- add_subdirectory (wasm-app )
9+
10+ # Use ExternalProject to avoid incorporating WAMR library compilation flags into the
11+ # compilation of the wasm application, which could lead to compatibility
12+ # issues due to different targets.
13+ # Like: clang: error: unsupported option '-arch' for target 'wasm32-wasi'
14+ list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR} /../cmake)
15+ find_package (WASISDK REQUIRED )
16+
17+ include (ExternalProject )
18+ ExternalProject_Add (wasm-app
19+ SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR} /wasm-app"
20+ CONFIGURE_COMMAND ${CMAKE_COMMAND} -S ${CMAKE_CURRENT_SOURCE_DIR} /wasm-app -B build
21+ -DWASI_SDK_PREFIX=${WASISDK_HOME}
22+ -DCMAKE_TOOLCHAIN_FILE=${WASISDK_TOOLCHAIN}
23+ BUILD_COMMAND ${CMAKE_COMMAND} --build build
24+ INSTALL_COMMAND ${CMAKE_COMMAND} --install build --prefix ${CMAKE_CURRENT_BINARY_DIR}
25+ )
Original file line number Diff line number Diff line change 22# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
33
44cmake_minimum_required (VERSION 3.14 )
5- project (wasm-app )
5+ project (file_wasm )
66
7- set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR} /../../.. )
7+ set (CMAKE_BUILD_TYPE Debug) # Otherwise no debug symbols (addr2line )
88
9- if (APPLE )
10- set (HAVE_FLAG_SEARCH_PATHS_FIRST 0)
11- set (CMAKE_C_LINK_FLAGS "" )
12- set (CMAKE_CXX_LINK_FLAGS "" )
13- endif ()
14-
15- set (CMAKE_SYSTEM_PROCESSOR wasm32)
16-
17- if (NOT DEFINED WASI_SDK_DIR)
18- set (WASI_SDK_DIR "/opt/wasi-sdk" )
19- endif ()
20-
21- set (CMAKE_C_COMPILER_TARGET "wasm32-wasi" )
22- set (CMAKE_C_COMPILER "${WASI_SDK_DIR} /bin/clang" )
23- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -Wno-unused-command-line-argument" )
24-
25- add_executable (file.wasm main.c )
26- target_link_libraries (file.wasm )
9+ add_executable (file main.c )
10+ set_target_properties (file PROPERTIES SUFFIX .wasm )
11+ install (FILES ${CMAKE_CURRENT_BINARY_DIR} /file .wasm DESTINATION wasm-app)
Original file line number Diff line number Diff line change @@ -66,7 +66,24 @@ add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE})
6666
6767
6868################ wasm application ################
69- add_subdirectory (wasm-apps )
69+ # Use ExternalProject to avoid incorporating WAMR library compilation flags into the
70+ # compilation of the wasm application, which could lead to compatibility
71+ # issues due to different targets.
72+ # Like: clang: error: unsupported option '-arch' for target 'wasm32-wasi'
73+
74+ list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR} /../cmake)
75+ find_package (WASISDK REQUIRED )
76+
77+ include (ExternalProject )
78+ ExternalProject_Add (wasm-apps
79+ SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR} /wasm-apps"
80+ CONFIGURE_COMMAND ${CMAKE_COMMAND} -S ${CMAKE_CURRENT_SOURCE_DIR} /wasm-apps -B build
81+ -DWASI_SDK_PREFIX=${WASISDK_HOME}
82+ -DCMAKE_TOOLCHAIN_FILE=${WASISDK_PTHREAD_TOOLCHAIN}
83+ BUILD_COMMAND ${CMAKE_COMMAND} --build build
84+ INSTALL_COMMAND ${CMAKE_COMMAND} --install build --prefix ${CMAKE_CURRENT_BINARY_DIR}
85+ )
86+
7087
7188################ wamr runtime ################
7289include (${SHARED_DIR} /utils/uncommon/shared_uncommon.cmake )
Original file line number Diff line number Diff line change 11# Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
33
4- if (APPLE )
5- set (HAVE_FLAG_SEARCH_PATHS_FIRST 0)
6- set (CMAKE_C_LINK_FLAGS "" )
7- set (CMAKE_CXX_LINK_FLAGS "" )
8- endif ()
4+ cmake_minimum_required (VERSION 3.14 )
5+ project (wasi_threads_wasm)
96
10- if (NOT DEFINED WASI_SDK_DIR)
11- set (WASI_SDK_DIR "/opt/wasi-sdk" )
12- endif ()
13-
14- if (DEFINED WASI_SYSROOT)
15- set (CMAKE_SYSROOT "${WASI_SYSROOT} " )
16- endif ()
17-
18- set (CMAKE_C_COMPILER "${WASI_SDK_DIR} /bin/clang" )
19- set (CMAKE_ASM_COMPILER "${WASI_SDK_DIR} /bin/clang" )
20- set (CMAKE_EXE_LINKER_FLAGS "-target wasm32-wasi-threads" )
21-
22- if ("$ENV{COLLECT_CODE_COVERAGE} " STREQUAL "1" OR COLLECT_CODE_COVERAGE EQUAL 1)
23- set (CMAKE_C_FLAGS "" )
24- set (CMAKE_CXX_FLAGS "" )
25- endif ()
7+ set (CMAKE_BUILD_TYPE Debug) # Otherwise no debug symbols (addr2line)
268
279function (compile_sample SOURCE_FILE )
2810 get_filename_component (FILE_NAME ${SOURCE_FILE} NAME_WLE )
@@ -41,6 +23,8 @@ function (compile_sample SOURCE_FILE)
4123 LINKER:--export=malloc
4224 LINKER:--export=free
4325 )
26+
27+ install (FILES ${CMAKE_CURRENT_BINARY_DIR} /${WASM_MODULE} DESTINATION wasm-apps)
4428endfunction ()
4529
46- compile_sample (no_pthread.c wasi_thread_start.S )
30+ compile_sample (no_pthread.c wasi_thread_start.S )
You can’t perform that action at this time.
0 commit comments