From 349855253f4d2569787c436f4bffe08865abe990 Mon Sep 17 00:00:00 2001 From: Volodymyr Shymanskyy Date: Wed, 8 Jan 2020 22:48:38 +0200 Subject: [PATCH] Fix WasiEnv build --- CMakeLists.txt | 19 +++++++++++++++---- README.md | 4 ++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d95ae8a..7cba8bc 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,8 +39,6 @@ endif() if(WASIENV) set(CMAKE_C_COMPILER "wasicc") set(CMAKE_CXX_COMPILER "wasic++") - - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto -Wl,--lto-O3 -Wl,-z,stack-size=8388608") endif() if(BUILD_32BIT) @@ -77,7 +75,6 @@ include_directories("./source/") #-fno-optimize-sibling-calls -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Dd_m3HasWASI") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG=1") if(EMSCRIPTEN) @@ -86,7 +83,19 @@ if(EMSCRIPTEN) if(WASM_TCO) set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Xclang -target-feature -Xclang +tail-call") endif() +elseif(WASIENV) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Dd_m3HasMetaWASI") + + set(CMAKE_C_FLAGS_RELEASE "-O3 -Wfatal-errors -fomit-frame-pointer -fno-stack-check -fno-stack-protector") + + # TODO: LTO breaks wasm imports currently: + # https://www.mail-archive.com/llvm-bugs@lists.llvm.org/msg36273.html + + #-flto -Wl,--lto-O3 + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,stack-size=8388608") elseif(WIN32) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Dd_m3HasWASI") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS /WX- /diagnostics:column") string(REGEX REPLACE "/W[0-4]" "/W0" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") @@ -105,6 +114,8 @@ elseif(WIN32) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:8388608") # stack size else() + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Dd_m3HasWASI") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wparentheses -Wundef -Wpointer-arith -Wstrict-aliasing=2") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=shadow -Werror=implicit-function-declaration") # -Werror=cast-align set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function -Wno-unused-variable -Wno-unused-parameter -Wno-missing-field-initializers") @@ -123,7 +134,7 @@ else() endif() check_ipo_supported(RESULT result) -if(result) +if(result AND NOT WASIENV) # TODO: LTO breaks wasm imports set_property(TARGET ${OUT_FILE} PROPERTY INTERPROCEDURAL_OPTIMIZATION True) message("LTO: ON") else() diff --git a/README.md b/README.md index 34deddf..5be27b7 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ # Wasm3 -[![WAPM](https://img.shields.io/badge/wapm-v0.4.0-654ff0.svg)](https://wapm.io/package/vshymanskyy/wasm3) +[![WAPM](https://img.shields.io/badge/wapm-v0.4.2-654ff0.svg)](https://wapm.io/package/vshymanskyy/wasm3) [![GitHub issues](https://img.shields.io/github/issues-raw/wasm3/wasm3.svg?label=issues&color=success)](https://github.com/wasm3/wasm3/issues) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/wasm3/wasm3) [![Tests status](https://img.shields.io/github/workflow/status/wasm3/wasm3/tests.svg?label=tests)](https://github.com/wasm3/wasm3/actions) @@ -38,7 +38,7 @@ Minimum useful system requirements: **~64Kb** for code and **~10Kb** RAM Arduino MKR*, Arduino Due, Particle Photon, ESP8266, ESP32, Air602 (W600), nRF52, nRF51, Blue Pill (STM32F103C8T6), MXChip AZ3166 (EMW3166), - Maix (K210), HiFive1 (E310), Fomu (ICE40UP5K), etc. + Maix (K210), HiFive1 (E310), Fomu (ICE40UP5K), ATmega1284 etc. - **OpenWRT**-enabled routers - Browsers... yes, using WebAssembly itself! - `wasm3` can execute `wasm3` (self-hosting)