From 7962c470852cf5f8460bb7cd854f56d4abc1a49b Mon Sep 17 00:00:00 2001 From: qdaoming-intel <54129441+qdaoming-intel@users.noreply.github.com> Date: Tue, 25 Feb 2020 16:00:37 +0800 Subject: [PATCH] =?UTF-8?q?Diasble=20AOT=20in=20SGX=20build=20by=20default?= =?UTF-8?q?,=20as=20it=20requires=20SGX=20SDKv2.8=20or=20la=E2=80=A6=20(#1?= =?UTF-8?q?80)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Diasble AOT in SGX build by default, as it requires SGX SDKv2.8 or later. * Update bh_platform.c Co-authored-by: daomingq Co-authored-by: wenyongh --- core/shared/platform/linux-sgx/bh_platform.c | 12 ++++++++++++ product-mini/platforms/linux-sgx/CMakeLists.txt | 5 +++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/core/shared/platform/linux-sgx/bh_platform.c b/core/shared/platform/linux-sgx/bh_platform.c index ac213227..5b66a13d 100644 --- a/core/shared/platform/linux-sgx/bh_platform.c +++ b/core/shared/platform/linux-sgx/bh_platform.c @@ -7,7 +7,9 @@ #include "bh_platform.h" #include +#if WASM_ENABLE_AOT != 0 #include "sgx_rsrv_mem_mngr.h" +#endif #define FIXED_BUFFER_SIZE (1<<9) static bh_print_function_t print_function = NULL; @@ -72,6 +74,7 @@ int bh_vprintf_sgx(const char * format, va_list arg) void* bh_mmap(void *hint, unsigned int size, int prot, int flags) { +#if WASM_ENABLE_AOT != 0 int mprot = 0; unsigned alignedSize = (size+4095) & (unsigned)~4095; //Page aligned void* ret = NULL; @@ -96,15 +99,21 @@ void* bh_mmap(void *hint, unsigned int size, int prot, int flags) } return ret; +#else + return NULL; +#endif } void bh_munmap(void *addr, uint32 size) { +#if WASM_ENABLE_AOT != 0 sgx_free_rsrv_mem(addr, size); +#endif } int bh_mprotect(void *addr, uint32 size, int prot) { +#if WASM_ENABLE_AOT != 0 int mprot = 0; sgx_status_t st = 0; @@ -118,4 +127,7 @@ int bh_mprotect(void *addr, uint32 size, int prot) if (st != SGX_SUCCESS) bh_printf_sgx("bh_mprotect(addr=0x%lx,size=%d,prot=0x%x) failed.", addr, size, prot); return (st == SGX_SUCCESS? 0:-1); +#else + return -1; +#endif } diff --git a/product-mini/platforms/linux-sgx/CMakeLists.txt b/product-mini/platforms/linux-sgx/CMakeLists.txt index 276d0afc..9e92dff4 100644 --- a/product-mini/platforms/linux-sgx/CMakeLists.txt +++ b/product-mini/platforms/linux-sgx/CMakeLists.txt @@ -32,8 +32,9 @@ if (NOT DEFINED WAMR_BUILD_INTERP) endif () if (NOT DEFINED WAMR_BUILD_AOT) - # Enable AOT by default. - set (WAMR_BUILD_AOT 1) + # Disable AOT by default. + # If enabling AOT, please install Intel SGX SDKv2.8 or later. + set (WAMR_BUILD_AOT 0) endif () if (NOT DEFINED WAMR_BUILD_JIT)