mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-02-06 15:05:19 +00:00
Fix linux-sgx build error when libc-wasi is disabled (#2997)
Compilation error was reported when `cmake -DWAMR_BUILD_LIBC_WASI=0` on linux-sgx platform: ``` core/shared/platform/linux-sgx/sgx_socket.c:8:10: fatal error: libc_errno.h: No such file or directory 8 | #include "libc_errno.h" | ^~~~~~~~~~~~~~ ``` After fixing, both `cmake -DWAMR_BUILD_LIBC_WASI=1` and `WAMR_BUILD_LIBC_WASI=0` work good.
This commit is contained in:
parent
9121db5671
commit
3198018214
|
@ -119,6 +119,18 @@ strcpy(char *dest, const char *src)
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if WASM_ENABLE_LIBC_WASI == 0
|
||||||
|
bool
|
||||||
|
os_is_handle_valid(os_file_handle *handle)
|
||||||
|
{
|
||||||
|
assert(handle != NULL);
|
||||||
|
|
||||||
|
return *handle > -1;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
/* implemented in posix_file.c */
|
||||||
|
#endif
|
||||||
|
|
||||||
void *
|
void *
|
||||||
os_mmap(void *hint, size_t size, int prot, int flags, os_file_handle file)
|
os_mmap(void *hint, size_t size, int prot, int flags, os_file_handle file)
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,10 +5,11 @@
|
||||||
|
|
||||||
#include "platform_api_vmcore.h"
|
#include "platform_api_vmcore.h"
|
||||||
#include "platform_api_extension.h"
|
#include "platform_api_extension.h"
|
||||||
#include "libc_errno.h"
|
|
||||||
|
|
||||||
#ifndef SGX_DISABLE_WASI
|
#ifndef SGX_DISABLE_WASI
|
||||||
|
|
||||||
|
#include "libc_errno.h"
|
||||||
|
|
||||||
#define TRACE_OCALL_FAIL() os_printf("ocall %s failed!\n", __FUNCTION__)
|
#define TRACE_OCALL_FAIL() os_printf("ocall %s failed!\n", __FUNCTION__)
|
||||||
|
|
||||||
/** OCALLs prototypes **/
|
/** OCALLs prototypes **/
|
||||||
|
|
|
@ -164,3 +164,15 @@ else()
|
||||||
OUTPUT_VARIABLE cmdOutput
|
OUTPUT_VARIABLE cmdOutput
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (WAMR_BUILD_LIBC_WASI EQUAL 1)
|
||||||
|
execute_process(
|
||||||
|
COMMAND bash -c "sed -i -E 's/^WAMR_BUILD_LIBC_WASI = 0/WAMR_BUILD_LIBC_WASI = 1/g' ${CMAKE_CURRENT_SOURCE_DIR}/enclave-sample/Makefile"
|
||||||
|
OUTPUT_VARIABLE cmdOutput
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
execute_process(
|
||||||
|
COMMAND bash -c "sed -i -E 's/^WAMR_BUILD_LIBC_WASI = 1/WAMR_BUILD_LIBC_WASI = 0/g' ${CMAKE_CURRENT_SOURCE_DIR}/enclave-sample/Makefile"
|
||||||
|
OUTPUT_VARIABLE cmdOutput
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
|
@ -510,7 +510,7 @@ handle_cmd_set_log_level(uint64 *args, uint32 argc)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SGX_DISABLE_WASI
|
#if WASM_ENABLE_LIBC_WASI != 0
|
||||||
static void
|
static void
|
||||||
handle_cmd_set_wasi_args(uint64 *args, int32 argc)
|
handle_cmd_set_wasi_args(uint64 *args, int32 argc)
|
||||||
{
|
{
|
||||||
|
@ -637,7 +637,7 @@ handle_cmd_set_wasi_args(uint64 *args, int32 argc)
|
||||||
{
|
{
|
||||||
*args = true;
|
*args = true;
|
||||||
}
|
}
|
||||||
#endif /* end of SGX_DISABLE_WASI */
|
#endif /* end of WASM_ENABLE_LIBC_WASI != 0 */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
handle_cmd_get_version(uint64 *args, uint32 argc)
|
handle_cmd_get_version(uint64 *args, uint32 argc)
|
||||||
|
|
|
@ -16,6 +16,7 @@ WAMR_BUILD_LIB_RATS = 0
|
||||||
WAMR_BUILD_GLOBAL_HEAP_POOL = 0
|
WAMR_BUILD_GLOBAL_HEAP_POOL = 0
|
||||||
WAMR_BUILD_GLOBAL_HEAP_SIZE = 10485760
|
WAMR_BUILD_GLOBAL_HEAP_SIZE = 10485760
|
||||||
WAMR_BUILD_STATIC_PGO = 0
|
WAMR_BUILD_STATIC_PGO = 0
|
||||||
|
WAMR_BUILD_LIBC_WASI = 1
|
||||||
|
|
||||||
VMLIB_BUILD_DIR ?= $(CURDIR)/../build
|
VMLIB_BUILD_DIR ?= $(CURDIR)/../build
|
||||||
LIB_RATS_SRC ?= $(VMLIB_BUILD_DIR)/_deps/librats-build
|
LIB_RATS_SRC ?= $(VMLIB_BUILD_DIR)/_deps/librats-build
|
||||||
|
@ -66,7 +67,9 @@ ifeq ($(WAMR_BUILD_LIB_RATS), 1)
|
||||||
App_Include_Paths += -I$(LIB_RATS_INCLUDE_DIR)
|
App_Include_Paths += -I$(LIB_RATS_INCLUDE_DIR)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
App_C_Flags := $(SGX_COMMON_CFLAGS) -fPIC -Wno-attributes $(App_Include_Paths) -DWASM_ENABLE_STATIC_PGO=$(WAMR_BUILD_STATIC_PGO)
|
App_C_Flags := $(SGX_COMMON_CFLAGS) -fPIC -Wno-attributes $(App_Include_Paths) \
|
||||||
|
-DWASM_ENABLE_STATIC_PGO=$(WAMR_BUILD_STATIC_PGO) \
|
||||||
|
-DWASM_ENABLE_LIBC_WASI=$(WAMR_BUILD_LIBC_WASI)
|
||||||
|
|
||||||
# Three configuration modes - Debug, prerelease, release
|
# Three configuration modes - Debug, prerelease, release
|
||||||
# Debug - Macro DEBUG enabled.
|
# Debug - Macro DEBUG enabled.
|
||||||
|
@ -135,7 +138,13 @@ ifeq ($(WAMR_BUILD_LIB_RATS), 1)
|
||||||
Enclave_Include_Paths += -I$(LIB_RATS_INCLUDE_DIR) -I$(SGX_SSL)/include
|
Enclave_Include_Paths += -I$(LIB_RATS_INCLUDE_DIR) -I$(SGX_SSL)/include
|
||||||
endif
|
endif
|
||||||
|
|
||||||
Enclave_C_Flags := $(SGX_COMMON_CFLAGS) -nostdinc -fvisibility=hidden -fpie -fstack-protector $(Enclave_Include_Paths) -DWASM_GLOBAL_HEAP_SIZE=$(WAMR_BUILD_GLOBAL_HEAP_SIZE) -DWASM_ENABLE_GLOBAL_HEAP_POOL=$(WAMR_BUILD_GLOBAL_HEAP_POOL) -DWASM_ENABLE_LIB_RATS=$(WAMR_BUILD_LIB_RATS) -DWASM_ENABLE_STATIC_PGO=$(WAMR_BUILD_STATIC_PGO)
|
Enclave_C_Flags := $(SGX_COMMON_CFLAGS) -nostdinc -fvisibility=hidden \
|
||||||
|
-fpie -fstack-protector $(Enclave_Include_Paths) \
|
||||||
|
-DWASM_GLOBAL_HEAP_SIZE=$(WAMR_BUILD_GLOBAL_HEAP_SIZE) \
|
||||||
|
-DWASM_ENABLE_GLOBAL_HEAP_POOL=$(WAMR_BUILD_GLOBAL_HEAP_POOL) \
|
||||||
|
-DWASM_ENABLE_LIB_RATS=$(WAMR_BUILD_LIB_RATS) \
|
||||||
|
-DWASM_ENABLE_STATIC_PGO=$(WAMR_BUILD_STATIC_PGO) \
|
||||||
|
-DWASM_ENABLE_LIBC_WASI=$(WAMR_BUILD_LIBC_WASI)
|
||||||
ifeq ($(SPEC_TEST), 1)
|
ifeq ($(SPEC_TEST), 1)
|
||||||
Enclave_C_Flags += -DWASM_ENABLE_SPEC_TEST=1
|
Enclave_C_Flags += -DWASM_ENABLE_SPEC_TEST=1
|
||||||
else
|
else
|
||||||
|
|
|
@ -102,7 +102,7 @@ Enclave_Include_Paths := -IEnclave -I$(WAMR_ROOT)/core/iwasm/include \
|
||||||
Enclave_C_Flags := $(SGX_COMMON_CFLAGS) -nostdinc -fvisibility=hidden -fpie -fstack-protector $(Enclave_Include_Paths)
|
Enclave_C_Flags := $(SGX_COMMON_CFLAGS) -nostdinc -fvisibility=hidden -fpie -fstack-protector $(Enclave_Include_Paths)
|
||||||
|
|
||||||
# disable wasi
|
# disable wasi
|
||||||
Enclave_C_Flags += -DSGX_DISABLE_WASI
|
Enclave_C_Flags += -DWASM_ENABLE_LIBC_WASI=0
|
||||||
|
|
||||||
ifeq ($(SPEC_TEST), 1)
|
ifeq ($(SPEC_TEST), 1)
|
||||||
Enclave_C_Flags += -DWASM_ENABLE_SPEC_TEST=1
|
Enclave_C_Flags += -DWASM_ENABLE_SPEC_TEST=1
|
||||||
|
|
Loading…
Reference in New Issue
Block a user