Skip to content

Commit

Permalink
Fix ProjectWAVM
Browse files Browse the repository at this point in the history
  • Loading branch information
chfast committed Jul 31, 2018
1 parent 6cb6bef commit 436522d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
26 changes: 19 additions & 7 deletions cmake/ProjectWAVM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,24 @@ endif()
set(ProjectWAVMIncluded TRUE)

include(ExternalProject)
include(GNUInstallDirs)


find_package(LLVM 6.0 REQUIRED CONFIG)
message(STATUS "LLVM: ${LLVM_DIR}")
llvm_map_components_to_libnames(llvm_libs support core passes mcjit native DebugInfoDWARF)

set(prefix ${CMAKE_BINARY_DIR}/deps)
set(source_dir ${prefix}/src/wavm)
set(binary_dir ${prefix}/src/wavm-build)
set(include_dir ${source_dir}/Include)

set(runtime_library ${binary_dir}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}Runtime${CMAKE_STATIC_LIBRARY_SUFFIX})
set(platform_library ${binary_dir}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}Platform${CMAKE_STATIC_LIBRARY_SUFFIX})
set(wasm_library ${binary_dir}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}WASM${CMAKE_STATIC_LIBRARY_SUFFIX})
set(ir_library ${binary_dir}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}IR${CMAKE_STATIC_LIBRARY_SUFFIX})
set(logging_library ${binary_dir}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}Logging${CMAKE_STATIC_LIBRARY_SUFFIX})
set(unwind_library ${binary_dir}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}WAVMUnwind${CMAKE_STATIC_LIBRARY_SUFFIX})

set(patch_command "sed -E 's/ SHARED / /' CMakeLists.txt")
set(other_libraries ${platform_library} ${wasm_library} ${ir_library} ${logging_library} ${unwind_library})

ExternalProject_Add(wavm
PREFIX ${prefix}
Expand All @@ -27,22 +33,28 @@ ExternalProject_Add(wavm
URL_HASH SHA256=da184e2c077e257dea82c13b2e5ae1fc03d1dc306a1c9a6f84838cff7390b75a
PATCH_COMMAND sh ${CMAKE_CURRENT_LIST_DIR}/patch_wavm.sh
CMAKE_ARGS
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DCMAKE_BUILD_TYPE=Release
-DLLVM_DIR=${LLVM_DIR}
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DCMAKE_CXX_FLAGS=-Wno-error
INSTALL_COMMAND ""
BUILD_BYPRODUCTS ${runtime_library}
BUILD_BYPRODUCTS ${runtime_library} ${other_libraries}
)

file(MAKE_DIRECTORY ${include_dir}) # Must exist.


add_library(wavm::runtime STATIC IMPORTED)
add_library(wavm::wavm STATIC IMPORTED)
set_target_properties(
wavm::runtime
wavm::wavm
PROPERTIES
IMPORTED_CONFIGURATIONS Release
IMPORTED_LOCATION_RELEASE ${runtime_library}
INTERFACE_INCLUDE_DIRECTORIES ${include_dir}
INTERFACE_LINK_LIBRARIES "${other_libraries};${llvm_libs}"
)

add_dependencies(wavm::runtime wavm)
add_dependencies(wavm::wavm wavm)
3 changes: 2 additions & 1 deletion cmake/patch_wavm.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/sh

sed -iE 's/ SHARED / /' CMakeLists.txt
sed -i 's/SHARED//' CMakeLists.txt
sed -i 's/-Werror//' CMakeLists.txt
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ endif()

if(HERA_WAVM)
target_compile_definitions(hera PRIVATE HERA_WAVM=1)
target_link_libraries(hera PRIVATE wavm::runtime)
target_link_libraries(hera PRIVATE wavm::wavm)
endif()

0 comments on commit 436522d

Please # to comment.