mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-05-08 12:46:14 +00:00
Fix the build issues on mac for some samples (#358)
Fix the build issues on mac for basic/multi-module/multi-thread/ simple/spawn-thread/wasm-c-api under samples. And all these samples could be run as expected. Signed-off-by: Xiaokang Qin <xiaokang.qxk@antgroup.com>
This commit is contained in:
parent
0103f6429c
commit
049760b849
|
@ -2137,7 +2137,11 @@ static void convert_timestamp(
|
||||||
struct timespec *out
|
struct timespec *out
|
||||||
) {
|
) {
|
||||||
// Store sub-second remainder.
|
// Store sub-second remainder.
|
||||||
|
#ifndef __APPLE__
|
||||||
out->tv_nsec = (__syscall_slong_t)(in % 1000000000);
|
out->tv_nsec = (__syscall_slong_t)(in % 1000000000);
|
||||||
|
#else
|
||||||
|
out->tv_nsec = (long)(in % 1000000000);
|
||||||
|
#endif
|
||||||
in /= 1000000000;
|
in /= 1000000000;
|
||||||
|
|
||||||
// Clamp to the maximum in case it would overflow our system's time_t.
|
// Clamp to the maximum in case it would overflow our system's time_t.
|
||||||
|
|
|
@ -6,7 +6,10 @@ cmake_minimum_required (VERSION 2.8)
|
||||||
project (basic)
|
project (basic)
|
||||||
|
|
||||||
################ runtime settings ################
|
################ runtime settings ################
|
||||||
set (WAMR_BUILD_PLATFORM "linux")
|
string (TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM)
|
||||||
|
if (APPLE)
|
||||||
|
add_definitions(-DBH_PLATFORM_DARWIN)
|
||||||
|
endif ()
|
||||||
|
|
||||||
# Reset default linker flags
|
# Reset default linker flags
|
||||||
set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
|
set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
|
||||||
|
@ -23,9 +26,16 @@ set (WAMR_BUILD_LIBC_WASI 1)
|
||||||
set (WAMR_BUILD_FAST_INTERP 0)
|
set (WAMR_BUILD_FAST_INTERP 0)
|
||||||
|
|
||||||
# linker flags
|
# linker flags
|
||||||
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections -pie -fPIE")
|
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie -fPIE")
|
||||||
|
if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
|
||||||
|
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
|
||||||
|
endif ()
|
||||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security")
|
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security")
|
||||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mindirect-branch-register")
|
if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
|
||||||
|
if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
|
||||||
|
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mindirect-branch-register")
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
|
||||||
# build out vmlib
|
# build out vmlib
|
||||||
set (WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
|
set (WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
|
||||||
|
@ -39,4 +49,8 @@ include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake)
|
||||||
|
|
||||||
add_executable (basic src/main.c src/native_impl.c ${UNCOMMON_SHARED_SOURCE})
|
add_executable (basic src/main.c src/native_impl.c ${UNCOMMON_SHARED_SOURCE})
|
||||||
|
|
||||||
target_link_libraries (basic vmlib -lm -ldl -lpthread -lrt)
|
if (APPLE)
|
||||||
|
target_link_libraries (basic vmlib -lm -ldl -lpthread)
|
||||||
|
else ()
|
||||||
|
target_link_libraries (basic vmlib -lm -ldl -lpthread -lrt)
|
||||||
|
endif ()
|
||||||
|
|
|
@ -5,7 +5,10 @@ cmake_minimum_required(VERSION 2.8)
|
||||||
project(multi_module)
|
project(multi_module)
|
||||||
|
|
||||||
################ runtime settings ################
|
################ runtime settings ################
|
||||||
set(WAMR_BUILD_PLATFORM "linux")
|
string (TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM)
|
||||||
|
if (APPLE)
|
||||||
|
add_definitions(-DBH_PLATFORM_DARWIN)
|
||||||
|
endif ()
|
||||||
|
|
||||||
# Resetdefault linker flags
|
# Resetdefault linker flags
|
||||||
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
|
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
|
||||||
|
@ -22,8 +25,16 @@ set(WAMR_BUILD_FAST_INTERP 0)
|
||||||
set(WAMR_BUILD_MULTI_MODULE 1)
|
set(WAMR_BUILD_MULTI_MODULE 1)
|
||||||
|
|
||||||
# compiling and linking flags
|
# compiling and linking flags
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections -pie -fPIE")
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie -fPIE")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security -mindirect-branch-register")
|
if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
|
||||||
|
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
|
||||||
|
endif ()
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security")
|
||||||
|
if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
|
||||||
|
if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
|
||||||
|
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mindirect-branch-register")
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
|
||||||
# build out vmlib
|
# build out vmlib
|
||||||
set(WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
|
set(WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
|
||||||
|
|
|
@ -5,7 +5,10 @@ cmake_minimum_required(VERSION 2.8)
|
||||||
project(pthread)
|
project(pthread)
|
||||||
|
|
||||||
################ runtime settings ################
|
################ runtime settings ################
|
||||||
set(WAMR_BUILD_PLATFORM "linux")
|
string (TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM)
|
||||||
|
if (APPLE)
|
||||||
|
add_definitions(-DBH_PLATFORM_DARWIN)
|
||||||
|
endif ()
|
||||||
|
|
||||||
# Resetdefault linker flags
|
# Resetdefault linker flags
|
||||||
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
|
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
|
||||||
|
@ -21,7 +24,10 @@ set(WAMR_BUILD_FAST_INTERP 1)
|
||||||
set(WAMR_BUILD_LIB_PTHREAD 1)
|
set(WAMR_BUILD_LIB_PTHREAD 1)
|
||||||
|
|
||||||
# compiling and linking flags
|
# compiling and linking flags
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections -pie -fPIE")
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie -fPIE")
|
||||||
|
if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
|
||||||
|
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
|
||||||
|
endif ()
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security")
|
||||||
|
|
||||||
# build out vmlib
|
# build out vmlib
|
||||||
|
|
|
@ -6,7 +6,11 @@ project(wasm-apps)
|
||||||
|
|
||||||
set(WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
|
set(WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
|
||||||
|
|
||||||
set(CMAKE_SYSTEM_NAME Linux)
|
if (APPLE)
|
||||||
|
set (HAVE_FLAG_SEARCH_PATHS_FIRST 0)
|
||||||
|
set (CMAKE_C_LINK_FLAGS "")
|
||||||
|
set (CMAKE_CXX_LINK_FLAGS "")
|
||||||
|
endif ()
|
||||||
set(CMAKE_SYSTEM_PROCESSOR wasm32)
|
set(CMAKE_SYSTEM_PROCESSOR wasm32)
|
||||||
set (CMAKE_SYSROOT ${WAMR_ROOT_DIR}/wamr-sdk/app/libc-builtin-sysroot)
|
set (CMAKE_SYSROOT ${WAMR_ROOT_DIR}/wamr-sdk/app/libc-builtin-sysroot)
|
||||||
|
|
||||||
|
@ -31,4 +35,4 @@ set (CMAKE_EXE_LINKER_FLAGS
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(test.wasm main.c)
|
add_executable(test.wasm main.c)
|
||||||
target_link_libraries(test.wasm)
|
target_link_libraries(test.wasm)
|
||||||
|
|
|
@ -5,7 +5,10 @@ cmake_minimum_required(VERSION 2.8)
|
||||||
project(spawn_thread)
|
project(spawn_thread)
|
||||||
|
|
||||||
################ runtime settings ################
|
################ runtime settings ################
|
||||||
set(WAMR_BUILD_PLATFORM "linux")
|
string (TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM)
|
||||||
|
if (APPLE)
|
||||||
|
add_definitions(-DBH_PLATFORM_DARWIN)
|
||||||
|
endif ()
|
||||||
|
|
||||||
# Resetdefault linker flags
|
# Resetdefault linker flags
|
||||||
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
|
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
|
||||||
|
@ -21,7 +24,10 @@ set(WAMR_BUILD_FAST_INTERP 1)
|
||||||
set(WAMR_BUILD_LIB_PTHREAD 1)
|
set(WAMR_BUILD_LIB_PTHREAD 1)
|
||||||
|
|
||||||
# compiling and linking flags
|
# compiling and linking flags
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections -pie -fPIE")
|
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie -fPIE")
|
||||||
|
if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
|
||||||
|
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
|
||||||
|
endif ()
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security")
|
||||||
|
|
||||||
# build out vmlib
|
# build out vmlib
|
||||||
|
@ -43,4 +49,4 @@ set (RUNTIME_SOURCE_ALL
|
||||||
${UNCOMMON_SHARED_SOURCE}
|
${UNCOMMON_SHARED_SOURCE}
|
||||||
)
|
)
|
||||||
add_executable (spawn_thread ${RUNTIME_SOURCE_ALL})
|
add_executable (spawn_thread ${RUNTIME_SOURCE_ALL})
|
||||||
target_link_libraries(spawn_thread vmlib -lpthread -lm)
|
target_link_libraries(spawn_thread vmlib -lpthread -lm)
|
||||||
|
|
|
@ -6,7 +6,11 @@ project(wasm-apps)
|
||||||
|
|
||||||
set(WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
|
set(WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
|
||||||
|
|
||||||
set(CMAKE_SYSTEM_NAME Linux)
|
if (APPLE)
|
||||||
|
set (HAVE_FLAG_SEARCH_PATHS_FIRST 0)
|
||||||
|
set (CMAKE_C_LINK_FLAGS "")
|
||||||
|
set (CMAKE_CXX_LINK_FLAGS "")
|
||||||
|
endif ()
|
||||||
set(CMAKE_SYSTEM_PROCESSOR wasm32)
|
set(CMAKE_SYSTEM_PROCESSOR wasm32)
|
||||||
set (CMAKE_SYSROOT ${WAMR_ROOT_DIR}/wamr-sdk/app/libc-builtin-sysroot)
|
set (CMAKE_SYSROOT ${WAMR_ROOT_DIR}/wamr-sdk/app/libc-builtin-sysroot)
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,10 @@ if(NOT CMAKE_BUILD_TYPE)
|
||||||
set(CMAKE_BUILD_TYPE Release)
|
set(CMAKE_BUILD_TYPE Release)
|
||||||
endif()
|
endif()
|
||||||
################ runtime settings ################
|
################ runtime settings ################
|
||||||
set(WAMR_BUILD_PLATFORM "linux")
|
string (TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM)
|
||||||
|
if (APPLE)
|
||||||
|
add_definitions(-DBH_PLATFORM_DARWIN)
|
||||||
|
endif ()
|
||||||
|
|
||||||
# Resetdefault linker flags
|
# Resetdefault linker flags
|
||||||
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
|
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
|
||||||
|
@ -37,8 +40,16 @@ if(NOT DEFINED WAMR_BUILD_FAST_INTERP)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# compiling and linking flags
|
# compiling and linking flags
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections -pie -fPIE")
|
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie -fPIE")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security -mindirect-branch-register")
|
if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
|
||||||
|
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
|
||||||
|
endif ()
|
||||||
|
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security")
|
||||||
|
if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
|
||||||
|
if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
|
||||||
|
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mindirect-branch-register")
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
|
||||||
# build out vmlib
|
# build out vmlib
|
||||||
set(WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
|
set(WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user