Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to Emscripten's native Bazel rules. #132

Merged
merged 14 commits into from
Mar 15, 2022

Conversation

PiotrSikora
Copy link
Member

Signed-off-by: Piotr Sikora [email protected]

@PiotrSikora
Copy link
Member Author

Envoy PR: envoyproxy/envoy#19579.

@PiotrSikora
Copy link
Member Author

@lambdai @kyessenov @douglas-reid FYI, as this is going to break the auto-update in Istio Proxy.

Most notably, the path to generated .wasm files changes (see Envoy PR: envoyproxy/envoy#19579).

@PiotrSikora
Copy link
Member Author

Hold for some fixes.

@PiotrSikora
Copy link
Member Author

Splitting this into 2 parts: update to Emscripten v3.1.1 (#133) and migration to @emsdk toolchain (this PR), since the toolchain needs more work upstream to make it work for us.

@PiotrSikora PiotrSikora changed the title Update Emscripten to v3.1.1 with Bazel rules. Migrate to Emscripten's native Bazel rules. Jan 19, 2022
@PiotrSikora
Copy link
Member Author

This is on hold until emscripten-core/emsdk#971 and emscripten-core/emsdk#972 are fixed.

@PiotrSikora
Copy link
Member Author

Note: This breaks Proxy-Wasm plugins that use abseil-cpp. The old toolchain's transition used --cpu=wasm32 (supported by abseil-cpp), but @emsdk toolchain's transition uses --cpu=wasm (not supported by abseil-cpp), and results in -pthread being added to linkopts, which emcc converts into WebAssemby threads proposal, which isn't enabled.

I've added support for --cpu=wasm in abseil/abseil-cpp#1129, which fixes build of Proxy-Wasm plugins in Istio Proxy, but it requires either updating abseil-cpp past abseil/abseil-cpp#1129 or cherry-picking it.

@raakella
Copy link

@PiotrSikora When I tried to upgrade to this SHA in our WASM module, it is breaking boost dependency. It works with previous SHA. Below is the error I am getting:

NFO: Analyzed 6 targets (0 packages loaded, 0 targets configured).
INFO: Found 6 targets...
ERROR: /private/var/tmp/_bazel_rakella/a6244b9ef447cd4131541c975f986f7f/external/boost/BUILD.bazel:795:14: Compiling libs/exception/src/clone_current_exception_non_intrusive.cpp failed: (Exit 1): emcc.sh failed: error executing command external/emsdk/emscripten_toolchain/emcc.sh '--sysroot=external/emscripten_bin_mac/emscripten/cache/sysroot' -fdiagnostics-color -fno-exceptions -fno-strict-aliasing -funsigned-char ... (remaining 34 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox
In file included from external/boost/libs/exception/src/clone_current_exception_non_intrusive.cpp:14:
external/boost/boost/exception/detail/clone_current_exception.hpp:22:6: error: This header requires exception handling to be enabled.
#    error This header requires exception handling to be enabled.
     ^

Any suggestions on how to proceed? It works with the previous commit.I suspect some defaults have changed with the bazel rules.

WORKSPACE:

workspace(name = "wasm-module")


load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# Pulls proxy wasm cpp SDK with a specific SHA
PROXY_WASM_CPP_SDK_SHA = "c32d380ca6c9b1afac38a3841be99c37af2698bf"
PROXY_WASM_CPP_SDK_SHA256 = "f83b83fe919905d8a6bb6ed6a0afb30d41a02cb52f33b616292c1de010d237db"

http_archive(
    name = "proxy_wasm_cpp_sdk",
    sha256 = PROXY_WASM_CPP_SDK_SHA256,
    strip_prefix = "proxy-wasm-cpp-sdk-" + PROXY_WASM_CPP_SDK_SHA,
    url = "https://github.com/proxy-wasm/proxy-wasm-cpp-sdk/archive/" + PROXY_WASM_CPP_SDK_SHA + ".tar.gz",
)

load("@proxy_wasm_cpp_sdk//bazel:repositories.bzl", "proxy_wasm_cpp_host_repositories")

proxy_wasm_cpp_host_repositories()


load("@proxy_wasm_cpp_sdk//bazel:dependencies.bzl", "proxy_wasm_cpp_host_dependencies")

proxy_wasm_cpp_host_dependencies()

load("@proxy_wasm_cpp_sdk//bazel:dependencies_extra.bzl", "proxy_wasm_cpp_host_dependencies_extra")

proxy_wasm_cpp_host_dependencies_extra()

local_repository(
    name = "mgw_wasm_websocket_api",
    path = "../../../../mgw-api/extensions/filters/http/mgw-wasm-websocket/v3"

)
############## changes to add boost ##############
git_repository(
    name = "com_github_nelhage_rules_boost",
    commit = "789a047e61c0292c3b989514f5ca18a9945b0029",
    remote = "https://github.com/nelhage/rules_boost",
    shallow_since = "1652895814 -0700",
)

load("@com_github_nelhage_rules_boost//:boost/boost.bzl", "boost_deps")
boost_deps()

bazel Build file:

load("@proxy_wasm_cpp_sdk//bazel:defs.bzl", "proxy_wasm_cc_binary")

proxy_wasm_cc_binary(
    name = "filtert.wasm",
    srcs = ["filter.cc", "filter.h"],
    deps = [
        "@proxy_wasm_cpp_sdk//:proxy_wasm_intrinsics_full",
        ############## changes to add boost ##############
        "@boost//:json"
    ],
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants