From b6411ddc7b6bdab1db908766ce3490e9dd9298f3 Mon Sep 17 00:00:00 2001 From: vms Date: Fri, 17 Apr 2020 22:43:37 +0300 Subject: [PATCH] update sdk: - move to wasi-sdk 10 - use new log function --- Dockerfile | 7 +++---- Makefile | 6 +++--- sdk/logger.c | 15 --------------- sdk/logger.h | 11 +++++++---- 4 files changed, 13 insertions(+), 26 deletions(-) delete mode 100644 sdk/logger.c diff --git a/Dockerfile b/Dockerfile index a5678d6..f77add1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,12 @@ -FROM ubuntu:19.04 +FROM ubuntu:18.04 RUN apt-get update \ && apt-get install -y ca-certificates \ curl \ git \ - make \ - libtinfo5 + make -RUN curl -L https://github.com/CraneStation/wasi-sdk/releases/download/wasi-sdk-6/wasi-sdk-6.0-linux.tar.gz | tar xz --strip-components=1 -C / +RUN curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-10/wasi-sdk-10.0-linux.tar.gz | tar xz --strip-components=1 -C / VOLUME /code WORKDIR /code diff --git a/Makefile b/Makefile index d788873..744ad93 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,11 @@ TARGET = hello_world -CC = /opt/wasi-sdk/bin/clang -SYSROOT = /opt/wasi-sdk/share/wasi-sysroot +CC = /bin/clang +SYSROOT = /share/wasi-sysroot TARGET_TRIPLE = wasm32-unknown-wasi CFLAGS = -nostartfiles -fvisibility=hidden LDFLAGS = -Wl,--no-entry,--demangle,--allow-undefined EXPORT_FUNCS = --export=allocate,--export=deallocate,--export=invoke -SDK = sdk/allocator.c sdk/logger.c sdk/syscalls_stubs.c +SDK = sdk/allocator.c sdk/syscalls_stubs.c SRC = src/main.c .PHONY: default all clean diff --git a/sdk/logger.c b/sdk/logger.c deleted file mode 100644 index 7a6f881..0000000 --- a/sdk/logger.c +++ /dev/null @@ -1,15 +0,0 @@ -#include "logger.h" - -#define __LOGGER_IMPORT(name) \ - __attribute__((__import_module__("logger"), __import_name__(#name))) - -void __write(char ch) __LOGGER_IMPORT(write); -void __flush() __LOGGER_IMPORT(flush); - -void wasm_log(const char *str, int len) { - for(int byteId = 0; byteId < len; ++byteId) { - __write(str[byteId]); - } - - __flush(); -} diff --git a/sdk/logger.h b/sdk/logger.h index d53d6b5..78eaed2 100644 --- a/sdk/logger.h +++ b/sdk/logger.h @@ -1,12 +1,15 @@ #ifndef FLUENCE_C_SDK_LOGGER_H #define FLUENCE_C_SDK_LOGGER_H +#define __LOGGER_IMPORT(name) \ + __attribute__((__import_module__("logger"), __import_name__(#name))) + /** - * Writes provided string to Wasm VM logger. + * Writes provided utf8 string to Wasm VM logger. * - * @param str a pointer to a message that should be logged. - * @param len a size of a message that should be logged. + * @param str a pointer to the string that should be logged. + * @param len a size of the string that should be logged. */ -void wasm_log(const char *str, int len); +void log_utf8_string(const char *str, int len) __LOGGER_IMPORT(log_utf8_string); #endif //FLUENCE_C_SDK_LOGGER_H