mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-05-08 20:56:13 +00:00
Fix sample ref-types/wasm-c-api build error with wat2wasm low version (#1702)
Fix build error in sample ref-types and wasm-c-api caused by the version of wat2wasm: refine makefile to auto detect the wat2wasm version and add the compile flag accordingly.
This commit is contained in:
parent
c718e76dea
commit
375a2c9a49
|
@ -102,6 +102,15 @@ find_program(WAT2WASM
|
||||||
|
|
||||||
if(NOT WAT2WASM)
|
if(NOT WAT2WASM)
|
||||||
message(SEND_ERROR "can not find wat2wasm")
|
message(SEND_ERROR "can not find wat2wasm")
|
||||||
|
else ()
|
||||||
|
execute_process(COMMAND ${WAT2WASM} --version
|
||||||
|
OUTPUT_VARIABLE WAT2WASM_VERSION_OUTPUT)
|
||||||
|
string(STRIP ${WAT2WASM_VERSION_OUTPUT} WAT2WASM_VERSION)
|
||||||
|
message("-- Found wat2wasm ${WAT2WASM_VERSION}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (${WAT2WASM_VERSION} VERSION_LESS 1.0.26)
|
||||||
|
set(WAT2WASM_FLAGS "--enable-reference-types")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake)
|
include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake)
|
||||||
|
@ -122,7 +131,7 @@ endif()
|
||||||
# wat to wasm
|
# wat to wasm
|
||||||
file(GLOB WAT_FILE src/hello.wat)
|
file(GLOB WAT_FILE src/hello.wat)
|
||||||
add_custom_target(hello_wasm ALL
|
add_custom_target(hello_wasm ALL
|
||||||
COMMAND ${WAT2WASM} ${WAT_FILE} --enable-reference-types -o ${PROJECT_BINARY_DIR}/hello.wasm
|
COMMAND ${WAT2WASM} ${WAT_FILE} ${WAT2WASM_FLAGS} -o ${PROJECT_BINARY_DIR}/hello.wasm
|
||||||
DEPENDS ${WAT_FILE}
|
DEPENDS ${WAT_FILE}
|
||||||
BYPRODUCTS ${PROJECT_BINARY_DIR}/hello.wasm
|
BYPRODUCTS ${PROJECT_BINARY_DIR}/hello.wasm
|
||||||
VERBATIM
|
VERBATIM
|
||||||
|
|
|
@ -104,6 +104,15 @@ find_program(WAT2WASM
|
||||||
|
|
||||||
if(NOT WAT2WASM)
|
if(NOT WAT2WASM)
|
||||||
message(SEND_ERROR "can not find wat2wasm")
|
message(SEND_ERROR "can not find wat2wasm")
|
||||||
|
else ()
|
||||||
|
execute_process(COMMAND ${WAT2WASM} --version
|
||||||
|
OUTPUT_VARIABLE WAT2WASM_VERSION_OUTPUT)
|
||||||
|
string(STRIP ${WAT2WASM_VERSION_OUTPUT} WAT2WASM_VERSION)
|
||||||
|
message("-- Found wat2wasm ${WAT2WASM_VERSION}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (${WAT2WASM_VERSION} VERSION_LESS 1.0.26)
|
||||||
|
set(WAT2WASM_FLAGS "--enable-reference-types")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if(${WAMR_BUILD_AOT} EQUAL 1)
|
if(${WAMR_BUILD_AOT} EQUAL 1)
|
||||||
|
@ -161,7 +170,7 @@ foreach(EX ${EXAMPLES})
|
||||||
set(WAT ${CMAKE_CURRENT_LIST_DIR}/src/${EX}.wat)
|
set(WAT ${CMAKE_CURRENT_LIST_DIR}/src/${EX}.wat)
|
||||||
|
|
||||||
add_custom_target(${EX}_WASM
|
add_custom_target(${EX}_WASM
|
||||||
COMMAND ${WAT2WASM} ${WAT} --enable-reference-types -o ${PROJECT_BINARY_DIR}/${EX}.wasm
|
COMMAND ${WAT2WASM} ${WAT} ${WAT2WASM_FLAGS} -o ${PROJECT_BINARY_DIR}/${EX}.wasm
|
||||||
DEPENDS ${WAT}
|
DEPENDS ${WAT}
|
||||||
BYPRODUCTS ${PROJECT_BINARY_DIR}/${EX}.wasm
|
BYPRODUCTS ${PROJECT_BINARY_DIR}/${EX}.wasm
|
||||||
VERBATIM
|
VERBATIM
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
(module
|
(module
|
||||||
(func (export "func") (param i32 f64 f32) (result i32) (unreachable))
|
(func (export "func") (param i32 f64 f32) (result i32) (unreachable))
|
||||||
(global (export "global") f64 (f64.const 0))
|
(global (export "global") f64 (f64.const 0))
|
||||||
(table (export "table") 0 50 anyfunc)
|
(table (export "table") 0 50 funcref)
|
||||||
(memory (export "memory") 1)
|
(memory (export "memory") 1)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user