mirror of
https://github.com/fluencelabs/c-template
synced 2025-04-24 14:22:12 +00:00
update sdk:
- move to wasi-sdk 10 - use new log function
This commit is contained in:
parent
4a35c5ed83
commit
b6411ddc7b
@ -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
|
||||
|
6
Makefile
6
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
|
||||
|
15
sdk/logger.c
15
sdk/logger.c
@ -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();
|
||||
}
|
11
sdk/logger.h
11
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user