diff --git a/CMakeLists.txt b/CMakeLists.txt index 345daebf7cf..defaf4999f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -330,16 +330,56 @@ else() message(STATUS "Building libbinaryen as shared library.") add_library(binaryen SHARED ${binaryen_SOURCES} ${binaryen_objs}) endif() +target_include_directories(binaryen INTERFACE + $ + ) if(NOT (BUILD_STATIC_LIB AND BYN_INSTALL_TOOLS_ONLY)) install(TARGETS binaryen + EXPORT binaryenConfig RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install( + EXPORT binaryenConfig + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/binaryen + NAMESPACE binaryen:: + ) endif() if(NOT BYN_INSTALL_TOOLS_ONLY) - install(FILES src/binaryen-c.h src/wasm-delegations.def DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + install( + FILES src/binaryen-c.h src/wasm-delegations.def src/wasm-delegations-fields.def + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/binaryen) + install(DIRECTORY src/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/binaryen # set scoping for headers + FILES_MATCHING PATTERN "*.h" + ) +endif() + +function(binaryen_add_executable name sources) + add_executable(${name} ${sources}) + target_link_libraries(${name} ${CMAKE_THREAD_LIBS_INIT}) + target_link_libraries(${name} binaryen) + set_property(TARGET ${name} PROPERTY CXX_STANDARD ${CXX_STANDARD}) + set_property(TARGET ${name} PROPERTY CXX_STANDARD_REQUIRED ON) + binaryen_setup_rpath(${name}) + install(TARGETS ${name} DESTINATION ${CMAKE_INSTALL_BINDIR}) +endfunction() + +OPTION(BUILD_TOOLS "Build tools" OFF) +if(BUILD_TOOLS) + binaryen_add_executable(wasm-opt src/tools/wasm-opt.cpp) + binaryen_add_executable(wasm-shell src/tools/wasm-shell.cpp) + binaryen_add_executable(wasm-metadce src/tools/wasm-metadce.cpp) + binaryen_add_executable(wasm2js src/tools/wasm2js.cpp) + binaryen_add_executable(wasm-emscripten-finalize src/tools/wasm-emscripten-finalize.cpp) + binaryen_add_executable(wasm-as src/tools/wasm-as.cpp) + binaryen_add_executable(wasm-dis src/tools/wasm-dis.cpp) + binaryen_add_executable(wasm-ctor-eval src/tools/wasm-ctor-eval.cpp) + binaryen_add_executable(wasm-reduce src/tools/wasm-reduce.cpp) + binaryen_add_executable(wasm-split src/tools/wasm-split.cpp) endif() + # binaryen.js # # Note that we can't emit binaryen.js directly, as there is libbinaryen already diff --git a/src/wasm-features.h b/src/wasm-features.h index e28dcf4d153..07f9278fddc 100644 --- a/src/wasm-features.h +++ b/src/wasm-features.h @@ -99,7 +99,7 @@ struct FeatureSet { operator uint32_t() const { return features; } bool isMVP() const { return features == MVP; } - bool has(FeatureSet f) { return (features & f) == f; } + bool has(FeatureSet f) { return (features & f) == static_cast(f); } bool hasAtomics() const { return (features & Atomics) != 0; } bool hasMutableGlobals() const { return (features & MutableGlobals) != 0; } bool hasTruncSat() const { return (features & TruncSat) != 0; } diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h index 9fc11de765c..7f4d1c12b18 100644 --- a/src/wasm-interpreter.h +++ b/src/wasm-interpreter.h @@ -2559,9 +2559,9 @@ template class ModuleInstanceBase { // Returns the instance that defines the memory used by this one. SubType* getMemoryInstance() { auto* inst = instance.self(); - while (inst->wasm.memory.imported()) { - inst = inst->linkedInstances.at(inst->wasm.memory.module).get(); - } + // while (inst->wasm.memory.imported()) { + // inst = inst->linkedInstances.at(inst->wasm.memory.module).get(); + // } return inst; }