# HG changeset patch # User Vesa Norilo # Date 1642957353 -7200 # Sun Jan 23 19:02:33 2022 +0200 # Branch dev # Node ID f17f8b390dd249cde07e67604ca2170caf94dc42 # Parent d0255fe2496c3f9d28446d1679c9016e3fca540c Binaryen backend: function import fix diff --git a/.build.yml b/.build.yml deleted file mode 100644 --- a/.build.yml +++ /dev/null @@ -1,23 +0,0 @@ -image: ubuntu/20.04 -packages: -- cmake -sources: -- hg+https://hg.sr.ht/~vnorilo/kronos -tasks: -- configure: | - set -ex - git clone --depth 1 https://github.com/emscripten-core/emsdk.git - emsdk/emsdk install latest - emsdk/emsdk activate latest - chmod 777 emsdk/emsdk_env.sh - . ./emsdk/emsdk_env.sh - mkdir build - cd build - emcmake cmake ../kronos -DCMAKE_BUILD_TYPE=Release -- build: | - cd build - make -j -triggers: -- action: email - condition: failure - to: \ No newline at end of file diff --git a/.builds/ubuntu.build b/.builds/ubuntu.build new file mode 100644 --- /dev/null +++ b/.builds/ubuntu.build @@ -0,0 +1,19 @@ +image: ubuntu/20.04 +packages: +- cmake g++ python3 libsndfile-dev libtinyxml-dev libreadline6-dev llvm-6.0-dev +sources: +- hg+https://hg.sr.ht/~vnorilo/kronos +tasks: +- configure: | + mkdir build + cd build + emcmake cmake ../kronos -DCMAKE_BUILD_TYPE=Release +- build: | + cd build + make -j kronos veneer +- test: | + make test +triggers: +- action: email + condition: failure + to: \ No newline at end of file diff --git a/.builds/wasm.build b/.builds/wasm.build new file mode 100644 --- /dev/null +++ b/.builds/wasm.build @@ -0,0 +1,23 @@ +image: ubuntu/20.04 +packages: +- cmake +sources: +- hg+https://hg.sr.ht/~vnorilo/kronos +tasks: +- configure: | + set -ex + git clone --depth 1 https://github.com/emscripten-core/emsdk.git + emsdk/emsdk install latest + emsdk/emsdk activate latest + chmod 777 emsdk/emsdk_env.sh + . ./emsdk/emsdk_env.sh + mkdir build + cd build + emcmake cmake ../kronos -DCMAKE_BUILD_TYPE=Release +- build: | + cd build + make -j kronos veneer +triggers: +- action: email + condition: failure + to: \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -263,7 +263,7 @@ set(BUILD_WITH_MESSAGE_PRINT OFF) set(BUILD_WITH_O2LITE_DISCOVERY OFF) set(BUILD_WITH_O2LITE_CLOCKSYNC OFF) - add_definitions("-DO2_EXPORT=extern" -DO2L_NO_BROADCAST -DO2_NO_O2DISCOVERY) + add_definitions("-DO2_EXPORT=extern" -DO2L_NO_BROADCAST -DO2_NO_ZEROCONF) add_subdirectory(${O2_DIR} o2) set_target_properties(o2_static o2lite_static PROPERTIES FOLDER libs) diff --git a/cmake/Binaryen.cmake b/cmake/Binaryen.cmake --- a/cmake/Binaryen.cmake +++ b/cmake/Binaryen.cmake @@ -23,7 +23,11 @@ GIT_REPOSITORY https://github.com/WebAssembly/binaryen.git GIT_TAG ${BINARYEN_VERSION} CMAKE_COMMAND "${CMAKE_CMD}" - CMAKE_ARGS ${CMAKE_ARGS} -DCMAKE_CXX_STANDARD=17 + CMAKE_ARGS + ${CMAKE_ARGS} + "-DCMAKE_CXX_STANDARD=17" + "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" + "-DCMAKE_CONFIGURATION_TYPES=${CMAKE_CONFIGURATION_TYPES}" BUILD_COMMAND cmake --build . --target binaryen --config $ INSTALL_COMMAND "") diff --git a/src/backends/BinaryenEmitter.cpp b/src/backends/BinaryenEmitter.cpp --- a/src/backends/BinaryenEmitter.cpp +++ b/src/backends/BinaryenEmitter.cpp @@ -551,7 +551,8 @@ auto Mod = (wasm::Module*)M; if (Mod->getFunctionOrNull(sym.c_str()) == nullptr) { - BinaryenAddFunctionImport(M, sym.c_str(), "import", sym.c_str(), fn.d->GetParamType(), fn.d->ty.returnType); + auto paramTypes = BinaryenTypeCreate(paramTys.data(), paramTys.size()); + BinaryenAddFunctionImport(M, sym.c_str(), "import", sym.c_str(), paramTypes, returnTy); } auto fncall = BinaryenCall(M, sym.c_str(), (BinaryenExpressionRef*)pass.data(), (int)pass.size(), returnTy); diff --git a/src/backends/BinaryenModule.cpp b/src/backends/BinaryenModule.cpp --- a/src/backends/BinaryenModule.cpp +++ b/src/backends/BinaryenModule.cpp @@ -245,16 +245,27 @@ BinaryenModuleAutoDrop(M); #ifndef NDEBUG - BinaryenModuleValidate(M); + if (!BinaryenModuleValidate(M)) { + std::cerr << "Invalid code emitted!"; + } + BinaryenModulePrint(M); #endif #ifdef EMSCRIPTEN std::clog << "Optimizing code...\n"; #endif if (CL::OptLevel() > 0) { BinaryenSetOptimizeLevel(CL::OptLevel()); + BinaryenSetFastMath(true); + BinaryenSetAllowInliningFunctionsWithLoops(true); BinaryenModuleOptimize(M); } +#ifndef NDEBUG + if (!BinaryenModuleValidate(M)) { + std::cerr << "Invalid code after optimizer!"; + } +#endif + #ifdef EMSCRIPTEN std::clog << "Emitting...\n"; #endif