From 077bf2390118d46250a960ecc87f0dcfbf70ed1b Mon Sep 17 00:00:00 2001 From: Takeshi Yoneda Date: Wed, 12 May 2021 14:11:57 +0900 Subject: [PATCH] Add WAVM and update cache keys. Signed-off-by: Takeshi Yoneda --- .github/workflows/cpp.yml | 6 +++--- BUILD | 7 +++---- bazel/external/llvm.BUILD | 2 -- bazel/external/wamr.BUILD | 1 - bazel/external/wavm.BUILD | 38 ++++++++++++++++++++++++++++++++++++++ bazel/repositories.bzl | 8 ++++++++ 6 files changed, 52 insertions(+), 10 deletions(-) create mode 100644 bazel/external/wavm.BUILD diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index 20227bebb..dbbdfda1b 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -59,8 +59,8 @@ jobs: strategy: matrix: - # TODO(mathetake): Add other runtimes. - runtime: [ "wamr", "wasmtime" ] + # TODO(mathetake): Add V8. + runtime: [ "wamr", "wasmtime", "wavm" ] steps: - uses: actions/checkout@v2 @@ -69,7 +69,7 @@ jobs: uses: actions/cache@v1 with: path: "/home/runner/.cache/bazel" - key: bazel-${{ matrix.runtime }} + key: bazel-${{ matrix.runtime }}-clang - name: Test run: | diff --git a/BUILD b/BUILD index bdb57d2f1..a9f7fd2cb 100644 --- a/BUILD +++ b/BUILD @@ -78,13 +78,12 @@ cc_library( cc_library( name = "wavm_lib", srcs = glob([ - # TODO(@mathetake): Add WAVM lib. - # "src/wavm/*.h", - # "src/wavm/*.cc", + "src/wavm/*.h", + "src/wavm/*.cc", ]), deps = [ ":common_lib", - # TODO(@mathetake): Add WAVM lib. + "@wavm//:wavm_lib", ], ) diff --git a/bazel/external/llvm.BUILD b/bazel/external/llvm.BUILD index 8f1b80238..acccdbd9e 100644 --- a/bazel/external/llvm.BUILD +++ b/bazel/external/llvm.BUILD @@ -7,7 +7,6 @@ package(default_visibility = ["//visibility:public"]) filegroup( name = "srcs", srcs = glob(["**"]), - visibility = ["//visibility:public"], ) cmake( @@ -46,7 +45,6 @@ cmake( }, lib_source = ":srcs", out_static_libs = [ - # Order from llvm-config --libnames. "libLLVMInterpreter.a", "libLLVMWindowsManifest.a", "libLLVMLibDriver.a", diff --git a/bazel/external/wamr.BUILD b/bazel/external/wamr.BUILD index 076215fd4..2c1b0b997 100644 --- a/bazel/external/wamr.BUILD +++ b/bazel/external/wamr.BUILD @@ -7,7 +7,6 @@ package(default_visibility = ["//visibility:public"]) filegroup( name = "srcs", srcs = glob(["**"]), - visibility = ["//visibility:public"], ) cmake( diff --git a/bazel/external/wavm.BUILD b/bazel/external/wavm.BUILD new file mode 100644 index 000000000..b9edd18df --- /dev/null +++ b/bazel/external/wavm.BUILD @@ -0,0 +1,38 @@ +load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake") + +licenses(["notice"]) # Apache 2 + +package(default_visibility = ["//visibility:public"]) + +filegroup( + name = "srcs", + srcs = glob(["**"]), +) + +cmake( + name = "wavm_lib", + binaries = ["wavm"], + cache_entries = { + "LLVM_DIR": "$EXT_BUILD_DEPS/copy_llvm/llvm/lib/cmake/llvm", + "WAVM_ENABLE_STATIC_LINKING": "on", + "WAVM_ENABLE_RELEASE_ASSERTS": "on", + "WAVM_ENABLE_UNWIND": "on", + # Workaround for the issue with statically linked libstdc++ + # using -l:libstdc++.a. + "CMAKE_CXX_FLAGS": "-lstdc++ -Wno-unused-command-line-argument", + }, + defines = ["WASM_WAVM"], + env_vars = { + # Workaround for the -DDEBUG flag added in fastbuild on macOS, + # which conflicts with DEBUG macro used in LLVM. + "CFLAGS": "-UDEBUG", + "CXXFLAGS": "-UDEBUG", + "ASMFLAGS": "-UDEBUG", + }, + lib_source = ":srcs", + static_libraries = [ + "libWAVM.a", + "libWAVMUnwind.a", + ], + deps = ["@llvm//:llvm_lib"], +) diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index 05188e92f..4694b7a17 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -90,3 +90,11 @@ def proxy_wasm_cpp_host_repositories(): patch_args = ["-p1"], patches = ["@proxy_wasm_cpp_host//bazel/external:llvm.patch"], ) + + http_archive( + name = "wavm", + build_file = "@proxy_wasm_cpp_host//bazel/external:wavm.BUILD", + sha256 = "ce899269516313b400005a8cc9bc3bcd8329663f43f7b4baae211ea0cd456a39", + strip_prefix = "WAVM-79c3aa29366615d9b1593cd527e5b4b94cc6072a", + url = "https://github.com/WAVM/WAVM/archive/79c3aa29366615d9b1593cd527e5b4b94cc6072a.tar.gz", + )