From c4bb89969b046fd2f2d58da225aa0d9aa992698c Mon Sep 17 00:00:00 2001 From: Sergey Bogolepov Date: Mon, 5 Feb 2018 11:19:48 +0300 Subject: [PATCH] Added commentary about wasm mem* functions --- backend.native/konan.properties | 4 ++-- runtime/src/main/cpp/Porting.h | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/backend.native/konan.properties b/backend.native/konan.properties index 4fc51c6a722..3164afed5d4 100644 --- a/backend.native/konan.properties +++ b/backend.native/konan.properties @@ -324,10 +324,10 @@ targetSysRoot.wasm32 = target-sysroot-2-wasm optFlags.wasm32 = -internalize optNooptFlags.wasm32 = -O1 optOptFlags.wasm32 = -O3 -optDebugFlags.wasm32 = +optDebugFlags.wasm32 = -O0 llcFlags.wasm32 = llcNooptFlags.wasm32 = -O1 llcOptFlags.wasm32 = -O3 -llcDebugFlags.wasm32 = +llcDebugFlags.wasm32 = -O0 # The stack size is in bytes. s2wasmFlags.wasm32 = --allocate-stack 1048576 --import-memory diff --git a/runtime/src/main/cpp/Porting.h b/runtime/src/main/cpp/Porting.h index e11e80d924a..dcee456628e 100644 --- a/runtime/src/main/cpp/Porting.h +++ b/runtime/src/main/cpp/Porting.h @@ -46,7 +46,11 @@ int snprintf(char* buffer, size_t size, const char* format, ...); size_t strnlen(const char* buffer, size_t maxSize); - +// These functions should be marked with RUNTIME_USED attribute for wasm target +// because clang replaces these operations with intrinsics that will be +// replaced back to library calls only on codegen step. And there is no stdlib +// for wasm target for now :( +// Otherwise `opt` will see no usages of these definitions and will remove them. extern "C" { #ifdef KONAN_WASM @@ -65,9 +69,6 @@ int memcmp(const void *s1, const void *s2, size_t n); RUNTIME_USED void *memset(void *b, int c, size_t len); -RUNTIME_USED -size_t strlen(const char *s); - #endif }