From af4a96e2a07f48b1385ad001adb838c8594bbfe8 Mon Sep 17 00:00:00 2001 From: renjipanicker Date: Mon, 24 Feb 2020 14:46:18 +0530 Subject: [PATCH] Fixed darwin build (#178) * RSIZE_MAX is already defined by system on darwin * MADV_HUGEPAGE is not available on darwin * Fixed linker error 'Undefined symbol _get_ext_lib_export_apis' on darwin when building iwasm dylib --- core/shared/platform/darwin/bh_definition.c | 4 ++++ core/shared/platform/darwin/bh_platform.c | 2 ++ product-mini/platforms/darwin/CMakeLists.txt | 1 + 3 files changed, 7 insertions(+) diff --git a/core/shared/platform/darwin/bh_definition.c b/core/shared/platform/darwin/bh_definition.c index 8fb58d2f8..f093cc9c5 100644 --- a/core/shared/platform/darwin/bh_definition.c +++ b/core/shared/platform/darwin/bh_definition.c @@ -5,6 +5,10 @@ #include "bh_platform.h" +#ifdef RSIZE_MAX +#undef RSIZE_MAX +#endif + #define RSIZE_MAX 0x7FFFFFFF int b_memcpy_s(void * s1, unsigned int s1max, const void * s2, unsigned int n) diff --git a/core/shared/platform/darwin/bh_platform.c b/core/shared/platform/darwin/bh_platform.c index 4eda405b0..8a660b6d3 100755 --- a/core/shared/platform/darwin/bh_platform.c +++ b/core/shared/platform/darwin/bh_platform.c @@ -137,12 +137,14 @@ bh_mmap(void *hint, uint32 size, int prot, int flags) request_size -= size; } +#ifndef __APPLE__ if (size >= 2 * 1024 * 1024) { /* Try to use huge page to improve performance */ if (!madvise(addr, size, MADV_HUGEPAGE)) /* make huge page become effective */ memset(addr, 0, size); } +#endif return addr_aligned; } diff --git a/product-mini/platforms/darwin/CMakeLists.txt b/product-mini/platforms/darwin/CMakeLists.txt index b2c3ada7a..5a44af8c8 100644 --- a/product-mini/platforms/darwin/CMakeLists.txt +++ b/product-mini/platforms/darwin/CMakeLists.txt @@ -52,6 +52,7 @@ if (NOT DEFINED WAMR_BUILD_LIBC_WASI) set (WAMR_BUILD_LIBC_WASI 0) endif () +set (CMAKE_SHARED_LINKER_FLAGS "-Wl,-U,_get_ext_lib_export_apis") set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") set (CMAKE_MACOSX_RPATH True)