diff --git a/.bazelrc b/.bazelrc new file mode 100644 index 000000000..5a0373356 --- /dev/null +++ b/.bazelrc @@ -0,0 +1,90 @@ +# Disable Bzlmod +common --noenable_bzlmod + +# Pass CC, CXX and PATH from the environment. +build --action_env=CC +build --action_env=CXX +build --action_env=PATH + +# Use Clang compiler. +build:clang --action_env=BAZEL_COMPILER=clang +build:clang --action_env=CC=clang +build:clang --action_env=CXX=clang++ +build:clang --copt -Wno-pragma-once-outside-header --cxxopt -Wno-pragma-once-outside-header + +# Common flags for Clang sanitizers. +build:clang-xsan --config=clang +build:clang-xsan --copt -O1 +build:clang-xsan --copt -fno-omit-frame-pointer +build:clang-xsan --copt -fno-optimize-sibling-calls +build:clang-xsan --copt -fno-sanitize-recover=all +build:clang-xsan --linkopt -fsanitize-link-c++-runtime +build:clang-xsan --linkopt -fuse-ld=lld +build:clang-xsan --linkopt -rtlib=compiler-rt +build:clang-xsan --linkopt --unwindlib=libgcc + +# Use Clang compiler with Address and Undefined Behavior Sanitizers. +build:clang-asan --config=clang-xsan +build:clang-asan --copt -DADDRESS_SANITIZER=1 +build:clang-asan --copt -DUNDEFINED_SANITIZER=1 +build:clang-asan --copt -fsanitize=address,undefined +build:clang-asan --copt -fsanitize-address-use-after-scope +build:clang-asan --linkopt -fsanitize=address,undefined +build:clang-asan --linkopt -fsanitize-address-use-after-scope +build:clang-asan --test_env=ASAN_OPTIONS=check_initialization_order=1:detect_stack_use_after_return=1:strict_init_order=1:strict_string_checks=1 +build:clang-asan --test_env=UBSAN_OPTIONS=print_stacktrace=1 +build:clang-asan --test_env=ASAN_SYMBOLIZER_PATH + +# Use Clang compiler with Address and Undefined Behavior Sanitizers (strict version). +build:clang-asan-strict --config=clang-asan +build:clang-asan-strict --copt -fsanitize=integer,local-bounds,nullability +build:clang-asan-strict --linkopt -fsanitize=integer,local-bounds,nullability + +# Use Honggfuzz with Address and Undefined Behavior Sanitizers (strict version). +build:clang-asan-honggfuzz --config=clang-asan-strict +build:clang-asan-honggfuzz --@rules_fuzzing//fuzzing:cc_engine=@rules_fuzzing//fuzzing/engines:honggfuzz +build:clang-asan-honggfuzz --@rules_fuzzing//fuzzing:cc_engine_instrumentation=honggfuzz + +# Use LibFuzzer with Address and Undefined Behavior Sanitizers (strict version). +build:clang-asan-libfuzzer --config=clang-asan-strict +build:clang-asan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine=@rules_fuzzing//fuzzing/engines:libfuzzer +build:clang-asan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_instrumentation=libfuzzer + +# Use Clang compiler with Thread Sanitizer. +build:clang-tsan --config=clang-xsan +build:clang-tsan --copt -DTHREAD_SANITIZER=1 +build:clang-tsan --copt -fsanitize=thread +build:clang-tsan --linkopt -fsanitize=thread +build:clang-tsan --test_env=TSAN_OPTIONS=suppressions=bazel/tsan_suppressions.txt + +# Use Clang-Tidy tool. +build:clang-tidy --config=clang +build:clang-tidy --aspects @bazel_clang_tidy//clang_tidy:clang_tidy.bzl%clang_tidy_aspect +build:clang-tidy --@bazel_clang_tidy//:clang_tidy_config=@proxy_wasm_cpp_host//:clang_tidy_config +build:clang-tidy --output_groups=report + +# Use GCC compiler. +build:gcc --action_env=BAZEL_COMPILER=gcc +build:gcc --action_env=CC=gcc +build:gcc --action_env=CXX=g++ + +build:hermetic-llvm --incompatible_enable_cc_toolchain_resolution +build:hermetic-llvm --action_env BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 +build:hermetic-llvm --extra_toolchains @emsdk//emscripten_toolchain:cc-toolchain-wasm + +build:hermetic-llvm-macos --config=hermetic-llvm +# Below flags mitigate https://github.com/bazel-contrib/toolchains_llvm/pull/229. +build:hermetic-llvm-macos --features=-libtool +build:hermetic-llvm-macos --features=-supports_dynamic_linker + +build --enable_platform_specific_config + +# Use C++20. +build:linux --cxxopt=-std=c++20 --host_cxxopt=-std=c++20 +build:macos --cxxopt=-std=c++20 --host_cxxopt=-std=c++20 +build:windows --cxxopt="/std:c++20" --host_cxxopt="/std:c++20" + + +# Enable symlinks and runfiles on Windows (enabled by default on other platforms). +startup --windows_enable_symlinks +build:windows --enable_runfiles diff --git a/.bazelversion b/.bazelversion new file mode 100644 index 000000000..f22d756da --- /dev/null +++ b/.bazelversion @@ -0,0 +1 @@ +6.5.0 diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 000000000..df9f5c944 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,38 @@ +Checks: clang-*, + -clang-analyzer-core.CallAndMessage, + -clang-analyzer-optin.portability.UnixAPI, + -clang-analyzer-unix.Malloc, + -clang-diagnostic-pragma-once-outside-header, + -clang-diagnostic-builtin-macro-redefined, + cppcoreguidelines-pro-type-member-init, + cppcoreguidelines-pro-type-static-cast-downcast, + misc-*, + -misc-non-private-member-variables-in-classes, + -misc-use-anonymous-namespace, + -misc-const-correctness, + -misc-include-cleaner, + -misc-unused-parameters, + modernize-*, + -modernize-avoid-c-arrays, + -modernize-use-trailing-return-type, + -modernize-return-braced-init-list, + -modernize-use-default-member-init, + -modernize-type-traits, + -modernize-use-emplace, + llvm-include-order, + performance-*, + -performance-no-int-to-ptr, + -performance-avoid-endl, + portability-*, + readability-*, + -readability-convert-member-functions-to-static, + -readability-function-cognitive-complexity, + -readability-magic-numbers, + -readability-make-member-function-const, + -readability-simplify-boolean-expr, + -readability-identifier-length, + -readability-container-data-pointer, + -readability-redundant-casting, + -readability-avoid-return-with-void-value, + +WarningsAsErrors: '*' diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml deleted file mode 100644 index dfd30a1a5..000000000 --- a/.github/workflows/cpp.yml +++ /dev/null @@ -1,75 +0,0 @@ -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: C++ - -on: - - pull_request: - branches: - - master - - 'envoy-release/**' - - push: - branches: - - master - - 'envoy-release/**' - -jobs: - - format: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - name: Format (clang-format) - run: | - sudo apt-get install clang-format-9 - find . -name "*.h" -o -name "*.cc" -o -name "*.proto" | grep -v ".pb." | xargs -n1 clang-format-9 -i - git diff --exit-code - - - name: Format (buildifier) - run: | - go get -u github.com/bazelbuild/buildtools/buildifier - export PATH=$PATH:$(go env GOPATH)/bin - find . -name "BUILD" | xargs -n1 buildifier -mode=check - - name: Format (addlicense) - run: | - go get -u github.com/google/addlicense - export PATH=$PATH:$(go env GOPATH)/bin - addlicense -check . - - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - name: Mount bazel cache - uses: actions/cache@v1 - with: - path: "/home/runner/.cache/bazel" - key: bazel - - - name: Install bazelisk - run: | - curl -LO "https://github.com/bazelbuild/bazelisk/releases/download/v1.1.0/bazelisk-linux-amd64" - mkdir -p "${GITHUB_WORKSPACE}/bin/" - mv bazelisk-linux-amd64 "${GITHUB_WORKSPACE}/bin/bazel" - chmod +x "${GITHUB_WORKSPACE}/bin/bazel" - - - name: Test - run: | - "${GITHUB_WORKSPACE}/bin/bazel" test //... diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 000000000..8f61d3582 --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,164 @@ +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: Format + +on: + + pull_request: + branches: + - main + - 'envoy-release/**' + - 'istio-release/**' + + push: + branches: + - main + - 'envoy-release/**' + - 'istio-release/**' + + schedule: + - cron: '0 0 * * *' + + workflow_dispatch: + +concurrency: + + group: ${{ github.head_ref || github.run_id }}-${{ github.workflow }} + cancel-in-progress: true + +jobs: + + addlicense: + name: verify licenses + + runs-on: ubuntu-24.04-16core + + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-go@v2 + with: + go-version: '^1.16' + + - name: Install dependencies + run: | + go install github.com/google/addlicense@latest + echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH" + + - name: Format (addlicense) + run: addlicense -ignore "bazel/cargo/*/remote/**" -check . + + buildifier: + name: check format with buildifier + + runs-on: ubuntu-24.04-16core + + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-go@v2 + with: + go-version: '^1.16' + + - name: Install dependencies + run: | + go install github.com/bazelbuild/buildtools/buildifier@latest + echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH" + + - name: Format (buildifier) + run: find . -name "WORKSPACE" -o -name "*BUILD*" -o -name "*.bzl" | xargs -n1 buildifier -mode=check + + rules_rust: + name: check format with rules_rust + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Format (bazel query) + run: | + bazel query 'deps(//bazel/cargo/...)' + + - name: Format (rules_rust) + run: | + bazel run //bazel/cargo/wasmsign:crates_vendor + bazel run //bazel/cargo/wasmtime:crates_vendor + git diff --exit-code + + clang_format: + name: check format with clang-format + + runs-on: ubuntu-24.04-16core + + steps: + - uses: actions/checkout@v2 + + - name: Install dependencies (Linux) + run: sudo apt update -y && sudo apt install -y clang-format-18 + + - name: Format (clang-format) + run: | + find . -name "*.h" -o -name "*.cc" -o -name "*.proto" | grep -v ".pb." | xargs -n1 clang-format-18 -i + git diff --exit-code + + clang_tidy: + name: check format with clang-tidy + + runs-on: ubuntu-24.04-16core + + steps: + - uses: actions/checkout@v2 + + - name: Install dependencies (Linux) + run: sudo apt update -y && sudo apt install -y clang-tidy-18 lld-18 && sudo ln -sf /usr/bin/lld-18 /usr/bin/lld + + - name: set cache name + id: vars + # The cache tag consists of the following parts: + # * clang-tidy- prefix + # * matrix.name, which separates the cache for each build type. + # * hash of WORKSPACE, .bazelrc, and .bazelversion, which is + # purely to differentiate caches for substantial changes in bazel. + # * github.sha, which is the commit hash of the commit used to generate + # the cache entry. + run: echo "CACHE_TAG=clang-tidy-${{ matrix.name }}-${{ hashFiles('WORKSPACE', '.bazelrc', '.bazelversion') }}" >> "$GITHUB_OUTPUT" + + - name: bazel cache + uses: actions/cache/restore@v3 + with: + path: /tmp/bazel/cache + key: ${{ steps.vars.outputs.CACHE_TAG }}-${{ github.sha }} + restore-keys: | + ${{ steps.vars.outputs.CACHE_TAG }}-${{ github.sha }} + ${{ steps.vars.outputs.CACHE_TAG }}- + clang-tidy-${{ matrix.name }}- + clang-tidy- + + - name: Bazel build + run: > + bazel build + --config clang-tidy + --define engine=multi + --disk_cache /tmp/bazel/cache + --copt=-DPROXY_WASM_VERIFY_WITH_ED25519_PUBKEY=\"$(xxd -p -c 256 test/test_data/signature_key1.pub | cut -b9-)\" + //... + + - name: save bazel cache + uses: actions/cache/save@v3 + if: always() + with: + path: /tmp/bazel/cache + key: ${{ steps.vars.outputs.CACHE_TAG }}-${{ github.sha }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..cc6ddbc5f --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,379 @@ +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: Test + +on: + + pull_request: + branches: + - main + - 'envoy-release/**' + - 'istio-release/**' + + push: + branches: + - main + - 'envoy-release/**' + - 'istio-release/**' + + schedule: + - cron: '0 0 * * *' + + workflow_dispatch: + +concurrency: + + group: ${{ github.head_ref || github.run_id }}-${{ github.workflow }} + cancel-in-progress: true + +jobs: + + test_data: + name: build test data + + runs-on: ubuntu-24.04-16core + + steps: + - uses: actions/checkout@v2 + + - name: set cache name + id: vars + # The cache tag consists of the following parts: + # * test-deps-bazel-cache- prefix + # * hash of WORKSPACE, .bazelrc, and .bazelversion, which is + # purely to differentiate caches for substantial changes in bazel. + # * github.sha, which is the commit hash of the commit used to generate + # the cache entry. + run: echo "CACHE_TAG=test-deps-bazel-cache-${{ hashFiles('WORKSPACE', '.bazelrc', '.bazelversion') }}" >> "$GITHUB_OUTPUT" + + - name: bazel cache + uses: actions/cache/restore@v3 + with: + path: /tmp/bazel/cache + key: ${{ steps.vars.outputs.CACHE_TAG }}-${{ github.sha }} + restore-keys: | + ${{ steps.vars.outputs.CACHE_TAG }}-${{ github.sha }} + ${{ steps.vars.outputs.CACHE_TAG }}- + test-deps-bazel-cache-${{ matrix.name }}- + test-deps-bazel-cache- + + - name: Bazel build + run: > + bazel build + --verbose_failures + --test_output=errors + --config=clang + --disk_cache /tmp/bazel/cache + -c opt + $(bazel query 'kind(was.*_rust_binary, //test/test_data/...)') + $(bazel query 'kind(_optimized_wasm_cc_binary, //test/test_data/...)') + + # Currently, in Github Action, "Bazel build step" creates `wasm_canary_check.wasm` directory as a temporal directory. + # Since the name of this directory has "*.wasm" pattern, the step "Mangle build rules to use existing test data" fails. + # So, here, we clear out the directories in test_data. + - name: Clean up test data + shell: bash + run: | + # Remove temporal directories + for i in $(find bazel-bin/test/test_data/ -mindepth 1 -maxdepth 1 -type d); do \ + rm -rf $i; \ + done + + - name: Upload test data + uses: actions/upload-artifact@v4 + with: + name: test_data + path: bazel-bin/test/test_data/*.wasm + if-no-files-found: error + retention-days: 3 + + - name: remove unaccessed files from cache + shell: bash + run: > + find /tmp/bazel/cache + -type f + -name '*' + -amin +360 + -exec rm {} \; + + - name: save bazel cache + uses: actions/cache/save@v3 + if: always() + with: + path: /tmp/bazel/cache + key: ${{ steps.vars.outputs.CACHE_TAG }}-${{ github.sha }} + + build: + name: ${{ matrix.action }} with ${{ matrix.name }} + + needs: test_data + + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + include: + - name: 'NullVM on Linux/x86_64' + engine: 'null' + os: ubuntu-24.04-16core + arch: x86_64 + action: test + flags: --config=gcc + - name: 'NullVM on Linux/x86_64 with ASan' + engine: 'null' + os: ubuntu-24.04-16core + arch: x86_64 + action: test + flags: --config=clang-asan --define=crypto=system + - name: 'NullVM on Linux/x86_64 with TSan' + engine: 'null' + os: ubuntu-24.04-16core + arch: x86_64 + action: test + flags: --config=clang-tsan + - name: 'NullVM on Windows/x86_64' + engine: 'null' + os: windows-2022 + arch: x86_64 + action: test + targets: -//test/fuzz/... + - name: 'V8 on Linux/x86_64' + engine: 'v8' + repo: 'v8' + os: ubuntu-24.04-16core + arch: x86_64 + action: test + flags: --config=hermetic-llvm --define=crypto=system + cache: true + - name: 'V8 on Linux/x86_64 with ASan' + engine: 'v8' + repo: 'v8' + os: ubuntu-24.04-16core + arch: x86_64 + action: test + flags: --config=hermetic-llvm --config=clang-asan + cache: true + - name: 'V8 on Linux/x86_64 with TSan' + engine: 'v8' + repo: 'v8' + os: ubuntu-24.04-16core + arch: x86_64 + action: test + flags: --config=hermetic-llvm --config=clang-tsan + cache: true + - name: 'V8 on Linux/x86_64 with GCC' + engine: 'v8' + repo: 'v8' + os: ubuntu-24.04-16core + arch: x86_64 + action: test + flags: --config=gcc + cache: true + - name: 'V8 on Linux/aarch64' + engine: 'v8' + repo: 'v8' + os: ubuntu-24.04-arm + arch: aarch64 + action: test + targets: -//test/fuzz/... + flags: --config=hermetic-llvm --@v8//bazel/config:v8_target_cpu=arm64 + cache: true + - name: 'V8 on macOS/x86_64' + engine: 'v8' + repo: 'v8' + os: macos-13 + arch: x86_64 + action: test + flags: --config=hermetic-llvm-macos + cache: true + - name: 'WAMR interp on Linux/x86_64' + engine: 'wamr-interp' + repo: 'com_github_bytecodealliance_wasm_micro_runtime' + os: ubuntu-24.04-16core + arch: x86_64 + action: test + flags: --config=clang + - name: 'WAMR interp on macOS/x86_64' + engine: 'wamr-interp' + repo: 'com_github_bytecodealliance_wasm_micro_runtime' + os: macos-13 + arch: x86_64 + action: test + - name: 'WAMR jit on Linux/x86_64' + engine: 'wamr-jit' + repo: 'com_github_bytecodealliance_wasm_micro_runtime' + os: ubuntu-24.04-16core + arch: x86_64 + action: test + flags: --config=clang + deps: lld-18 + cache: true + - name: 'WAMR jit on macOS/x86_64' + engine: 'wamr-jit' + repo: 'com_github_bytecodealliance_wasm_micro_runtime' + os: macos-13 + arch: x86_64 + action: test + cache: true + - name: 'WasmEdge on Linux/x86_64' + engine: 'wasmedge' + repo: 'com_github_wasmedge_wasmedge' + os: ubuntu-24.04-16core + arch: x86_64 + action: test + flags: --config=clang + - name: 'WasmEdge on macOS/x86_64' + engine: 'wasmedge' + repo: 'com_github_wasmedge_wasmedge' + os: macos-13 + arch: x86_64 + action: test + - name: 'Wasmtime on Linux/x86_64' + engine: 'wasmtime' + repo: 'com_github_bytecodealliance_wasmtime' + os: ubuntu-24.04-16core + arch: x86_64 + action: test + flags: --config=clang -c opt + - name: 'Wasmtime on Linux/x86_64 with ASan' + engine: 'wasmtime' + repo: 'com_github_bytecodealliance_wasmtime' + os: ubuntu-24.04-16core + arch: x86_64 + action: test + flags: --config=clang-asan --define=crypto=system + - name: 'Wasmtime on Linux/aarch64' + engine: 'wasmtime' + repo: 'com_github_bytecodealliance_wasmtime' + os: ubuntu-24.04-arm + arch: aarch64 + action: build + flags: --config=hermetic-llvm + - name: 'Wasmtime on Linux/s390x' + engine: 'wasmtime' + repo: 'com_github_bytecodealliance_wasmtime' + os: ubuntu-24.04-16core + arch: s390x + action: test + flags: --config=clang --test_timeout=1800 + # s390x build-tools image built from bazel/external/Dockerfile.bazel + run_under: docker run --rm --env HOME=$HOME --env USER=$(id -un) --volume "$HOME:$HOME" --workdir $(pwd) --user $(id -u):$(id -g) --platform linux/s390x ghcr.io/proxy-wasm/build-tools:ubuntu-22.04-bazel-6.5.0 + cache: true + - name: 'Wasmtime on macOS/x86_64' + engine: 'wasmtime' + repo: 'com_github_bytecodealliance_wasmtime' + os: macos-13 + arch: x86_64 + action: test + + steps: + - uses: actions/checkout@v2 + + - name: Install dependencies (Linux) + if: ${{ matrix.deps != '' && startsWith(matrix.os, 'ubuntu') }} + run: sudo apt update -y && sudo apt install -y ${{ matrix.deps }} + + # Needed for s390x test which runs on a GHCR Docker Ubuntu image. + - name: Login to GitHub Container Registry + if: startsWith(matrix.run_under, 'docker') + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Activate Docker/QEMU + if: startsWith(matrix.run_under, 'docker') + run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + + - name: set cache name + id: vars + # The cache tag consists of the following parts: + # * bazel-cache- prefix + # * matrix.name, which separates the cache for each build type. + # * hash of WORKSPACE, .bazelrc, and .bazelversion, which is + # purely to differentiate caches for substantial changes in bazel. + # * github.sha, which is the commit hash of the commit used to generate + # the cache entry. + run: echo "CACHE_TAG=bazel-cache-${{ matrix.name }}-${{ hashFiles('WORKSPACE', '.bazelrc', '.bazelversion') }}" >> "$GITHUB_OUTPUT" + + - name: bazel cache + uses: actions/cache/restore@v3 + with: + path: /tmp/bazel/cache + key: ${{ steps.vars.outputs.CACHE_TAG }}-${{ github.sha }} + restore-keys: | + ${{ steps.vars.outputs.CACHE_TAG }}-${{ github.sha }} + ${{ steps.vars.outputs.CACHE_TAG }}- + bazel-cache-${{ matrix.name }}- + bazel-cache- + + - name: Download test data + uses: actions/download-artifact@v4 + with: + name: test_data + path: test/test_data/ + + - name: Mangle build rules to use existing test data + shell: bash + run: | + sed 's/\.wasm//g' test/BUILD > test/BUILD.tmp && mv test/BUILD.tmp test/BUILD + echo "package(default_visibility = [\"//visibility:public\"])" > test/test_data/BUILD + for i in $(cd test/test_data && ls -1 *.wasm | sed 's/\.wasm$//g'); do \ + echo "filegroup(name = \"$i\", srcs = [\"$i.wasm\"])" >> test/test_data/BUILD; \ + done + + - name: Bazel build/test + shell: bash + run: > + ${{ matrix.run_under }} + bazel ${{ matrix.action }} + --verbose_failures + --test_output=errors + --define engine=${{ matrix.engine }} + --disk_cache /tmp/bazel/cache + ${{ matrix.flags }} + -- //test/... ${{ matrix.targets }} + + - name: Bazel build/test (signed Wasm module) + if: ${{ matrix.engine != 'null' && !startsWith(matrix.os, 'windows') }} + run: > + ${{ matrix.run_under }} + bazel ${{ matrix.action }} + --verbose_failures + --test_output=errors + --define engine=${{ matrix.engine }} + --disk_cache /tmp/bazel/cache + ${{ matrix.flags }} + --per_file_copt=src/signature_util.cc,test/signature_util_test.cc@-DPROXY_WASM_VERIFY_WITH_ED25519_PUBKEY=\"$(xxd -p -c 256 test/test_data/signature_key1.pub | cut -b9-)\" + //test:signature_util_test + + - name: remove unaccessed files from cache + shell: bash + run: > + find /tmp/bazel/cache + -type f + -name '*' + -amin +360 + -exec rm {} \; + + - name: save bazel cache + uses: actions/cache/save@v3 + if: always() + with: + path: /tmp/bazel/cache + key: ${{ steps.vars.outputs.CACHE_TAG }}-${{ github.sha }} + diff --git a/.gitignore b/.gitignore index a6ef824c1..54c8a3b00 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ /bazel-* +/external +/compile_commands.json +/.cache/ diff --git a/BUILD b/BUILD index 1aa823d91..6db5fd903 100644 --- a/BUILD +++ b/BUILD @@ -1,62 +1,299 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +load( + "@proxy_wasm_cpp_host//bazel:select.bzl", + "proxy_wasm_select_engine_null", + "proxy_wasm_select_engine_v8", + "proxy_wasm_select_engine_wamr", + "proxy_wasm_select_engine_wasmedge", + "proxy_wasm_select_engine_wasmtime", +) +load("@rules_cc//cc:defs.bzl", "cc_library") + licenses(["notice"]) # Apache 2 package(default_visibility = ["//visibility:public"]) -COPTS = select({ - "@bazel_tools//src/conditions:windows": [ - "/std:c++17", - "-DWITHOUT_ZLIB", +exports_files(["LICENSE"]) + +filegroup( + name = "clang_tidy_config", + data = [".clang-tidy"], +) + +cc_library( + name = "wasm_vm_headers", + hdrs = [ + "include/proxy-wasm/limits.h", + "include/proxy-wasm/sdk.h", + "include/proxy-wasm/wasm_vm.h", + "include/proxy-wasm/word.h", ], - "//conditions:default": [ - "-std=c++17", - "-DWITHOUT_ZLIB", + deps = [ + "@proxy_wasm_cpp_sdk//:common_lib", ], -}) +) cc_library( - name = "include", - hdrs = glob(["include/proxy-wasm/**/*.h"]), + name = "headers", + hdrs = [ + "include/proxy-wasm/context.h", + "include/proxy-wasm/context_interface.h", + "include/proxy-wasm/exports.h", + "include/proxy-wasm/vm_id_handle.h", + "include/proxy-wasm/wasm.h", + ], deps = [ - "@proxy_wasm_cpp_sdk//:common_lib", + ":wasm_vm_headers", ], ) cc_library( - name = "lib", - srcs = glob( - ["src/**/*.cc"], - exclude = [ - "src/**/wavm*", - "src/**/v8*", - ], - ) + glob(["src/**/*.h"]), - copts = COPTS, + name = "base_lib", + srcs = [ + "src/bytecode_util.cc", + "src/context.cc", + "src/exports.cc", + "src/hash.cc", + "src/hash.h", + "src/pairs_util.cc", + "src/shared_data.cc", + "src/shared_data.h", + "src/shared_queue.cc", + "src/shared_queue.h", + "src/signature_util.cc", + "src/vm_id_handle.cc", + "src/wasm.cc", + "src/wasm.h", + ], + hdrs = [ + "include/proxy-wasm/bytecode_util.h", + "include/proxy-wasm/pairs_util.h", + "include/proxy-wasm/signature_util.h", + ], + linkopts = select({ + "//bazel:crypto_system": ["-lcrypto"], + "//conditions:default": [], + }), + deps = [ + ":headers", + ] + select({ + "//bazel:crypto_system": [], + "//conditions:default": ["@boringssl//:crypto"], + }), + alwayslink = 1, +) + +cc_library( + name = "null_lib", + srcs = [ + "src/null/null.cc", + "src/null/null_plugin.cc", + "src/null/null_vm.cc", + ], + hdrs = [ + "include/proxy-wasm/null.h", + "include/proxy-wasm/null_plugin.h", + "include/proxy-wasm/null_vm.h", + "include/proxy-wasm/null_vm_plugin.h", + "include/proxy-wasm/wasm_api_impl.h", + ], + defines = [ + "PROXY_WASM_HAS_RUNTIME_NULL", + "PROXY_WASM_HOST_ENGINE_NULL", + ], deps = [ - ":include", - "@boringssl//:crypto", + ":headers", "@com_google_protobuf//:protobuf_lite", "@proxy_wasm_cpp_sdk//:api_lib", ], ) -cc_test( - name = "wasm_vm_test", - srcs = ["wasm_vm_test.cc"], - copts = COPTS, +cc_library( + name = "v8_lib", + srcs = [ + "src/v8/v8.cc", + ], + hdrs = ["include/proxy-wasm/v8.h"], + defines = [ + "PROXY_WASM_HAS_RUNTIME_V8", + "PROXY_WASM_HOST_ENGINE_V8", + ], deps = [ - ":lib", - "@com_google_googletest//:gtest", - "@com_google_googletest//:gtest_main", + ":wasm_vm_headers", + "//external:wee8", ], ) -cc_test( - name = "context_test", - srcs = ["context_test.cc"], - copts = COPTS, +cc_library( + name = "wamr_lib", + srcs = [ + "src/common/types.h", + "src/wamr/types.h", + "src/wamr/wamr.cc", + ], + hdrs = ["include/proxy-wasm/wamr.h"], + defines = [ + "PROXY_WASM_HAS_RUNTIME_WAMR", + "PROXY_WASM_HOST_ENGINE_WAMR", + ], deps = [ - ":include", - "@com_google_googletest//:gtest", - "@com_google_googletest//:gtest_main", + ":wasm_vm_headers", + "//external:wamr", + ], +) + +cc_library( + name = "wasmedge_lib", + srcs = [ + "src/common/types.h", + "src/wasmedge/types.h", + "src/wasmedge/wasmedge.cc", + ], + hdrs = ["include/proxy-wasm/wasmedge.h"], + defines = [ + "PROXY_WASM_HAS_RUNTIME_WASMEDGE", + "PROXY_WASM_HOST_ENGINE_WASMEDGE", ], + linkopts = select({ + "@platforms//os:macos": [ + "-ldl", + ], + "//conditions:default": [ + "-lrt", + "-ldl", + ], + }), + deps = [ + ":wasm_vm_headers", + "//external:wasmedge", + ], +) + +cc_library( + name = "wasmtime_lib", + srcs = [ + "src/common/types.h", + "src/wasmtime/types.h", + "src/wasmtime/wasmtime.cc", + ], + hdrs = ["include/proxy-wasm/wasmtime.h"], + copts = [ + "-DWASM_API_EXTERN=", + ], + defines = [ + "PROXY_WASM_HAS_RUNTIME_WASMTIME", + "PROXY_WASM_HOST_ENGINE_WASMTIME", + ], + # See: https://bytecodealliance.github.io/wasmtime/c-api/ + linkopts = select({ + "@platforms//os:macos": [], + "@platforms//os:windows": [ + "ws2_32.lib", + "advapi32.lib", + "userenv.lib", + "ntdll.lib", + "shell32.lib", + "ole32.lib", + "bcrypt.lib", + ], + "//conditions:default": [ + "-ldl", + "-lm", + "-lpthread", + ], + }), + deps = [ + ":wasm_vm_headers", + "//external:wasmtime", + ], +) + +genrule( + name = "prefixed_wasmtime_sources", + srcs = [ + "src/wasmtime/types.h", + "src/wasmtime/wasmtime.cc", + ], + outs = [ + "src/wasmtime/prefixed_types.h", + "src/wasmtime/prefixed_wasmtime.cc", + ], + cmd = """ + for file in $(SRCS); do + sed -e 's/wasm_/wasmtime_wasm_/g' \ + -e 's/include\\/wasm.h/include\\/prefixed_wasm.h/g' \ + -e 's/wasmtime\\/types.h/wasmtime\\/prefixed_types.h/g' \ + $$file >$(@D)/$$(dirname $$file)/prefixed_$$(basename $$file) + done + """, +) + +cc_library( + name = "prefixed_wasmtime_lib", + srcs = [ + "src/common/types.h", + "src/wasmtime/prefixed_types.h", + "src/wasmtime/prefixed_wasmtime.cc", + ], + hdrs = ["include/proxy-wasm/wasmtime.h"], + copts = [ + "-DWASM_API_EXTERN=", + ], + defines = [ + "PROXY_WASM_HAS_RUNTIME_WASMTIME", + "PROXY_WASM_HOST_ENGINE_WASMTIME", + ], + # See: https://bytecodealliance.github.io/wasmtime/c-api/ + linkopts = select({ + "@platforms//os:macos": [], + "@platforms//os:windows": [ + "ws2_32.lib", + "advapi32.lib", + "userenv.lib", + "ntdll.lib", + "shell32.lib", + "ole32.lib", + "bcrypt.lib", + ], + "//conditions:default": [ + "-ldl", + "-lm", + "-lpthread", + ], + }), + deps = [ + ":wasm_vm_headers", + "//external:prefixed_wasmtime", + ], +) + +cc_library( + name = "lib", + deps = [ + ":base_lib", + ] + proxy_wasm_select_engine_null( + [":null_lib"], + ) + proxy_wasm_select_engine_v8( + [":v8_lib"], + ) + proxy_wasm_select_engine_wamr( + [":wamr_lib"], + ) + proxy_wasm_select_engine_wasmedge( + [":wasmedge_lib"], + ) + proxy_wasm_select_engine_wasmtime( + [":wasmtime_lib"], + [":prefixed_wasmtime_lib"], + ), ) diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 000000000..e4190bb47 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1 @@ +* @PiotrSikora @martijneken @mpwarres @leonm1 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 654a07164..d3f60f57a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -26,3 +26,7 @@ information on using pull requests. This project follows [Google's Open Source Community Guidelines](https://opensource.google/conduct/). + +## Development + +See the [Development Guidelines](DEVELOPMENT.md). diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md new file mode 100644 index 000000000..791fe23a1 --- /dev/null +++ b/DEVELOPMENT.md @@ -0,0 +1,11 @@ +# Development guidelines + +## Generate compilation database + +[JSON Compilation Database](https://clang.llvm.org/docs/JSONCompilationDatabase.html) files can be used by [clangd](https://clangd.llvm.org/) or similar tools to add source code cross-references and code completion functionality to editors. + +The following command can be used to generate the `compile_commands.json` file: + +``` +BAZEL_BUILD_OPTION_LIST="--define=engine=multi" ./tools/gen_compilation_database.py --include_all //test/... //:lib +``` diff --git a/README.md b/README.md index 8cb5694ee..bd198e723 100644 --- a/README.md +++ b/README.md @@ -1 +1,5 @@ # WebAssembly for Proxies (C++ host implementation) + +## How to Contribute + +See [CONTRIBUTING](CONTRIBUTING.md). diff --git a/WORKSPACE b/WORKSPACE index bc20f1fa5..dad42c2f8 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,53 +1,29 @@ workspace(name = "proxy_wasm_cpp_host") -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") - -git_repository( - name = "proxy_wasm_cpp_sdk", - commit = "1b5f69ce1535b0c21f88c4af4ebf0ec51d255abe", - remote = "https://github.com/proxy-wasm/proxy-wasm-cpp-sdk", -) - -http_archive( - name = "com_google_absl", - sha256 = "19391fb4882601a65cb648d638c11aa301ce5f525ef02da1a9eafd22f72d7c59", - strip_prefix = "abseil-cpp-37dd2562ec830d547a1524bb306be313ac3f2556", - # 2020-01-29 - urls = ["https://github.com/abseil/abseil-cpp/archive/37dd2562ec830d547a1524bb306be313ac3f2556.tar.gz"], -) - -# required by com_google_protobuf -http_archive( - name = "bazel_skylib", - sha256 = "97e70364e9249702246c0e9444bccdc4b847bed1eb03c5a3ece4f83dfe6abc44", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz", - "https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz", - ], -) - -load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") - -bazel_skylib_workspace() - -git_repository( - name = "com_google_protobuf", - commit = "655310ca192a6e3a050e0ca0b7084a2968072260", - remote = "https://github.com/protocolbuffers/protobuf", - shallow_since = "1565024848 -0700", -) - -http_archive( - name = "boringssl", - sha256 = "bb55b0ed2f0cb548b5dce6a6b8307ce37f7f748eb9f1be6bfe2d266ff2b4d52b", - strip_prefix = "boringssl-2192bbc878822cf6ab5977d4257a1339453d9d39", - urls = ["https://github.com/google/boringssl/archive/2192bbc878822cf6ab5977d4257a1339453d9d39.tar.gz"], -) - -http_archive( - name = "com_google_googletest", - sha256 = "9dc9157a9a1551ec7a7e43daea9a694a0bb5fb8bec81235d8a1e6ef64c716dcb", - strip_prefix = "googletest-release-1.10.0", - urls = ["https://github.com/google/googletest/archive/release-1.10.0.tar.gz"], -) +load("@proxy_wasm_cpp_host//bazel:repositories.bzl", "proxy_wasm_cpp_host_repositories") + +proxy_wasm_cpp_host_repositories() + +load("@proxy_wasm_cpp_host//bazel:dependencies.bzl", "proxy_wasm_cpp_host_dependencies") + +proxy_wasm_cpp_host_dependencies() + +load("@proxy_wasm_cpp_host//bazel:dependencies_python.bzl", "proxy_wasm_cpp_host_dependencies_python") + +proxy_wasm_cpp_host_dependencies_python() + +load("@proxy_wasm_cpp_host//bazel:dependencies_import.bzl", "proxy_wasm_cpp_host_dependencies_import") + +proxy_wasm_cpp_host_dependencies_import() + +load("@proxy_wasm_cpp_sdk//bazel:repositories.bzl", "proxy_wasm_cpp_sdk_repositories") + +proxy_wasm_cpp_sdk_repositories() + +load("@proxy_wasm_cpp_sdk//bazel:dependencies.bzl", "proxy_wasm_cpp_sdk_dependencies") + +proxy_wasm_cpp_sdk_dependencies() + +load("@proxy_wasm_cpp_sdk//bazel:dependencies_extra.bzl", "proxy_wasm_cpp_sdk_dependencies_extra") + +proxy_wasm_cpp_sdk_dependencies_extra() diff --git a/bazel/BUILD b/bazel/BUILD new file mode 100644 index 000000000..15f323fa7 --- /dev/null +++ b/bazel/BUILD @@ -0,0 +1,72 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +load("@bazel_skylib//lib:selects.bzl", "selects") + +package(default_visibility = ["//visibility:public"]) + +config_setting( + name = "engine_null", + values = {"define": "engine=null"}, +) + +config_setting( + name = "engine_v8", + values = {"define": "engine=v8"}, +) + +config_setting( + name = "engine_wamr_interp", + values = {"define": "engine=wamr-interp"}, +) + +config_setting( + name = "engine_wamr_jit", + values = {"define": "engine=wamr-jit"}, +) + +config_setting( + name = "engine_wasmedge", + values = {"define": "engine=wasmedge"}, +) + +config_setting( + name = "engine_wasmtime", + values = {"define": "engine=wasmtime"}, +) + +config_setting( + name = "multiengine", + values = {"define": "engine=multi"}, +) + +config_setting( + name = "requested_crypto_system", + values = {"define": "crypto=system"}, +) + +config_setting( + name = "linux_s390x", + values = {"cpu": "s390x"}, +) + +selects.config_setting_group( + name = "crypto_system", + match_any = [ + ":requested_crypto_system", + ":linux_s390x", + ], +) + +exports_files(["tsan_suppressions.txt"]) diff --git a/bazel/cargo/wasmsign/BUILD.bazel b/bazel/cargo/wasmsign/BUILD.bazel new file mode 100644 index 000000000..ceb559374 --- /dev/null +++ b/bazel/cargo/wasmsign/BUILD.bazel @@ -0,0 +1,36 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +load("@rules_rust//crate_universe:defs.bzl", "crates_vendor") + +exports_files( + [ + "Cargo.toml", + "Cargo.Bazel.lock", + ], +) + +# Run this target to regenerate cargo_lockfile and vendor_path/*. +# $ bazelisk run bazel/cargo/wasmsign:crates_vendor -- --repin +crates_vendor( + name = "crates_vendor", + cargo_lockfile = ":Cargo.Bazel.lock", + generate_binaries = True, + generate_target_compatible_with = False, + manifests = [":Cargo.toml"], + mode = "remote", + repository_name = "cu", # shorten generated paths for Windows... + tags = ["manual"], + vendor_path = "remote", +) diff --git a/bazel/cargo/wasmsign/Cargo.Bazel.lock b/bazel/cargo/wasmsign/Cargo.Bazel.lock new file mode 100644 index 000000000..b9a45d0b5 --- /dev/null +++ b/bazel/cargo/wasmsign/Cargo.Bazel.lock @@ -0,0 +1,247 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + +[[package]] +name = "anyhow" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clap" +version = "2.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +dependencies = [ + "ansi_term", + "atty", + "bitflags", + "strsim", + "textwrap", + "unicode-width", + "vec_map", +] + +[[package]] +name = "ct-codecs" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3b7eb4404b8195a9abb6356f4ac07d8ba267045c8d6d220ac4dc992e6cc75df" + +[[package]] +name = "ed25519-compact" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e18997d4604542d0736fae2c5ad6de987f0a50530cbcc14a7ce5a685328a252d" +dependencies = [ + "ct-codecs", + "getrandom", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "hmac-sha512" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4ce1f4656bae589a3fab938f9f09bf58645b7ed01a2c5f8a3c238e01a4ef78a" + +[[package]] +name = "libc" +version = "0.2.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "parity-wasm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be5e13c266502aadf83426d87d81a0f5d1ef45b8027f5a471c360abfe4bfae92" + +[[package]] +name = "proc-macro2" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + +[[package]] +name = "syn" +version = "2.0.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "thiserror" +version = "1.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-width" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" + +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasmsign" +version = "0.1.2" +source = "git+https://github.com/jedisct1/wasmsign#6a6ef1c6f99063a5bd4ef9efc2ee41c5ea8f4f96" +dependencies = [ + "anyhow", + "byteorder", + "clap", + "ed25519-compact", + "hmac-sha512", + "parity-wasm", + "thiserror", +] + +[[package]] +name = "wasmsign-bazel" +version = "0.1.2" +dependencies = [ + "wasmsign", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/bazel/cargo/wasmsign/Cargo.toml b/bazel/cargo/wasmsign/Cargo.toml new file mode 100644 index 000000000..5267cb2d1 --- /dev/null +++ b/bazel/cargo/wasmsign/Cargo.toml @@ -0,0 +1,28 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +[package] +edition = "2018" +name = "wasmsign-bazel" +version = "0.1.2" + +[lib] +path = "fake_lib.rs" + +[dependencies] +wasmsign = {git = "https://github.com/jedisct1/wasmsign", revision = "fa4d5598f778390df09be94232972b5b865a56b8"} + +# Ready to upgrade to wasmsign2: +# Which generates: //bazel/cargo/wasmsign/remote:wasmsign2-cli__wasmsign2 +#wasmsign2-cli = {git = "https://github.com/wasm-signatures/wasmsign2", revision = "07c60eee7f4c655d5a91404f5a9ffd97316d01f1"} diff --git a/bazel/cargo/wasmsign/remote/BUILD.ansi_term-0.12.1.bazel b/bazel/cargo/wasmsign/remote/BUILD.ansi_term-0.12.1.bazel new file mode 100644 index 000000000..c9b94b758 --- /dev/null +++ b/bazel/cargo/wasmsign/remote/BUILD.ansi_term-0.12.1.bazel @@ -0,0 +1,56 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmsign:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "ansi_term", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=ansi_term", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.12.1", + deps = select({ + "@rules_rust//rust/platform:aarch64-pc-windows-msvc": [ + "@cu__winapi-0.3.9//:winapi", # cfg(target_os = "windows") + ], + "@rules_rust//rust/platform:i686-pc-windows-msvc": [ + "@cu__winapi-0.3.9//:winapi", # cfg(target_os = "windows") + ], + "@rules_rust//rust/platform:x86_64-pc-windows-msvc": [ + "@cu__winapi-0.3.9//:winapi", # cfg(target_os = "windows") + ], + "//conditions:default": [], + }), +) diff --git a/bazel/cargo/wasmsign/remote/BUILD.anyhow-1.0.86.bazel b/bazel/cargo/wasmsign/remote/BUILD.anyhow-1.0.86.bazel new file mode 100644 index 000000000..6c6cb4127 --- /dev/null +++ b/bazel/cargo/wasmsign/remote/BUILD.anyhow-1.0.86.bazel @@ -0,0 +1,97 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmsign:crates_vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "anyhow", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + "std", + ], + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=anyhow", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.86", + deps = [ + "@cu__anyhow-1.0.86//:build_script_build", + ], +) + +cargo_build_script( + name = "anyhow_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + crate_features = [ + "default", + "std", + ], + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=anyhow", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.86", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = ":anyhow_bs", + tags = ["manual"], +) diff --git a/bazel/cargo/wasmsign/remote/BUILD.atty-0.2.14.bazel b/bazel/cargo/wasmsign/remote/BUILD.atty-0.2.14.bazel new file mode 100644 index 000000000..041f36f9e --- /dev/null +++ b/bazel/cargo/wasmsign/remote/BUILD.atty-0.2.14.bazel @@ -0,0 +1,128 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmsign:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "atty", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=atty", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.2.14", + deps = select({ + "@rules_rust//rust/platform:aarch64-apple-darwin": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:aarch64-apple-ios": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:aarch64-apple-ios-sim": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:aarch64-fuchsia": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:aarch64-linux-android": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:aarch64-pc-windows-msvc": [ + "@cu__winapi-0.3.9//:winapi", # cfg(windows) + ], + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:armv7-linux-androideabi": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:i686-apple-darwin": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:i686-linux-android": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:i686-pc-windows-msvc": [ + "@cu__winapi-0.3.9//:winapi", # cfg(windows) + ], + "@rules_rust//rust/platform:i686-unknown-freebsd": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:i686-unknown-linux-gnu": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:s390x-unknown-linux-gnu": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:x86_64-apple-darwin": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:x86_64-apple-ios": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:x86_64-fuchsia": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:x86_64-linux-android": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:x86_64-pc-windows-msvc": [ + "@cu__winapi-0.3.9//:winapi", # cfg(windows) + ], + "@rules_rust//rust/platform:x86_64-unknown-freebsd": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "//conditions:default": [], + }), +) diff --git a/bazel/cargo/wasmsign/remote/BUILD.bazel b/bazel/cargo/wasmsign/remote/BUILD.bazel new file mode 100644 index 000000000..87eba7241 --- /dev/null +++ b/bazel/cargo/wasmsign/remote/BUILD.bazel @@ -0,0 +1,45 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmsign:crates_vendor +############################################################################### + +package(default_visibility = ["//visibility:public"]) + +exports_files( + [ + "cargo-bazel.json", + "crates.bzl", + "defs.bzl", + ] + glob( + include = ["*.bazel"], + allow_empty = True, + ), +) + +filegroup( + name = "srcs", + srcs = glob( + include = [ + "*.bazel", + "*.bzl", + ], + allow_empty = True, + ), +) + +# Workspace Member Dependencies +alias( + name = "wasmsign", + actual = "@cu__wasmsign-0.1.2//:wasmsign", + tags = ["manual"], +) + +# Binaries +alias( + name = "wasmsign__wasmsign", + actual = "@cu__wasmsign-0.1.2//:wasmsign__bin", + tags = ["manual"], +) diff --git a/bazel/cargo/wasmsign/remote/BUILD.bitflags-1.3.2.bazel b/bazel/cargo/wasmsign/remote/BUILD.bitflags-1.3.2.bazel new file mode 100644 index 000000000..653792564 --- /dev/null +++ b/bazel/cargo/wasmsign/remote/BUILD.bitflags-1.3.2.bazel @@ -0,0 +1,47 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmsign:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "bitflags", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + ], + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=bitflags", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.3.2", +) diff --git a/bazel/cargo/wasmsign/remote/BUILD.byteorder-1.5.0.bazel b/bazel/cargo/wasmsign/remote/BUILD.byteorder-1.5.0.bazel new file mode 100644 index 000000000..fd6870278 --- /dev/null +++ b/bazel/cargo/wasmsign/remote/BUILD.byteorder-1.5.0.bazel @@ -0,0 +1,48 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmsign:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "byteorder", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + "std", + ], + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=byteorder", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.5.0", +) diff --git a/bazel/cargo/wasmsign/remote/BUILD.cfg-if-1.0.0.bazel b/bazel/cargo/wasmsign/remote/BUILD.cfg-if-1.0.0.bazel new file mode 100644 index 000000000..e7c34e5d4 --- /dev/null +++ b/bazel/cargo/wasmsign/remote/BUILD.cfg-if-1.0.0.bazel @@ -0,0 +1,44 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmsign:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "cfg_if", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=cfg-if", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.0", +) diff --git a/bazel/cargo/wasmsign/remote/BUILD.clap-2.34.0.bazel b/bazel/cargo/wasmsign/remote/BUILD.clap-2.34.0.bazel new file mode 100644 index 000000000..ed355234f --- /dev/null +++ b/bazel/cargo/wasmsign/remote/BUILD.clap-2.34.0.bazel @@ -0,0 +1,156 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmsign:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "clap", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "ansi_term", + "atty", + "color", + "default", + "strsim", + "suggestions", + "vec_map", + ], + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=clap", + "manual", + "noclippy", + "norustfmt", + ], + version = "2.34.0", + deps = [ + "@cu__atty-0.2.14//:atty", + "@cu__bitflags-1.3.2//:bitflags", + "@cu__strsim-0.8.0//:strsim", + "@cu__textwrap-0.11.0//:textwrap", + "@cu__unicode-width-0.1.13//:unicode_width", + "@cu__vec_map-0.8.2//:vec_map", + ] + select({ + "@rules_rust//rust/platform:aarch64-apple-darwin": [ + "@cu__ansi_term-0.12.1//:ansi_term", # cfg(not(windows)) + ], + "@rules_rust//rust/platform:aarch64-apple-ios": [ + "@cu__ansi_term-0.12.1//:ansi_term", # cfg(not(windows)) + ], + "@rules_rust//rust/platform:aarch64-apple-ios-sim": [ + "@cu__ansi_term-0.12.1//:ansi_term", # cfg(not(windows)) + ], + "@rules_rust//rust/platform:aarch64-fuchsia": [ + "@cu__ansi_term-0.12.1//:ansi_term", # cfg(not(windows)) + ], + "@rules_rust//rust/platform:aarch64-linux-android": [ + "@cu__ansi_term-0.12.1//:ansi_term", # cfg(not(windows)) + ], + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [ + "@cu__ansi_term-0.12.1//:ansi_term", # cfg(not(windows)) + ], + "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu": [ + "@cu__ansi_term-0.12.1//:ansi_term", # cfg(not(windows)) + ], + "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710": [ + "@cu__ansi_term-0.12.1//:ansi_term", # cfg(not(windows)) + ], + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi": [ + "@cu__ansi_term-0.12.1//:ansi_term", # cfg(not(windows)) + ], + "@rules_rust//rust/platform:armv7-linux-androideabi": [ + "@cu__ansi_term-0.12.1//:ansi_term", # cfg(not(windows)) + ], + "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi": [ + "@cu__ansi_term-0.12.1//:ansi_term", # cfg(not(windows)) + ], + "@rules_rust//rust/platform:i686-apple-darwin": [ + "@cu__ansi_term-0.12.1//:ansi_term", # cfg(not(windows)) + ], + "@rules_rust//rust/platform:i686-linux-android": [ + "@cu__ansi_term-0.12.1//:ansi_term", # cfg(not(windows)) + ], + "@rules_rust//rust/platform:i686-unknown-freebsd": [ + "@cu__ansi_term-0.12.1//:ansi_term", # cfg(not(windows)) + ], + "@rules_rust//rust/platform:i686-unknown-linux-gnu": [ + "@cu__ansi_term-0.12.1//:ansi_term", # cfg(not(windows)) + ], + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu": [ + "@cu__ansi_term-0.12.1//:ansi_term", # cfg(not(windows)) + ], + "@rules_rust//rust/platform:riscv32imc-unknown-none-elf": [ + "@cu__ansi_term-0.12.1//:ansi_term", # cfg(not(windows)) + ], + "@rules_rust//rust/platform:riscv64gc-unknown-none-elf": [ + "@cu__ansi_term-0.12.1//:ansi_term", # cfg(not(windows)) + ], + "@rules_rust//rust/platform:s390x-unknown-linux-gnu": [ + "@cu__ansi_term-0.12.1//:ansi_term", # cfg(not(windows)) + ], + "@rules_rust//rust/platform:thumbv7em-none-eabi": [ + "@cu__ansi_term-0.12.1//:ansi_term", # cfg(not(windows)) + ], + "@rules_rust//rust/platform:thumbv8m.main-none-eabi": [ + "@cu__ansi_term-0.12.1//:ansi_term", # cfg(not(windows)) + ], + "@rules_rust//rust/platform:wasm32-unknown-unknown": [ + "@cu__ansi_term-0.12.1//:ansi_term", # cfg(not(windows)) + ], + "@rules_rust//rust/platform:wasm32-wasi": [ + "@cu__ansi_term-0.12.1//:ansi_term", # cfg(not(windows)) + ], + "@rules_rust//rust/platform:x86_64-apple-darwin": [ + "@cu__ansi_term-0.12.1//:ansi_term", # cfg(not(windows)) + ], + "@rules_rust//rust/platform:x86_64-apple-ios": [ + "@cu__ansi_term-0.12.1//:ansi_term", # cfg(not(windows)) + ], + "@rules_rust//rust/platform:x86_64-fuchsia": [ + "@cu__ansi_term-0.12.1//:ansi_term", # cfg(not(windows)) + ], + "@rules_rust//rust/platform:x86_64-linux-android": [ + "@cu__ansi_term-0.12.1//:ansi_term", # cfg(not(windows)) + ], + "@rules_rust//rust/platform:x86_64-unknown-freebsd": [ + "@cu__ansi_term-0.12.1//:ansi_term", # cfg(not(windows)) + ], + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [ + "@cu__ansi_term-0.12.1//:ansi_term", # cfg(not(windows)) + ], + "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu": [ + "@cu__ansi_term-0.12.1//:ansi_term", # cfg(not(windows)) + ], + "@rules_rust//rust/platform:x86_64-unknown-none": [ + "@cu__ansi_term-0.12.1//:ansi_term", # cfg(not(windows)) + ], + "//conditions:default": [], + }), +) diff --git a/bazel/cargo/wasmsign/remote/BUILD.ct-codecs-1.1.1.bazel b/bazel/cargo/wasmsign/remote/BUILD.ct-codecs-1.1.1.bazel new file mode 100644 index 000000000..a0cbb9f65 --- /dev/null +++ b/bazel/cargo/wasmsign/remote/BUILD.ct-codecs-1.1.1.bazel @@ -0,0 +1,48 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmsign:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "ct_codecs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + "std", + ], + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=ct-codecs", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.1.1", +) diff --git a/bazel/cargo/wasmsign/remote/BUILD.ed25519-compact-1.0.16.bazel b/bazel/cargo/wasmsign/remote/BUILD.ed25519-compact-1.0.16.bazel new file mode 100644 index 000000000..f0da91e4f --- /dev/null +++ b/bazel/cargo/wasmsign/remote/BUILD.ed25519-compact-1.0.16.bazel @@ -0,0 +1,57 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmsign:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "ed25519_compact", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "ct-codecs", + "default", + "getrandom", + "pem", + "random", + "std", + "x25519", + ], + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=ed25519-compact", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.16", + deps = [ + "@cu__ct-codecs-1.1.1//:ct_codecs", + "@cu__getrandom-0.2.15//:getrandom", + ], +) diff --git a/bazel/cargo/wasmsign/remote/BUILD.getrandom-0.2.15.bazel b/bazel/cargo/wasmsign/remote/BUILD.getrandom-0.2.15.bazel new file mode 100644 index 000000000..619a612bd --- /dev/null +++ b/bazel/cargo/wasmsign/remote/BUILD.getrandom-0.2.15.bazel @@ -0,0 +1,124 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmsign:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "getrandom", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=getrandom", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.2.15", + deps = [ + "@cu__cfg-if-1.0.0//:cfg_if", + ] + select({ + "@rules_rust//rust/platform:aarch64-apple-darwin": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:aarch64-apple-ios": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:aarch64-apple-ios-sim": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:aarch64-fuchsia": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:aarch64-linux-android": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:armv7-linux-androideabi": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:i686-apple-darwin": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:i686-linux-android": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:i686-unknown-freebsd": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:i686-unknown-linux-gnu": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:s390x-unknown-linux-gnu": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:wasm32-wasi": [ + "@cu__wasi-0.11.0-wasi-snapshot-preview1//:wasi", # cfg(target_os = "wasi") + ], + "@rules_rust//rust/platform:x86_64-apple-darwin": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:x86_64-apple-ios": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:x86_64-fuchsia": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:x86_64-linux-android": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:x86_64-unknown-freebsd": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "//conditions:default": [], + }), +) diff --git a/bazel/cargo/wasmsign/remote/BUILD.hermit-abi-0.1.19.bazel b/bazel/cargo/wasmsign/remote/BUILD.hermit-abi-0.1.19.bazel new file mode 100644 index 000000000..2be88f2ce --- /dev/null +++ b/bazel/cargo/wasmsign/remote/BUILD.hermit-abi-0.1.19.bazel @@ -0,0 +1,47 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmsign:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "hermit_abi", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=hermit-abi", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.1.19", + deps = [ + "@cu__libc-0.2.155//:libc", + ], +) diff --git a/bazel/cargo/wasmsign/remote/BUILD.hmac-sha512-1.1.5.bazel b/bazel/cargo/wasmsign/remote/BUILD.hmac-sha512-1.1.5.bazel new file mode 100644 index 000000000..c6f58d5ae --- /dev/null +++ b/bazel/cargo/wasmsign/remote/BUILD.hmac-sha512-1.1.5.bazel @@ -0,0 +1,48 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmsign:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "hmac_sha512", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + "sha384", + ], + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=hmac-sha512", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.1.5", +) diff --git a/bazel/cargo/wasmsign/remote/BUILD.libc-0.2.155.bazel b/bazel/cargo/wasmsign/remote/BUILD.libc-0.2.155.bazel new file mode 100644 index 000000000..61bb833b9 --- /dev/null +++ b/bazel/cargo/wasmsign/remote/BUILD.libc-0.2.155.bazel @@ -0,0 +1,89 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmsign:crates_vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "libc", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=libc", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.2.155", + deps = [ + "@cu__libc-0.2.155//:build_script_build", + ], +) + +cargo_build_script( + name = "libc_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=libc", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.2.155", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = ":libc_bs", + tags = ["manual"], +) diff --git a/bazel/cargo/wasmsign/remote/BUILD.parity-wasm-0.42.2.bazel b/bazel/cargo/wasmsign/remote/BUILD.parity-wasm-0.42.2.bazel new file mode 100644 index 000000000..ad79a67a5 --- /dev/null +++ b/bazel/cargo/wasmsign/remote/BUILD.parity-wasm-0.42.2.bazel @@ -0,0 +1,48 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmsign:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "parity_wasm", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + "std", + ], + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=parity-wasm", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.42.2", +) diff --git a/bazel/cargo/wasmsign/remote/BUILD.proc-macro2-1.0.86.bazel b/bazel/cargo/wasmsign/remote/BUILD.proc-macro2-1.0.86.bazel new file mode 100644 index 000000000..072a238b8 --- /dev/null +++ b/bazel/cargo/wasmsign/remote/BUILD.proc-macro2-1.0.86.bazel @@ -0,0 +1,98 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmsign:crates_vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "proc_macro2", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + "proc-macro", + ], + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=proc-macro2", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.86", + deps = [ + "@cu__proc-macro2-1.0.86//:build_script_build", + "@cu__unicode-ident-1.0.12//:unicode_ident", + ], +) + +cargo_build_script( + name = "proc-macro2_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + crate_features = [ + "default", + "proc-macro", + ], + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=proc-macro2", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.86", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = ":proc-macro2_bs", + tags = ["manual"], +) diff --git a/bazel/cargo/wasmsign/remote/BUILD.quote-1.0.36.bazel b/bazel/cargo/wasmsign/remote/BUILD.quote-1.0.36.bazel new file mode 100644 index 000000000..554f71a78 --- /dev/null +++ b/bazel/cargo/wasmsign/remote/BUILD.quote-1.0.36.bazel @@ -0,0 +1,51 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmsign:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "quote", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + "proc-macro", + ], + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=quote", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.36", + deps = [ + "@cu__proc-macro2-1.0.86//:proc_macro2", + ], +) diff --git a/bazel/cargo/wasmsign/remote/BUILD.strsim-0.8.0.bazel b/bazel/cargo/wasmsign/remote/BUILD.strsim-0.8.0.bazel new file mode 100644 index 000000000..928090c3d --- /dev/null +++ b/bazel/cargo/wasmsign/remote/BUILD.strsim-0.8.0.bazel @@ -0,0 +1,44 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmsign:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "strsim", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=strsim", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.8.0", +) diff --git a/bazel/cargo/wasmsign/remote/BUILD.syn-2.0.72.bazel b/bazel/cargo/wasmsign/remote/BUILD.syn-2.0.72.bazel new file mode 100644 index 000000000..0ac5ed93c --- /dev/null +++ b/bazel/cargo/wasmsign/remote/BUILD.syn-2.0.72.bazel @@ -0,0 +1,57 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmsign:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "syn", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "clone-impls", + "default", + "derive", + "parsing", + "printing", + "proc-macro", + ], + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=syn", + "manual", + "noclippy", + "norustfmt", + ], + version = "2.0.72", + deps = [ + "@cu__proc-macro2-1.0.86//:proc_macro2", + "@cu__quote-1.0.36//:quote", + "@cu__unicode-ident-1.0.12//:unicode_ident", + ], +) diff --git a/bazel/cargo/wasmsign/remote/BUILD.textwrap-0.11.0.bazel b/bazel/cargo/wasmsign/remote/BUILD.textwrap-0.11.0.bazel new file mode 100644 index 000000000..49e49e09e --- /dev/null +++ b/bazel/cargo/wasmsign/remote/BUILD.textwrap-0.11.0.bazel @@ -0,0 +1,47 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmsign:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "textwrap", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=textwrap", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.11.0", + deps = [ + "@cu__unicode-width-0.1.13//:unicode_width", + ], +) diff --git a/bazel/cargo/wasmsign/remote/BUILD.thiserror-1.0.63.bazel b/bazel/cargo/wasmsign/remote/BUILD.thiserror-1.0.63.bazel new file mode 100644 index 000000000..588c5d5c2 --- /dev/null +++ b/bazel/cargo/wasmsign/remote/BUILD.thiserror-1.0.63.bazel @@ -0,0 +1,92 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmsign:crates_vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "thiserror", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2021", + proc_macro_deps = [ + "@cu__thiserror-impl-1.0.63//:thiserror_impl", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=thiserror", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.63", + deps = [ + "@cu__thiserror-1.0.63//:build_script_build", + ], +) + +cargo_build_script( + name = "thiserror_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=thiserror", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.63", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = ":thiserror_bs", + tags = ["manual"], +) diff --git a/bazel/cargo/wasmsign/remote/BUILD.thiserror-impl-1.0.63.bazel b/bazel/cargo/wasmsign/remote/BUILD.thiserror-impl-1.0.63.bazel new file mode 100644 index 000000000..fc2cf7141 --- /dev/null +++ b/bazel/cargo/wasmsign/remote/BUILD.thiserror-impl-1.0.63.bazel @@ -0,0 +1,49 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmsign:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_proc_macro") + +package(default_visibility = ["//visibility:public"]) + +rust_proc_macro( + name = "thiserror_impl", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=thiserror-impl", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.63", + deps = [ + "@cu__proc-macro2-1.0.86//:proc_macro2", + "@cu__quote-1.0.36//:quote", + "@cu__syn-2.0.72//:syn", + ], +) diff --git a/bazel/cargo/wasmsign/remote/BUILD.unicode-ident-1.0.12.bazel b/bazel/cargo/wasmsign/remote/BUILD.unicode-ident-1.0.12.bazel new file mode 100644 index 000000000..caed93c98 --- /dev/null +++ b/bazel/cargo/wasmsign/remote/BUILD.unicode-ident-1.0.12.bazel @@ -0,0 +1,44 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmsign:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "unicode_ident", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=unicode-ident", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.12", +) diff --git a/bazel/cargo/wasmsign/remote/BUILD.unicode-width-0.1.13.bazel b/bazel/cargo/wasmsign/remote/BUILD.unicode-width-0.1.13.bazel new file mode 100644 index 000000000..449da1a99 --- /dev/null +++ b/bazel/cargo/wasmsign/remote/BUILD.unicode-width-0.1.13.bazel @@ -0,0 +1,47 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmsign:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "unicode_width", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + ], + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=unicode-width", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.1.13", +) diff --git a/bazel/cargo/wasmsign/remote/BUILD.vec_map-0.8.2.bazel b/bazel/cargo/wasmsign/remote/BUILD.vec_map-0.8.2.bazel new file mode 100644 index 000000000..21fe8eee8 --- /dev/null +++ b/bazel/cargo/wasmsign/remote/BUILD.vec_map-0.8.2.bazel @@ -0,0 +1,44 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmsign:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "vec_map", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=vec_map", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.8.2", +) diff --git a/bazel/cargo/wasmsign/remote/BUILD.wasi-0.11.0+wasi-snapshot-preview1.bazel b/bazel/cargo/wasmsign/remote/BUILD.wasi-0.11.0+wasi-snapshot-preview1.bazel new file mode 100644 index 000000000..b5ff1e516 --- /dev/null +++ b/bazel/cargo/wasmsign/remote/BUILD.wasi-0.11.0+wasi-snapshot-preview1.bazel @@ -0,0 +1,44 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmsign:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "wasi", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=wasi", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.11.0+wasi-snapshot-preview1", +) diff --git a/bazel/cargo/wasmsign/remote/BUILD.wasmsign-0.1.2.bazel b/bazel/cargo/wasmsign/remote/BUILD.wasmsign-0.1.2.bazel new file mode 100644 index 000000000..07b49f69b --- /dev/null +++ b/bazel/cargo/wasmsign/remote/BUILD.wasmsign-0.1.2.bazel @@ -0,0 +1,100 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmsign:crates_vendor +############################################################################### + +load( + "@rules_rust//rust:defs.bzl", + "rust_binary", + "rust_library", +) + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "wasmsign", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=wasmsign", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.1.2", + deps = [ + "@cu__anyhow-1.0.86//:anyhow", + "@cu__byteorder-1.5.0//:byteorder", + "@cu__clap-2.34.0//:clap", + "@cu__ed25519-compact-1.0.16//:ed25519_compact", + "@cu__hmac-sha512-1.1.5//:hmac_sha512", + "@cu__parity-wasm-0.42.2//:parity_wasm", + "@cu__thiserror-1.0.63//:thiserror", + ], +) + +rust_binary( + name = "wasmsign__bin", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/bin/wasmsign.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=wasmsign", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.1.2", + deps = [ + ":wasmsign", + "@cu__anyhow-1.0.86//:anyhow", + "@cu__byteorder-1.5.0//:byteorder", + "@cu__clap-2.34.0//:clap", + "@cu__ed25519-compact-1.0.16//:ed25519_compact", + "@cu__hmac-sha512-1.1.5//:hmac_sha512", + "@cu__parity-wasm-0.42.2//:parity_wasm", + "@cu__thiserror-1.0.63//:thiserror", + ], +) diff --git a/bazel/cargo/wasmsign/remote/BUILD.winapi-0.3.9.bazel b/bazel/cargo/wasmsign/remote/BUILD.winapi-0.3.9.bazel new file mode 100644 index 000000000..02f57bf83 --- /dev/null +++ b/bazel/cargo/wasmsign/remote/BUILD.winapi-0.3.9.bazel @@ -0,0 +1,103 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmsign:crates_vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "winapi", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "consoleapi", + "minwinbase", + "minwindef", + "processenv", + "winbase", + ], + crate_root = "src/lib.rs", + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=winapi", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.3.9", + deps = [ + "@cu__winapi-0.3.9//:build_script_build", + ], +) + +cargo_build_script( + name = "winapi_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + crate_features = [ + "consoleapi", + "minwinbase", + "minwindef", + "processenv", + "winbase", + ], + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=winapi", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.3.9", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = ":winapi_bs", + tags = ["manual"], +) diff --git a/bazel/cargo/wasmsign/remote/BUILD.winapi-i686-pc-windows-gnu-0.4.0.bazel b/bazel/cargo/wasmsign/remote/BUILD.winapi-i686-pc-windows-gnu-0.4.0.bazel new file mode 100644 index 000000000..c1fb3c90b --- /dev/null +++ b/bazel/cargo/wasmsign/remote/BUILD.winapi-i686-pc-windows-gnu-0.4.0.bazel @@ -0,0 +1,89 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmsign:crates_vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "winapi_i686_pc_windows_gnu", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=winapi-i686-pc-windows-gnu", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.4.0", + deps = [ + "@cu__winapi-i686-pc-windows-gnu-0.4.0//:build_script_build", + ], +) + +cargo_build_script( + name = "winapi-i686-pc-windows-gnu_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=winapi-i686-pc-windows-gnu", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.4.0", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = ":winapi-i686-pc-windows-gnu_bs", + tags = ["manual"], +) diff --git a/bazel/cargo/wasmsign/remote/BUILD.winapi-x86_64-pc-windows-gnu-0.4.0.bazel b/bazel/cargo/wasmsign/remote/BUILD.winapi-x86_64-pc-windows-gnu-0.4.0.bazel new file mode 100644 index 000000000..3468dd114 --- /dev/null +++ b/bazel/cargo/wasmsign/remote/BUILD.winapi-x86_64-pc-windows-gnu-0.4.0.bazel @@ -0,0 +1,89 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmsign:crates_vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "winapi_x86_64_pc_windows_gnu", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=winapi-x86_64-pc-windows-gnu", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.4.0", + deps = [ + "@cu__winapi-x86_64-pc-windows-gnu-0.4.0//:build_script_build", + ], +) + +cargo_build_script( + name = "winapi-x86_64-pc-windows-gnu_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=winapi-x86_64-pc-windows-gnu", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.4.0", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = ":winapi-x86_64-pc-windows-gnu_bs", + tags = ["manual"], +) diff --git a/bazel/cargo/wasmsign/remote/alias_rules.bzl b/bazel/cargo/wasmsign/remote/alias_rules.bzl new file mode 100644 index 000000000..14b04c127 --- /dev/null +++ b/bazel/cargo/wasmsign/remote/alias_rules.bzl @@ -0,0 +1,47 @@ +"""Alias that transitions its target to `compilation_mode=opt`. Use `transition_alias="opt"` to enable.""" + +load("@rules_cc//cc:defs.bzl", "CcInfo") +load("@rules_rust//rust:rust_common.bzl", "COMMON_PROVIDERS") + +def _transition_alias_impl(ctx): + # `ctx.attr.actual` is a list of 1 item due to the transition + providers = [ctx.attr.actual[0][provider] for provider in COMMON_PROVIDERS] + if CcInfo in ctx.attr.actual[0]: + providers.append(ctx.attr.actual[0][CcInfo]) + return providers + +def _change_compilation_mode(compilation_mode): + def _change_compilation_mode_impl(_settings, _attr): + return { + "//command_line_option:compilation_mode": compilation_mode, + } + + return transition( + implementation = _change_compilation_mode_impl, + inputs = [], + outputs = [ + "//command_line_option:compilation_mode", + ], + ) + +def _transition_alias_rule(compilation_mode): + return rule( + implementation = _transition_alias_impl, + provides = COMMON_PROVIDERS, + attrs = { + "actual": attr.label( + mandatory = True, + doc = "`rust_library()` target to transition to `compilation_mode=opt`.", + providers = COMMON_PROVIDERS, + cfg = _change_compilation_mode(compilation_mode), + ), + "_allowlist_function_transition": attr.label( + default = "@bazel_tools//tools/allowlists/function_transition_allowlist", + ), + }, + doc = "Transitions a Rust library crate to the `compilation_mode=opt`.", + ) + +transition_alias_dbg = _transition_alias_rule("dbg") +transition_alias_fastbuild = _transition_alias_rule("fastbuild") +transition_alias_opt = _transition_alias_rule("opt") diff --git a/bazel/cargo/wasmsign/remote/crates.bzl b/bazel/cargo/wasmsign/remote/crates.bzl new file mode 100644 index 000000000..b91fb21aa --- /dev/null +++ b/bazel/cargo/wasmsign/remote/crates.bzl @@ -0,0 +1,32 @@ +############################################################################### +# @generated +# This file is auto-generated by the cargo-bazel tool. +# +# DO NOT MODIFY: Local changes may be replaced in future executions. +############################################################################### +"""Rules for defining repositories for remote `crates_vendor` repositories""" + +load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") + +# buildifier: disable=bzl-visibility +load("@proxy_wasm_cpp_host//bazel/cargo/wasmsign/remote:defs.bzl", _crate_repositories = "crate_repositories") + +# buildifier: disable=bzl-visibility +load("@rules_rust//crate_universe/private:crates_vendor.bzl", "crates_vendor_remote_repository") + +def crate_repositories(): + """Generates repositories for vendored crates. + + Returns: + A list of repos visible to the module through the module extension. + """ + maybe( + crates_vendor_remote_repository, + name = "cu", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmsign/remote:BUILD.bazel"), + defs_module = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmsign/remote:defs.bzl"), + ) + + direct_deps = [struct(repo = "cu", is_dev_dep = False)] + direct_deps.extend(_crate_repositories()) + return direct_deps diff --git a/bazel/cargo/wasmsign/remote/defs.bzl b/bazel/cargo/wasmsign/remote/defs.bzl new file mode 100644 index 000000000..57a80662e --- /dev/null +++ b/bazel/cargo/wasmsign/remote/defs.bzl @@ -0,0 +1,705 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmsign:crates_vendor +############################################################################### +""" +# `crates_repository` API + +- [aliases](#aliases) +- [crate_deps](#crate_deps) +- [all_crate_deps](#all_crate_deps) +- [crate_repositories](#crate_repositories) + +""" + +load("@bazel_skylib//lib:selects.bzl", "selects") +load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") + +############################################################################### +# MACROS API +############################################################################### + +# An identifier that represent common dependencies (unconditional). +_COMMON_CONDITION = "" + +def _flatten_dependency_maps(all_dependency_maps): + """Flatten a list of dependency maps into one dictionary. + + Dependency maps have the following structure: + + ```python + DEPENDENCIES_MAP = { + # The first key in the map is a Bazel package + # name of the workspace this file is defined in. + "workspace_member_package": { + + # Not all dependencies are supported for all platforms. + # the condition key is the condition required to be true + # on the host platform. + "condition": { + + # An alias to a crate target. # The label of the crate target the + # Aliases are only crate names. # package name refers to. + "package_name": "@full//:label", + } + } + } + ``` + + Args: + all_dependency_maps (list): A list of dicts as described above + + Returns: + dict: A dictionary as described above + """ + dependencies = {} + + for workspace_deps_map in all_dependency_maps: + for pkg_name, conditional_deps_map in workspace_deps_map.items(): + if pkg_name not in dependencies: + non_frozen_map = dict() + for key, values in conditional_deps_map.items(): + non_frozen_map.update({key: dict(values.items())}) + dependencies.setdefault(pkg_name, non_frozen_map) + continue + + for condition, deps_map in conditional_deps_map.items(): + # If the condition has not been recorded, do so and continue + if condition not in dependencies[pkg_name]: + dependencies[pkg_name].setdefault(condition, dict(deps_map.items())) + continue + + # Alert on any miss-matched dependencies + inconsistent_entries = [] + for crate_name, crate_label in deps_map.items(): + existing = dependencies[pkg_name][condition].get(crate_name) + if existing and existing != crate_label: + inconsistent_entries.append((crate_name, existing, crate_label)) + dependencies[pkg_name][condition].update({crate_name: crate_label}) + + return dependencies + +def crate_deps(deps, package_name = None): + """Finds the fully qualified label of the requested crates for the package where this macro is called. + + Args: + deps (list): The desired list of crate targets. + package_name (str, optional): The package name of the set of dependencies to look up. + Defaults to `native.package_name()`. + + Returns: + list: A list of labels to generated rust targets (str) + """ + + if not deps: + return [] + + if package_name == None: + package_name = native.package_name() + + # Join both sets of dependencies + dependencies = _flatten_dependency_maps([ + _NORMAL_DEPENDENCIES, + _NORMAL_DEV_DEPENDENCIES, + _PROC_MACRO_DEPENDENCIES, + _PROC_MACRO_DEV_DEPENDENCIES, + _BUILD_DEPENDENCIES, + _BUILD_PROC_MACRO_DEPENDENCIES, + ]).pop(package_name, {}) + + # Combine all conditional packages so we can easily index over a flat list + # TODO: Perhaps this should actually return select statements and maintain + # the conditionals of the dependencies + flat_deps = {} + for deps_set in dependencies.values(): + for crate_name, crate_label in deps_set.items(): + flat_deps.update({crate_name: crate_label}) + + missing_crates = [] + crate_targets = [] + for crate_target in deps: + if crate_target not in flat_deps: + missing_crates.append(crate_target) + else: + crate_targets.append(flat_deps[crate_target]) + + if missing_crates: + fail("Could not find crates `{}` among dependencies of `{}`. Available dependencies were `{}`".format( + missing_crates, + package_name, + dependencies, + )) + + return crate_targets + +def all_crate_deps( + normal = False, + normal_dev = False, + proc_macro = False, + proc_macro_dev = False, + build = False, + build_proc_macro = False, + package_name = None): + """Finds the fully qualified label of all requested direct crate dependencies \ + for the package where this macro is called. + + If no parameters are set, all normal dependencies are returned. Setting any one flag will + otherwise impact the contents of the returned list. + + Args: + normal (bool, optional): If True, normal dependencies are included in the + output list. + normal_dev (bool, optional): If True, normal dev dependencies will be + included in the output list.. + proc_macro (bool, optional): If True, proc_macro dependencies are included + in the output list. + proc_macro_dev (bool, optional): If True, dev proc_macro dependencies are + included in the output list. + build (bool, optional): If True, build dependencies are included + in the output list. + build_proc_macro (bool, optional): If True, build proc_macro dependencies are + included in the output list. + package_name (str, optional): The package name of the set of dependencies to look up. + Defaults to `native.package_name()` when unset. + + Returns: + list: A list of labels to generated rust targets (str) + """ + + if package_name == None: + package_name = native.package_name() + + # Determine the relevant maps to use + all_dependency_maps = [] + if normal: + all_dependency_maps.append(_NORMAL_DEPENDENCIES) + if normal_dev: + all_dependency_maps.append(_NORMAL_DEV_DEPENDENCIES) + if proc_macro: + all_dependency_maps.append(_PROC_MACRO_DEPENDENCIES) + if proc_macro_dev: + all_dependency_maps.append(_PROC_MACRO_DEV_DEPENDENCIES) + if build: + all_dependency_maps.append(_BUILD_DEPENDENCIES) + if build_proc_macro: + all_dependency_maps.append(_BUILD_PROC_MACRO_DEPENDENCIES) + + # Default to always using normal dependencies + if not all_dependency_maps: + all_dependency_maps.append(_NORMAL_DEPENDENCIES) + + dependencies = _flatten_dependency_maps(all_dependency_maps).pop(package_name, None) + + if not dependencies: + if dependencies == None: + fail("Tried to get all_crate_deps for package " + package_name + " but that package had no Cargo.toml file") + else: + return [] + + crate_deps = list(dependencies.pop(_COMMON_CONDITION, {}).values()) + for condition, deps in dependencies.items(): + crate_deps += selects.with_or({ + tuple(_CONDITIONS[condition]): deps.values(), + "//conditions:default": [], + }) + + return crate_deps + +def aliases( + normal = False, + normal_dev = False, + proc_macro = False, + proc_macro_dev = False, + build = False, + build_proc_macro = False, + package_name = None): + """Produces a map of Crate alias names to their original label + + If no dependency kinds are specified, `normal` and `proc_macro` are used by default. + Setting any one flag will otherwise determine the contents of the returned dict. + + Args: + normal (bool, optional): If True, normal dependencies are included in the + output list. + normal_dev (bool, optional): If True, normal dev dependencies will be + included in the output list.. + proc_macro (bool, optional): If True, proc_macro dependencies are included + in the output list. + proc_macro_dev (bool, optional): If True, dev proc_macro dependencies are + included in the output list. + build (bool, optional): If True, build dependencies are included + in the output list. + build_proc_macro (bool, optional): If True, build proc_macro dependencies are + included in the output list. + package_name (str, optional): The package name of the set of dependencies to look up. + Defaults to `native.package_name()` when unset. + + Returns: + dict: The aliases of all associated packages + """ + if package_name == None: + package_name = native.package_name() + + # Determine the relevant maps to use + all_aliases_maps = [] + if normal: + all_aliases_maps.append(_NORMAL_ALIASES) + if normal_dev: + all_aliases_maps.append(_NORMAL_DEV_ALIASES) + if proc_macro: + all_aliases_maps.append(_PROC_MACRO_ALIASES) + if proc_macro_dev: + all_aliases_maps.append(_PROC_MACRO_DEV_ALIASES) + if build: + all_aliases_maps.append(_BUILD_ALIASES) + if build_proc_macro: + all_aliases_maps.append(_BUILD_PROC_MACRO_ALIASES) + + # Default to always using normal aliases + if not all_aliases_maps: + all_aliases_maps.append(_NORMAL_ALIASES) + all_aliases_maps.append(_PROC_MACRO_ALIASES) + + aliases = _flatten_dependency_maps(all_aliases_maps).pop(package_name, None) + + if not aliases: + return dict() + + common_items = aliases.pop(_COMMON_CONDITION, {}).items() + + # If there are only common items in the dictionary, immediately return them + if not len(aliases.keys()) == 1: + return dict(common_items) + + # Build a single select statement where each conditional has accounted for the + # common set of aliases. + crate_aliases = {"//conditions:default": dict(common_items)} + for condition, deps in aliases.items(): + condition_triples = _CONDITIONS[condition] + for triple in condition_triples: + if triple in crate_aliases: + crate_aliases[triple].update(deps) + else: + crate_aliases.update({triple: dict(deps.items() + common_items)}) + + return select(crate_aliases) + +############################################################################### +# WORKSPACE MEMBER DEPS AND ALIASES +############################################################################### + +_NORMAL_DEPENDENCIES = { + "bazel/cargo/wasmsign": { + _COMMON_CONDITION: { + "wasmsign": Label("@cu__wasmsign-0.1.2//:wasmsign"), + }, + }, +} + +_NORMAL_ALIASES = { + "bazel/cargo/wasmsign": { + _COMMON_CONDITION: { + }, + }, +} + +_NORMAL_DEV_DEPENDENCIES = { + "bazel/cargo/wasmsign": { + }, +} + +_NORMAL_DEV_ALIASES = { + "bazel/cargo/wasmsign": { + }, +} + +_PROC_MACRO_DEPENDENCIES = { + "bazel/cargo/wasmsign": { + }, +} + +_PROC_MACRO_ALIASES = { + "bazel/cargo/wasmsign": { + }, +} + +_PROC_MACRO_DEV_DEPENDENCIES = { + "bazel/cargo/wasmsign": { + }, +} + +_PROC_MACRO_DEV_ALIASES = { + "bazel/cargo/wasmsign": { + }, +} + +_BUILD_DEPENDENCIES = { + "bazel/cargo/wasmsign": { + }, +} + +_BUILD_ALIASES = { + "bazel/cargo/wasmsign": { + }, +} + +_BUILD_PROC_MACRO_DEPENDENCIES = { + "bazel/cargo/wasmsign": { + }, +} + +_BUILD_PROC_MACRO_ALIASES = { + "bazel/cargo/wasmsign": { + }, +} + +_CONDITIONS = { + "aarch64-apple-darwin": ["@rules_rust//rust/platform:aarch64-apple-darwin"], + "aarch64-apple-ios": ["@rules_rust//rust/platform:aarch64-apple-ios"], + "aarch64-apple-ios-sim": ["@rules_rust//rust/platform:aarch64-apple-ios-sim"], + "aarch64-fuchsia": ["@rules_rust//rust/platform:aarch64-fuchsia"], + "aarch64-linux-android": ["@rules_rust//rust/platform:aarch64-linux-android"], + "aarch64-pc-windows-msvc": ["@rules_rust//rust/platform:aarch64-pc-windows-msvc"], + "aarch64-unknown-linux-gnu": ["@rules_rust//rust/platform:aarch64-unknown-linux-gnu"], + "aarch64-unknown-nixos-gnu": ["@rules_rust//rust/platform:aarch64-unknown-nixos-gnu"], + "aarch64-unknown-nto-qnx710": ["@rules_rust//rust/platform:aarch64-unknown-nto-qnx710"], + "arm-unknown-linux-gnueabi": ["@rules_rust//rust/platform:arm-unknown-linux-gnueabi"], + "armv7-linux-androideabi": ["@rules_rust//rust/platform:armv7-linux-androideabi"], + "armv7-unknown-linux-gnueabi": ["@rules_rust//rust/platform:armv7-unknown-linux-gnueabi"], + "cfg(not(windows))": ["@rules_rust//rust/platform:aarch64-apple-darwin", "@rules_rust//rust/platform:aarch64-apple-ios", "@rules_rust//rust/platform:aarch64-apple-ios-sim", "@rules_rust//rust/platform:aarch64-fuchsia", "@rules_rust//rust/platform:aarch64-linux-android", "@rules_rust//rust/platform:aarch64-unknown-linux-gnu", "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu", "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710", "@rules_rust//rust/platform:arm-unknown-linux-gnueabi", "@rules_rust//rust/platform:armv7-linux-androideabi", "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi", "@rules_rust//rust/platform:i686-apple-darwin", "@rules_rust//rust/platform:i686-linux-android", "@rules_rust//rust/platform:i686-unknown-freebsd", "@rules_rust//rust/platform:i686-unknown-linux-gnu", "@rules_rust//rust/platform:powerpc-unknown-linux-gnu", "@rules_rust//rust/platform:riscv32imc-unknown-none-elf", "@rules_rust//rust/platform:riscv64gc-unknown-none-elf", "@rules_rust//rust/platform:s390x-unknown-linux-gnu", "@rules_rust//rust/platform:thumbv7em-none-eabi", "@rules_rust//rust/platform:thumbv8m.main-none-eabi", "@rules_rust//rust/platform:wasm32-unknown-unknown", "@rules_rust//rust/platform:wasm32-wasi", "@rules_rust//rust/platform:x86_64-apple-darwin", "@rules_rust//rust/platform:x86_64-apple-ios", "@rules_rust//rust/platform:x86_64-fuchsia", "@rules_rust//rust/platform:x86_64-linux-android", "@rules_rust//rust/platform:x86_64-unknown-freebsd", "@rules_rust//rust/platform:x86_64-unknown-linux-gnu", "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu", "@rules_rust//rust/platform:x86_64-unknown-none"], + "cfg(target_os = \"hermit\")": [], + "cfg(target_os = \"wasi\")": ["@rules_rust//rust/platform:wasm32-wasi"], + "cfg(target_os = \"windows\")": ["@rules_rust//rust/platform:aarch64-pc-windows-msvc", "@rules_rust//rust/platform:i686-pc-windows-msvc", "@rules_rust//rust/platform:x86_64-pc-windows-msvc"], + "cfg(unix)": ["@rules_rust//rust/platform:aarch64-apple-darwin", "@rules_rust//rust/platform:aarch64-apple-ios", "@rules_rust//rust/platform:aarch64-apple-ios-sim", "@rules_rust//rust/platform:aarch64-fuchsia", "@rules_rust//rust/platform:aarch64-linux-android", "@rules_rust//rust/platform:aarch64-unknown-linux-gnu", "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu", "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710", "@rules_rust//rust/platform:arm-unknown-linux-gnueabi", "@rules_rust//rust/platform:armv7-linux-androideabi", "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi", "@rules_rust//rust/platform:i686-apple-darwin", "@rules_rust//rust/platform:i686-linux-android", "@rules_rust//rust/platform:i686-unknown-freebsd", "@rules_rust//rust/platform:i686-unknown-linux-gnu", "@rules_rust//rust/platform:powerpc-unknown-linux-gnu", "@rules_rust//rust/platform:s390x-unknown-linux-gnu", "@rules_rust//rust/platform:x86_64-apple-darwin", "@rules_rust//rust/platform:x86_64-apple-ios", "@rules_rust//rust/platform:x86_64-fuchsia", "@rules_rust//rust/platform:x86_64-linux-android", "@rules_rust//rust/platform:x86_64-unknown-freebsd", "@rules_rust//rust/platform:x86_64-unknown-linux-gnu", "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu"], + "cfg(windows)": ["@rules_rust//rust/platform:aarch64-pc-windows-msvc", "@rules_rust//rust/platform:i686-pc-windows-msvc", "@rules_rust//rust/platform:x86_64-pc-windows-msvc"], + "i686-apple-darwin": ["@rules_rust//rust/platform:i686-apple-darwin"], + "i686-linux-android": ["@rules_rust//rust/platform:i686-linux-android"], + "i686-pc-windows-gnu": [], + "i686-pc-windows-msvc": ["@rules_rust//rust/platform:i686-pc-windows-msvc"], + "i686-unknown-freebsd": ["@rules_rust//rust/platform:i686-unknown-freebsd"], + "i686-unknown-linux-gnu": ["@rules_rust//rust/platform:i686-unknown-linux-gnu"], + "powerpc-unknown-linux-gnu": ["@rules_rust//rust/platform:powerpc-unknown-linux-gnu"], + "riscv32imc-unknown-none-elf": ["@rules_rust//rust/platform:riscv32imc-unknown-none-elf"], + "riscv64gc-unknown-none-elf": ["@rules_rust//rust/platform:riscv64gc-unknown-none-elf"], + "s390x-unknown-linux-gnu": ["@rules_rust//rust/platform:s390x-unknown-linux-gnu"], + "thumbv7em-none-eabi": ["@rules_rust//rust/platform:thumbv7em-none-eabi"], + "thumbv8m.main-none-eabi": ["@rules_rust//rust/platform:thumbv8m.main-none-eabi"], + "wasm32-unknown-unknown": ["@rules_rust//rust/platform:wasm32-unknown-unknown"], + "wasm32-wasi": ["@rules_rust//rust/platform:wasm32-wasi"], + "x86_64-apple-darwin": ["@rules_rust//rust/platform:x86_64-apple-darwin"], + "x86_64-apple-ios": ["@rules_rust//rust/platform:x86_64-apple-ios"], + "x86_64-fuchsia": ["@rules_rust//rust/platform:x86_64-fuchsia"], + "x86_64-linux-android": ["@rules_rust//rust/platform:x86_64-linux-android"], + "x86_64-pc-windows-gnu": [], + "x86_64-pc-windows-msvc": ["@rules_rust//rust/platform:x86_64-pc-windows-msvc"], + "x86_64-unknown-freebsd": ["@rules_rust//rust/platform:x86_64-unknown-freebsd"], + "x86_64-unknown-linux-gnu": ["@rules_rust//rust/platform:x86_64-unknown-linux-gnu"], + "x86_64-unknown-nixos-gnu": ["@rules_rust//rust/platform:x86_64-unknown-nixos-gnu"], + "x86_64-unknown-none": ["@rules_rust//rust/platform:x86_64-unknown-none"], +} + +############################################################################### + +def crate_repositories(): + """A macro for defining repositories for all generated crates. + + Returns: + A list of repos visible to the module through the module extension. + """ + maybe( + http_archive, + name = "cu__ansi_term-0.12.1", + sha256 = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2", + type = "tar.gz", + urls = ["https://static.crates.io/crates/ansi_term/0.12.1/download"], + strip_prefix = "ansi_term-0.12.1", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmsign/remote:BUILD.ansi_term-0.12.1.bazel"), + ) + + maybe( + http_archive, + name = "cu__anyhow-1.0.86", + sha256 = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da", + type = "tar.gz", + urls = ["https://static.crates.io/crates/anyhow/1.0.86/download"], + strip_prefix = "anyhow-1.0.86", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmsign/remote:BUILD.anyhow-1.0.86.bazel"), + ) + + maybe( + http_archive, + name = "cu__atty-0.2.14", + sha256 = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8", + type = "tar.gz", + urls = ["https://static.crates.io/crates/atty/0.2.14/download"], + strip_prefix = "atty-0.2.14", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmsign/remote:BUILD.atty-0.2.14.bazel"), + ) + + maybe( + http_archive, + name = "cu__bitflags-1.3.2", + sha256 = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a", + type = "tar.gz", + urls = ["https://static.crates.io/crates/bitflags/1.3.2/download"], + strip_prefix = "bitflags-1.3.2", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmsign/remote:BUILD.bitflags-1.3.2.bazel"), + ) + + maybe( + http_archive, + name = "cu__byteorder-1.5.0", + sha256 = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b", + type = "tar.gz", + urls = ["https://static.crates.io/crates/byteorder/1.5.0/download"], + strip_prefix = "byteorder-1.5.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmsign/remote:BUILD.byteorder-1.5.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__cfg-if-1.0.0", + sha256 = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd", + type = "tar.gz", + urls = ["https://static.crates.io/crates/cfg-if/1.0.0/download"], + strip_prefix = "cfg-if-1.0.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmsign/remote:BUILD.cfg-if-1.0.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__clap-2.34.0", + sha256 = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c", + type = "tar.gz", + urls = ["https://static.crates.io/crates/clap/2.34.0/download"], + strip_prefix = "clap-2.34.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmsign/remote:BUILD.clap-2.34.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__ct-codecs-1.1.1", + sha256 = "f3b7eb4404b8195a9abb6356f4ac07d8ba267045c8d6d220ac4dc992e6cc75df", + type = "tar.gz", + urls = ["https://static.crates.io/crates/ct-codecs/1.1.1/download"], + strip_prefix = "ct-codecs-1.1.1", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmsign/remote:BUILD.ct-codecs-1.1.1.bazel"), + ) + + maybe( + http_archive, + name = "cu__ed25519-compact-1.0.16", + sha256 = "e18997d4604542d0736fae2c5ad6de987f0a50530cbcc14a7ce5a685328a252d", + type = "tar.gz", + urls = ["https://static.crates.io/crates/ed25519-compact/1.0.16/download"], + strip_prefix = "ed25519-compact-1.0.16", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmsign/remote:BUILD.ed25519-compact-1.0.16.bazel"), + ) + + maybe( + http_archive, + name = "cu__getrandom-0.2.15", + sha256 = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7", + type = "tar.gz", + urls = ["https://static.crates.io/crates/getrandom/0.2.15/download"], + strip_prefix = "getrandom-0.2.15", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmsign/remote:BUILD.getrandom-0.2.15.bazel"), + ) + + maybe( + http_archive, + name = "cu__hermit-abi-0.1.19", + sha256 = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33", + type = "tar.gz", + urls = ["https://static.crates.io/crates/hermit-abi/0.1.19/download"], + strip_prefix = "hermit-abi-0.1.19", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmsign/remote:BUILD.hermit-abi-0.1.19.bazel"), + ) + + maybe( + http_archive, + name = "cu__hmac-sha512-1.1.5", + sha256 = "e4ce1f4656bae589a3fab938f9f09bf58645b7ed01a2c5f8a3c238e01a4ef78a", + type = "tar.gz", + urls = ["https://static.crates.io/crates/hmac-sha512/1.1.5/download"], + strip_prefix = "hmac-sha512-1.1.5", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmsign/remote:BUILD.hmac-sha512-1.1.5.bazel"), + ) + + maybe( + http_archive, + name = "cu__libc-0.2.155", + sha256 = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c", + type = "tar.gz", + urls = ["https://static.crates.io/crates/libc/0.2.155/download"], + strip_prefix = "libc-0.2.155", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmsign/remote:BUILD.libc-0.2.155.bazel"), + ) + + maybe( + http_archive, + name = "cu__parity-wasm-0.42.2", + sha256 = "be5e13c266502aadf83426d87d81a0f5d1ef45b8027f5a471c360abfe4bfae92", + type = "tar.gz", + urls = ["https://static.crates.io/crates/parity-wasm/0.42.2/download"], + strip_prefix = "parity-wasm-0.42.2", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmsign/remote:BUILD.parity-wasm-0.42.2.bazel"), + ) + + maybe( + http_archive, + name = "cu__proc-macro2-1.0.86", + sha256 = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77", + type = "tar.gz", + urls = ["https://static.crates.io/crates/proc-macro2/1.0.86/download"], + strip_prefix = "proc-macro2-1.0.86", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmsign/remote:BUILD.proc-macro2-1.0.86.bazel"), + ) + + maybe( + http_archive, + name = "cu__quote-1.0.36", + sha256 = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7", + type = "tar.gz", + urls = ["https://static.crates.io/crates/quote/1.0.36/download"], + strip_prefix = "quote-1.0.36", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmsign/remote:BUILD.quote-1.0.36.bazel"), + ) + + maybe( + http_archive, + name = "cu__strsim-0.8.0", + sha256 = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a", + type = "tar.gz", + urls = ["https://static.crates.io/crates/strsim/0.8.0/download"], + strip_prefix = "strsim-0.8.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmsign/remote:BUILD.strsim-0.8.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__syn-2.0.72", + sha256 = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af", + type = "tar.gz", + urls = ["https://static.crates.io/crates/syn/2.0.72/download"], + strip_prefix = "syn-2.0.72", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmsign/remote:BUILD.syn-2.0.72.bazel"), + ) + + maybe( + http_archive, + name = "cu__textwrap-0.11.0", + sha256 = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060", + type = "tar.gz", + urls = ["https://static.crates.io/crates/textwrap/0.11.0/download"], + strip_prefix = "textwrap-0.11.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmsign/remote:BUILD.textwrap-0.11.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__thiserror-1.0.63", + sha256 = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724", + type = "tar.gz", + urls = ["https://static.crates.io/crates/thiserror/1.0.63/download"], + strip_prefix = "thiserror-1.0.63", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmsign/remote:BUILD.thiserror-1.0.63.bazel"), + ) + + maybe( + http_archive, + name = "cu__thiserror-impl-1.0.63", + sha256 = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261", + type = "tar.gz", + urls = ["https://static.crates.io/crates/thiserror-impl/1.0.63/download"], + strip_prefix = "thiserror-impl-1.0.63", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmsign/remote:BUILD.thiserror-impl-1.0.63.bazel"), + ) + + maybe( + http_archive, + name = "cu__unicode-ident-1.0.12", + sha256 = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b", + type = "tar.gz", + urls = ["https://static.crates.io/crates/unicode-ident/1.0.12/download"], + strip_prefix = "unicode-ident-1.0.12", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmsign/remote:BUILD.unicode-ident-1.0.12.bazel"), + ) + + maybe( + http_archive, + name = "cu__unicode-width-0.1.13", + sha256 = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d", + type = "tar.gz", + urls = ["https://static.crates.io/crates/unicode-width/0.1.13/download"], + strip_prefix = "unicode-width-0.1.13", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmsign/remote:BUILD.unicode-width-0.1.13.bazel"), + ) + + maybe( + http_archive, + name = "cu__vec_map-0.8.2", + sha256 = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191", + type = "tar.gz", + urls = ["https://static.crates.io/crates/vec_map/0.8.2/download"], + strip_prefix = "vec_map-0.8.2", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmsign/remote:BUILD.vec_map-0.8.2.bazel"), + ) + + maybe( + http_archive, + name = "cu__wasi-0.11.0-wasi-snapshot-preview1", + sha256 = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423", + type = "tar.gz", + urls = ["https://static.crates.io/crates/wasi/0.11.0+wasi-snapshot-preview1/download"], + strip_prefix = "wasi-0.11.0+wasi-snapshot-preview1", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmsign/remote:BUILD.wasi-0.11.0+wasi-snapshot-preview1.bazel"), + ) + + maybe( + new_git_repository, + name = "cu__wasmsign-0.1.2", + commit = "6a6ef1c6f99063a5bd4ef9efc2ee41c5ea8f4f96", + init_submodules = True, + remote = "https://github.com/jedisct1/wasmsign", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmsign/remote:BUILD.wasmsign-0.1.2.bazel"), + ) + + maybe( + http_archive, + name = "cu__winapi-0.3.9", + sha256 = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419", + type = "tar.gz", + urls = ["https://static.crates.io/crates/winapi/0.3.9/download"], + strip_prefix = "winapi-0.3.9", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmsign/remote:BUILD.winapi-0.3.9.bazel"), + ) + + maybe( + http_archive, + name = "cu__winapi-i686-pc-windows-gnu-0.4.0", + sha256 = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6", + type = "tar.gz", + urls = ["https://static.crates.io/crates/winapi-i686-pc-windows-gnu/0.4.0/download"], + strip_prefix = "winapi-i686-pc-windows-gnu-0.4.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmsign/remote:BUILD.winapi-i686-pc-windows-gnu-0.4.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__winapi-x86_64-pc-windows-gnu-0.4.0", + sha256 = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f", + type = "tar.gz", + urls = ["https://static.crates.io/crates/winapi-x86_64-pc-windows-gnu/0.4.0/download"], + strip_prefix = "winapi-x86_64-pc-windows-gnu-0.4.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmsign/remote:BUILD.winapi-x86_64-pc-windows-gnu-0.4.0.bazel"), + ) + + return [ + struct(repo = "cu__wasmsign-0.1.2", is_dev_dep = False), + ] diff --git a/bazel/cargo/wasmtime/BUILD.bazel b/bazel/cargo/wasmtime/BUILD.bazel new file mode 100644 index 000000000..969a2a96a --- /dev/null +++ b/bazel/cargo/wasmtime/BUILD.bazel @@ -0,0 +1,35 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +load("@rules_rust//crate_universe:defs.bzl", "crates_vendor") + +exports_files( + [ + "Cargo.toml", + "Cargo.Bazel.lock", + ], +) + +# Run this target to regenerate cargo_lockfile and vendor_path/*. +# $ bazelisk run bazel/cargo/wasmtime:crates_vendor -- --repin +crates_vendor( + name = "crates_vendor", + cargo_lockfile = ":Cargo.Bazel.lock", + generate_target_compatible_with = False, + manifests = [":Cargo.toml"], + mode = "remote", + repository_name = "cu", # shorten generated paths for Windows... + tags = ["manual"], + vendor_path = "remote", +) diff --git a/bazel/cargo/wasmtime/Cargo.Bazel.lock b/bazel/cargo/wasmtime/Cargo.Bazel.lock new file mode 100644 index 000000000..93579f697 --- /dev/null +++ b/bazel/cargo/wasmtime/Cargo.Bazel.lock @@ -0,0 +1,1031 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "anyhow" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" + +[[package]] +name = "arbitrary" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" + +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + +[[package]] +name = "cc" +version = "1.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "cobs" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15" + +[[package]] +name = "cranelift-bforest" +version = "0.111.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b80c3a50b9c4c7e5b5f73c0ed746687774fc9e36ef652b110da8daebf0c6e0e6" +dependencies = [ + "cranelift-entity", +] + +[[package]] +name = "cranelift-bitset" +version = "0.111.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38778758c2ca918b05acb2199134e0c561fb577c50574259b26190b6c2d95ded" +dependencies = [ + "serde", + "serde_derive", +] + +[[package]] +name = "cranelift-codegen" +version = "0.111.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58258667ad10e468bfc13a8d620f50dfcd4bb35d668123e97defa2549b9ad397" +dependencies = [ + "bumpalo", + "cranelift-bforest", + "cranelift-bitset", + "cranelift-codegen-meta", + "cranelift-codegen-shared", + "cranelift-control", + "cranelift-entity", + "cranelift-isle", + "gimli", + "hashbrown 0.14.5", + "log", + "regalloc2", + "rustc-hash", + "smallvec", + "target-lexicon", +] + +[[package]] +name = "cranelift-codegen-meta" +version = "0.111.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "043f0b702e529dcb07ff92bd7d40e7d5317b5493595172c5eb0983343751ee06" +dependencies = [ + "cranelift-codegen-shared", +] + +[[package]] +name = "cranelift-codegen-shared" +version = "0.111.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7763578888ab53eca5ce7da141953f828e82c2bfadcffc106d10d1866094ffbb" + +[[package]] +name = "cranelift-control" +version = "0.111.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32db15f08c05df570f11e8ab33cb1ec449a64b37c8a3498377b77650bef33d8b" +dependencies = [ + "arbitrary", +] + +[[package]] +name = "cranelift-entity" +version = "0.111.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5289cdb399381a27e7bbfa1b42185916007c3d49aeef70b1d01cb4caa8010130" +dependencies = [ + "cranelift-bitset", + "serde", + "serde_derive", +] + +[[package]] +name = "cranelift-frontend" +version = "0.111.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31ba8ab24eb9470477e98ddfa3c799a649ac5a0d9a2042868c4c952133c234e8" +dependencies = [ + "cranelift-codegen", + "log", + "smallvec", + "target-lexicon", +] + +[[package]] +name = "cranelift-isle" +version = "0.111.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b72a3c5c166a70426dcb209bdd0bb71a787c1ea76023dc0974fbabca770e8f9" + +[[package]] +name = "cranelift-native" +version = "0.111.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46a42424c956bbc31fc5c2706073df896156c5420ae8fa2a5d48dbc7b295d71b" +dependencies = [ + "cranelift-codegen", + "libc", + "target-lexicon", +] + +[[package]] +name = "cranelift-wasm" +version = "0.111.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49778df4289933d735b93c30a345513e030cf83101de0036e19b760f8aa09f68" +dependencies = [ + "cranelift-codegen", + "cranelift-entity", + "cranelift-frontend", + "itertools", + "log", + "smallvec", + "wasmparser", + "wasmtime-types", +] + +[[package]] +name = "crc32fast" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + +[[package]] +name = "embedded-io" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" + +[[package]] +name = "env_logger" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" +dependencies = [ + "humantime", + "is-terminal", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "fallible-iterator" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" + +[[package]] +name = "gimli" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" +dependencies = [ + "fallible-iterator", + "indexmap", + "stable_deref_trait", +] + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash", +] + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash", + "serde", +] + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + +[[package]] +name = "id-arena" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" + +[[package]] +name = "indexmap" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0" +dependencies = [ + "equivalent", + "hashbrown 0.14.5", + "serde", +] + +[[package]] +name = "is-terminal" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys", +] + +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "leb128" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" + +[[package]] +name = "libc" +version = "0.2.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "libm" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" + +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + +[[package]] +name = "log" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" + +[[package]] +name = "mach2" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b955cdeb2a02b9117f121ce63aa52d08ade45de53e48fe6a38b39c10f6f709" +dependencies = [ + "libc", +] + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "memfd" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2cffa4ad52c6f791f4f8b15f0c05f9824b2ced1160e88cc393d64fff9a8ac64" +dependencies = [ + "rustix", +] + +[[package]] +name = "object" +version = "0.36.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f203fa8daa7bb185f760ae12bd8e097f63d17041dcdcaf675ac54cdf863170e" +dependencies = [ + "crc32fast", + "hashbrown 0.14.5", + "indexmap", + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "pin-project-lite" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" + +[[package]] +name = "postcard" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a55c51ee6c0db07e68448e336cf8ea4131a620edefebf9893e759b2d793420f8" +dependencies = [ + "cobs", + "embedded-io", + "serde", +] + +[[package]] +name = "proc-macro2" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "psm" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5787f7cda34e3033a72192c018bc5883100330f362ef279a8cbccfce8bb4e874" +dependencies = [ + "cc", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "regalloc2" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad156d539c879b7a24a363a2016d77961786e71f48f2e2fc8302a92abd2429a6" +dependencies = [ + "hashbrown 0.13.2", + "log", + "rustc-hash", + "slice-group-by", + "smallvec", +] + +[[package]] +name = "regex" +version = "1.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustix" +version = "0.38.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "semver" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" + +[[package]] +name = "serde" +version = "1.0.204" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.204" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.120" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "slice-group-by" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +dependencies = [ + "serde", +] + +[[package]] +name = "sptr" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b9b39299b249ad65f3b7e96443bad61c02ca5cd3589f46cb6d610a0fd6c0d6a" + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "syn" +version = "2.0.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "target-lexicon" +version = "0.12.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" + +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "thiserror" +version = "1.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wasm-encoder" +version = "0.215.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb56df3e06b8e6b77e37d2969a50ba51281029a9aeb3855e76b7f49b6418847" +dependencies = [ + "leb128", +] + +[[package]] +name = "wasmparser" +version = "0.215.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53fbde0881f24199b81cf49b6ff8f9c145ac8eb1b7fc439adb5c099734f7d90e" +dependencies = [ + "ahash", + "bitflags", + "hashbrown 0.14.5", + "indexmap", + "semver", + "serde", +] + +[[package]] +name = "wasmprinter" +version = "0.215.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8e9a325d85053408209b3d2ce5eaddd0dd6864d1cff7a007147ba073157defc" +dependencies = [ + "anyhow", + "termcolor", + "wasmparser", +] + +[[package]] +name = "wasmtime" +version = "24.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a5883d64dfc8423c56e3d8df27cffc44db25336aa468e8e0724fddf30a333d7" +dependencies = [ + "anyhow", + "bitflags", + "bumpalo", + "cc", + "cfg-if", + "hashbrown 0.14.5", + "indexmap", + "libc", + "libm", + "log", + "mach2", + "memfd", + "object", + "once_cell", + "paste", + "postcard", + "psm", + "rustix", + "serde", + "serde_derive", + "smallvec", + "sptr", + "target-lexicon", + "wasmparser", + "wasmtime-asm-macros", + "wasmtime-component-macro", + "wasmtime-cranelift", + "wasmtime-environ", + "wasmtime-jit-icache-coherence", + "wasmtime-slab", + "wasmtime-versioned-export-macros", + "windows-sys", +] + +[[package]] +name = "wasmtime-asm-macros" +version = "24.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c4dc7e2a379c0dd6be5b55857d14c4b277f43a9c429a9e14403eb61776ae3be" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "wasmtime-c-api-bazel" +version = "24.0.0" +dependencies = [ + "anyhow", + "env_logger", + "log", + "once_cell", + "tracing", + "wasmtime", + "wasmtime-c-api-macros", +] + +[[package]] +name = "wasmtime-c-api-macros" +version = "24.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime?tag=v24.0.0#6fc3d274c7994dad20c816ccc0739bf766b39a11" +dependencies = [ + "proc-macro2", + "quote", +] + +[[package]] +name = "wasmtime-component-macro" +version = "24.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b07773d1c3dab5f014ec61316ee317aa424033e17e70a63abdf7c3a47e58fcf" +dependencies = [ + "anyhow", + "proc-macro2", + "quote", + "syn", + "wasmtime-component-util", + "wasmtime-wit-bindgen", + "wit-parser", +] + +[[package]] +name = "wasmtime-component-util" +version = "24.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e38d735320f4e83478369ce649ad8fe87c6b893220902e798547a225fc0c5874" + +[[package]] +name = "wasmtime-cranelift" +version = "24.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e570d831d0785d93d7d8c722b1eb9a34e0d0c1534317666f65892818358a2da9" +dependencies = [ + "anyhow", + "cfg-if", + "cranelift-codegen", + "cranelift-control", + "cranelift-entity", + "cranelift-frontend", + "cranelift-native", + "cranelift-wasm", + "gimli", + "log", + "object", + "target-lexicon", + "thiserror", + "wasmparser", + "wasmtime-environ", + "wasmtime-versioned-export-macros", +] + +[[package]] +name = "wasmtime-environ" +version = "24.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5fe80dfbd81687431a7d4f25929fae1ae96894786d5c96b14ae41164ee97377" +dependencies = [ + "anyhow", + "cranelift-bitset", + "cranelift-entity", + "gimli", + "indexmap", + "log", + "object", + "postcard", + "serde", + "serde_derive", + "target-lexicon", + "wasm-encoder", + "wasmparser", + "wasmprinter", + "wasmtime-types", +] + +[[package]] +name = "wasmtime-jit-icache-coherence" +version = "24.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d15de8429db996f0d17a4163a35eccc3f874cbfb50f29c379951ea1bbb39452e" +dependencies = [ + "anyhow", + "cfg-if", + "libc", + "windows-sys", +] + +[[package]] +name = "wasmtime-slab" +version = "24.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f68d38fa6b30c5e1fc7d608263062997306f79e577ebd197ddcd6b0f55d87d1" + +[[package]] +name = "wasmtime-types" +version = "24.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6634e7079d9c5cfc81af8610ed59b488cc5b7f9777a2f4c1667a2565c2e45249" +dependencies = [ + "anyhow", + "cranelift-entity", + "serde", + "serde_derive", + "smallvec", + "wasmparser", +] + +[[package]] +name = "wasmtime-versioned-export-macros" +version = "24.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3850e3511d6c7f11a72d571890b0ed5f6204681f7f050b9de2690e7f13123fed" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "wasmtime-wit-bindgen" +version = "24.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cb331ac7ed1d5ba49cddcdb6b11973752a857148858bb308777d2fc5584121f" +dependencies = [ + "anyhow", + "heck", + "indexmap", + "wit-parser", +] + +[[package]] +name = "winapi-util" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "wit-parser" +version = "0.215.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "935a97eaffd57c3b413aa510f8f0b550a4a9fe7d59e79cd8b89a83dcb860321f" +dependencies = [ + "anyhow", + "id-arena", + "indexmap", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser", +] + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/bazel/cargo/wasmtime/Cargo.toml b/bazel/cargo/wasmtime/Cargo.toml new file mode 100644 index 000000000..b038be7fd --- /dev/null +++ b/bazel/cargo/wasmtime/Cargo.toml @@ -0,0 +1,31 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +[package] +edition = "2021" +name = "wasmtime-c-api-bazel" +version = "24.0.0" +rust-version = "1.78.0" + +[lib] +path = "fake_lib.rs" + +[dependencies] +env_logger = "0.10" +anyhow = "1.0" +once_cell = "1.12" +log = {version = "0.4.8", default-features = false} +tracing = "0.1.26" +wasmtime = {version = "24.0.0", default-features = false, features = ['cranelift', 'runtime', 'gc', 'std']} +wasmtime-c-api-macros = {git = "https://github.com/bytecodealliance/wasmtime", tag = "v24.0.0"} diff --git a/bazel/cargo/wasmtime/remote/BUILD.ahash-0.8.11.bazel b/bazel/cargo/wasmtime/remote/BUILD.ahash-0.8.11.bazel new file mode 100644 index 000000000..3efe4bb2b --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.ahash-0.8.11.bazel @@ -0,0 +1,192 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "ahash", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=ahash", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.8.11", + deps = [ + "@cu__ahash-0.8.11//:build_script_build", + "@cu__cfg-if-1.0.0//:cfg_if", + "@cu__zerocopy-0.7.35//:zerocopy", + ] + select({ + "@rules_rust//rust/platform:aarch64-apple-darwin": [ + "@cu__once_cell-1.19.0//:once_cell", # cfg(not(all(target_arch = "arm", target_os = "none"))) + ], + "@rules_rust//rust/platform:aarch64-apple-ios": [ + "@cu__once_cell-1.19.0//:once_cell", # cfg(not(all(target_arch = "arm", target_os = "none"))) + ], + "@rules_rust//rust/platform:aarch64-apple-ios-sim": [ + "@cu__once_cell-1.19.0//:once_cell", # cfg(not(all(target_arch = "arm", target_os = "none"))) + ], + "@rules_rust//rust/platform:aarch64-fuchsia": [ + "@cu__once_cell-1.19.0//:once_cell", # cfg(not(all(target_arch = "arm", target_os = "none"))) + ], + "@rules_rust//rust/platform:aarch64-linux-android": [ + "@cu__once_cell-1.19.0//:once_cell", # cfg(not(all(target_arch = "arm", target_os = "none"))) + ], + "@rules_rust//rust/platform:aarch64-pc-windows-msvc": [ + "@cu__once_cell-1.19.0//:once_cell", # cfg(not(all(target_arch = "arm", target_os = "none"))) + ], + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [ + "@cu__once_cell-1.19.0//:once_cell", # cfg(not(all(target_arch = "arm", target_os = "none"))) + ], + "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu": [ + "@cu__once_cell-1.19.0//:once_cell", # cfg(not(all(target_arch = "arm", target_os = "none"))) + ], + "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710": [ + "@cu__once_cell-1.19.0//:once_cell", # cfg(not(all(target_arch = "arm", target_os = "none"))) + ], + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi": [ + "@cu__once_cell-1.19.0//:once_cell", # cfg(not(all(target_arch = "arm", target_os = "none"))) + ], + "@rules_rust//rust/platform:armv7-linux-androideabi": [ + "@cu__once_cell-1.19.0//:once_cell", # cfg(not(all(target_arch = "arm", target_os = "none"))) + ], + "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi": [ + "@cu__once_cell-1.19.0//:once_cell", # cfg(not(all(target_arch = "arm", target_os = "none"))) + ], + "@rules_rust//rust/platform:i686-apple-darwin": [ + "@cu__once_cell-1.19.0//:once_cell", # cfg(not(all(target_arch = "arm", target_os = "none"))) + ], + "@rules_rust//rust/platform:i686-linux-android": [ + "@cu__once_cell-1.19.0//:once_cell", # cfg(not(all(target_arch = "arm", target_os = "none"))) + ], + "@rules_rust//rust/platform:i686-pc-windows-msvc": [ + "@cu__once_cell-1.19.0//:once_cell", # cfg(not(all(target_arch = "arm", target_os = "none"))) + ], + "@rules_rust//rust/platform:i686-unknown-freebsd": [ + "@cu__once_cell-1.19.0//:once_cell", # cfg(not(all(target_arch = "arm", target_os = "none"))) + ], + "@rules_rust//rust/platform:i686-unknown-linux-gnu": [ + "@cu__once_cell-1.19.0//:once_cell", # cfg(not(all(target_arch = "arm", target_os = "none"))) + ], + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu": [ + "@cu__once_cell-1.19.0//:once_cell", # cfg(not(all(target_arch = "arm", target_os = "none"))) + ], + "@rules_rust//rust/platform:riscv32imc-unknown-none-elf": [ + "@cu__once_cell-1.19.0//:once_cell", # cfg(not(all(target_arch = "arm", target_os = "none"))) + ], + "@rules_rust//rust/platform:riscv64gc-unknown-none-elf": [ + "@cu__once_cell-1.19.0//:once_cell", # cfg(not(all(target_arch = "arm", target_os = "none"))) + ], + "@rules_rust//rust/platform:s390x-unknown-linux-gnu": [ + "@cu__once_cell-1.19.0//:once_cell", # cfg(not(all(target_arch = "arm", target_os = "none"))) + ], + "@rules_rust//rust/platform:wasm32-unknown-unknown": [ + "@cu__once_cell-1.19.0//:once_cell", # cfg(not(all(target_arch = "arm", target_os = "none"))) + ], + "@rules_rust//rust/platform:wasm32-wasi": [ + "@cu__once_cell-1.19.0//:once_cell", # cfg(not(all(target_arch = "arm", target_os = "none"))) + ], + "@rules_rust//rust/platform:x86_64-apple-darwin": [ + "@cu__once_cell-1.19.0//:once_cell", # cfg(not(all(target_arch = "arm", target_os = "none"))) + ], + "@rules_rust//rust/platform:x86_64-apple-ios": [ + "@cu__once_cell-1.19.0//:once_cell", # cfg(not(all(target_arch = "arm", target_os = "none"))) + ], + "@rules_rust//rust/platform:x86_64-fuchsia": [ + "@cu__once_cell-1.19.0//:once_cell", # cfg(not(all(target_arch = "arm", target_os = "none"))) + ], + "@rules_rust//rust/platform:x86_64-linux-android": [ + "@cu__once_cell-1.19.0//:once_cell", # cfg(not(all(target_arch = "arm", target_os = "none"))) + ], + "@rules_rust//rust/platform:x86_64-pc-windows-msvc": [ + "@cu__once_cell-1.19.0//:once_cell", # cfg(not(all(target_arch = "arm", target_os = "none"))) + ], + "@rules_rust//rust/platform:x86_64-unknown-freebsd": [ + "@cu__once_cell-1.19.0//:once_cell", # cfg(not(all(target_arch = "arm", target_os = "none"))) + ], + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [ + "@cu__once_cell-1.19.0//:once_cell", # cfg(not(all(target_arch = "arm", target_os = "none"))) + ], + "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu": [ + "@cu__once_cell-1.19.0//:once_cell", # cfg(not(all(target_arch = "arm", target_os = "none"))) + ], + "@rules_rust//rust/platform:x86_64-unknown-none": [ + "@cu__once_cell-1.19.0//:once_cell", # cfg(not(all(target_arch = "arm", target_os = "none"))) + ], + "//conditions:default": [], + }), +) + +cargo_build_script( + name = "ahash_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=ahash", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.8.11", + visibility = ["//visibility:private"], + deps = [ + "@cu__version_check-0.9.5//:version_check", + ], +) + +alias( + name = "build_script_build", + actual = ":ahash_bs", + tags = ["manual"], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.aho-corasick-1.1.3.bazel b/bazel/cargo/wasmtime/remote/BUILD.aho-corasick-1.1.3.bazel new file mode 100644 index 000000000..193a2843c --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.aho-corasick-1.1.3.bazel @@ -0,0 +1,51 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "aho_corasick", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "perf-literal", + "std", + ], + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=aho-corasick", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.1.3", + deps = [ + "@cu__memchr-2.7.4//:memchr", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.anyhow-1.0.86.bazel b/bazel/cargo/wasmtime/remote/BUILD.anyhow-1.0.86.bazel new file mode 100644 index 000000000..3021b737f --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.anyhow-1.0.86.bazel @@ -0,0 +1,97 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "anyhow", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + "std", + ], + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=anyhow", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.86", + deps = [ + "@cu__anyhow-1.0.86//:build_script_build", + ], +) + +cargo_build_script( + name = "anyhow_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + crate_features = [ + "default", + "std", + ], + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=anyhow", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.86", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = ":anyhow_bs", + tags = ["manual"], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.arbitrary-1.3.2.bazel b/bazel/cargo/wasmtime/remote/BUILD.arbitrary-1.3.2.bazel new file mode 100644 index 000000000..d36ba3e9a --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.arbitrary-1.3.2.bazel @@ -0,0 +1,44 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "arbitrary", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=arbitrary", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.3.2", +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.bazel b/bazel/cargo/wasmtime/remote/BUILD.bazel new file mode 100644 index 000000000..db793c6e6 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.bazel @@ -0,0 +1,74 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +package(default_visibility = ["//visibility:public"]) + +exports_files( + [ + "cargo-bazel.json", + "crates.bzl", + "defs.bzl", + ] + glob( + include = ["*.bazel"], + allow_empty = True, + ), +) + +filegroup( + name = "srcs", + srcs = glob( + include = [ + "*.bazel", + "*.bzl", + ], + allow_empty = True, + ), +) + +# Workspace Member Dependencies +alias( + name = "anyhow", + actual = "@cu__anyhow-1.0.86//:anyhow", + tags = ["manual"], +) + +alias( + name = "env_logger", + actual = "@cu__env_logger-0.10.2//:env_logger", + tags = ["manual"], +) + +alias( + name = "log", + actual = "@cu__log-0.4.22//:log", + tags = ["manual"], +) + +alias( + name = "once_cell", + actual = "@cu__once_cell-1.19.0//:once_cell", + tags = ["manual"], +) + +alias( + name = "tracing", + actual = "@cu__tracing-0.1.40//:tracing", + tags = ["manual"], +) + +alias( + name = "wasmtime", + actual = "@cu__wasmtime-24.0.0//:wasmtime", + tags = ["manual"], +) + +alias( + name = "wasmtime-c-api-macros", + actual = "@cu__wasmtime-c-api-macros-24.0.0//:wasmtime_c_api_macros", + tags = ["manual"], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.bitflags-2.6.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.bitflags-2.6.0.bazel new file mode 100644 index 000000000..31767882b --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.bitflags-2.6.0.bazel @@ -0,0 +1,119 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "bitflags", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = select({ + "@rules_rust//rust/platform:aarch64-apple-darwin": [ + "std", # aarch64-apple-darwin + ], + "@rules_rust//rust/platform:aarch64-apple-ios": [ + "std", # aarch64-apple-ios + ], + "@rules_rust//rust/platform:aarch64-apple-ios-sim": [ + "std", # aarch64-apple-ios-sim + ], + "@rules_rust//rust/platform:aarch64-fuchsia": [ + "std", # aarch64-fuchsia + ], + "@rules_rust//rust/platform:aarch64-linux-android": [ + "std", # aarch64-linux-android + ], + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [ + "std", # aarch64-unknown-linux-gnu + ], + "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu": [ + "std", # aarch64-unknown-nixos-gnu + ], + "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710": [ + "std", # aarch64-unknown-nto-qnx710 + ], + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi": [ + "std", # arm-unknown-linux-gnueabi + ], + "@rules_rust//rust/platform:armv7-linux-androideabi": [ + "std", # armv7-linux-androideabi + ], + "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi": [ + "std", # armv7-unknown-linux-gnueabi + ], + "@rules_rust//rust/platform:i686-apple-darwin": [ + "std", # i686-apple-darwin + ], + "@rules_rust//rust/platform:i686-linux-android": [ + "std", # i686-linux-android + ], + "@rules_rust//rust/platform:i686-unknown-freebsd": [ + "std", # i686-unknown-freebsd + ], + "@rules_rust//rust/platform:i686-unknown-linux-gnu": [ + "std", # i686-unknown-linux-gnu + ], + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu": [ + "std", # powerpc-unknown-linux-gnu + ], + "@rules_rust//rust/platform:s390x-unknown-linux-gnu": [ + "std", # s390x-unknown-linux-gnu + ], + "@rules_rust//rust/platform:x86_64-apple-darwin": [ + "std", # x86_64-apple-darwin + ], + "@rules_rust//rust/platform:x86_64-apple-ios": [ + "std", # x86_64-apple-ios + ], + "@rules_rust//rust/platform:x86_64-fuchsia": [ + "std", # x86_64-fuchsia + ], + "@rules_rust//rust/platform:x86_64-linux-android": [ + "std", # x86_64-linux-android + ], + "@rules_rust//rust/platform:x86_64-unknown-freebsd": [ + "std", # x86_64-unknown-freebsd + ], + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [ + "std", # x86_64-unknown-linux-gnu + ], + "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu": [ + "std", # x86_64-unknown-nixos-gnu + ], + "//conditions:default": [], + }), + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=bitflags", + "manual", + "noclippy", + "norustfmt", + ], + version = "2.6.0", +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.bumpalo-3.16.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.bumpalo-3.16.0.bazel new file mode 100644 index 000000000..2dd737714 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.bumpalo-3.16.0.bazel @@ -0,0 +1,47 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "bumpalo", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + ], + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=bumpalo", + "manual", + "noclippy", + "norustfmt", + ], + version = "3.16.0", +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.cc-1.1.7.bazel b/bazel/cargo/wasmtime/remote/BUILD.cc-1.1.7.bazel new file mode 100644 index 000000000..14f88e535 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.cc-1.1.7.bazel @@ -0,0 +1,44 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "cc", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=cc", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.1.7", +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.cfg-if-1.0.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.cfg-if-1.0.0.bazel new file mode 100644 index 000000000..f9019274b --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.cfg-if-1.0.0.bazel @@ -0,0 +1,44 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "cfg_if", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=cfg-if", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.0", +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.cobs-0.2.3.bazel b/bazel/cargo/wasmtime/remote/BUILD.cobs-0.2.3.bazel new file mode 100644 index 000000000..00da2e823 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.cobs-0.2.3.bazel @@ -0,0 +1,44 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "cobs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=cobs", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.2.3", +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.cranelift-bforest-0.111.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.cranelift-bforest-0.111.0.bazel new file mode 100644 index 000000000..a4651a993 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.cranelift-bforest-0.111.0.bazel @@ -0,0 +1,47 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "cranelift_bforest", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=cranelift-bforest", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.111.0", + deps = [ + "@cu__cranelift-entity-0.111.0//:cranelift_entity", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.cranelift-bitset-0.111.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.cranelift-bitset-0.111.0.bazel new file mode 100644 index 000000000..7d70417f0 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.cranelift-bitset-0.111.0.bazel @@ -0,0 +1,53 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "cranelift_bitset", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "enable-serde", + ], + crate_root = "src/lib.rs", + edition = "2021", + proc_macro_deps = [ + "@cu__serde_derive-1.0.204//:serde_derive", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=cranelift-bitset", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.111.0", + deps = [ + "@cu__serde-1.0.204//:serde", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.cranelift-codegen-0.111.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.cranelift-codegen-0.111.0.bazel new file mode 100644 index 000000000..cb569892f --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.cranelift-codegen-0.111.0.bazel @@ -0,0 +1,120 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "cranelift_codegen", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "gimli", + "host-arch", + "std", + "trace-log", + "unwind", + ], + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=cranelift-codegen", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.111.0", + deps = [ + "@cu__bumpalo-3.16.0//:bumpalo", + "@cu__cranelift-bforest-0.111.0//:cranelift_bforest", + "@cu__cranelift-bitset-0.111.0//:cranelift_bitset", + "@cu__cranelift-codegen-0.111.0//:build_script_build", + "@cu__cranelift-codegen-shared-0.111.0//:cranelift_codegen_shared", + "@cu__cranelift-control-0.111.0//:cranelift_control", + "@cu__cranelift-entity-0.111.0//:cranelift_entity", + "@cu__gimli-0.29.0//:gimli", + "@cu__hashbrown-0.14.5//:hashbrown", + "@cu__log-0.4.22//:log", + "@cu__regalloc2-0.9.3//:regalloc2", + "@cu__rustc-hash-1.1.0//:rustc_hash", + "@cu__smallvec-1.13.2//:smallvec", + "@cu__target-lexicon-0.12.16//:target_lexicon", + ], +) + +cargo_build_script( + name = "cranelift-codegen_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + crate_features = [ + "gimli", + "host-arch", + "std", + "trace-log", + "unwind", + ], + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=cranelift-codegen", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.111.0", + visibility = ["//visibility:private"], + deps = [ + "@cu__cranelift-codegen-meta-0.111.0//:cranelift_codegen_meta", + "@cu__cranelift-isle-0.111.0//:cranelift_isle", + ], +) + +alias( + name = "build_script_build", + actual = ":cranelift-codegen_bs", + tags = ["manual"], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.cranelift-codegen-meta-0.111.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.cranelift-codegen-meta-0.111.0.bazel new file mode 100644 index 000000000..9ccb599a1 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.cranelift-codegen-meta-0.111.0.bazel @@ -0,0 +1,47 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "cranelift_codegen_meta", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=cranelift-codegen-meta", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.111.0", + deps = [ + "@cu__cranelift-codegen-shared-0.111.0//:cranelift_codegen_shared", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.cranelift-codegen-shared-0.111.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.cranelift-codegen-shared-0.111.0.bazel new file mode 100644 index 000000000..8820100ff --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.cranelift-codegen-shared-0.111.0.bazel @@ -0,0 +1,44 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "cranelift_codegen_shared", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=cranelift-codegen-shared", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.111.0", +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.cranelift-control-0.111.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.cranelift-control-0.111.0.bazel new file mode 100644 index 000000000..51c64ada2 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.cranelift-control-0.111.0.bazel @@ -0,0 +1,51 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "cranelift_control", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + "fuzz", + ], + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=cranelift-control", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.111.0", + deps = [ + "@cu__arbitrary-1.3.2//:arbitrary", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.cranelift-entity-0.111.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.cranelift-entity-0.111.0.bazel new file mode 100644 index 000000000..f59f1f47b --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.cranelift-entity-0.111.0.bazel @@ -0,0 +1,56 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "cranelift_entity", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "enable-serde", + "serde", + "serde_derive", + ], + crate_root = "src/lib.rs", + edition = "2021", + proc_macro_deps = [ + "@cu__serde_derive-1.0.204//:serde_derive", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=cranelift-entity", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.111.0", + deps = [ + "@cu__cranelift-bitset-0.111.0//:cranelift_bitset", + "@cu__serde-1.0.204//:serde", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.cranelift-frontend-0.111.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.cranelift-frontend-0.111.0.bazel new file mode 100644 index 000000000..b1ae57324 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.cranelift-frontend-0.111.0.bazel @@ -0,0 +1,54 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "cranelift_frontend", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + "std", + ], + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=cranelift-frontend", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.111.0", + deps = [ + "@cu__cranelift-codegen-0.111.0//:cranelift_codegen", + "@cu__log-0.4.22//:log", + "@cu__smallvec-1.13.2//:smallvec", + "@cu__target-lexicon-0.12.16//:target_lexicon", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.cranelift-isle-0.111.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.cranelift-isle-0.111.0.bazel new file mode 100644 index 000000000..687a5406a --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.cranelift-isle-0.111.0.bazel @@ -0,0 +1,95 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "cranelift_isle", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + ], + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=cranelift-isle", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.111.0", + deps = [ + "@cu__cranelift-isle-0.111.0//:build_script_build", + ], +) + +cargo_build_script( + name = "cranelift-isle_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + crate_features = [ + "default", + ], + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=cranelift-isle", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.111.0", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = ":cranelift-isle_bs", + tags = ["manual"], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.cranelift-native-0.111.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.cranelift-native-0.111.0.bazel new file mode 100644 index 000000000..c6b0a99f0 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.cranelift-native-0.111.0.bazel @@ -0,0 +1,60 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "cranelift_native", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + "std", + ], + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=cranelift-native", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.111.0", + deps = [ + "@cu__cranelift-codegen-0.111.0//:cranelift_codegen", + "@cu__target-lexicon-0.12.16//:target_lexicon", + ] + select({ + "@rules_rust//rust/platform:riscv64gc-unknown-none-elf": [ + "@cu__libc-0.2.155//:libc", # cfg(any(target_arch = "s390x", target_arch = "riscv64")) + ], + "@rules_rust//rust/platform:s390x-unknown-linux-gnu": [ + "@cu__libc-0.2.155//:libc", # cfg(any(target_arch = "s390x", target_arch = "riscv64")) + ], + "//conditions:default": [], + }), +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.cranelift-wasm-0.111.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.cranelift-wasm-0.111.0.bazel new file mode 100644 index 000000000..38d4bb412 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.cranelift-wasm-0.111.0.bazel @@ -0,0 +1,58 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "cranelift_wasm", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + "std", + ], + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=cranelift-wasm", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.111.0", + deps = [ + "@cu__cranelift-codegen-0.111.0//:cranelift_codegen", + "@cu__cranelift-entity-0.111.0//:cranelift_entity", + "@cu__cranelift-frontend-0.111.0//:cranelift_frontend", + "@cu__itertools-0.12.1//:itertools", + "@cu__log-0.4.22//:log", + "@cu__smallvec-1.13.2//:smallvec", + "@cu__wasmparser-0.215.0//:wasmparser", + "@cu__wasmtime-types-24.0.0//:wasmtime_types", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.crc32fast-1.4.2.bazel b/bazel/cargo/wasmtime/remote/BUILD.crc32fast-1.4.2.bazel new file mode 100644 index 000000000..063a0afb7 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.crc32fast-1.4.2.bazel @@ -0,0 +1,50 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "crc32fast", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "std", + ], + crate_root = "src/lib.rs", + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=crc32fast", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.4.2", + deps = [ + "@cu__cfg-if-1.0.0//:cfg_if", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.either-1.13.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.either-1.13.0.bazel new file mode 100644 index 000000000..043006849 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.either-1.13.0.bazel @@ -0,0 +1,47 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "either", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "use_std", + ], + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=either", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.13.0", +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.embedded-io-0.4.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.embedded-io-0.4.0.bazel new file mode 100644 index 000000000..c9ef73301 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.embedded-io-0.4.0.bazel @@ -0,0 +1,47 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "embedded_io", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "alloc", + ], + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=embedded-io", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.4.0", +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.env_logger-0.10.2.bazel b/bazel/cargo/wasmtime/remote/BUILD.env_logger-0.10.2.bazel new file mode 100644 index 000000000..ce9eb6262 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.env_logger-0.10.2.bazel @@ -0,0 +1,58 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "env_logger", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "auto-color", + "color", + "default", + "humantime", + "regex", + ], + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=env_logger", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.10.2", + deps = [ + "@cu__humantime-2.1.0//:humantime", + "@cu__is-terminal-0.4.12//:is_terminal", + "@cu__log-0.4.22//:log", + "@cu__regex-1.10.5//:regex", + "@cu__termcolor-1.4.1//:termcolor", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.equivalent-1.0.1.bazel b/bazel/cargo/wasmtime/remote/BUILD.equivalent-1.0.1.bazel new file mode 100644 index 000000000..c3be9a81d --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.equivalent-1.0.1.bazel @@ -0,0 +1,44 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "equivalent", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=equivalent", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.1", +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.errno-0.3.9.bazel b/bazel/cargo/wasmtime/remote/BUILD.errno-0.3.9.bazel new file mode 100644 index 000000000..904e5aba0 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.errno-0.3.9.bazel @@ -0,0 +1,134 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "errno", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "std", + ], + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=errno", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.3.9", + deps = select({ + "@rules_rust//rust/platform:aarch64-apple-darwin": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:aarch64-apple-ios": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:aarch64-apple-ios-sim": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:aarch64-fuchsia": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:aarch64-linux-android": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:aarch64-pc-windows-msvc": [ + "@cu__windows-sys-0.52.0//:windows_sys", # cfg(windows) + ], + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:armv7-linux-androideabi": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:i686-apple-darwin": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:i686-linux-android": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:i686-pc-windows-msvc": [ + "@cu__windows-sys-0.52.0//:windows_sys", # cfg(windows) + ], + "@rules_rust//rust/platform:i686-unknown-freebsd": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:i686-unknown-linux-gnu": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:s390x-unknown-linux-gnu": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:wasm32-wasi": [ + "@cu__libc-0.2.155//:libc", # cfg(target_os = "wasi") + ], + "@rules_rust//rust/platform:x86_64-apple-darwin": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:x86_64-apple-ios": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:x86_64-fuchsia": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:x86_64-linux-android": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:x86_64-pc-windows-msvc": [ + "@cu__windows-sys-0.52.0//:windows_sys", # cfg(windows) + ], + "@rules_rust//rust/platform:x86_64-unknown-freebsd": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu": [ + "@cu__libc-0.2.155//:libc", # cfg(unix) + ], + "//conditions:default": [], + }), +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.fallible-iterator-0.3.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.fallible-iterator-0.3.0.bazel new file mode 100644 index 000000000..b2bdbf6fc --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.fallible-iterator-0.3.0.bazel @@ -0,0 +1,44 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "fallible_iterator", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=fallible-iterator", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.3.0", +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.gimli-0.29.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.gimli-0.29.0.bazel new file mode 100644 index 000000000..852f5bdee --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.gimli-0.29.0.bazel @@ -0,0 +1,53 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "gimli", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "read", + "read-core", + "std", + "write", + ], + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=gimli", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.29.0", + deps = [ + "@cu__indexmap-2.3.0//:indexmap", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.hashbrown-0.13.2.bazel b/bazel/cargo/wasmtime/remote/BUILD.hashbrown-0.13.2.bazel new file mode 100644 index 000000000..4bcf220d3 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.hashbrown-0.13.2.bazel @@ -0,0 +1,52 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "hashbrown", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "ahash", + "default", + "inline-more", + ], + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=hashbrown", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.13.2", + deps = [ + "@cu__ahash-0.8.11//:ahash", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.hashbrown-0.14.5.bazel b/bazel/cargo/wasmtime/remote/BUILD.hashbrown-0.14.5.bazel new file mode 100644 index 000000000..921bfbbea --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.hashbrown-0.14.5.bazel @@ -0,0 +1,53 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "hashbrown", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "ahash", + "raw", + "serde", + ], + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=hashbrown", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.14.5", + deps = [ + "@cu__ahash-0.8.11//:ahash", + "@cu__serde-1.0.204//:serde", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.heck-0.4.1.bazel b/bazel/cargo/wasmtime/remote/BUILD.heck-0.4.1.bazel new file mode 100644 index 000000000..5f94cda10 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.heck-0.4.1.bazel @@ -0,0 +1,44 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "heck", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=heck", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.4.1", +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.hermit-abi-0.3.9.bazel b/bazel/cargo/wasmtime/remote/BUILD.hermit-abi-0.3.9.bazel new file mode 100644 index 000000000..75dff9155 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.hermit-abi-0.3.9.bazel @@ -0,0 +1,44 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "hermit_abi", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=hermit-abi", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.3.9", +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.humantime-2.1.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.humantime-2.1.0.bazel new file mode 100644 index 000000000..d1691cafd --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.humantime-2.1.0.bazel @@ -0,0 +1,44 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "humantime", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=humantime", + "manual", + "noclippy", + "norustfmt", + ], + version = "2.1.0", +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.id-arena-2.2.1.bazel b/bazel/cargo/wasmtime/remote/BUILD.id-arena-2.2.1.bazel new file mode 100644 index 000000000..1248a97fb --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.id-arena-2.2.1.bazel @@ -0,0 +1,44 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "id_arena", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=id-arena", + "manual", + "noclippy", + "norustfmt", + ], + version = "2.2.1", +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.indexmap-2.3.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.indexmap-2.3.0.bazel new file mode 100644 index 000000000..07d4be633 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.indexmap-2.3.0.bazel @@ -0,0 +1,54 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "indexmap", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + "serde", + "std", + ], + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=indexmap", + "manual", + "noclippy", + "norustfmt", + ], + version = "2.3.0", + deps = [ + "@cu__equivalent-1.0.1//:equivalent", + "@cu__hashbrown-0.14.5//:hashbrown", + "@cu__serde-1.0.204//:serde", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.is-terminal-0.4.12.bazel b/bazel/cargo/wasmtime/remote/BUILD.is-terminal-0.4.12.bazel new file mode 100644 index 000000000..84a3f0fb0 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.is-terminal-0.4.12.bazel @@ -0,0 +1,131 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "is_terminal", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=is-terminal", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.4.12", + deps = select({ + "@rules_rust//rust/platform:aarch64-apple-darwin": [ + "@cu__libc-0.2.155//:libc", # cfg(any(unix, target_os = "wasi")) + ], + "@rules_rust//rust/platform:aarch64-apple-ios": [ + "@cu__libc-0.2.155//:libc", # cfg(any(unix, target_os = "wasi")) + ], + "@rules_rust//rust/platform:aarch64-apple-ios-sim": [ + "@cu__libc-0.2.155//:libc", # cfg(any(unix, target_os = "wasi")) + ], + "@rules_rust//rust/platform:aarch64-fuchsia": [ + "@cu__libc-0.2.155//:libc", # cfg(any(unix, target_os = "wasi")) + ], + "@rules_rust//rust/platform:aarch64-linux-android": [ + "@cu__libc-0.2.155//:libc", # cfg(any(unix, target_os = "wasi")) + ], + "@rules_rust//rust/platform:aarch64-pc-windows-msvc": [ + "@cu__windows-sys-0.52.0//:windows_sys", # cfg(windows) + ], + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [ + "@cu__libc-0.2.155//:libc", # cfg(any(unix, target_os = "wasi")) + ], + "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu": [ + "@cu__libc-0.2.155//:libc", # cfg(any(unix, target_os = "wasi")) + ], + "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710": [ + "@cu__libc-0.2.155//:libc", # cfg(any(unix, target_os = "wasi")) + ], + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi": [ + "@cu__libc-0.2.155//:libc", # cfg(any(unix, target_os = "wasi")) + ], + "@rules_rust//rust/platform:armv7-linux-androideabi": [ + "@cu__libc-0.2.155//:libc", # cfg(any(unix, target_os = "wasi")) + ], + "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi": [ + "@cu__libc-0.2.155//:libc", # cfg(any(unix, target_os = "wasi")) + ], + "@rules_rust//rust/platform:i686-apple-darwin": [ + "@cu__libc-0.2.155//:libc", # cfg(any(unix, target_os = "wasi")) + ], + "@rules_rust//rust/platform:i686-linux-android": [ + "@cu__libc-0.2.155//:libc", # cfg(any(unix, target_os = "wasi")) + ], + "@rules_rust//rust/platform:i686-pc-windows-msvc": [ + "@cu__windows-sys-0.52.0//:windows_sys", # cfg(windows) + ], + "@rules_rust//rust/platform:i686-unknown-freebsd": [ + "@cu__libc-0.2.155//:libc", # cfg(any(unix, target_os = "wasi")) + ], + "@rules_rust//rust/platform:i686-unknown-linux-gnu": [ + "@cu__libc-0.2.155//:libc", # cfg(any(unix, target_os = "wasi")) + ], + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu": [ + "@cu__libc-0.2.155//:libc", # cfg(any(unix, target_os = "wasi")) + ], + "@rules_rust//rust/platform:s390x-unknown-linux-gnu": [ + "@cu__libc-0.2.155//:libc", # cfg(any(unix, target_os = "wasi")) + ], + "@rules_rust//rust/platform:wasm32-wasi": [ + "@cu__libc-0.2.155//:libc", # cfg(any(unix, target_os = "wasi")) + ], + "@rules_rust//rust/platform:x86_64-apple-darwin": [ + "@cu__libc-0.2.155//:libc", # cfg(any(unix, target_os = "wasi")) + ], + "@rules_rust//rust/platform:x86_64-apple-ios": [ + "@cu__libc-0.2.155//:libc", # cfg(any(unix, target_os = "wasi")) + ], + "@rules_rust//rust/platform:x86_64-fuchsia": [ + "@cu__libc-0.2.155//:libc", # cfg(any(unix, target_os = "wasi")) + ], + "@rules_rust//rust/platform:x86_64-linux-android": [ + "@cu__libc-0.2.155//:libc", # cfg(any(unix, target_os = "wasi")) + ], + "@rules_rust//rust/platform:x86_64-pc-windows-msvc": [ + "@cu__windows-sys-0.52.0//:windows_sys", # cfg(windows) + ], + "@rules_rust//rust/platform:x86_64-unknown-freebsd": [ + "@cu__libc-0.2.155//:libc", # cfg(any(unix, target_os = "wasi")) + ], + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [ + "@cu__libc-0.2.155//:libc", # cfg(any(unix, target_os = "wasi")) + ], + "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu": [ + "@cu__libc-0.2.155//:libc", # cfg(any(unix, target_os = "wasi")) + ], + "//conditions:default": [], + }), +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.itertools-0.12.1.bazel b/bazel/cargo/wasmtime/remote/BUILD.itertools-0.12.1.bazel new file mode 100644 index 000000000..6578e4624 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.itertools-0.12.1.bazel @@ -0,0 +1,52 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "itertools", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + "use_alloc", + "use_std", + ], + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=itertools", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.12.1", + deps = [ + "@cu__either-1.13.0//:either", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.itoa-1.0.11.bazel b/bazel/cargo/wasmtime/remote/BUILD.itoa-1.0.11.bazel new file mode 100644 index 000000000..71c5cae88 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.itoa-1.0.11.bazel @@ -0,0 +1,44 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "itoa", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=itoa", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.11", +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.leb128-0.2.5.bazel b/bazel/cargo/wasmtime/remote/BUILD.leb128-0.2.5.bazel new file mode 100644 index 000000000..12f06a0c6 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.leb128-0.2.5.bazel @@ -0,0 +1,44 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "leb128", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=leb128", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.2.5", +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.libc-0.2.155.bazel b/bazel/cargo/wasmtime/remote/BUILD.libc-0.2.155.bazel new file mode 100644 index 000000000..07f451864 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.libc-0.2.155.bazel @@ -0,0 +1,203 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "libc", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + "std", + ] + select({ + "@rules_rust//rust/platform:aarch64-apple-darwin": [ + "extra_traits", # aarch64-apple-darwin + ], + "@rules_rust//rust/platform:aarch64-apple-ios": [ + "extra_traits", # aarch64-apple-ios + ], + "@rules_rust//rust/platform:aarch64-apple-ios-sim": [ + "extra_traits", # aarch64-apple-ios-sim + ], + "@rules_rust//rust/platform:aarch64-fuchsia": [ + "extra_traits", # aarch64-fuchsia + ], + "@rules_rust//rust/platform:aarch64-linux-android": [ + "extra_traits", # aarch64-linux-android + ], + "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710": [ + "extra_traits", # aarch64-unknown-nto-qnx710 + ], + "@rules_rust//rust/platform:armv7-linux-androideabi": [ + "extra_traits", # armv7-linux-androideabi + ], + "@rules_rust//rust/platform:i686-apple-darwin": [ + "extra_traits", # i686-apple-darwin + ], + "@rules_rust//rust/platform:i686-linux-android": [ + "extra_traits", # i686-linux-android + ], + "@rules_rust//rust/platform:i686-unknown-freebsd": [ + "extra_traits", # i686-unknown-freebsd + ], + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu": [ + "extra_traits", # powerpc-unknown-linux-gnu + ], + "@rules_rust//rust/platform:s390x-unknown-linux-gnu": [ + "extra_traits", # s390x-unknown-linux-gnu + ], + "@rules_rust//rust/platform:x86_64-apple-darwin": [ + "extra_traits", # x86_64-apple-darwin + ], + "@rules_rust//rust/platform:x86_64-apple-ios": [ + "extra_traits", # x86_64-apple-ios + ], + "@rules_rust//rust/platform:x86_64-fuchsia": [ + "extra_traits", # x86_64-fuchsia + ], + "@rules_rust//rust/platform:x86_64-linux-android": [ + "extra_traits", # x86_64-linux-android + ], + "@rules_rust//rust/platform:x86_64-unknown-freebsd": [ + "extra_traits", # x86_64-unknown-freebsd + ], + "//conditions:default": [], + }), + crate_root = "src/lib.rs", + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=libc", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.2.155", + deps = [ + "@cu__libc-0.2.155//:build_script_build", + ], +) + +cargo_build_script( + name = "libc_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + crate_features = [ + "default", + "std", + ] + select({ + "@rules_rust//rust/platform:aarch64-apple-darwin": [ + "extra_traits", # aarch64-apple-darwin + ], + "@rules_rust//rust/platform:aarch64-apple-ios": [ + "extra_traits", # aarch64-apple-ios + ], + "@rules_rust//rust/platform:aarch64-apple-ios-sim": [ + "extra_traits", # aarch64-apple-ios-sim + ], + "@rules_rust//rust/platform:aarch64-fuchsia": [ + "extra_traits", # aarch64-fuchsia + ], + "@rules_rust//rust/platform:aarch64-linux-android": [ + "extra_traits", # aarch64-linux-android + ], + "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710": [ + "extra_traits", # aarch64-unknown-nto-qnx710 + ], + "@rules_rust//rust/platform:armv7-linux-androideabi": [ + "extra_traits", # armv7-linux-androideabi + ], + "@rules_rust//rust/platform:i686-apple-darwin": [ + "extra_traits", # i686-apple-darwin + ], + "@rules_rust//rust/platform:i686-linux-android": [ + "extra_traits", # i686-linux-android + ], + "@rules_rust//rust/platform:i686-unknown-freebsd": [ + "extra_traits", # i686-unknown-freebsd + ], + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu": [ + "extra_traits", # powerpc-unknown-linux-gnu + ], + "@rules_rust//rust/platform:s390x-unknown-linux-gnu": [ + "extra_traits", # s390x-unknown-linux-gnu + ], + "@rules_rust//rust/platform:x86_64-apple-darwin": [ + "extra_traits", # x86_64-apple-darwin + ], + "@rules_rust//rust/platform:x86_64-apple-ios": [ + "extra_traits", # x86_64-apple-ios + ], + "@rules_rust//rust/platform:x86_64-fuchsia": [ + "extra_traits", # x86_64-fuchsia + ], + "@rules_rust//rust/platform:x86_64-linux-android": [ + "extra_traits", # x86_64-linux-android + ], + "@rules_rust//rust/platform:x86_64-unknown-freebsd": [ + "extra_traits", # x86_64-unknown-freebsd + ], + "//conditions:default": [], + }), + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=libc", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.2.155", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = ":libc_bs", + tags = ["manual"], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.libm-0.2.8.bazel b/bazel/cargo/wasmtime/remote/BUILD.libm-0.2.8.bazel new file mode 100644 index 000000000..cf70de29c --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.libm-0.2.8.bazel @@ -0,0 +1,95 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "libm", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + ], + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=libm", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.2.8", + deps = [ + "@cu__libm-0.2.8//:build_script_build", + ], +) + +cargo_build_script( + name = "libm_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + crate_features = [ + "default", + ], + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=libm", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.2.8", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = ":libm_bs", + tags = ["manual"], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.linux-raw-sys-0.4.14.bazel b/bazel/cargo/wasmtime/remote/BUILD.linux-raw-sys-0.4.14.bazel new file mode 100644 index 000000000..733fee359 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.linux-raw-sys-0.4.14.bazel @@ -0,0 +1,79 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "linux_raw_sys", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "general", + "ioctl", + "no_std", + ] + select({ + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [ + "elf", # aarch64-unknown-linux-gnu + "errno", # aarch64-unknown-linux-gnu + ], + "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu": [ + "elf", # aarch64-unknown-nixos-gnu + "errno", # aarch64-unknown-nixos-gnu + ], + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi": [ + "elf", # arm-unknown-linux-gnueabi + "errno", # arm-unknown-linux-gnueabi + ], + "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi": [ + "elf", # armv7-unknown-linux-gnueabi + "errno", # armv7-unknown-linux-gnueabi + ], + "@rules_rust//rust/platform:i686-unknown-linux-gnu": [ + "elf", # i686-unknown-linux-gnu + "errno", # i686-unknown-linux-gnu + ], + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [ + "elf", # x86_64-unknown-linux-gnu + "errno", # x86_64-unknown-linux-gnu + ], + "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu": [ + "elf", # x86_64-unknown-nixos-gnu + "errno", # x86_64-unknown-nixos-gnu + ], + "//conditions:default": [], + }), + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=linux-raw-sys", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.4.14", +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.log-0.4.22.bazel b/bazel/cargo/wasmtime/remote/BUILD.log-0.4.22.bazel new file mode 100644 index 000000000..7afd4d234 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.log-0.4.22.bazel @@ -0,0 +1,47 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "log", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "std", + ], + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=log", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.4.22", +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.mach2-0.4.2.bazel b/bazel/cargo/wasmtime/remote/BUILD.mach2-0.4.2.bazel new file mode 100644 index 000000000..6c5f412cc --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.mach2-0.4.2.bazel @@ -0,0 +1,68 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "mach2", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + ], + crate_root = "src/lib.rs", + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=mach2", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.4.2", + deps = select({ + "@rules_rust//rust/platform:aarch64-apple-darwin": [ + "@cu__libc-0.2.155//:libc", # cfg(any(target_os = "macos", target_os = "ios")) + ], + "@rules_rust//rust/platform:aarch64-apple-ios": [ + "@cu__libc-0.2.155//:libc", # cfg(any(target_os = "macos", target_os = "ios")) + ], + "@rules_rust//rust/platform:aarch64-apple-ios-sim": [ + "@cu__libc-0.2.155//:libc", # cfg(any(target_os = "macos", target_os = "ios")) + ], + "@rules_rust//rust/platform:i686-apple-darwin": [ + "@cu__libc-0.2.155//:libc", # cfg(any(target_os = "macos", target_os = "ios")) + ], + "@rules_rust//rust/platform:x86_64-apple-darwin": [ + "@cu__libc-0.2.155//:libc", # cfg(any(target_os = "macos", target_os = "ios")) + ], + "@rules_rust//rust/platform:x86_64-apple-ios": [ + "@cu__libc-0.2.155//:libc", # cfg(any(target_os = "macos", target_os = "ios")) + ], + "//conditions:default": [], + }), +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.memchr-2.7.4.bazel b/bazel/cargo/wasmtime/remote/BUILD.memchr-2.7.4.bazel new file mode 100644 index 000000000..bee4bd07c --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.memchr-2.7.4.bazel @@ -0,0 +1,48 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "memchr", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "alloc", + "std", + ], + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=memchr", + "manual", + "noclippy", + "norustfmt", + ], + version = "2.7.4", +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.memfd-0.6.4.bazel b/bazel/cargo/wasmtime/remote/BUILD.memfd-0.6.4.bazel new file mode 100644 index 000000000..db840ec0d --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.memfd-0.6.4.bazel @@ -0,0 +1,47 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "memfd", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=memfd", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.6.4", + deps = [ + "@cu__rustix-0.38.34//:rustix", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.object-0.36.2.bazel b/bazel/cargo/wasmtime/remote/BUILD.object-0.36.2.bazel new file mode 100644 index 000000000..11133ca1e --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.object-0.36.2.bazel @@ -0,0 +1,62 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "object", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "coff", + "elf", + "macho", + "pe", + "read_core", + "std", + "write", + "write_core", + "write_std", + "xcoff", + ], + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=object", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.36.2", + deps = [ + "@cu__crc32fast-1.4.2//:crc32fast", + "@cu__hashbrown-0.14.5//:hashbrown", + "@cu__indexmap-2.3.0//:indexmap", + "@cu__memchr-2.7.4//:memchr", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.once_cell-1.19.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.once_cell-1.19.0.bazel new file mode 100644 index 000000000..d4155cdc0 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.once_cell-1.19.0.bazel @@ -0,0 +1,50 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "once_cell", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "alloc", + "default", + "race", + "std", + ], + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=once_cell", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.19.0", +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.paste-1.0.15.bazel b/bazel/cargo/wasmtime/remote/BUILD.paste-1.0.15.bazel new file mode 100644 index 000000000..aa2c97e31 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.paste-1.0.15.bazel @@ -0,0 +1,89 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_proc_macro") + +package(default_visibility = ["//visibility:public"]) + +rust_proc_macro( + name = "paste", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=paste", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.15", + deps = [ + "@cu__paste-1.0.15//:build_script_build", + ], +) + +cargo_build_script( + name = "paste_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=paste", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.15", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = ":paste_bs", + tags = ["manual"], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.pin-project-lite-0.2.14.bazel b/bazel/cargo/wasmtime/remote/BUILD.pin-project-lite-0.2.14.bazel new file mode 100644 index 000000000..65aba34bd --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.pin-project-lite-0.2.14.bazel @@ -0,0 +1,44 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "pin_project_lite", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=pin-project-lite", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.2.14", +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.postcard-1.0.8.bazel b/bazel/cargo/wasmtime/remote/BUILD.postcard-1.0.8.bazel new file mode 100644 index 000000000..d3af18cb4 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.postcard-1.0.8.bazel @@ -0,0 +1,54 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "postcard", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "alloc", + "embedded-io", + "use-std", + ], + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=postcard", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.8", + deps = [ + "@cu__cobs-0.2.3//:cobs", + "@cu__embedded-io-0.4.0//:embedded_io", + "@cu__serde-1.0.204//:serde", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.proc-macro2-1.0.86.bazel b/bazel/cargo/wasmtime/remote/BUILD.proc-macro2-1.0.86.bazel new file mode 100644 index 000000000..f5ffa7899 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.proc-macro2-1.0.86.bazel @@ -0,0 +1,98 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "proc_macro2", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + "proc-macro", + ], + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=proc-macro2", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.86", + deps = [ + "@cu__proc-macro2-1.0.86//:build_script_build", + "@cu__unicode-ident-1.0.12//:unicode_ident", + ], +) + +cargo_build_script( + name = "proc-macro2_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + crate_features = [ + "default", + "proc-macro", + ], + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=proc-macro2", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.86", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = ":proc-macro2_bs", + tags = ["manual"], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.psm-0.1.21.bazel b/bazel/cargo/wasmtime/remote/BUILD.psm-0.1.21.bazel new file mode 100644 index 000000000..ec02d2243 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.psm-0.1.21.bazel @@ -0,0 +1,92 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "psm", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=psm", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.1.21", + deps = [ + "@cu__psm-0.1.21//:build_script_build", + ], +) + +cargo_build_script( + name = "psm_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=psm", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.1.21", + visibility = ["//visibility:private"], + deps = [ + "@cu__cc-1.1.7//:cc", + ], +) + +alias( + name = "build_script_build", + actual = ":psm_bs", + tags = ["manual"], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.quote-1.0.36.bazel b/bazel/cargo/wasmtime/remote/BUILD.quote-1.0.36.bazel new file mode 100644 index 000000000..3ad108f8f --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.quote-1.0.36.bazel @@ -0,0 +1,51 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "quote", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + "proc-macro", + ], + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=quote", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.36", + deps = [ + "@cu__proc-macro2-1.0.86//:proc_macro2", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.regalloc2-0.9.3.bazel b/bazel/cargo/wasmtime/remote/BUILD.regalloc2-0.9.3.bazel new file mode 100644 index 000000000..cbd3ed5fd --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.regalloc2-0.9.3.bazel @@ -0,0 +1,57 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "regalloc2", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "checker", + "default", + "std", + "trace-log", + ], + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=regalloc2", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.9.3", + deps = [ + "@cu__hashbrown-0.13.2//:hashbrown", + "@cu__log-0.4.22//:log", + "@cu__rustc-hash-1.1.0//:rustc_hash", + "@cu__slice-group-by-0.3.1//:slice_group_by", + "@cu__smallvec-1.13.2//:smallvec", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.regex-1.10.5.bazel b/bazel/cargo/wasmtime/remote/BUILD.regex-1.10.5.bazel new file mode 100644 index 000000000..efdf89bd0 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.regex-1.10.5.bazel @@ -0,0 +1,60 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "regex", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "perf", + "perf-backtrack", + "perf-cache", + "perf-dfa", + "perf-inline", + "perf-literal", + "perf-onepass", + "std", + ], + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=regex", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.10.5", + deps = [ + "@cu__aho-corasick-1.1.3//:aho_corasick", + "@cu__memchr-2.7.4//:memchr", + "@cu__regex-automata-0.4.7//:regex_automata", + "@cu__regex-syntax-0.8.4//:regex_syntax", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.regex-automata-0.4.7.bazel b/bazel/cargo/wasmtime/remote/BUILD.regex-automata-0.4.7.bazel new file mode 100644 index 000000000..da56abc92 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.regex-automata-0.4.7.bazel @@ -0,0 +1,64 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "regex_automata", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "alloc", + "dfa-onepass", + "hybrid", + "meta", + "nfa-backtrack", + "nfa-pikevm", + "nfa-thompson", + "perf-inline", + "perf-literal", + "perf-literal-multisubstring", + "perf-literal-substring", + "std", + "syntax", + ], + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=regex-automata", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.4.7", + deps = [ + "@cu__aho-corasick-1.1.3//:aho_corasick", + "@cu__memchr-2.7.4//:memchr", + "@cu__regex-syntax-0.8.4//:regex_syntax", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.regex-syntax-0.8.4.bazel b/bazel/cargo/wasmtime/remote/BUILD.regex-syntax-0.8.4.bazel new file mode 100644 index 000000000..36b411c94 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.regex-syntax-0.8.4.bazel @@ -0,0 +1,47 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "regex_syntax", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "std", + ], + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=regex-syntax", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.8.4", +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.rustc-hash-1.1.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.rustc-hash-1.1.0.bazel new file mode 100644 index 000000000..4892ae611 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.rustc-hash-1.1.0.bazel @@ -0,0 +1,48 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "rustc_hash", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + "std", + ], + crate_root = "src/lib.rs", + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=rustc-hash", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.1.0", +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.rustix-0.38.34.bazel b/bazel/cargo/wasmtime/remote/BUILD.rustix-0.38.34.bazel new file mode 100644 index 000000000..8cde617b3 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.rustix-0.38.34.bazel @@ -0,0 +1,385 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "rustix", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + aliases = select({ + "@rules_rust//rust/platform:aarch64-apple-darwin": { + "@cu__errno-0.3.9//:errno": "libc_errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + }, + "@rules_rust//rust/platform:aarch64-apple-ios": { + "@cu__errno-0.3.9//:errno": "libc_errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + }, + "@rules_rust//rust/platform:aarch64-apple-ios-sim": { + "@cu__errno-0.3.9//:errno": "libc_errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + }, + "@rules_rust//rust/platform:aarch64-fuchsia": { + "@cu__errno-0.3.9//:errno": "libc_errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + }, + "@rules_rust//rust/platform:aarch64-linux-android": { + "@cu__errno-0.3.9//:errno": "libc_errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + }, + "@rules_rust//rust/platform:aarch64-pc-windows-msvc": { + "@cu__errno-0.3.9//:errno": "libc_errno", # cfg(windows) + }, + "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710": { + "@cu__errno-0.3.9//:errno": "libc_errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + }, + "@rules_rust//rust/platform:armv7-linux-androideabi": { + "@cu__errno-0.3.9//:errno": "libc_errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + }, + "@rules_rust//rust/platform:i686-apple-darwin": { + "@cu__errno-0.3.9//:errno": "libc_errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + }, + "@rules_rust//rust/platform:i686-linux-android": { + "@cu__errno-0.3.9//:errno": "libc_errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + }, + "@rules_rust//rust/platform:i686-pc-windows-msvc": { + "@cu__errno-0.3.9//:errno": "libc_errno", # cfg(windows) + }, + "@rules_rust//rust/platform:i686-unknown-freebsd": { + "@cu__errno-0.3.9//:errno": "libc_errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + }, + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu": { + "@cu__errno-0.3.9//:errno": "libc_errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + }, + "@rules_rust//rust/platform:riscv32imc-unknown-none-elf": { + "@cu__errno-0.3.9//:errno": "libc_errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + }, + "@rules_rust//rust/platform:riscv64gc-unknown-none-elf": { + "@cu__errno-0.3.9//:errno": "libc_errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + }, + "@rules_rust//rust/platform:s390x-unknown-linux-gnu": { + "@cu__errno-0.3.9//:errno": "libc_errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + }, + "@rules_rust//rust/platform:thumbv7em-none-eabi": { + "@cu__errno-0.3.9//:errno": "libc_errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + }, + "@rules_rust//rust/platform:thumbv8m.main-none-eabi": { + "@cu__errno-0.3.9//:errno": "libc_errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + }, + "@rules_rust//rust/platform:wasm32-unknown-unknown": { + "@cu__errno-0.3.9//:errno": "libc_errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + }, + "@rules_rust//rust/platform:wasm32-wasi": { + "@cu__errno-0.3.9//:errno": "libc_errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + }, + "@rules_rust//rust/platform:x86_64-apple-darwin": { + "@cu__errno-0.3.9//:errno": "libc_errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + }, + "@rules_rust//rust/platform:x86_64-apple-ios": { + "@cu__errno-0.3.9//:errno": "libc_errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + }, + "@rules_rust//rust/platform:x86_64-fuchsia": { + "@cu__errno-0.3.9//:errno": "libc_errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + }, + "@rules_rust//rust/platform:x86_64-linux-android": { + "@cu__errno-0.3.9//:errno": "libc_errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + }, + "@rules_rust//rust/platform:x86_64-pc-windows-msvc": { + "@cu__errno-0.3.9//:errno": "libc_errno", # cfg(windows) + }, + "@rules_rust//rust/platform:x86_64-unknown-freebsd": { + "@cu__errno-0.3.9//:errno": "libc_errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + }, + "@rules_rust//rust/platform:x86_64-unknown-none": { + "@cu__errno-0.3.9//:errno": "libc_errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + }, + "//conditions:default": {}, + }), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "alloc", + "default", + "libc-extra-traits", + "mm", + "std", + "use-libc-auxv", + ] + select({ + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [ + "fs", # aarch64-unknown-linux-gnu + ], + "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu": [ + "fs", # aarch64-unknown-nixos-gnu + ], + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi": [ + "fs", # arm-unknown-linux-gnueabi + ], + "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi": [ + "fs", # armv7-unknown-linux-gnueabi + ], + "@rules_rust//rust/platform:i686-unknown-linux-gnu": [ + "fs", # i686-unknown-linux-gnu + ], + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu": [ + "fs", # powerpc-unknown-linux-gnu + ], + "@rules_rust//rust/platform:s390x-unknown-linux-gnu": [ + "fs", # s390x-unknown-linux-gnu + ], + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [ + "fs", # x86_64-unknown-linux-gnu + ], + "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu": [ + "fs", # x86_64-unknown-nixos-gnu + ], + "//conditions:default": [], + }), + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=rustix", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.38.34", + deps = [ + "@cu__bitflags-2.6.0//:bitflags", + "@cu__rustix-0.38.34//:build_script_build", + ] + select({ + "@rules_rust//rust/platform:aarch64-apple-darwin": [ + "@cu__errno-0.3.9//:errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + "@cu__libc-0.2.155//:libc", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + ], + "@rules_rust//rust/platform:aarch64-apple-ios": [ + "@cu__errno-0.3.9//:errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + "@cu__libc-0.2.155//:libc", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + ], + "@rules_rust//rust/platform:aarch64-apple-ios-sim": [ + "@cu__errno-0.3.9//:errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + "@cu__libc-0.2.155//:libc", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + ], + "@rules_rust//rust/platform:aarch64-fuchsia": [ + "@cu__errno-0.3.9//:errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + "@cu__libc-0.2.155//:libc", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + ], + "@rules_rust//rust/platform:aarch64-linux-android": [ + "@cu__errno-0.3.9//:errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + "@cu__libc-0.2.155//:libc", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + "@cu__linux-raw-sys-0.4.14//:linux_raw_sys", # cfg(all(any(target_os = "android", target_os = "linux"), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + ], + "@rules_rust//rust/platform:aarch64-pc-windows-msvc": [ + "@cu__errno-0.3.9//:errno", # cfg(windows) + "@cu__windows-sys-0.52.0//:windows_sys", # cfg(windows) + ], + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [ + "@cu__linux-raw-sys-0.4.14//:linux_raw_sys", # cfg(all(not(rustix_use_libc), not(miri), target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64")))) + ], + "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu": [ + "@cu__linux-raw-sys-0.4.14//:linux_raw_sys", # cfg(all(not(rustix_use_libc), not(miri), target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64")))) + ], + "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710": [ + "@cu__errno-0.3.9//:errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + "@cu__libc-0.2.155//:libc", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + ], + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi": [ + "@cu__linux-raw-sys-0.4.14//:linux_raw_sys", # cfg(all(not(rustix_use_libc), not(miri), target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64")))) + ], + "@rules_rust//rust/platform:armv7-linux-androideabi": [ + "@cu__errno-0.3.9//:errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + "@cu__libc-0.2.155//:libc", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + "@cu__linux-raw-sys-0.4.14//:linux_raw_sys", # cfg(all(any(target_os = "android", target_os = "linux"), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + ], + "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi": [ + "@cu__linux-raw-sys-0.4.14//:linux_raw_sys", # cfg(all(not(rustix_use_libc), not(miri), target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64")))) + ], + "@rules_rust//rust/platform:i686-apple-darwin": [ + "@cu__errno-0.3.9//:errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + "@cu__libc-0.2.155//:libc", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + ], + "@rules_rust//rust/platform:i686-linux-android": [ + "@cu__errno-0.3.9//:errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + "@cu__libc-0.2.155//:libc", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + "@cu__linux-raw-sys-0.4.14//:linux_raw_sys", # cfg(all(any(target_os = "android", target_os = "linux"), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + ], + "@rules_rust//rust/platform:i686-pc-windows-msvc": [ + "@cu__errno-0.3.9//:errno", # cfg(windows) + "@cu__windows-sys-0.52.0//:windows_sys", # cfg(windows) + ], + "@rules_rust//rust/platform:i686-unknown-freebsd": [ + "@cu__errno-0.3.9//:errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + "@cu__libc-0.2.155//:libc", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + ], + "@rules_rust//rust/platform:i686-unknown-linux-gnu": [ + "@cu__linux-raw-sys-0.4.14//:linux_raw_sys", # cfg(all(not(rustix_use_libc), not(miri), target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64")))) + ], + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu": [ + "@cu__errno-0.3.9//:errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + "@cu__libc-0.2.155//:libc", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + "@cu__linux-raw-sys-0.4.14//:linux_raw_sys", # cfg(all(any(target_os = "android", target_os = "linux"), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + ], + "@rules_rust//rust/platform:riscv32imc-unknown-none-elf": [ + "@cu__errno-0.3.9//:errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + "@cu__libc-0.2.155//:libc", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + ], + "@rules_rust//rust/platform:riscv64gc-unknown-none-elf": [ + "@cu__errno-0.3.9//:errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + "@cu__libc-0.2.155//:libc", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + ], + "@rules_rust//rust/platform:s390x-unknown-linux-gnu": [ + "@cu__errno-0.3.9//:errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + "@cu__libc-0.2.155//:libc", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + "@cu__linux-raw-sys-0.4.14//:linux_raw_sys", # cfg(all(any(target_os = "android", target_os = "linux"), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + ], + "@rules_rust//rust/platform:thumbv7em-none-eabi": [ + "@cu__errno-0.3.9//:errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + "@cu__libc-0.2.155//:libc", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + ], + "@rules_rust//rust/platform:thumbv8m.main-none-eabi": [ + "@cu__errno-0.3.9//:errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + "@cu__libc-0.2.155//:libc", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + ], + "@rules_rust//rust/platform:wasm32-unknown-unknown": [ + "@cu__errno-0.3.9//:errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + "@cu__libc-0.2.155//:libc", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + ], + "@rules_rust//rust/platform:wasm32-wasi": [ + "@cu__errno-0.3.9//:errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + "@cu__libc-0.2.155//:libc", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + ], + "@rules_rust//rust/platform:x86_64-apple-darwin": [ + "@cu__errno-0.3.9//:errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + "@cu__libc-0.2.155//:libc", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + ], + "@rules_rust//rust/platform:x86_64-apple-ios": [ + "@cu__errno-0.3.9//:errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + "@cu__libc-0.2.155//:libc", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + ], + "@rules_rust//rust/platform:x86_64-fuchsia": [ + "@cu__errno-0.3.9//:errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + "@cu__libc-0.2.155//:libc", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + ], + "@rules_rust//rust/platform:x86_64-linux-android": [ + "@cu__errno-0.3.9//:errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + "@cu__libc-0.2.155//:libc", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + "@cu__linux-raw-sys-0.4.14//:linux_raw_sys", # cfg(all(any(target_os = "android", target_os = "linux"), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + ], + "@rules_rust//rust/platform:x86_64-pc-windows-msvc": [ + "@cu__errno-0.3.9//:errno", # cfg(windows) + "@cu__windows-sys-0.52.0//:windows_sys", # cfg(windows) + ], + "@rules_rust//rust/platform:x86_64-unknown-freebsd": [ + "@cu__errno-0.3.9//:errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + "@cu__libc-0.2.155//:libc", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + ], + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [ + "@cu__linux-raw-sys-0.4.14//:linux_raw_sys", # cfg(all(not(rustix_use_libc), not(miri), target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64")))) + ], + "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu": [ + "@cu__linux-raw-sys-0.4.14//:linux_raw_sys", # cfg(all(not(rustix_use_libc), not(miri), target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64")))) + ], + "@rules_rust//rust/platform:x86_64-unknown-none": [ + "@cu__errno-0.3.9//:errno", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + "@cu__libc-0.2.155//:libc", # cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))))) + ], + "//conditions:default": [], + }), +) + +cargo_build_script( + name = "rustix_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + crate_features = [ + "alloc", + "default", + "libc-extra-traits", + "mm", + "std", + "use-libc-auxv", + ] + select({ + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [ + "fs", # aarch64-unknown-linux-gnu + ], + "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu": [ + "fs", # aarch64-unknown-nixos-gnu + ], + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi": [ + "fs", # arm-unknown-linux-gnueabi + ], + "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi": [ + "fs", # armv7-unknown-linux-gnueabi + ], + "@rules_rust//rust/platform:i686-unknown-linux-gnu": [ + "fs", # i686-unknown-linux-gnu + ], + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu": [ + "fs", # powerpc-unknown-linux-gnu + ], + "@rules_rust//rust/platform:s390x-unknown-linux-gnu": [ + "fs", # s390x-unknown-linux-gnu + ], + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [ + "fs", # x86_64-unknown-linux-gnu + ], + "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu": [ + "fs", # x86_64-unknown-nixos-gnu + ], + "//conditions:default": [], + }), + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=rustix", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.38.34", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = ":rustix_bs", + tags = ["manual"], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.ryu-1.0.18.bazel b/bazel/cargo/wasmtime/remote/BUILD.ryu-1.0.18.bazel new file mode 100644 index 000000000..59399d34a --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.ryu-1.0.18.bazel @@ -0,0 +1,44 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "ryu", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=ryu", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.18", +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.semver-1.0.23.bazel b/bazel/cargo/wasmtime/remote/BUILD.semver-1.0.23.bazel new file mode 100644 index 000000000..cb1d7f86c --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.semver-1.0.23.bazel @@ -0,0 +1,89 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "semver", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=semver", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.23", + deps = [ + "@cu__semver-1.0.23//:build_script_build", + ], +) + +cargo_build_script( + name = "semver_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=semver", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.23", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = ":semver_bs", + tags = ["manual"], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.serde-1.0.204.bazel b/bazel/cargo/wasmtime/remote/BUILD.serde-1.0.204.bazel new file mode 100644 index 000000000..7e417ffd9 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.serde-1.0.204.bazel @@ -0,0 +1,104 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "serde", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "alloc", + "derive", + "serde_derive", + "std", + ], + crate_root = "src/lib.rs", + edition = "2018", + proc_macro_deps = [ + "@cu__serde_derive-1.0.204//:serde_derive", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=serde", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.204", + deps = [ + "@cu__serde-1.0.204//:build_script_build", + ], +) + +cargo_build_script( + name = "serde_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + crate_features = [ + "alloc", + "derive", + "serde_derive", + "std", + ], + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=serde", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.204", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = ":serde_bs", + tags = ["manual"], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.serde_derive-1.0.204.bazel b/bazel/cargo/wasmtime/remote/BUILD.serde_derive-1.0.204.bazel new file mode 100644 index 000000000..ef5fe8588 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.serde_derive-1.0.204.bazel @@ -0,0 +1,52 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_proc_macro") + +package(default_visibility = ["//visibility:public"]) + +rust_proc_macro( + name = "serde_derive", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + ], + crate_root = "src/lib.rs", + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=serde_derive", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.204", + deps = [ + "@cu__proc-macro2-1.0.86//:proc_macro2", + "@cu__quote-1.0.36//:quote", + "@cu__syn-2.0.72//:syn", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.serde_json-1.0.120.bazel b/bazel/cargo/wasmtime/remote/BUILD.serde_json-1.0.120.bazel new file mode 100644 index 000000000..108736275 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.serde_json-1.0.120.bazel @@ -0,0 +1,92 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "serde_json", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=serde_json", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.120", + deps = [ + "@cu__itoa-1.0.11//:itoa", + "@cu__ryu-1.0.18//:ryu", + "@cu__serde-1.0.204//:serde", + "@cu__serde_json-1.0.120//:build_script_build", + ], +) + +cargo_build_script( + name = "serde_json_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=serde_json", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.120", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = ":serde_json_bs", + tags = ["manual"], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.slice-group-by-0.3.1.bazel b/bazel/cargo/wasmtime/remote/BUILD.slice-group-by-0.3.1.bazel new file mode 100644 index 000000000..8f7e3cdc9 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.slice-group-by-0.3.1.bazel @@ -0,0 +1,44 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "slice_group_by", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=slice-group-by", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.3.1", +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.smallvec-1.13.2.bazel b/bazel/cargo/wasmtime/remote/BUILD.smallvec-1.13.2.bazel new file mode 100644 index 000000000..d6bcdee92 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.smallvec-1.13.2.bazel @@ -0,0 +1,51 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "smallvec", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "serde", + "union", + ], + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=smallvec", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.13.2", + deps = [ + "@cu__serde-1.0.204//:serde", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.sptr-0.3.2.bazel b/bazel/cargo/wasmtime/remote/BUILD.sptr-0.3.2.bazel new file mode 100644 index 000000000..e4da3ae80 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.sptr-0.3.2.bazel @@ -0,0 +1,47 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "sptr", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + ], + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=sptr", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.3.2", +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.stable_deref_trait-1.2.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.stable_deref_trait-1.2.0.bazel new file mode 100644 index 000000000..3bce00c61 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.stable_deref_trait-1.2.0.bazel @@ -0,0 +1,44 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "stable_deref_trait", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=stable_deref_trait", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.2.0", +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.syn-2.0.72.bazel b/bazel/cargo/wasmtime/remote/BUILD.syn-2.0.72.bazel new file mode 100644 index 000000000..acacb26fd --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.syn-2.0.72.bazel @@ -0,0 +1,60 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "syn", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "clone-impls", + "default", + "derive", + "extra-traits", + "full", + "parsing", + "printing", + "proc-macro", + "visit-mut", + ], + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=syn", + "manual", + "noclippy", + "norustfmt", + ], + version = "2.0.72", + deps = [ + "@cu__proc-macro2-1.0.86//:proc_macro2", + "@cu__quote-1.0.36//:quote", + "@cu__unicode-ident-1.0.12//:unicode_ident", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.target-lexicon-0.12.16.bazel b/bazel/cargo/wasmtime/remote/BUILD.target-lexicon-0.12.16.bazel new file mode 100644 index 000000000..200965695 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.target-lexicon-0.12.16.bazel @@ -0,0 +1,95 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "target_lexicon", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + ], + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=target-lexicon", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.12.16", + deps = [ + "@cu__target-lexicon-0.12.16//:build_script_build", + ], +) + +cargo_build_script( + name = "target-lexicon_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + crate_features = [ + "default", + ], + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=target-lexicon", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.12.16", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = ":target-lexicon_bs", + tags = ["manual"], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.termcolor-1.4.1.bazel b/bazel/cargo/wasmtime/remote/BUILD.termcolor-1.4.1.bazel new file mode 100644 index 000000000..ccdaaf3f8 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.termcolor-1.4.1.bazel @@ -0,0 +1,56 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "termcolor", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=termcolor", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.4.1", + deps = select({ + "@rules_rust//rust/platform:aarch64-pc-windows-msvc": [ + "@cu__winapi-util-0.1.8//:winapi_util", # cfg(windows) + ], + "@rules_rust//rust/platform:i686-pc-windows-msvc": [ + "@cu__winapi-util-0.1.8//:winapi_util", # cfg(windows) + ], + "@rules_rust//rust/platform:x86_64-pc-windows-msvc": [ + "@cu__winapi-util-0.1.8//:winapi_util", # cfg(windows) + ], + "//conditions:default": [], + }), +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.thiserror-1.0.63.bazel b/bazel/cargo/wasmtime/remote/BUILD.thiserror-1.0.63.bazel new file mode 100644 index 000000000..075c39ee8 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.thiserror-1.0.63.bazel @@ -0,0 +1,92 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "thiserror", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2021", + proc_macro_deps = [ + "@cu__thiserror-impl-1.0.63//:thiserror_impl", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=thiserror", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.63", + deps = [ + "@cu__thiserror-1.0.63//:build_script_build", + ], +) + +cargo_build_script( + name = "thiserror_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=thiserror", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.63", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = ":thiserror_bs", + tags = ["manual"], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.thiserror-impl-1.0.63.bazel b/bazel/cargo/wasmtime/remote/BUILD.thiserror-impl-1.0.63.bazel new file mode 100644 index 000000000..827631585 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.thiserror-impl-1.0.63.bazel @@ -0,0 +1,49 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_proc_macro") + +package(default_visibility = ["//visibility:public"]) + +rust_proc_macro( + name = "thiserror_impl", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=thiserror-impl", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.63", + deps = [ + "@cu__proc-macro2-1.0.86//:proc_macro2", + "@cu__quote-1.0.36//:quote", + "@cu__syn-2.0.72//:syn", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.tracing-0.1.40.bazel b/bazel/cargo/wasmtime/remote/BUILD.tracing-0.1.40.bazel new file mode 100644 index 000000000..e8bbf2590 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.tracing-0.1.40.bazel @@ -0,0 +1,57 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "tracing", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "attributes", + "default", + "std", + "tracing-attributes", + ], + crate_root = "src/lib.rs", + edition = "2018", + proc_macro_deps = [ + "@cu__tracing-attributes-0.1.27//:tracing_attributes", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=tracing", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.1.40", + deps = [ + "@cu__pin-project-lite-0.2.14//:pin_project_lite", + "@cu__tracing-core-0.1.32//:tracing_core", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.tracing-attributes-0.1.27.bazel b/bazel/cargo/wasmtime/remote/BUILD.tracing-attributes-0.1.27.bazel new file mode 100644 index 000000000..8dc144d30 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.tracing-attributes-0.1.27.bazel @@ -0,0 +1,49 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_proc_macro") + +package(default_visibility = ["//visibility:public"]) + +rust_proc_macro( + name = "tracing_attributes", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=tracing-attributes", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.1.27", + deps = [ + "@cu__proc-macro2-1.0.86//:proc_macro2", + "@cu__quote-1.0.36//:quote", + "@cu__syn-2.0.72//:syn", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.tracing-core-0.1.32.bazel b/bazel/cargo/wasmtime/remote/BUILD.tracing-core-0.1.32.bazel new file mode 100644 index 000000000..cd5b7378b --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.tracing-core-0.1.32.bazel @@ -0,0 +1,51 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "tracing_core", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "once_cell", + "std", + ], + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=tracing-core", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.1.32", + deps = [ + "@cu__once_cell-1.19.0//:once_cell", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.unicode-ident-1.0.12.bazel b/bazel/cargo/wasmtime/remote/BUILD.unicode-ident-1.0.12.bazel new file mode 100644 index 000000000..e21e8cd07 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.unicode-ident-1.0.12.bazel @@ -0,0 +1,44 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "unicode_ident", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=unicode-ident", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.12", +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.unicode-xid-0.2.4.bazel b/bazel/cargo/wasmtime/remote/BUILD.unicode-xid-0.2.4.bazel new file mode 100644 index 000000000..a8b5dda0b --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.unicode-xid-0.2.4.bazel @@ -0,0 +1,44 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "unicode_xid", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=unicode-xid", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.2.4", +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.version_check-0.9.5.bazel b/bazel/cargo/wasmtime/remote/BUILD.version_check-0.9.5.bazel new file mode 100644 index 000000000..e24cea268 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.version_check-0.9.5.bazel @@ -0,0 +1,44 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "version_check", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=version_check", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.9.5", +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.wasm-encoder-0.215.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.wasm-encoder-0.215.0.bazel new file mode 100644 index 000000000..e24ef2076 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.wasm-encoder-0.215.0.bazel @@ -0,0 +1,47 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "wasm_encoder", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=wasm-encoder", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.215.0", + deps = [ + "@cu__leb128-0.2.5//:leb128", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.wasmparser-0.215.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.wasmparser-0.215.0.bazel new file mode 100644 index 000000000..3f3d22eb9 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.wasmparser-0.215.0.bazel @@ -0,0 +1,57 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "wasmparser", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "serde", + "std", + "validate", + ], + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=wasmparser", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.215.0", + deps = [ + "@cu__ahash-0.8.11//:ahash", + "@cu__bitflags-2.6.0//:bitflags", + "@cu__hashbrown-0.14.5//:hashbrown", + "@cu__indexmap-2.3.0//:indexmap", + "@cu__semver-1.0.23//:semver", + "@cu__serde-1.0.204//:serde", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.wasmprinter-0.215.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.wasmprinter-0.215.0.bazel new file mode 100644 index 000000000..5ee382b0f --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.wasmprinter-0.215.0.bazel @@ -0,0 +1,49 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "wasmprinter", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=wasmprinter", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.215.0", + deps = [ + "@cu__anyhow-1.0.86//:anyhow", + "@cu__termcolor-1.4.1//:termcolor", + "@cu__wasmparser-0.215.0//:wasmparser", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.wasmtime-24.0.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.wasmtime-24.0.0.bazel new file mode 100644 index 000000000..1f77ab476 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.wasmtime-24.0.0.bazel @@ -0,0 +1,230 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "wasmtime", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "cranelift", + "gc", + "runtime", + "std", + ], + crate_root = "src/lib.rs", + edition = "2021", + proc_macro_deps = [ + "@cu__paste-1.0.15//:paste", + "@cu__serde_derive-1.0.204//:serde_derive", + "@cu__wasmtime-versioned-export-macros-24.0.0//:wasmtime_versioned_export_macros", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=wasmtime", + "manual", + "noclippy", + "norustfmt", + ], + version = "24.0.0", + deps = [ + "@cu__anyhow-1.0.86//:anyhow", + "@cu__bitflags-2.6.0//:bitflags", + "@cu__bumpalo-3.16.0//:bumpalo", + "@cu__cfg-if-1.0.0//:cfg_if", + "@cu__hashbrown-0.14.5//:hashbrown", + "@cu__indexmap-2.3.0//:indexmap", + "@cu__libc-0.2.155//:libc", + "@cu__libm-0.2.8//:libm", + "@cu__log-0.4.22//:log", + "@cu__object-0.36.2//:object", + "@cu__once_cell-1.19.0//:once_cell", + "@cu__postcard-1.0.8//:postcard", + "@cu__serde-1.0.204//:serde", + "@cu__smallvec-1.13.2//:smallvec", + "@cu__sptr-0.3.2//:sptr", + "@cu__target-lexicon-0.12.16//:target_lexicon", + "@cu__wasmparser-0.215.0//:wasmparser", + "@cu__wasmtime-24.0.0//:build_script_build", + "@cu__wasmtime-asm-macros-24.0.0//:wasmtime_asm_macros", + "@cu__wasmtime-cranelift-24.0.0//:wasmtime_cranelift", + "@cu__wasmtime-environ-24.0.0//:wasmtime_environ", + "@cu__wasmtime-jit-icache-coherence-24.0.0//:wasmtime_jit_icache_coherence", + "@cu__wasmtime-slab-24.0.0//:wasmtime_slab", + ] + select({ + "@rules_rust//rust/platform:aarch64-apple-darwin": [ + "@cu__mach2-0.4.2//:mach2", # cfg(target_os = "macos") + "@cu__rustix-0.38.34//:rustix", # cfg(unix) + ], + "@rules_rust//rust/platform:aarch64-apple-ios": [ + "@cu__rustix-0.38.34//:rustix", # cfg(unix) + ], + "@rules_rust//rust/platform:aarch64-apple-ios-sim": [ + "@cu__rustix-0.38.34//:rustix", # cfg(unix) + ], + "@rules_rust//rust/platform:aarch64-fuchsia": [ + "@cu__rustix-0.38.34//:rustix", # cfg(unix) + ], + "@rules_rust//rust/platform:aarch64-linux-android": [ + "@cu__rustix-0.38.34//:rustix", # cfg(unix) + ], + "@rules_rust//rust/platform:aarch64-pc-windows-msvc": [ + "@cu__windows-sys-0.52.0//:windows_sys", # cfg(target_os = "windows") + ], + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [ + "@cu__memfd-0.6.4//:memfd", # cfg(target_os = "linux") + "@cu__rustix-0.38.34//:rustix", # cfg(unix) + ], + "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu": [ + "@cu__memfd-0.6.4//:memfd", # cfg(target_os = "linux") + "@cu__rustix-0.38.34//:rustix", # cfg(unix) + ], + "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710": [ + "@cu__rustix-0.38.34//:rustix", # cfg(unix) + ], + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi": [ + "@cu__memfd-0.6.4//:memfd", # cfg(target_os = "linux") + "@cu__rustix-0.38.34//:rustix", # cfg(unix) + ], + "@rules_rust//rust/platform:armv7-linux-androideabi": [ + "@cu__rustix-0.38.34//:rustix", # cfg(unix) + ], + "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi": [ + "@cu__memfd-0.6.4//:memfd", # cfg(target_os = "linux") + "@cu__rustix-0.38.34//:rustix", # cfg(unix) + ], + "@rules_rust//rust/platform:i686-apple-darwin": [ + "@cu__mach2-0.4.2//:mach2", # cfg(target_os = "macos") + "@cu__rustix-0.38.34//:rustix", # cfg(unix) + ], + "@rules_rust//rust/platform:i686-linux-android": [ + "@cu__rustix-0.38.34//:rustix", # cfg(unix) + ], + "@rules_rust//rust/platform:i686-pc-windows-msvc": [ + "@cu__windows-sys-0.52.0//:windows_sys", # cfg(target_os = "windows") + ], + "@rules_rust//rust/platform:i686-unknown-freebsd": [ + "@cu__rustix-0.38.34//:rustix", # cfg(unix) + ], + "@rules_rust//rust/platform:i686-unknown-linux-gnu": [ + "@cu__memfd-0.6.4//:memfd", # cfg(target_os = "linux") + "@cu__rustix-0.38.34//:rustix", # cfg(unix) + ], + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu": [ + "@cu__memfd-0.6.4//:memfd", # cfg(target_os = "linux") + "@cu__rustix-0.38.34//:rustix", # cfg(unix) + ], + "@rules_rust//rust/platform:s390x-unknown-linux-gnu": [ + "@cu__memfd-0.6.4//:memfd", # cfg(target_os = "linux") + "@cu__psm-0.1.21//:psm", # cfg(target_arch = "s390x") + "@cu__rustix-0.38.34//:rustix", # cfg(unix) + ], + "@rules_rust//rust/platform:x86_64-apple-darwin": [ + "@cu__mach2-0.4.2//:mach2", # cfg(target_os = "macos") + "@cu__rustix-0.38.34//:rustix", # cfg(unix) + ], + "@rules_rust//rust/platform:x86_64-apple-ios": [ + "@cu__rustix-0.38.34//:rustix", # cfg(unix) + ], + "@rules_rust//rust/platform:x86_64-fuchsia": [ + "@cu__rustix-0.38.34//:rustix", # cfg(unix) + ], + "@rules_rust//rust/platform:x86_64-linux-android": [ + "@cu__rustix-0.38.34//:rustix", # cfg(unix) + ], + "@rules_rust//rust/platform:x86_64-pc-windows-msvc": [ + "@cu__windows-sys-0.52.0//:windows_sys", # cfg(target_os = "windows") + ], + "@rules_rust//rust/platform:x86_64-unknown-freebsd": [ + "@cu__rustix-0.38.34//:rustix", # cfg(unix) + ], + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [ + "@cu__memfd-0.6.4//:memfd", # cfg(target_os = "linux") + "@cu__rustix-0.38.34//:rustix", # cfg(unix) + ], + "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu": [ + "@cu__memfd-0.6.4//:memfd", # cfg(target_os = "linux") + "@cu__rustix-0.38.34//:rustix", # cfg(unix) + ], + "//conditions:default": [], + }), +) + +cargo_build_script( + name = "wasmtime_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + crate_features = [ + "cranelift", + "gc", + "runtime", + "std", + ], + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2021", + proc_macro_deps = [ + "@cu__wasmtime-versioned-export-macros-24.0.0//:wasmtime_versioned_export_macros", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=wasmtime", + "manual", + "noclippy", + "norustfmt", + ], + version = "24.0.0", + visibility = ["//visibility:private"], + deps = [ + "@cu__cc-1.1.7//:cc", + ], +) + +alias( + name = "build_script_build", + actual = ":wasmtime_bs", + tags = ["manual"], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.wasmtime-asm-macros-24.0.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.wasmtime-asm-macros-24.0.0.bazel new file mode 100644 index 000000000..d90c660db --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.wasmtime-asm-macros-24.0.0.bazel @@ -0,0 +1,47 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "wasmtime_asm_macros", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=wasmtime-asm-macros", + "manual", + "noclippy", + "norustfmt", + ], + version = "24.0.0", + deps = [ + "@cu__cfg-if-1.0.0//:cfg_if", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.wasmtime-c-api-macros-24.0.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.wasmtime-c-api-macros-24.0.0.bazel new file mode 100644 index 000000000..735e52d30 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.wasmtime-c-api-macros-24.0.0.bazel @@ -0,0 +1,48 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_proc_macro") + +package(default_visibility = ["//visibility:public"]) + +rust_proc_macro( + name = "wasmtime_c_api_macros", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=wasmtime-c-api-macros", + "manual", + "noclippy", + "norustfmt", + ], + version = "24.0.0", + deps = [ + "@cu__proc-macro2-1.0.86//:proc_macro2", + "@cu__quote-1.0.36//:quote", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.wasmtime-component-macro-24.0.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.wasmtime-component-macro-24.0.0.bazel new file mode 100644 index 000000000..5e50e4fc8 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.wasmtime-component-macro-24.0.0.bazel @@ -0,0 +1,96 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_proc_macro") + +package(default_visibility = ["//visibility:public"]) + +rust_proc_macro( + name = "wasmtime_component_macro", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=wasmtime-component-macro", + "manual", + "noclippy", + "norustfmt", + ], + version = "24.0.0", + deps = [ + "@cu__anyhow-1.0.86//:anyhow", + "@cu__proc-macro2-1.0.86//:proc_macro2", + "@cu__quote-1.0.36//:quote", + "@cu__syn-2.0.72//:syn", + "@cu__wasmtime-component-macro-24.0.0//:build_script_build", + "@cu__wasmtime-component-util-24.0.0//:wasmtime_component_util", + "@cu__wasmtime-wit-bindgen-24.0.0//:wasmtime_wit_bindgen", + "@cu__wit-parser-0.215.0//:wit_parser", + ], +) + +cargo_build_script( + name = "wasmtime-component-macro_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=wasmtime-component-macro", + "manual", + "noclippy", + "norustfmt", + ], + version = "24.0.0", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = ":wasmtime-component-macro_bs", + tags = ["manual"], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.wasmtime-component-util-24.0.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.wasmtime-component-util-24.0.0.bazel new file mode 100644 index 000000000..9823cd36b --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.wasmtime-component-util-24.0.0.bazel @@ -0,0 +1,44 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "wasmtime_component_util", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=wasmtime-component-util", + "manual", + "noclippy", + "norustfmt", + ], + version = "24.0.0", +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.wasmtime-cranelift-24.0.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.wasmtime-cranelift-24.0.0.bazel new file mode 100644 index 000000000..4687bb7c8 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.wasmtime-cranelift-24.0.0.bazel @@ -0,0 +1,67 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "wasmtime_cranelift", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "gc", + ], + crate_root = "src/lib.rs", + edition = "2021", + proc_macro_deps = [ + "@cu__wasmtime-versioned-export-macros-24.0.0//:wasmtime_versioned_export_macros", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=wasmtime-cranelift", + "manual", + "noclippy", + "norustfmt", + ], + version = "24.0.0", + deps = [ + "@cu__anyhow-1.0.86//:anyhow", + "@cu__cfg-if-1.0.0//:cfg_if", + "@cu__cranelift-codegen-0.111.0//:cranelift_codegen", + "@cu__cranelift-control-0.111.0//:cranelift_control", + "@cu__cranelift-entity-0.111.0//:cranelift_entity", + "@cu__cranelift-frontend-0.111.0//:cranelift_frontend", + "@cu__cranelift-native-0.111.0//:cranelift_native", + "@cu__cranelift-wasm-0.111.0//:cranelift_wasm", + "@cu__gimli-0.29.0//:gimli", + "@cu__log-0.4.22//:log", + "@cu__object-0.36.2//:object", + "@cu__target-lexicon-0.12.16//:target_lexicon", + "@cu__thiserror-1.0.63//:thiserror", + "@cu__wasmparser-0.215.0//:wasmparser", + "@cu__wasmtime-environ-24.0.0//:wasmtime_environ", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.wasmtime-environ-24.0.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.wasmtime-environ-24.0.0.bazel new file mode 100644 index 000000000..879839848 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.wasmtime-environ-24.0.0.bazel @@ -0,0 +1,68 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "wasmtime_environ", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "compile", + "gc", + "std", + ], + crate_root = "src/lib.rs", + edition = "2021", + proc_macro_deps = [ + "@cu__serde_derive-1.0.204//:serde_derive", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=wasmtime-environ", + "manual", + "noclippy", + "norustfmt", + ], + version = "24.0.0", + deps = [ + "@cu__anyhow-1.0.86//:anyhow", + "@cu__cranelift-bitset-0.111.0//:cranelift_bitset", + "@cu__cranelift-entity-0.111.0//:cranelift_entity", + "@cu__gimli-0.29.0//:gimli", + "@cu__indexmap-2.3.0//:indexmap", + "@cu__log-0.4.22//:log", + "@cu__object-0.36.2//:object", + "@cu__postcard-1.0.8//:postcard", + "@cu__serde-1.0.204//:serde", + "@cu__target-lexicon-0.12.16//:target_lexicon", + "@cu__wasm-encoder-0.215.0//:wasm_encoder", + "@cu__wasmparser-0.215.0//:wasmparser", + "@cu__wasmprinter-0.215.0//:wasmprinter", + "@cu__wasmtime-types-24.0.0//:wasmtime_types", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.wasmtime-jit-icache-coherence-24.0.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.wasmtime-jit-icache-coherence-24.0.0.bazel new file mode 100644 index 000000000..a1c3e8bdd --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.wasmtime-jit-icache-coherence-24.0.0.bazel @@ -0,0 +1,113 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "wasmtime_jit_icache_coherence", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=wasmtime-jit-icache-coherence", + "manual", + "noclippy", + "norustfmt", + ], + version = "24.0.0", + deps = [ + "@cu__anyhow-1.0.86//:anyhow", + "@cu__cfg-if-1.0.0//:cfg_if", + ] + select({ + "@rules_rust//rust/platform:aarch64-apple-darwin": [ + "@cu__libc-0.2.155//:libc", # cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd", target_os = "android")) + ], + "@rules_rust//rust/platform:aarch64-linux-android": [ + "@cu__libc-0.2.155//:libc", # cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd", target_os = "android")) + ], + "@rules_rust//rust/platform:aarch64-pc-windows-msvc": [ + "@cu__windows-sys-0.52.0//:windows_sys", # cfg(target_os = "windows") + ], + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [ + "@cu__libc-0.2.155//:libc", # cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd", target_os = "android")) + ], + "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu": [ + "@cu__libc-0.2.155//:libc", # cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd", target_os = "android")) + ], + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi": [ + "@cu__libc-0.2.155//:libc", # cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd", target_os = "android")) + ], + "@rules_rust//rust/platform:armv7-linux-androideabi": [ + "@cu__libc-0.2.155//:libc", # cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd", target_os = "android")) + ], + "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi": [ + "@cu__libc-0.2.155//:libc", # cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd", target_os = "android")) + ], + "@rules_rust//rust/platform:i686-apple-darwin": [ + "@cu__libc-0.2.155//:libc", # cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd", target_os = "android")) + ], + "@rules_rust//rust/platform:i686-linux-android": [ + "@cu__libc-0.2.155//:libc", # cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd", target_os = "android")) + ], + "@rules_rust//rust/platform:i686-pc-windows-msvc": [ + "@cu__windows-sys-0.52.0//:windows_sys", # cfg(target_os = "windows") + ], + "@rules_rust//rust/platform:i686-unknown-freebsd": [ + "@cu__libc-0.2.155//:libc", # cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd", target_os = "android")) + ], + "@rules_rust//rust/platform:i686-unknown-linux-gnu": [ + "@cu__libc-0.2.155//:libc", # cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd", target_os = "android")) + ], + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu": [ + "@cu__libc-0.2.155//:libc", # cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd", target_os = "android")) + ], + "@rules_rust//rust/platform:s390x-unknown-linux-gnu": [ + "@cu__libc-0.2.155//:libc", # cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd", target_os = "android")) + ], + "@rules_rust//rust/platform:x86_64-apple-darwin": [ + "@cu__libc-0.2.155//:libc", # cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd", target_os = "android")) + ], + "@rules_rust//rust/platform:x86_64-linux-android": [ + "@cu__libc-0.2.155//:libc", # cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd", target_os = "android")) + ], + "@rules_rust//rust/platform:x86_64-pc-windows-msvc": [ + "@cu__windows-sys-0.52.0//:windows_sys", # cfg(target_os = "windows") + ], + "@rules_rust//rust/platform:x86_64-unknown-freebsd": [ + "@cu__libc-0.2.155//:libc", # cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd", target_os = "android")) + ], + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [ + "@cu__libc-0.2.155//:libc", # cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd", target_os = "android")) + ], + "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu": [ + "@cu__libc-0.2.155//:libc", # cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd", target_os = "android")) + ], + "//conditions:default": [], + }), +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.wasmtime-slab-24.0.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.wasmtime-slab-24.0.0.bazel new file mode 100644 index 000000000..6a2147b54 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.wasmtime-slab-24.0.0.bazel @@ -0,0 +1,44 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "wasmtime_slab", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=wasmtime-slab", + "manual", + "noclippy", + "norustfmt", + ], + version = "24.0.0", +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.wasmtime-types-24.0.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.wasmtime-types-24.0.0.bazel new file mode 100644 index 000000000..4305c4a59 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.wasmtime-types-24.0.0.bazel @@ -0,0 +1,57 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "wasmtime_types", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "std", + ], + crate_root = "src/lib.rs", + edition = "2021", + proc_macro_deps = [ + "@cu__serde_derive-1.0.204//:serde_derive", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=wasmtime-types", + "manual", + "noclippy", + "norustfmt", + ], + version = "24.0.0", + deps = [ + "@cu__anyhow-1.0.86//:anyhow", + "@cu__cranelift-entity-0.111.0//:cranelift_entity", + "@cu__serde-1.0.204//:serde", + "@cu__smallvec-1.13.2//:smallvec", + "@cu__wasmparser-0.215.0//:wasmparser", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.wasmtime-versioned-export-macros-24.0.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.wasmtime-versioned-export-macros-24.0.0.bazel new file mode 100644 index 000000000..27dcf699a --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.wasmtime-versioned-export-macros-24.0.0.bazel @@ -0,0 +1,49 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_proc_macro") + +package(default_visibility = ["//visibility:public"]) + +rust_proc_macro( + name = "wasmtime_versioned_export_macros", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=wasmtime-versioned-export-macros", + "manual", + "noclippy", + "norustfmt", + ], + version = "24.0.0", + deps = [ + "@cu__proc-macro2-1.0.86//:proc_macro2", + "@cu__quote-1.0.36//:quote", + "@cu__syn-2.0.72//:syn", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.wasmtime-wit-bindgen-24.0.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.wasmtime-wit-bindgen-24.0.0.bazel new file mode 100644 index 000000000..53a8655c1 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.wasmtime-wit-bindgen-24.0.0.bazel @@ -0,0 +1,50 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "wasmtime_wit_bindgen", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=wasmtime-wit-bindgen", + "manual", + "noclippy", + "norustfmt", + ], + version = "24.0.0", + deps = [ + "@cu__anyhow-1.0.86//:anyhow", + "@cu__heck-0.4.1//:heck", + "@cu__indexmap-2.3.0//:indexmap", + "@cu__wit-parser-0.215.0//:wit_parser", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.winapi-util-0.1.8.bazel b/bazel/cargo/wasmtime/remote/BUILD.winapi-util-0.1.8.bazel new file mode 100644 index 000000000..7df210fa1 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.winapi-util-0.1.8.bazel @@ -0,0 +1,56 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "winapi_util", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=winapi-util", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.1.8", + deps = select({ + "@rules_rust//rust/platform:aarch64-pc-windows-msvc": [ + "@cu__windows-sys-0.52.0//:windows_sys", # cfg(windows) + ], + "@rules_rust//rust/platform:i686-pc-windows-msvc": [ + "@cu__windows-sys-0.52.0//:windows_sys", # cfg(windows) + ], + "@rules_rust//rust/platform:x86_64-pc-windows-msvc": [ + "@cu__windows-sys-0.52.0//:windows_sys", # cfg(windows) + ], + "//conditions:default": [], + }), +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.windows-sys-0.52.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.windows-sys-0.52.0.bazel new file mode 100644 index 000000000..eaa163139 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.windows-sys-0.52.0.bazel @@ -0,0 +1,63 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "windows_sys", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "Win32", + "Win32_Foundation", + "Win32_Security", + "Win32_Storage", + "Win32_Storage_FileSystem", + "Win32_System", + "Win32_System_Console", + "Win32_System_Diagnostics", + "Win32_System_Diagnostics_Debug", + "Win32_System_Kernel", + "Win32_System_Memory", + "Win32_System_SystemInformation", + "Win32_System_Threading", + "default", + ], + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=windows-sys", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.52.0", + deps = [ + "@cu__windows-targets-0.52.6//:windows_targets", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.windows-targets-0.52.6.bazel b/bazel/cargo/wasmtime/remote/BUILD.windows-targets-0.52.6.bazel new file mode 100644 index 000000000..eddc343ce --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.windows-targets-0.52.6.bazel @@ -0,0 +1,65 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "windows_targets", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=windows-targets", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.52.6", + deps = select({ + "@rules_rust//rust/platform:aarch64-pc-windows-msvc": [ + "@cu__windows_aarch64_msvc-0.52.6//:windows_aarch64_msvc", # cfg(all(target_arch = "aarch64", target_env = "msvc", not(windows_raw_dylib))) + ], + "@rules_rust//rust/platform:i686-pc-windows-msvc": [ + "@cu__windows_i686_msvc-0.52.6//:windows_i686_msvc", # cfg(all(target_arch = "x86", target_env = "msvc", not(windows_raw_dylib))) + ], + "@rules_rust//rust/platform:i686-unknown-linux-gnu": [ + "@cu__windows_i686_gnu-0.52.6//:windows_i686_gnu", # cfg(all(target_arch = "x86", target_env = "gnu", not(target_abi = "llvm"), not(windows_raw_dylib))) + ], + "@rules_rust//rust/platform:x86_64-pc-windows-msvc": [ + "@cu__windows_x86_64_msvc-0.52.6//:windows_x86_64_msvc", # cfg(all(any(target_arch = "x86_64", target_arch = "arm64ec"), target_env = "msvc", not(windows_raw_dylib))) + ], + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [ + "@cu__windows_x86_64_gnu-0.52.6//:windows_x86_64_gnu", # cfg(all(target_arch = "x86_64", target_env = "gnu", not(target_abi = "llvm"), not(windows_raw_dylib))) + ], + "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu": [ + "@cu__windows_x86_64_gnu-0.52.6//:windows_x86_64_gnu", # cfg(all(target_arch = "x86_64", target_env = "gnu", not(target_abi = "llvm"), not(windows_raw_dylib))) + ], + "//conditions:default": [], + }), +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.windows_aarch64_gnullvm-0.52.6.bazel b/bazel/cargo/wasmtime/remote/BUILD.windows_aarch64_gnullvm-0.52.6.bazel new file mode 100644 index 000000000..ec79e2200 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.windows_aarch64_gnullvm-0.52.6.bazel @@ -0,0 +1,89 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "windows_aarch64_gnullvm", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=windows_aarch64_gnullvm", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.52.6", + deps = [ + "@cu__windows_aarch64_gnullvm-0.52.6//:build_script_build", + ], +) + +cargo_build_script( + name = "windows_aarch64_gnullvm_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=windows_aarch64_gnullvm", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.52.6", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = ":windows_aarch64_gnullvm_bs", + tags = ["manual"], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.windows_aarch64_msvc-0.52.6.bazel b/bazel/cargo/wasmtime/remote/BUILD.windows_aarch64_msvc-0.52.6.bazel new file mode 100644 index 000000000..47ac38a7a --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.windows_aarch64_msvc-0.52.6.bazel @@ -0,0 +1,89 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "windows_aarch64_msvc", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=windows_aarch64_msvc", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.52.6", + deps = [ + "@cu__windows_aarch64_msvc-0.52.6//:build_script_build", + ], +) + +cargo_build_script( + name = "windows_aarch64_msvc_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=windows_aarch64_msvc", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.52.6", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = ":windows_aarch64_msvc_bs", + tags = ["manual"], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.windows_i686_gnu-0.52.6.bazel b/bazel/cargo/wasmtime/remote/BUILD.windows_i686_gnu-0.52.6.bazel new file mode 100644 index 000000000..e3f0ef486 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.windows_i686_gnu-0.52.6.bazel @@ -0,0 +1,89 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "windows_i686_gnu", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=windows_i686_gnu", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.52.6", + deps = [ + "@cu__windows_i686_gnu-0.52.6//:build_script_build", + ], +) + +cargo_build_script( + name = "windows_i686_gnu_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=windows_i686_gnu", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.52.6", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = ":windows_i686_gnu_bs", + tags = ["manual"], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.windows_i686_gnullvm-0.52.6.bazel b/bazel/cargo/wasmtime/remote/BUILD.windows_i686_gnullvm-0.52.6.bazel new file mode 100644 index 000000000..d89f239b5 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.windows_i686_gnullvm-0.52.6.bazel @@ -0,0 +1,89 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "windows_i686_gnullvm", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=windows_i686_gnullvm", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.52.6", + deps = [ + "@cu__windows_i686_gnullvm-0.52.6//:build_script_build", + ], +) + +cargo_build_script( + name = "windows_i686_gnullvm_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=windows_i686_gnullvm", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.52.6", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = ":windows_i686_gnullvm_bs", + tags = ["manual"], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.windows_i686_msvc-0.52.6.bazel b/bazel/cargo/wasmtime/remote/BUILD.windows_i686_msvc-0.52.6.bazel new file mode 100644 index 000000000..f6e758e5b --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.windows_i686_msvc-0.52.6.bazel @@ -0,0 +1,89 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "windows_i686_msvc", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=windows_i686_msvc", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.52.6", + deps = [ + "@cu__windows_i686_msvc-0.52.6//:build_script_build", + ], +) + +cargo_build_script( + name = "windows_i686_msvc_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=windows_i686_msvc", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.52.6", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = ":windows_i686_msvc_bs", + tags = ["manual"], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.windows_x86_64_gnu-0.52.6.bazel b/bazel/cargo/wasmtime/remote/BUILD.windows_x86_64_gnu-0.52.6.bazel new file mode 100644 index 000000000..cbccf337a --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.windows_x86_64_gnu-0.52.6.bazel @@ -0,0 +1,89 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "windows_x86_64_gnu", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=windows_x86_64_gnu", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.52.6", + deps = [ + "@cu__windows_x86_64_gnu-0.52.6//:build_script_build", + ], +) + +cargo_build_script( + name = "windows_x86_64_gnu_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=windows_x86_64_gnu", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.52.6", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = ":windows_x86_64_gnu_bs", + tags = ["manual"], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.windows_x86_64_gnullvm-0.52.6.bazel b/bazel/cargo/wasmtime/remote/BUILD.windows_x86_64_gnullvm-0.52.6.bazel new file mode 100644 index 000000000..91ac1adff --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.windows_x86_64_gnullvm-0.52.6.bazel @@ -0,0 +1,89 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "windows_x86_64_gnullvm", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=windows_x86_64_gnullvm", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.52.6", + deps = [ + "@cu__windows_x86_64_gnullvm-0.52.6//:build_script_build", + ], +) + +cargo_build_script( + name = "windows_x86_64_gnullvm_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=windows_x86_64_gnullvm", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.52.6", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = ":windows_x86_64_gnullvm_bs", + tags = ["manual"], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.windows_x86_64_msvc-0.52.6.bazel b/bazel/cargo/wasmtime/remote/BUILD.windows_x86_64_msvc-0.52.6.bazel new file mode 100644 index 000000000..fda09849a --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.windows_x86_64_msvc-0.52.6.bazel @@ -0,0 +1,89 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "windows_x86_64_msvc", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=windows_x86_64_msvc", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.52.6", + deps = [ + "@cu__windows_x86_64_msvc-0.52.6//:build_script_build", + ], +) + +cargo_build_script( + name = "windows_x86_64_msvc_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=windows_x86_64_msvc", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.52.6", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = ":windows_x86_64_msvc_bs", + tags = ["manual"], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.wit-parser-0.215.0.bazel b/bazel/cargo/wasmtime/remote/BUILD.wit-parser-0.215.0.bazel new file mode 100644 index 000000000..f2e6ad6a2 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.wit-parser-0.215.0.bazel @@ -0,0 +1,58 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "wit_parser", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2021", + proc_macro_deps = [ + "@cu__serde_derive-1.0.204//:serde_derive", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=wit-parser", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.215.0", + deps = [ + "@cu__anyhow-1.0.86//:anyhow", + "@cu__id-arena-2.2.1//:id_arena", + "@cu__indexmap-2.3.0//:indexmap", + "@cu__log-0.4.22//:log", + "@cu__semver-1.0.23//:semver", + "@cu__serde-1.0.204//:serde", + "@cu__serde_json-1.0.120//:serde_json", + "@cu__unicode-xid-0.2.4//:unicode_xid", + "@cu__wasmparser-0.215.0//:wasmparser", + ], +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.zerocopy-0.7.35.bazel b/bazel/cargo/wasmtime/remote/BUILD.zerocopy-0.7.35.bazel new file mode 100644 index 000000000..5bb874604 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.zerocopy-0.7.35.bazel @@ -0,0 +1,47 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "zerocopy", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "simd", + ], + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=zerocopy", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.7.35", +) diff --git a/bazel/cargo/wasmtime/remote/BUILD.zerocopy-derive-0.7.35.bazel b/bazel/cargo/wasmtime/remote/BUILD.zerocopy-derive-0.7.35.bazel new file mode 100644 index 000000000..dc6f82dfc --- /dev/null +++ b/bazel/cargo/wasmtime/remote/BUILD.zerocopy-derive-0.7.35.bazel @@ -0,0 +1,49 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_proc_macro") + +package(default_visibility = ["//visibility:public"]) + +rust_proc_macro( + name = "zerocopy_derive", + srcs = glob( + include = ["**/*.rs"], + allow_empty = False, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=zerocopy-derive", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.7.35", + deps = [ + "@cu__proc-macro2-1.0.86//:proc_macro2", + "@cu__quote-1.0.36//:quote", + "@cu__syn-2.0.72//:syn", + ], +) diff --git a/bazel/cargo/wasmtime/remote/alias_rules.bzl b/bazel/cargo/wasmtime/remote/alias_rules.bzl new file mode 100644 index 000000000..14b04c127 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/alias_rules.bzl @@ -0,0 +1,47 @@ +"""Alias that transitions its target to `compilation_mode=opt`. Use `transition_alias="opt"` to enable.""" + +load("@rules_cc//cc:defs.bzl", "CcInfo") +load("@rules_rust//rust:rust_common.bzl", "COMMON_PROVIDERS") + +def _transition_alias_impl(ctx): + # `ctx.attr.actual` is a list of 1 item due to the transition + providers = [ctx.attr.actual[0][provider] for provider in COMMON_PROVIDERS] + if CcInfo in ctx.attr.actual[0]: + providers.append(ctx.attr.actual[0][CcInfo]) + return providers + +def _change_compilation_mode(compilation_mode): + def _change_compilation_mode_impl(_settings, _attr): + return { + "//command_line_option:compilation_mode": compilation_mode, + } + + return transition( + implementation = _change_compilation_mode_impl, + inputs = [], + outputs = [ + "//command_line_option:compilation_mode", + ], + ) + +def _transition_alias_rule(compilation_mode): + return rule( + implementation = _transition_alias_impl, + provides = COMMON_PROVIDERS, + attrs = { + "actual": attr.label( + mandatory = True, + doc = "`rust_library()` target to transition to `compilation_mode=opt`.", + providers = COMMON_PROVIDERS, + cfg = _change_compilation_mode(compilation_mode), + ), + "_allowlist_function_transition": attr.label( + default = "@bazel_tools//tools/allowlists/function_transition_allowlist", + ), + }, + doc = "Transitions a Rust library crate to the `compilation_mode=opt`.", + ) + +transition_alias_dbg = _transition_alias_rule("dbg") +transition_alias_fastbuild = _transition_alias_rule("fastbuild") +transition_alias_opt = _transition_alias_rule("opt") diff --git a/bazel/cargo/wasmtime/remote/crates.bzl b/bazel/cargo/wasmtime/remote/crates.bzl new file mode 100644 index 000000000..c2726d29f --- /dev/null +++ b/bazel/cargo/wasmtime/remote/crates.bzl @@ -0,0 +1,32 @@ +############################################################################### +# @generated +# This file is auto-generated by the cargo-bazel tool. +# +# DO NOT MODIFY: Local changes may be replaced in future executions. +############################################################################### +"""Rules for defining repositories for remote `crates_vendor` repositories""" + +load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") + +# buildifier: disable=bzl-visibility +load("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:defs.bzl", _crate_repositories = "crate_repositories") + +# buildifier: disable=bzl-visibility +load("@rules_rust//crate_universe/private:crates_vendor.bzl", "crates_vendor_remote_repository") + +def crate_repositories(): + """Generates repositories for vendored crates. + + Returns: + A list of repos visible to the module through the module extension. + """ + maybe( + crates_vendor_remote_repository, + name = "cu", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.bazel"), + defs_module = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:defs.bzl"), + ) + + direct_deps = [struct(repo = "cu", is_dev_dep = False)] + direct_deps.extend(_crate_repositories()) + return direct_deps diff --git a/bazel/cargo/wasmtime/remote/defs.bzl b/bazel/cargo/wasmtime/remote/defs.bzl new file mode 100644 index 000000000..0f2656ce1 --- /dev/null +++ b/bazel/cargo/wasmtime/remote/defs.bzl @@ -0,0 +1,1537 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//bazel/cargo/wasmtime:crates_vendor +############################################################################### +""" +# `crates_repository` API + +- [aliases](#aliases) +- [crate_deps](#crate_deps) +- [all_crate_deps](#all_crate_deps) +- [crate_repositories](#crate_repositories) + +""" + +load("@bazel_skylib//lib:selects.bzl", "selects") +load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") + +############################################################################### +# MACROS API +############################################################################### + +# An identifier that represent common dependencies (unconditional). +_COMMON_CONDITION = "" + +def _flatten_dependency_maps(all_dependency_maps): + """Flatten a list of dependency maps into one dictionary. + + Dependency maps have the following structure: + + ```python + DEPENDENCIES_MAP = { + # The first key in the map is a Bazel package + # name of the workspace this file is defined in. + "workspace_member_package": { + + # Not all dependencies are supported for all platforms. + # the condition key is the condition required to be true + # on the host platform. + "condition": { + + # An alias to a crate target. # The label of the crate target the + # Aliases are only crate names. # package name refers to. + "package_name": "@full//:label", + } + } + } + ``` + + Args: + all_dependency_maps (list): A list of dicts as described above + + Returns: + dict: A dictionary as described above + """ + dependencies = {} + + for workspace_deps_map in all_dependency_maps: + for pkg_name, conditional_deps_map in workspace_deps_map.items(): + if pkg_name not in dependencies: + non_frozen_map = dict() + for key, values in conditional_deps_map.items(): + non_frozen_map.update({key: dict(values.items())}) + dependencies.setdefault(pkg_name, non_frozen_map) + continue + + for condition, deps_map in conditional_deps_map.items(): + # If the condition has not been recorded, do so and continue + if condition not in dependencies[pkg_name]: + dependencies[pkg_name].setdefault(condition, dict(deps_map.items())) + continue + + # Alert on any miss-matched dependencies + inconsistent_entries = [] + for crate_name, crate_label in deps_map.items(): + existing = dependencies[pkg_name][condition].get(crate_name) + if existing and existing != crate_label: + inconsistent_entries.append((crate_name, existing, crate_label)) + dependencies[pkg_name][condition].update({crate_name: crate_label}) + + return dependencies + +def crate_deps(deps, package_name = None): + """Finds the fully qualified label of the requested crates for the package where this macro is called. + + Args: + deps (list): The desired list of crate targets. + package_name (str, optional): The package name of the set of dependencies to look up. + Defaults to `native.package_name()`. + + Returns: + list: A list of labels to generated rust targets (str) + """ + + if not deps: + return [] + + if package_name == None: + package_name = native.package_name() + + # Join both sets of dependencies + dependencies = _flatten_dependency_maps([ + _NORMAL_DEPENDENCIES, + _NORMAL_DEV_DEPENDENCIES, + _PROC_MACRO_DEPENDENCIES, + _PROC_MACRO_DEV_DEPENDENCIES, + _BUILD_DEPENDENCIES, + _BUILD_PROC_MACRO_DEPENDENCIES, + ]).pop(package_name, {}) + + # Combine all conditional packages so we can easily index over a flat list + # TODO: Perhaps this should actually return select statements and maintain + # the conditionals of the dependencies + flat_deps = {} + for deps_set in dependencies.values(): + for crate_name, crate_label in deps_set.items(): + flat_deps.update({crate_name: crate_label}) + + missing_crates = [] + crate_targets = [] + for crate_target in deps: + if crate_target not in flat_deps: + missing_crates.append(crate_target) + else: + crate_targets.append(flat_deps[crate_target]) + + if missing_crates: + fail("Could not find crates `{}` among dependencies of `{}`. Available dependencies were `{}`".format( + missing_crates, + package_name, + dependencies, + )) + + return crate_targets + +def all_crate_deps( + normal = False, + normal_dev = False, + proc_macro = False, + proc_macro_dev = False, + build = False, + build_proc_macro = False, + package_name = None): + """Finds the fully qualified label of all requested direct crate dependencies \ + for the package where this macro is called. + + If no parameters are set, all normal dependencies are returned. Setting any one flag will + otherwise impact the contents of the returned list. + + Args: + normal (bool, optional): If True, normal dependencies are included in the + output list. + normal_dev (bool, optional): If True, normal dev dependencies will be + included in the output list.. + proc_macro (bool, optional): If True, proc_macro dependencies are included + in the output list. + proc_macro_dev (bool, optional): If True, dev proc_macro dependencies are + included in the output list. + build (bool, optional): If True, build dependencies are included + in the output list. + build_proc_macro (bool, optional): If True, build proc_macro dependencies are + included in the output list. + package_name (str, optional): The package name of the set of dependencies to look up. + Defaults to `native.package_name()` when unset. + + Returns: + list: A list of labels to generated rust targets (str) + """ + + if package_name == None: + package_name = native.package_name() + + # Determine the relevant maps to use + all_dependency_maps = [] + if normal: + all_dependency_maps.append(_NORMAL_DEPENDENCIES) + if normal_dev: + all_dependency_maps.append(_NORMAL_DEV_DEPENDENCIES) + if proc_macro: + all_dependency_maps.append(_PROC_MACRO_DEPENDENCIES) + if proc_macro_dev: + all_dependency_maps.append(_PROC_MACRO_DEV_DEPENDENCIES) + if build: + all_dependency_maps.append(_BUILD_DEPENDENCIES) + if build_proc_macro: + all_dependency_maps.append(_BUILD_PROC_MACRO_DEPENDENCIES) + + # Default to always using normal dependencies + if not all_dependency_maps: + all_dependency_maps.append(_NORMAL_DEPENDENCIES) + + dependencies = _flatten_dependency_maps(all_dependency_maps).pop(package_name, None) + + if not dependencies: + if dependencies == None: + fail("Tried to get all_crate_deps for package " + package_name + " but that package had no Cargo.toml file") + else: + return [] + + crate_deps = list(dependencies.pop(_COMMON_CONDITION, {}).values()) + for condition, deps in dependencies.items(): + crate_deps += selects.with_or({ + tuple(_CONDITIONS[condition]): deps.values(), + "//conditions:default": [], + }) + + return crate_deps + +def aliases( + normal = False, + normal_dev = False, + proc_macro = False, + proc_macro_dev = False, + build = False, + build_proc_macro = False, + package_name = None): + """Produces a map of Crate alias names to their original label + + If no dependency kinds are specified, `normal` and `proc_macro` are used by default. + Setting any one flag will otherwise determine the contents of the returned dict. + + Args: + normal (bool, optional): If True, normal dependencies are included in the + output list. + normal_dev (bool, optional): If True, normal dev dependencies will be + included in the output list.. + proc_macro (bool, optional): If True, proc_macro dependencies are included + in the output list. + proc_macro_dev (bool, optional): If True, dev proc_macro dependencies are + included in the output list. + build (bool, optional): If True, build dependencies are included + in the output list. + build_proc_macro (bool, optional): If True, build proc_macro dependencies are + included in the output list. + package_name (str, optional): The package name of the set of dependencies to look up. + Defaults to `native.package_name()` when unset. + + Returns: + dict: The aliases of all associated packages + """ + if package_name == None: + package_name = native.package_name() + + # Determine the relevant maps to use + all_aliases_maps = [] + if normal: + all_aliases_maps.append(_NORMAL_ALIASES) + if normal_dev: + all_aliases_maps.append(_NORMAL_DEV_ALIASES) + if proc_macro: + all_aliases_maps.append(_PROC_MACRO_ALIASES) + if proc_macro_dev: + all_aliases_maps.append(_PROC_MACRO_DEV_ALIASES) + if build: + all_aliases_maps.append(_BUILD_ALIASES) + if build_proc_macro: + all_aliases_maps.append(_BUILD_PROC_MACRO_ALIASES) + + # Default to always using normal aliases + if not all_aliases_maps: + all_aliases_maps.append(_NORMAL_ALIASES) + all_aliases_maps.append(_PROC_MACRO_ALIASES) + + aliases = _flatten_dependency_maps(all_aliases_maps).pop(package_name, None) + + if not aliases: + return dict() + + common_items = aliases.pop(_COMMON_CONDITION, {}).items() + + # If there are only common items in the dictionary, immediately return them + if not len(aliases.keys()) == 1: + return dict(common_items) + + # Build a single select statement where each conditional has accounted for the + # common set of aliases. + crate_aliases = {"//conditions:default": dict(common_items)} + for condition, deps in aliases.items(): + condition_triples = _CONDITIONS[condition] + for triple in condition_triples: + if triple in crate_aliases: + crate_aliases[triple].update(deps) + else: + crate_aliases.update({triple: dict(deps.items() + common_items)}) + + return select(crate_aliases) + +############################################################################### +# WORKSPACE MEMBER DEPS AND ALIASES +############################################################################### + +_NORMAL_DEPENDENCIES = { + "bazel/cargo/wasmtime": { + _COMMON_CONDITION: { + "anyhow": Label("@cu__anyhow-1.0.86//:anyhow"), + "env_logger": Label("@cu__env_logger-0.10.2//:env_logger"), + "log": Label("@cu__log-0.4.22//:log"), + "once_cell": Label("@cu__once_cell-1.19.0//:once_cell"), + "tracing": Label("@cu__tracing-0.1.40//:tracing"), + "wasmtime": Label("@cu__wasmtime-24.0.0//:wasmtime"), + }, + }, +} + +_NORMAL_ALIASES = { + "bazel/cargo/wasmtime": { + _COMMON_CONDITION: { + }, + }, +} + +_NORMAL_DEV_DEPENDENCIES = { + "bazel/cargo/wasmtime": { + }, +} + +_NORMAL_DEV_ALIASES = { + "bazel/cargo/wasmtime": { + }, +} + +_PROC_MACRO_DEPENDENCIES = { + "bazel/cargo/wasmtime": { + _COMMON_CONDITION: { + "wasmtime-c-api-macros": Label("@cu__wasmtime-c-api-macros-24.0.0//:wasmtime_c_api_macros"), + }, + }, +} + +_PROC_MACRO_ALIASES = { + "bazel/cargo/wasmtime": { + }, +} + +_PROC_MACRO_DEV_DEPENDENCIES = { + "bazel/cargo/wasmtime": { + }, +} + +_PROC_MACRO_DEV_ALIASES = { + "bazel/cargo/wasmtime": { + }, +} + +_BUILD_DEPENDENCIES = { + "bazel/cargo/wasmtime": { + }, +} + +_BUILD_ALIASES = { + "bazel/cargo/wasmtime": { + }, +} + +_BUILD_PROC_MACRO_DEPENDENCIES = { + "bazel/cargo/wasmtime": { + }, +} + +_BUILD_PROC_MACRO_ALIASES = { + "bazel/cargo/wasmtime": { + }, +} + +_CONDITIONS = { + "aarch64-apple-darwin": ["@rules_rust//rust/platform:aarch64-apple-darwin"], + "aarch64-apple-ios": ["@rules_rust//rust/platform:aarch64-apple-ios"], + "aarch64-apple-ios-sim": ["@rules_rust//rust/platform:aarch64-apple-ios-sim"], + "aarch64-fuchsia": ["@rules_rust//rust/platform:aarch64-fuchsia"], + "aarch64-linux-android": ["@rules_rust//rust/platform:aarch64-linux-android"], + "aarch64-pc-windows-gnullvm": [], + "aarch64-pc-windows-msvc": ["@rules_rust//rust/platform:aarch64-pc-windows-msvc"], + "aarch64-unknown-linux-gnu": ["@rules_rust//rust/platform:aarch64-unknown-linux-gnu"], + "aarch64-unknown-nixos-gnu": ["@rules_rust//rust/platform:aarch64-unknown-nixos-gnu"], + "aarch64-unknown-nto-qnx710": ["@rules_rust//rust/platform:aarch64-unknown-nto-qnx710"], + "arm-unknown-linux-gnueabi": ["@rules_rust//rust/platform:arm-unknown-linux-gnueabi"], + "armv7-linux-androideabi": ["@rules_rust//rust/platform:armv7-linux-androideabi"], + "armv7-unknown-linux-gnueabi": ["@rules_rust//rust/platform:armv7-unknown-linux-gnueabi"], + "cfg(all(any(target_arch = \"x86_64\", target_arch = \"arm64ec\"), target_env = \"msvc\", not(windows_raw_dylib)))": ["@rules_rust//rust/platform:x86_64-pc-windows-msvc"], + "cfg(all(any(target_os = \"android\", target_os = \"linux\"), any(rustix_use_libc, miri, not(all(target_os = \"linux\", target_endian = \"little\", any(target_arch = \"arm\", all(target_arch = \"aarch64\", target_pointer_width = \"64\"), target_arch = \"riscv64\", all(rustix_use_experimental_asm, target_arch = \"powerpc64\"), all(rustix_use_experimental_asm, target_arch = \"mips\"), all(rustix_use_experimental_asm, target_arch = \"mips32r6\"), all(rustix_use_experimental_asm, target_arch = \"mips64\"), all(rustix_use_experimental_asm, target_arch = \"mips64r6\"), target_arch = \"x86\", all(target_arch = \"x86_64\", target_pointer_width = \"64\")))))))": ["@rules_rust//rust/platform:aarch64-linux-android", "@rules_rust//rust/platform:armv7-linux-androideabi", "@rules_rust//rust/platform:i686-linux-android", "@rules_rust//rust/platform:powerpc-unknown-linux-gnu", "@rules_rust//rust/platform:s390x-unknown-linux-gnu", "@rules_rust//rust/platform:x86_64-linux-android"], + "cfg(all(not(rustix_use_libc), not(miri), target_os = \"linux\", target_endian = \"little\", any(target_arch = \"arm\", all(target_arch = \"aarch64\", target_pointer_width = \"64\"), target_arch = \"riscv64\", all(rustix_use_experimental_asm, target_arch = \"powerpc64\"), all(rustix_use_experimental_asm, target_arch = \"mips\"), all(rustix_use_experimental_asm, target_arch = \"mips32r6\"), all(rustix_use_experimental_asm, target_arch = \"mips64\"), all(rustix_use_experimental_asm, target_arch = \"mips64r6\"), target_arch = \"x86\", all(target_arch = \"x86_64\", target_pointer_width = \"64\"))))": ["@rules_rust//rust/platform:aarch64-unknown-linux-gnu", "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu", "@rules_rust//rust/platform:arm-unknown-linux-gnueabi", "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi", "@rules_rust//rust/platform:i686-unknown-linux-gnu", "@rules_rust//rust/platform:x86_64-unknown-linux-gnu", "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu"], + "cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = \"linux\", target_endian = \"little\", any(target_arch = \"arm\", all(target_arch = \"aarch64\", target_pointer_width = \"64\"), target_arch = \"riscv64\", all(rustix_use_experimental_asm, target_arch = \"powerpc64\"), all(rustix_use_experimental_asm, target_arch = \"mips\"), all(rustix_use_experimental_asm, target_arch = \"mips32r6\"), all(rustix_use_experimental_asm, target_arch = \"mips64\"), all(rustix_use_experimental_asm, target_arch = \"mips64r6\"), target_arch = \"x86\", all(target_arch = \"x86_64\", target_pointer_width = \"64\")))))))": ["@rules_rust//rust/platform:aarch64-apple-darwin", "@rules_rust//rust/platform:aarch64-apple-ios", "@rules_rust//rust/platform:aarch64-apple-ios-sim", "@rules_rust//rust/platform:aarch64-fuchsia", "@rules_rust//rust/platform:aarch64-linux-android", "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710", "@rules_rust//rust/platform:armv7-linux-androideabi", "@rules_rust//rust/platform:i686-apple-darwin", "@rules_rust//rust/platform:i686-linux-android", "@rules_rust//rust/platform:i686-unknown-freebsd", "@rules_rust//rust/platform:powerpc-unknown-linux-gnu", "@rules_rust//rust/platform:riscv32imc-unknown-none-elf", "@rules_rust//rust/platform:riscv64gc-unknown-none-elf", "@rules_rust//rust/platform:s390x-unknown-linux-gnu", "@rules_rust//rust/platform:thumbv7em-none-eabi", "@rules_rust//rust/platform:thumbv8m.main-none-eabi", "@rules_rust//rust/platform:wasm32-unknown-unknown", "@rules_rust//rust/platform:wasm32-wasi", "@rules_rust//rust/platform:x86_64-apple-darwin", "@rules_rust//rust/platform:x86_64-apple-ios", "@rules_rust//rust/platform:x86_64-fuchsia", "@rules_rust//rust/platform:x86_64-linux-android", "@rules_rust//rust/platform:x86_64-unknown-freebsd", "@rules_rust//rust/platform:x86_64-unknown-none"], + "cfg(all(target_arch = \"aarch64\", target_env = \"msvc\", not(windows_raw_dylib)))": ["@rules_rust//rust/platform:aarch64-pc-windows-msvc"], + "cfg(all(target_arch = \"x86\", target_env = \"gnu\", not(target_abi = \"llvm\"), not(windows_raw_dylib)))": ["@rules_rust//rust/platform:i686-unknown-linux-gnu"], + "cfg(all(target_arch = \"x86\", target_env = \"msvc\", not(windows_raw_dylib)))": ["@rules_rust//rust/platform:i686-pc-windows-msvc"], + "cfg(all(target_arch = \"x86_64\", target_env = \"gnu\", not(target_abi = \"llvm\"), not(windows_raw_dylib)))": ["@rules_rust//rust/platform:x86_64-unknown-linux-gnu", "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu"], + "cfg(any())": [], + "cfg(any(target_arch = \"s390x\", target_arch = \"riscv64\"))": ["@rules_rust//rust/platform:riscv64gc-unknown-none-elf", "@rules_rust//rust/platform:s390x-unknown-linux-gnu"], + "cfg(any(target_os = \"linux\", target_os = \"macos\", target_os = \"freebsd\", target_os = \"android\"))": ["@rules_rust//rust/platform:aarch64-apple-darwin", "@rules_rust//rust/platform:aarch64-linux-android", "@rules_rust//rust/platform:aarch64-unknown-linux-gnu", "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu", "@rules_rust//rust/platform:arm-unknown-linux-gnueabi", "@rules_rust//rust/platform:armv7-linux-androideabi", "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi", "@rules_rust//rust/platform:i686-apple-darwin", "@rules_rust//rust/platform:i686-linux-android", "@rules_rust//rust/platform:i686-unknown-freebsd", "@rules_rust//rust/platform:i686-unknown-linux-gnu", "@rules_rust//rust/platform:powerpc-unknown-linux-gnu", "@rules_rust//rust/platform:s390x-unknown-linux-gnu", "@rules_rust//rust/platform:x86_64-apple-darwin", "@rules_rust//rust/platform:x86_64-linux-android", "@rules_rust//rust/platform:x86_64-unknown-freebsd", "@rules_rust//rust/platform:x86_64-unknown-linux-gnu", "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu"], + "cfg(any(target_os = \"macos\", target_os = \"ios\"))": ["@rules_rust//rust/platform:aarch64-apple-darwin", "@rules_rust//rust/platform:aarch64-apple-ios", "@rules_rust//rust/platform:aarch64-apple-ios-sim", "@rules_rust//rust/platform:i686-apple-darwin", "@rules_rust//rust/platform:x86_64-apple-darwin", "@rules_rust//rust/platform:x86_64-apple-ios"], + "cfg(any(unix, target_os = \"wasi\"))": ["@rules_rust//rust/platform:aarch64-apple-darwin", "@rules_rust//rust/platform:aarch64-apple-ios", "@rules_rust//rust/platform:aarch64-apple-ios-sim", "@rules_rust//rust/platform:aarch64-fuchsia", "@rules_rust//rust/platform:aarch64-linux-android", "@rules_rust//rust/platform:aarch64-unknown-linux-gnu", "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu", "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710", "@rules_rust//rust/platform:arm-unknown-linux-gnueabi", "@rules_rust//rust/platform:armv7-linux-androideabi", "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi", "@rules_rust//rust/platform:i686-apple-darwin", "@rules_rust//rust/platform:i686-linux-android", "@rules_rust//rust/platform:i686-unknown-freebsd", "@rules_rust//rust/platform:i686-unknown-linux-gnu", "@rules_rust//rust/platform:powerpc-unknown-linux-gnu", "@rules_rust//rust/platform:s390x-unknown-linux-gnu", "@rules_rust//rust/platform:wasm32-wasi", "@rules_rust//rust/platform:x86_64-apple-darwin", "@rules_rust//rust/platform:x86_64-apple-ios", "@rules_rust//rust/platform:x86_64-fuchsia", "@rules_rust//rust/platform:x86_64-linux-android", "@rules_rust//rust/platform:x86_64-unknown-freebsd", "@rules_rust//rust/platform:x86_64-unknown-linux-gnu", "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu"], + "cfg(not(all(target_arch = \"arm\", target_os = \"none\")))": ["@rules_rust//rust/platform:aarch64-apple-darwin", "@rules_rust//rust/platform:aarch64-apple-ios", "@rules_rust//rust/platform:aarch64-apple-ios-sim", "@rules_rust//rust/platform:aarch64-fuchsia", "@rules_rust//rust/platform:aarch64-linux-android", "@rules_rust//rust/platform:aarch64-pc-windows-msvc", "@rules_rust//rust/platform:aarch64-unknown-linux-gnu", "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu", "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710", "@rules_rust//rust/platform:arm-unknown-linux-gnueabi", "@rules_rust//rust/platform:armv7-linux-androideabi", "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi", "@rules_rust//rust/platform:i686-apple-darwin", "@rules_rust//rust/platform:i686-linux-android", "@rules_rust//rust/platform:i686-pc-windows-msvc", "@rules_rust//rust/platform:i686-unknown-freebsd", "@rules_rust//rust/platform:i686-unknown-linux-gnu", "@rules_rust//rust/platform:powerpc-unknown-linux-gnu", "@rules_rust//rust/platform:riscv32imc-unknown-none-elf", "@rules_rust//rust/platform:riscv64gc-unknown-none-elf", "@rules_rust//rust/platform:s390x-unknown-linux-gnu", "@rules_rust//rust/platform:wasm32-unknown-unknown", "@rules_rust//rust/platform:wasm32-wasi", "@rules_rust//rust/platform:x86_64-apple-darwin", "@rules_rust//rust/platform:x86_64-apple-ios", "@rules_rust//rust/platform:x86_64-fuchsia", "@rules_rust//rust/platform:x86_64-linux-android", "@rules_rust//rust/platform:x86_64-pc-windows-msvc", "@rules_rust//rust/platform:x86_64-unknown-freebsd", "@rules_rust//rust/platform:x86_64-unknown-linux-gnu", "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu", "@rules_rust//rust/platform:x86_64-unknown-none"], + "cfg(target_arch = \"s390x\")": ["@rules_rust//rust/platform:s390x-unknown-linux-gnu"], + "cfg(target_os = \"hermit\")": [], + "cfg(target_os = \"linux\")": ["@rules_rust//rust/platform:aarch64-unknown-linux-gnu", "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu", "@rules_rust//rust/platform:arm-unknown-linux-gnueabi", "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi", "@rules_rust//rust/platform:i686-unknown-linux-gnu", "@rules_rust//rust/platform:powerpc-unknown-linux-gnu", "@rules_rust//rust/platform:s390x-unknown-linux-gnu", "@rules_rust//rust/platform:x86_64-unknown-linux-gnu", "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu"], + "cfg(target_os = \"macos\")": ["@rules_rust//rust/platform:aarch64-apple-darwin", "@rules_rust//rust/platform:i686-apple-darwin", "@rules_rust//rust/platform:x86_64-apple-darwin"], + "cfg(target_os = \"wasi\")": ["@rules_rust//rust/platform:wasm32-wasi"], + "cfg(target_os = \"windows\")": ["@rules_rust//rust/platform:aarch64-pc-windows-msvc", "@rules_rust//rust/platform:i686-pc-windows-msvc", "@rules_rust//rust/platform:x86_64-pc-windows-msvc"], + "cfg(unix)": ["@rules_rust//rust/platform:aarch64-apple-darwin", "@rules_rust//rust/platform:aarch64-apple-ios", "@rules_rust//rust/platform:aarch64-apple-ios-sim", "@rules_rust//rust/platform:aarch64-fuchsia", "@rules_rust//rust/platform:aarch64-linux-android", "@rules_rust//rust/platform:aarch64-unknown-linux-gnu", "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu", "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710", "@rules_rust//rust/platform:arm-unknown-linux-gnueabi", "@rules_rust//rust/platform:armv7-linux-androideabi", "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi", "@rules_rust//rust/platform:i686-apple-darwin", "@rules_rust//rust/platform:i686-linux-android", "@rules_rust//rust/platform:i686-unknown-freebsd", "@rules_rust//rust/platform:i686-unknown-linux-gnu", "@rules_rust//rust/platform:powerpc-unknown-linux-gnu", "@rules_rust//rust/platform:s390x-unknown-linux-gnu", "@rules_rust//rust/platform:x86_64-apple-darwin", "@rules_rust//rust/platform:x86_64-apple-ios", "@rules_rust//rust/platform:x86_64-fuchsia", "@rules_rust//rust/platform:x86_64-linux-android", "@rules_rust//rust/platform:x86_64-unknown-freebsd", "@rules_rust//rust/platform:x86_64-unknown-linux-gnu", "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu"], + "cfg(windows)": ["@rules_rust//rust/platform:aarch64-pc-windows-msvc", "@rules_rust//rust/platform:i686-pc-windows-msvc", "@rules_rust//rust/platform:x86_64-pc-windows-msvc"], + "i686-apple-darwin": ["@rules_rust//rust/platform:i686-apple-darwin"], + "i686-linux-android": ["@rules_rust//rust/platform:i686-linux-android"], + "i686-pc-windows-gnullvm": [], + "i686-pc-windows-msvc": ["@rules_rust//rust/platform:i686-pc-windows-msvc"], + "i686-unknown-freebsd": ["@rules_rust//rust/platform:i686-unknown-freebsd"], + "i686-unknown-linux-gnu": ["@rules_rust//rust/platform:i686-unknown-linux-gnu"], + "powerpc-unknown-linux-gnu": ["@rules_rust//rust/platform:powerpc-unknown-linux-gnu"], + "riscv32imc-unknown-none-elf": ["@rules_rust//rust/platform:riscv32imc-unknown-none-elf"], + "riscv64gc-unknown-none-elf": ["@rules_rust//rust/platform:riscv64gc-unknown-none-elf"], + "s390x-unknown-linux-gnu": ["@rules_rust//rust/platform:s390x-unknown-linux-gnu"], + "thumbv7em-none-eabi": ["@rules_rust//rust/platform:thumbv7em-none-eabi"], + "thumbv8m.main-none-eabi": ["@rules_rust//rust/platform:thumbv8m.main-none-eabi"], + "wasm32-unknown-unknown": ["@rules_rust//rust/platform:wasm32-unknown-unknown"], + "wasm32-wasi": ["@rules_rust//rust/platform:wasm32-wasi"], + "x86_64-apple-darwin": ["@rules_rust//rust/platform:x86_64-apple-darwin"], + "x86_64-apple-ios": ["@rules_rust//rust/platform:x86_64-apple-ios"], + "x86_64-fuchsia": ["@rules_rust//rust/platform:x86_64-fuchsia"], + "x86_64-linux-android": ["@rules_rust//rust/platform:x86_64-linux-android"], + "x86_64-pc-windows-gnullvm": [], + "x86_64-pc-windows-msvc": ["@rules_rust//rust/platform:x86_64-pc-windows-msvc"], + "x86_64-unknown-freebsd": ["@rules_rust//rust/platform:x86_64-unknown-freebsd"], + "x86_64-unknown-linux-gnu": ["@rules_rust//rust/platform:x86_64-unknown-linux-gnu"], + "x86_64-unknown-nixos-gnu": ["@rules_rust//rust/platform:x86_64-unknown-nixos-gnu"], + "x86_64-unknown-none": ["@rules_rust//rust/platform:x86_64-unknown-none"], +} + +############################################################################### + +def crate_repositories(): + """A macro for defining repositories for all generated crates. + + Returns: + A list of repos visible to the module through the module extension. + """ + maybe( + http_archive, + name = "cu__ahash-0.8.11", + sha256 = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011", + type = "tar.gz", + urls = ["https://static.crates.io/crates/ahash/0.8.11/download"], + strip_prefix = "ahash-0.8.11", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.ahash-0.8.11.bazel"), + ) + + maybe( + http_archive, + name = "cu__aho-corasick-1.1.3", + sha256 = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916", + type = "tar.gz", + urls = ["https://static.crates.io/crates/aho-corasick/1.1.3/download"], + strip_prefix = "aho-corasick-1.1.3", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.aho-corasick-1.1.3.bazel"), + ) + + maybe( + http_archive, + name = "cu__anyhow-1.0.86", + sha256 = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da", + type = "tar.gz", + urls = ["https://static.crates.io/crates/anyhow/1.0.86/download"], + strip_prefix = "anyhow-1.0.86", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.anyhow-1.0.86.bazel"), + ) + + maybe( + http_archive, + name = "cu__arbitrary-1.3.2", + sha256 = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110", + type = "tar.gz", + urls = ["https://static.crates.io/crates/arbitrary/1.3.2/download"], + strip_prefix = "arbitrary-1.3.2", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.arbitrary-1.3.2.bazel"), + ) + + maybe( + http_archive, + name = "cu__bitflags-2.6.0", + sha256 = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de", + type = "tar.gz", + urls = ["https://static.crates.io/crates/bitflags/2.6.0/download"], + strip_prefix = "bitflags-2.6.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.bitflags-2.6.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__bumpalo-3.16.0", + sha256 = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c", + type = "tar.gz", + urls = ["https://static.crates.io/crates/bumpalo/3.16.0/download"], + strip_prefix = "bumpalo-3.16.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.bumpalo-3.16.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__cc-1.1.7", + sha256 = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc", + type = "tar.gz", + urls = ["https://static.crates.io/crates/cc/1.1.7/download"], + strip_prefix = "cc-1.1.7", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.cc-1.1.7.bazel"), + ) + + maybe( + http_archive, + name = "cu__cfg-if-1.0.0", + sha256 = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd", + type = "tar.gz", + urls = ["https://static.crates.io/crates/cfg-if/1.0.0/download"], + strip_prefix = "cfg-if-1.0.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.cfg-if-1.0.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__cobs-0.2.3", + sha256 = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15", + type = "tar.gz", + urls = ["https://static.crates.io/crates/cobs/0.2.3/download"], + strip_prefix = "cobs-0.2.3", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.cobs-0.2.3.bazel"), + ) + + maybe( + http_archive, + name = "cu__cranelift-bforest-0.111.0", + sha256 = "b80c3a50b9c4c7e5b5f73c0ed746687774fc9e36ef652b110da8daebf0c6e0e6", + type = "tar.gz", + urls = ["https://static.crates.io/crates/cranelift-bforest/0.111.0/download"], + strip_prefix = "cranelift-bforest-0.111.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.cranelift-bforest-0.111.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__cranelift-bitset-0.111.0", + sha256 = "38778758c2ca918b05acb2199134e0c561fb577c50574259b26190b6c2d95ded", + type = "tar.gz", + urls = ["https://static.crates.io/crates/cranelift-bitset/0.111.0/download"], + strip_prefix = "cranelift-bitset-0.111.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.cranelift-bitset-0.111.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__cranelift-codegen-0.111.0", + sha256 = "58258667ad10e468bfc13a8d620f50dfcd4bb35d668123e97defa2549b9ad397", + type = "tar.gz", + urls = ["https://static.crates.io/crates/cranelift-codegen/0.111.0/download"], + strip_prefix = "cranelift-codegen-0.111.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.cranelift-codegen-0.111.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__cranelift-codegen-meta-0.111.0", + sha256 = "043f0b702e529dcb07ff92bd7d40e7d5317b5493595172c5eb0983343751ee06", + type = "tar.gz", + urls = ["https://static.crates.io/crates/cranelift-codegen-meta/0.111.0/download"], + strip_prefix = "cranelift-codegen-meta-0.111.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.cranelift-codegen-meta-0.111.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__cranelift-codegen-shared-0.111.0", + sha256 = "7763578888ab53eca5ce7da141953f828e82c2bfadcffc106d10d1866094ffbb", + type = "tar.gz", + urls = ["https://static.crates.io/crates/cranelift-codegen-shared/0.111.0/download"], + strip_prefix = "cranelift-codegen-shared-0.111.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.cranelift-codegen-shared-0.111.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__cranelift-control-0.111.0", + sha256 = "32db15f08c05df570f11e8ab33cb1ec449a64b37c8a3498377b77650bef33d8b", + type = "tar.gz", + urls = ["https://static.crates.io/crates/cranelift-control/0.111.0/download"], + strip_prefix = "cranelift-control-0.111.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.cranelift-control-0.111.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__cranelift-entity-0.111.0", + sha256 = "5289cdb399381a27e7bbfa1b42185916007c3d49aeef70b1d01cb4caa8010130", + type = "tar.gz", + urls = ["https://static.crates.io/crates/cranelift-entity/0.111.0/download"], + strip_prefix = "cranelift-entity-0.111.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.cranelift-entity-0.111.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__cranelift-frontend-0.111.0", + sha256 = "31ba8ab24eb9470477e98ddfa3c799a649ac5a0d9a2042868c4c952133c234e8", + type = "tar.gz", + urls = ["https://static.crates.io/crates/cranelift-frontend/0.111.0/download"], + strip_prefix = "cranelift-frontend-0.111.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.cranelift-frontend-0.111.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__cranelift-isle-0.111.0", + sha256 = "2b72a3c5c166a70426dcb209bdd0bb71a787c1ea76023dc0974fbabca770e8f9", + type = "tar.gz", + urls = ["https://static.crates.io/crates/cranelift-isle/0.111.0/download"], + strip_prefix = "cranelift-isle-0.111.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.cranelift-isle-0.111.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__cranelift-native-0.111.0", + sha256 = "46a42424c956bbc31fc5c2706073df896156c5420ae8fa2a5d48dbc7b295d71b", + type = "tar.gz", + urls = ["https://static.crates.io/crates/cranelift-native/0.111.0/download"], + strip_prefix = "cranelift-native-0.111.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.cranelift-native-0.111.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__cranelift-wasm-0.111.0", + sha256 = "49778df4289933d735b93c30a345513e030cf83101de0036e19b760f8aa09f68", + type = "tar.gz", + urls = ["https://static.crates.io/crates/cranelift-wasm/0.111.0/download"], + strip_prefix = "cranelift-wasm-0.111.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.cranelift-wasm-0.111.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__crc32fast-1.4.2", + sha256 = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3", + type = "tar.gz", + urls = ["https://static.crates.io/crates/crc32fast/1.4.2/download"], + strip_prefix = "crc32fast-1.4.2", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.crc32fast-1.4.2.bazel"), + ) + + maybe( + http_archive, + name = "cu__either-1.13.0", + sha256 = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0", + type = "tar.gz", + urls = ["https://static.crates.io/crates/either/1.13.0/download"], + strip_prefix = "either-1.13.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.either-1.13.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__embedded-io-0.4.0", + sha256 = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced", + type = "tar.gz", + urls = ["https://static.crates.io/crates/embedded-io/0.4.0/download"], + strip_prefix = "embedded-io-0.4.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.embedded-io-0.4.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__env_logger-0.10.2", + sha256 = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580", + type = "tar.gz", + urls = ["https://static.crates.io/crates/env_logger/0.10.2/download"], + strip_prefix = "env_logger-0.10.2", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.env_logger-0.10.2.bazel"), + ) + + maybe( + http_archive, + name = "cu__equivalent-1.0.1", + sha256 = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5", + type = "tar.gz", + urls = ["https://static.crates.io/crates/equivalent/1.0.1/download"], + strip_prefix = "equivalent-1.0.1", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.equivalent-1.0.1.bazel"), + ) + + maybe( + http_archive, + name = "cu__errno-0.3.9", + sha256 = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba", + type = "tar.gz", + urls = ["https://static.crates.io/crates/errno/0.3.9/download"], + strip_prefix = "errno-0.3.9", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.errno-0.3.9.bazel"), + ) + + maybe( + http_archive, + name = "cu__fallible-iterator-0.3.0", + sha256 = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649", + type = "tar.gz", + urls = ["https://static.crates.io/crates/fallible-iterator/0.3.0/download"], + strip_prefix = "fallible-iterator-0.3.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.fallible-iterator-0.3.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__gimli-0.29.0", + sha256 = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd", + type = "tar.gz", + urls = ["https://static.crates.io/crates/gimli/0.29.0/download"], + strip_prefix = "gimli-0.29.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.gimli-0.29.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__hashbrown-0.13.2", + sha256 = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e", + type = "tar.gz", + urls = ["https://static.crates.io/crates/hashbrown/0.13.2/download"], + strip_prefix = "hashbrown-0.13.2", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.hashbrown-0.13.2.bazel"), + ) + + maybe( + http_archive, + name = "cu__hashbrown-0.14.5", + sha256 = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1", + type = "tar.gz", + urls = ["https://static.crates.io/crates/hashbrown/0.14.5/download"], + strip_prefix = "hashbrown-0.14.5", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.hashbrown-0.14.5.bazel"), + ) + + maybe( + http_archive, + name = "cu__heck-0.4.1", + sha256 = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8", + type = "tar.gz", + urls = ["https://static.crates.io/crates/heck/0.4.1/download"], + strip_prefix = "heck-0.4.1", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.heck-0.4.1.bazel"), + ) + + maybe( + http_archive, + name = "cu__hermit-abi-0.3.9", + sha256 = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024", + type = "tar.gz", + urls = ["https://static.crates.io/crates/hermit-abi/0.3.9/download"], + strip_prefix = "hermit-abi-0.3.9", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.hermit-abi-0.3.9.bazel"), + ) + + maybe( + http_archive, + name = "cu__humantime-2.1.0", + sha256 = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4", + type = "tar.gz", + urls = ["https://static.crates.io/crates/humantime/2.1.0/download"], + strip_prefix = "humantime-2.1.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.humantime-2.1.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__id-arena-2.2.1", + sha256 = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005", + type = "tar.gz", + urls = ["https://static.crates.io/crates/id-arena/2.2.1/download"], + strip_prefix = "id-arena-2.2.1", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.id-arena-2.2.1.bazel"), + ) + + maybe( + http_archive, + name = "cu__indexmap-2.3.0", + sha256 = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0", + type = "tar.gz", + urls = ["https://static.crates.io/crates/indexmap/2.3.0/download"], + strip_prefix = "indexmap-2.3.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.indexmap-2.3.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__is-terminal-0.4.12", + sha256 = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b", + type = "tar.gz", + urls = ["https://static.crates.io/crates/is-terminal/0.4.12/download"], + strip_prefix = "is-terminal-0.4.12", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.is-terminal-0.4.12.bazel"), + ) + + maybe( + http_archive, + name = "cu__itertools-0.12.1", + sha256 = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569", + type = "tar.gz", + urls = ["https://static.crates.io/crates/itertools/0.12.1/download"], + strip_prefix = "itertools-0.12.1", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.itertools-0.12.1.bazel"), + ) + + maybe( + http_archive, + name = "cu__itoa-1.0.11", + sha256 = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b", + type = "tar.gz", + urls = ["https://static.crates.io/crates/itoa/1.0.11/download"], + strip_prefix = "itoa-1.0.11", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.itoa-1.0.11.bazel"), + ) + + maybe( + http_archive, + name = "cu__leb128-0.2.5", + sha256 = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67", + type = "tar.gz", + urls = ["https://static.crates.io/crates/leb128/0.2.5/download"], + strip_prefix = "leb128-0.2.5", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.leb128-0.2.5.bazel"), + ) + + maybe( + http_archive, + name = "cu__libc-0.2.155", + sha256 = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c", + type = "tar.gz", + urls = ["https://static.crates.io/crates/libc/0.2.155/download"], + strip_prefix = "libc-0.2.155", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.libc-0.2.155.bazel"), + ) + + maybe( + http_archive, + name = "cu__libm-0.2.8", + sha256 = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058", + type = "tar.gz", + urls = ["https://static.crates.io/crates/libm/0.2.8/download"], + strip_prefix = "libm-0.2.8", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.libm-0.2.8.bazel"), + ) + + maybe( + http_archive, + name = "cu__linux-raw-sys-0.4.14", + sha256 = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89", + type = "tar.gz", + urls = ["https://static.crates.io/crates/linux-raw-sys/0.4.14/download"], + strip_prefix = "linux-raw-sys-0.4.14", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.linux-raw-sys-0.4.14.bazel"), + ) + + maybe( + http_archive, + name = "cu__log-0.4.22", + sha256 = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24", + type = "tar.gz", + urls = ["https://static.crates.io/crates/log/0.4.22/download"], + strip_prefix = "log-0.4.22", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.log-0.4.22.bazel"), + ) + + maybe( + http_archive, + name = "cu__mach2-0.4.2", + sha256 = "19b955cdeb2a02b9117f121ce63aa52d08ade45de53e48fe6a38b39c10f6f709", + type = "tar.gz", + urls = ["https://static.crates.io/crates/mach2/0.4.2/download"], + strip_prefix = "mach2-0.4.2", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.mach2-0.4.2.bazel"), + ) + + maybe( + http_archive, + name = "cu__memchr-2.7.4", + sha256 = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3", + type = "tar.gz", + urls = ["https://static.crates.io/crates/memchr/2.7.4/download"], + strip_prefix = "memchr-2.7.4", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.memchr-2.7.4.bazel"), + ) + + maybe( + http_archive, + name = "cu__memfd-0.6.4", + sha256 = "b2cffa4ad52c6f791f4f8b15f0c05f9824b2ced1160e88cc393d64fff9a8ac64", + type = "tar.gz", + urls = ["https://static.crates.io/crates/memfd/0.6.4/download"], + strip_prefix = "memfd-0.6.4", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.memfd-0.6.4.bazel"), + ) + + maybe( + http_archive, + name = "cu__object-0.36.2", + sha256 = "3f203fa8daa7bb185f760ae12bd8e097f63d17041dcdcaf675ac54cdf863170e", + type = "tar.gz", + urls = ["https://static.crates.io/crates/object/0.36.2/download"], + strip_prefix = "object-0.36.2", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.object-0.36.2.bazel"), + ) + + maybe( + http_archive, + name = "cu__once_cell-1.19.0", + sha256 = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92", + type = "tar.gz", + urls = ["https://static.crates.io/crates/once_cell/1.19.0/download"], + strip_prefix = "once_cell-1.19.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.once_cell-1.19.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__paste-1.0.15", + sha256 = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a", + type = "tar.gz", + urls = ["https://static.crates.io/crates/paste/1.0.15/download"], + strip_prefix = "paste-1.0.15", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.paste-1.0.15.bazel"), + ) + + maybe( + http_archive, + name = "cu__pin-project-lite-0.2.14", + sha256 = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02", + type = "tar.gz", + urls = ["https://static.crates.io/crates/pin-project-lite/0.2.14/download"], + strip_prefix = "pin-project-lite-0.2.14", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.pin-project-lite-0.2.14.bazel"), + ) + + maybe( + http_archive, + name = "cu__postcard-1.0.8", + sha256 = "a55c51ee6c0db07e68448e336cf8ea4131a620edefebf9893e759b2d793420f8", + type = "tar.gz", + urls = ["https://static.crates.io/crates/postcard/1.0.8/download"], + strip_prefix = "postcard-1.0.8", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.postcard-1.0.8.bazel"), + ) + + maybe( + http_archive, + name = "cu__proc-macro2-1.0.86", + sha256 = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77", + type = "tar.gz", + urls = ["https://static.crates.io/crates/proc-macro2/1.0.86/download"], + strip_prefix = "proc-macro2-1.0.86", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.proc-macro2-1.0.86.bazel"), + ) + + maybe( + http_archive, + name = "cu__psm-0.1.21", + sha256 = "5787f7cda34e3033a72192c018bc5883100330f362ef279a8cbccfce8bb4e874", + type = "tar.gz", + urls = ["https://static.crates.io/crates/psm/0.1.21/download"], + strip_prefix = "psm-0.1.21", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.psm-0.1.21.bazel"), + ) + + maybe( + http_archive, + name = "cu__quote-1.0.36", + sha256 = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7", + type = "tar.gz", + urls = ["https://static.crates.io/crates/quote/1.0.36/download"], + strip_prefix = "quote-1.0.36", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.quote-1.0.36.bazel"), + ) + + maybe( + http_archive, + name = "cu__regalloc2-0.9.3", + sha256 = "ad156d539c879b7a24a363a2016d77961786e71f48f2e2fc8302a92abd2429a6", + type = "tar.gz", + urls = ["https://static.crates.io/crates/regalloc2/0.9.3/download"], + strip_prefix = "regalloc2-0.9.3", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.regalloc2-0.9.3.bazel"), + ) + + maybe( + http_archive, + name = "cu__regex-1.10.5", + sha256 = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f", + type = "tar.gz", + urls = ["https://static.crates.io/crates/regex/1.10.5/download"], + strip_prefix = "regex-1.10.5", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.regex-1.10.5.bazel"), + ) + + maybe( + http_archive, + name = "cu__regex-automata-0.4.7", + sha256 = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df", + type = "tar.gz", + urls = ["https://static.crates.io/crates/regex-automata/0.4.7/download"], + strip_prefix = "regex-automata-0.4.7", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.regex-automata-0.4.7.bazel"), + ) + + maybe( + http_archive, + name = "cu__regex-syntax-0.8.4", + sha256 = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b", + type = "tar.gz", + urls = ["https://static.crates.io/crates/regex-syntax/0.8.4/download"], + strip_prefix = "regex-syntax-0.8.4", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.regex-syntax-0.8.4.bazel"), + ) + + maybe( + http_archive, + name = "cu__rustc-hash-1.1.0", + sha256 = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2", + type = "tar.gz", + urls = ["https://static.crates.io/crates/rustc-hash/1.1.0/download"], + strip_prefix = "rustc-hash-1.1.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.rustc-hash-1.1.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__rustix-0.38.34", + sha256 = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f", + type = "tar.gz", + urls = ["https://static.crates.io/crates/rustix/0.38.34/download"], + strip_prefix = "rustix-0.38.34", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.rustix-0.38.34.bazel"), + ) + + maybe( + http_archive, + name = "cu__ryu-1.0.18", + sha256 = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f", + type = "tar.gz", + urls = ["https://static.crates.io/crates/ryu/1.0.18/download"], + strip_prefix = "ryu-1.0.18", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.ryu-1.0.18.bazel"), + ) + + maybe( + http_archive, + name = "cu__semver-1.0.23", + sha256 = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b", + type = "tar.gz", + urls = ["https://static.crates.io/crates/semver/1.0.23/download"], + strip_prefix = "semver-1.0.23", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.semver-1.0.23.bazel"), + ) + + maybe( + http_archive, + name = "cu__serde-1.0.204", + sha256 = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12", + type = "tar.gz", + urls = ["https://static.crates.io/crates/serde/1.0.204/download"], + strip_prefix = "serde-1.0.204", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.serde-1.0.204.bazel"), + ) + + maybe( + http_archive, + name = "cu__serde_derive-1.0.204", + sha256 = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222", + type = "tar.gz", + urls = ["https://static.crates.io/crates/serde_derive/1.0.204/download"], + strip_prefix = "serde_derive-1.0.204", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.serde_derive-1.0.204.bazel"), + ) + + maybe( + http_archive, + name = "cu__serde_json-1.0.120", + sha256 = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5", + type = "tar.gz", + urls = ["https://static.crates.io/crates/serde_json/1.0.120/download"], + strip_prefix = "serde_json-1.0.120", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.serde_json-1.0.120.bazel"), + ) + + maybe( + http_archive, + name = "cu__slice-group-by-0.3.1", + sha256 = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7", + type = "tar.gz", + urls = ["https://static.crates.io/crates/slice-group-by/0.3.1/download"], + strip_prefix = "slice-group-by-0.3.1", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.slice-group-by-0.3.1.bazel"), + ) + + maybe( + http_archive, + name = "cu__smallvec-1.13.2", + sha256 = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67", + type = "tar.gz", + urls = ["https://static.crates.io/crates/smallvec/1.13.2/download"], + strip_prefix = "smallvec-1.13.2", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.smallvec-1.13.2.bazel"), + ) + + maybe( + http_archive, + name = "cu__sptr-0.3.2", + sha256 = "3b9b39299b249ad65f3b7e96443bad61c02ca5cd3589f46cb6d610a0fd6c0d6a", + type = "tar.gz", + urls = ["https://static.crates.io/crates/sptr/0.3.2/download"], + strip_prefix = "sptr-0.3.2", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.sptr-0.3.2.bazel"), + ) + + maybe( + http_archive, + name = "cu__stable_deref_trait-1.2.0", + sha256 = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3", + type = "tar.gz", + urls = ["https://static.crates.io/crates/stable_deref_trait/1.2.0/download"], + strip_prefix = "stable_deref_trait-1.2.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.stable_deref_trait-1.2.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__syn-2.0.72", + sha256 = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af", + type = "tar.gz", + urls = ["https://static.crates.io/crates/syn/2.0.72/download"], + strip_prefix = "syn-2.0.72", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.syn-2.0.72.bazel"), + ) + + maybe( + http_archive, + name = "cu__target-lexicon-0.12.16", + sha256 = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1", + type = "tar.gz", + urls = ["https://static.crates.io/crates/target-lexicon/0.12.16/download"], + strip_prefix = "target-lexicon-0.12.16", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.target-lexicon-0.12.16.bazel"), + ) + + maybe( + http_archive, + name = "cu__termcolor-1.4.1", + sha256 = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755", + type = "tar.gz", + urls = ["https://static.crates.io/crates/termcolor/1.4.1/download"], + strip_prefix = "termcolor-1.4.1", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.termcolor-1.4.1.bazel"), + ) + + maybe( + http_archive, + name = "cu__thiserror-1.0.63", + sha256 = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724", + type = "tar.gz", + urls = ["https://static.crates.io/crates/thiserror/1.0.63/download"], + strip_prefix = "thiserror-1.0.63", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.thiserror-1.0.63.bazel"), + ) + + maybe( + http_archive, + name = "cu__thiserror-impl-1.0.63", + sha256 = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261", + type = "tar.gz", + urls = ["https://static.crates.io/crates/thiserror-impl/1.0.63/download"], + strip_prefix = "thiserror-impl-1.0.63", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.thiserror-impl-1.0.63.bazel"), + ) + + maybe( + http_archive, + name = "cu__tracing-0.1.40", + sha256 = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef", + type = "tar.gz", + urls = ["https://static.crates.io/crates/tracing/0.1.40/download"], + strip_prefix = "tracing-0.1.40", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.tracing-0.1.40.bazel"), + ) + + maybe( + http_archive, + name = "cu__tracing-attributes-0.1.27", + sha256 = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7", + type = "tar.gz", + urls = ["https://static.crates.io/crates/tracing-attributes/0.1.27/download"], + strip_prefix = "tracing-attributes-0.1.27", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.tracing-attributes-0.1.27.bazel"), + ) + + maybe( + http_archive, + name = "cu__tracing-core-0.1.32", + sha256 = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54", + type = "tar.gz", + urls = ["https://static.crates.io/crates/tracing-core/0.1.32/download"], + strip_prefix = "tracing-core-0.1.32", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.tracing-core-0.1.32.bazel"), + ) + + maybe( + http_archive, + name = "cu__unicode-ident-1.0.12", + sha256 = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b", + type = "tar.gz", + urls = ["https://static.crates.io/crates/unicode-ident/1.0.12/download"], + strip_prefix = "unicode-ident-1.0.12", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.unicode-ident-1.0.12.bazel"), + ) + + maybe( + http_archive, + name = "cu__unicode-xid-0.2.4", + sha256 = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c", + type = "tar.gz", + urls = ["https://static.crates.io/crates/unicode-xid/0.2.4/download"], + strip_prefix = "unicode-xid-0.2.4", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.unicode-xid-0.2.4.bazel"), + ) + + maybe( + http_archive, + name = "cu__version_check-0.9.5", + sha256 = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a", + type = "tar.gz", + urls = ["https://static.crates.io/crates/version_check/0.9.5/download"], + strip_prefix = "version_check-0.9.5", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.version_check-0.9.5.bazel"), + ) + + maybe( + http_archive, + name = "cu__wasm-encoder-0.215.0", + sha256 = "4fb56df3e06b8e6b77e37d2969a50ba51281029a9aeb3855e76b7f49b6418847", + type = "tar.gz", + urls = ["https://static.crates.io/crates/wasm-encoder/0.215.0/download"], + strip_prefix = "wasm-encoder-0.215.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.wasm-encoder-0.215.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__wasmparser-0.215.0", + sha256 = "53fbde0881f24199b81cf49b6ff8f9c145ac8eb1b7fc439adb5c099734f7d90e", + type = "tar.gz", + urls = ["https://static.crates.io/crates/wasmparser/0.215.0/download"], + strip_prefix = "wasmparser-0.215.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.wasmparser-0.215.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__wasmprinter-0.215.0", + sha256 = "d8e9a325d85053408209b3d2ce5eaddd0dd6864d1cff7a007147ba073157defc", + type = "tar.gz", + urls = ["https://static.crates.io/crates/wasmprinter/0.215.0/download"], + strip_prefix = "wasmprinter-0.215.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.wasmprinter-0.215.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__wasmtime-24.0.0", + sha256 = "9a5883d64dfc8423c56e3d8df27cffc44db25336aa468e8e0724fddf30a333d7", + type = "tar.gz", + urls = ["https://static.crates.io/crates/wasmtime/24.0.0/download"], + strip_prefix = "wasmtime-24.0.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.wasmtime-24.0.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__wasmtime-asm-macros-24.0.0", + sha256 = "1c4dc7e2a379c0dd6be5b55857d14c4b277f43a9c429a9e14403eb61776ae3be", + type = "tar.gz", + urls = ["https://static.crates.io/crates/wasmtime-asm-macros/24.0.0/download"], + strip_prefix = "wasmtime-asm-macros-24.0.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.wasmtime-asm-macros-24.0.0.bazel"), + ) + + maybe( + new_git_repository, + name = "cu__wasmtime-c-api-macros-24.0.0", + commit = "6fc3d274c7994dad20c816ccc0739bf766b39a11", + init_submodules = True, + remote = "https://github.com/bytecodealliance/wasmtime", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.wasmtime-c-api-macros-24.0.0.bazel"), + strip_prefix = "crates/c-api-macros", + ) + + maybe( + http_archive, + name = "cu__wasmtime-component-macro-24.0.0", + sha256 = "4b07773d1c3dab5f014ec61316ee317aa424033e17e70a63abdf7c3a47e58fcf", + type = "tar.gz", + urls = ["https://static.crates.io/crates/wasmtime-component-macro/24.0.0/download"], + strip_prefix = "wasmtime-component-macro-24.0.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.wasmtime-component-macro-24.0.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__wasmtime-component-util-24.0.0", + sha256 = "e38d735320f4e83478369ce649ad8fe87c6b893220902e798547a225fc0c5874", + type = "tar.gz", + urls = ["https://static.crates.io/crates/wasmtime-component-util/24.0.0/download"], + strip_prefix = "wasmtime-component-util-24.0.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.wasmtime-component-util-24.0.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__wasmtime-cranelift-24.0.0", + sha256 = "e570d831d0785d93d7d8c722b1eb9a34e0d0c1534317666f65892818358a2da9", + type = "tar.gz", + urls = ["https://static.crates.io/crates/wasmtime-cranelift/24.0.0/download"], + strip_prefix = "wasmtime-cranelift-24.0.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.wasmtime-cranelift-24.0.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__wasmtime-environ-24.0.0", + sha256 = "c5fe80dfbd81687431a7d4f25929fae1ae96894786d5c96b14ae41164ee97377", + type = "tar.gz", + urls = ["https://static.crates.io/crates/wasmtime-environ/24.0.0/download"], + strip_prefix = "wasmtime-environ-24.0.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.wasmtime-environ-24.0.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__wasmtime-jit-icache-coherence-24.0.0", + sha256 = "d15de8429db996f0d17a4163a35eccc3f874cbfb50f29c379951ea1bbb39452e", + type = "tar.gz", + urls = ["https://static.crates.io/crates/wasmtime-jit-icache-coherence/24.0.0/download"], + strip_prefix = "wasmtime-jit-icache-coherence-24.0.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.wasmtime-jit-icache-coherence-24.0.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__wasmtime-slab-24.0.0", + sha256 = "1f68d38fa6b30c5e1fc7d608263062997306f79e577ebd197ddcd6b0f55d87d1", + type = "tar.gz", + urls = ["https://static.crates.io/crates/wasmtime-slab/24.0.0/download"], + strip_prefix = "wasmtime-slab-24.0.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.wasmtime-slab-24.0.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__wasmtime-types-24.0.0", + sha256 = "6634e7079d9c5cfc81af8610ed59b488cc5b7f9777a2f4c1667a2565c2e45249", + type = "tar.gz", + urls = ["https://static.crates.io/crates/wasmtime-types/24.0.0/download"], + strip_prefix = "wasmtime-types-24.0.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.wasmtime-types-24.0.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__wasmtime-versioned-export-macros-24.0.0", + sha256 = "3850e3511d6c7f11a72d571890b0ed5f6204681f7f050b9de2690e7f13123fed", + type = "tar.gz", + urls = ["https://static.crates.io/crates/wasmtime-versioned-export-macros/24.0.0/download"], + strip_prefix = "wasmtime-versioned-export-macros-24.0.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.wasmtime-versioned-export-macros-24.0.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__wasmtime-wit-bindgen-24.0.0", + sha256 = "3cb331ac7ed1d5ba49cddcdb6b11973752a857148858bb308777d2fc5584121f", + type = "tar.gz", + urls = ["https://static.crates.io/crates/wasmtime-wit-bindgen/24.0.0/download"], + strip_prefix = "wasmtime-wit-bindgen-24.0.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.wasmtime-wit-bindgen-24.0.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__winapi-util-0.1.8", + sha256 = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b", + type = "tar.gz", + urls = ["https://static.crates.io/crates/winapi-util/0.1.8/download"], + strip_prefix = "winapi-util-0.1.8", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.winapi-util-0.1.8.bazel"), + ) + + maybe( + http_archive, + name = "cu__windows-sys-0.52.0", + sha256 = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d", + type = "tar.gz", + urls = ["https://static.crates.io/crates/windows-sys/0.52.0/download"], + strip_prefix = "windows-sys-0.52.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.windows-sys-0.52.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__windows-targets-0.52.6", + sha256 = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973", + type = "tar.gz", + urls = ["https://static.crates.io/crates/windows-targets/0.52.6/download"], + strip_prefix = "windows-targets-0.52.6", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.windows-targets-0.52.6.bazel"), + ) + + maybe( + http_archive, + name = "cu__windows_aarch64_gnullvm-0.52.6", + sha256 = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3", + type = "tar.gz", + urls = ["https://static.crates.io/crates/windows_aarch64_gnullvm/0.52.6/download"], + strip_prefix = "windows_aarch64_gnullvm-0.52.6", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.windows_aarch64_gnullvm-0.52.6.bazel"), + ) + + maybe( + http_archive, + name = "cu__windows_aarch64_msvc-0.52.6", + sha256 = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469", + type = "tar.gz", + urls = ["https://static.crates.io/crates/windows_aarch64_msvc/0.52.6/download"], + strip_prefix = "windows_aarch64_msvc-0.52.6", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.windows_aarch64_msvc-0.52.6.bazel"), + ) + + maybe( + http_archive, + name = "cu__windows_i686_gnu-0.52.6", + sha256 = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b", + type = "tar.gz", + urls = ["https://static.crates.io/crates/windows_i686_gnu/0.52.6/download"], + strip_prefix = "windows_i686_gnu-0.52.6", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.windows_i686_gnu-0.52.6.bazel"), + ) + + maybe( + http_archive, + name = "cu__windows_i686_gnullvm-0.52.6", + sha256 = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66", + type = "tar.gz", + urls = ["https://static.crates.io/crates/windows_i686_gnullvm/0.52.6/download"], + strip_prefix = "windows_i686_gnullvm-0.52.6", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.windows_i686_gnullvm-0.52.6.bazel"), + ) + + maybe( + http_archive, + name = "cu__windows_i686_msvc-0.52.6", + sha256 = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66", + type = "tar.gz", + urls = ["https://static.crates.io/crates/windows_i686_msvc/0.52.6/download"], + strip_prefix = "windows_i686_msvc-0.52.6", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.windows_i686_msvc-0.52.6.bazel"), + ) + + maybe( + http_archive, + name = "cu__windows_x86_64_gnu-0.52.6", + sha256 = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78", + type = "tar.gz", + urls = ["https://static.crates.io/crates/windows_x86_64_gnu/0.52.6/download"], + strip_prefix = "windows_x86_64_gnu-0.52.6", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.windows_x86_64_gnu-0.52.6.bazel"), + ) + + maybe( + http_archive, + name = "cu__windows_x86_64_gnullvm-0.52.6", + sha256 = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d", + type = "tar.gz", + urls = ["https://static.crates.io/crates/windows_x86_64_gnullvm/0.52.6/download"], + strip_prefix = "windows_x86_64_gnullvm-0.52.6", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.windows_x86_64_gnullvm-0.52.6.bazel"), + ) + + maybe( + http_archive, + name = "cu__windows_x86_64_msvc-0.52.6", + sha256 = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec", + type = "tar.gz", + urls = ["https://static.crates.io/crates/windows_x86_64_msvc/0.52.6/download"], + strip_prefix = "windows_x86_64_msvc-0.52.6", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.windows_x86_64_msvc-0.52.6.bazel"), + ) + + maybe( + http_archive, + name = "cu__wit-parser-0.215.0", + sha256 = "935a97eaffd57c3b413aa510f8f0b550a4a9fe7d59e79cd8b89a83dcb860321f", + type = "tar.gz", + urls = ["https://static.crates.io/crates/wit-parser/0.215.0/download"], + strip_prefix = "wit-parser-0.215.0", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.wit-parser-0.215.0.bazel"), + ) + + maybe( + http_archive, + name = "cu__zerocopy-0.7.35", + sha256 = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0", + type = "tar.gz", + urls = ["https://static.crates.io/crates/zerocopy/0.7.35/download"], + strip_prefix = "zerocopy-0.7.35", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.zerocopy-0.7.35.bazel"), + ) + + maybe( + http_archive, + name = "cu__zerocopy-derive-0.7.35", + sha256 = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e", + type = "tar.gz", + urls = ["https://static.crates.io/crates/zerocopy-derive/0.7.35/download"], + strip_prefix = "zerocopy-derive-0.7.35", + build_file = Label("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:BUILD.zerocopy-derive-0.7.35.bazel"), + ) + + return [ + struct(repo = "cu__anyhow-1.0.86", is_dev_dep = False), + struct(repo = "cu__env_logger-0.10.2", is_dev_dep = False), + struct(repo = "cu__log-0.4.22", is_dev_dep = False), + struct(repo = "cu__once_cell-1.19.0", is_dev_dep = False), + struct(repo = "cu__tracing-0.1.40", is_dev_dep = False), + struct(repo = "cu__wasmtime-24.0.0", is_dev_dep = False), + struct(repo = "cu__wasmtime-c-api-macros-24.0.0", is_dev_dep = False), + ] diff --git a/bazel/cc_defs.bzl b/bazel/cc_defs.bzl new file mode 100644 index 000000000..5951de438 --- /dev/null +++ b/bazel/cc_defs.bzl @@ -0,0 +1,22 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +load("@rules_cc//cc:defs.bzl", _cc_test = "cc_test") +load("@rules_fuzzing//fuzzing:cc_defs.bzl", _cc_fuzz_test = "cc_fuzz_test") + +def cc_test(data = [], **kwargs): + _cc_test(data = data + ["//bazel:tsan_suppressions.txt"], **kwargs) + +def cc_fuzz_test(data = [], **kwargs): + _cc_fuzz_test(data = data + ["//bazel:tsan_suppressions.txt"], **kwargs) diff --git a/bazel/dependencies.bzl b/bazel/dependencies.bzl new file mode 100644 index 000000000..683fb9964 --- /dev/null +++ b/bazel/dependencies.bzl @@ -0,0 +1,103 @@ +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") +load("@envoy_toolshed//sysroot:sysroot.bzl", "setup_sysroots") +load("@proxy_wasm_cpp_host//bazel/cargo/wasmsign/remote:crates.bzl", wasmsign_crate_repositories = "crate_repositories") +load("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:crates.bzl", wasmtime_crate_repositories = "crate_repositories") +load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains") +load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencies") +load("@rules_rust//rust:repositories.bzl", "rust_repositories", "rust_repository_set") +load("@toolchains_llvm//toolchain:deps.bzl", "bazel_toolchain_dependencies") +load("@toolchains_llvm//toolchain:rules.bzl", "llvm_toolchain") + +def proxy_wasm_cpp_host_dependencies(): + # Bazel extensions. + + py_repositories() + python_register_toolchains( + name = "python_3_9", + python_version = "3.9", + ignore_root_user_error = True, # for docker run + ) + + rust_repositories() + rust_repository_set( + name = "rust_linux_x86_64", + exec_triple = "x86_64-unknown-linux-gnu", + extra_target_triples = [ + "aarch64-unknown-linux-gnu", + "wasm32-unknown-unknown", + "wasm32-wasi", # TODO: Change to wasm32-wasip1 once https://github.com/bazelbuild/rules_rust/issues/2782 is fixed + ], + version = "1.77.2", + ) + rust_repository_set( + name = "rust_linux_s390x", + exec_triple = "s390x-unknown-linux-gnu", + extra_target_triples = [ + "wasm32-unknown-unknown", + "wasm32-wasi", + ], + version = "1.77.2", + ) + crate_universe_dependencies(bootstrap = True) + + setup_sysroots() + bazel_toolchain_dependencies() + llvm_toolchain( + name = "llvm_toolchain", + llvm_version = "19.1.0", + sha256 = { + "linux-x86_64": "cee77d641690466a193d9b88c89705de1c02bbad46bde6a3b126793c0a0f2923", + "linux-aarch64": "7bb54afd330fe1a1c2d4c593fa1e2dbe2abd9bf34fb3597994ff41e443cf144b", + "darwin-aarch64": "9da86f64a99f5ce9b679caf54e938736ca269c5e069d0c94ad08b995c5f25c16", + "darwin-x86_64": "264f2f1e8b67f066749349ae8b4943d346cd44e099464164ef21b42a57663540", + }, + strip_prefix = { + "linux-x86_64": "LLVM-19.1.0-Linux-X64", + "linux-aarch64": "clang+llvm-19.1.0-aarch64-linux-gnu", + "darwin-aarch64": "LLVM-19.1.0-macOS-ARM64", + "darwin-x86_64": "LLVM-19.1.0-macOS-X64", + }, + urls = { + "linux-x86_64": ["https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.0/LLVM-19.1.0-Linux-X64.tar.xz"], + "linux-aarch64": ["https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.0/clang+llvm-19.1.0-aarch64-linux-gnu.tar.xz"], + "darwin-aarch64": ["https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.0/LLVM-19.1.0-macOS-ARM64.tar.xz"], + "darwin-x86_64": ["https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.0/LLVM-19.1.0-macOS-X64.tar.xz"], + }, + ) + + llvm_toolchain( + name = "llvm_aarch64", + llvm_version = "19.1.0", + toolchain_roots = { + "": "@llvm_toolchain_llvm//", + }, + sysroot = { + "linux-aarch64": "@sysroot_linux_arm64//:sysroot", + }, + ) + + # NullVM dependencies. + + protobuf_deps() + + # Wasmtime dependencies. + + wasmtime_crate_repositories() + + # Test dependencies. + + wasmsign_crate_repositories() diff --git a/bazel/dependencies_import.bzl b/bazel/dependencies_import.bzl new file mode 100644 index 000000000..e4cf5e879 --- /dev/null +++ b/bazel/dependencies_import.bzl @@ -0,0 +1,28 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +load("@fuzzing_py_deps//:requirements.bzl", pip_fuzzing_dependencies = "install_deps") +load("@llvm_toolchain//:toolchains.bzl", "llvm_register_toolchains") +load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies") +load("@rules_fuzzing//fuzzing:repositories.bzl", "rules_fuzzing_dependencies") +load("@v8_python_deps//:requirements.bzl", pip_v8_dependencies = "install_deps") + +def proxy_wasm_cpp_host_dependencies_import(): + llvm_register_toolchains() + + rules_foreign_cc_dependencies() + rules_fuzzing_dependencies() + + pip_fuzzing_dependencies() + pip_v8_dependencies() diff --git a/bazel/dependencies_python.bzl b/bazel/dependencies_python.bzl new file mode 100644 index 000000000..4207c79cf --- /dev/null +++ b/bazel/dependencies_python.bzl @@ -0,0 +1,27 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +load("@rules_fuzzing//fuzzing:init.bzl", "rules_fuzzing_init") +load("@rules_python//python:pip.bzl", "pip_parse") + +def proxy_wasm_cpp_host_dependencies_python(): + # NOTE: this loads @fuzzing_py_deps via pip_parse + rules_fuzzing_init() + + # V8 dependencies. + pip_parse( + name = "v8_python_deps", + extra_pip_args = ["--require-hashes"], + requirements_lock = "@v8//:bazel/requirements.txt", + ) diff --git a/bazel/external/BUILD b/bazel/external/BUILD index e69de29bb..6d6d1266c 100644 --- a/bazel/external/BUILD +++ b/bazel/external/BUILD @@ -0,0 +1,13 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/bazel/external/Dockerfile.bazel b/bazel/external/Dockerfile.bazel new file mode 100644 index 000000000..9b16abeb3 --- /dev/null +++ b/bazel/external/Dockerfile.bazel @@ -0,0 +1,75 @@ +# syntax=docker/dockerfile:1 +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +# Prep: +# docker run --rm --privileged tonistiigi/binfmt --install all +# docker run --rm --privileged multiarch/qemu-user-static --reset -p yes +# Need to see "F" flag: cat /proc/sys/fs/binfmt_misc/qemu-* +# +# Build: +# docker buildx build --platform linux/s390x -t $IMAGE -f Dockerfile.bazel +# +# Push: +# docker image tag $IMAGE ghcr.io/proxy-wasm/$IMAGE +# docker push ghcr.io/proxy-wasm/$IMAGE +# +# Test: +# docker run --rm --volume $(pwd):/mnt --workdir /mnt \ +# --platform linux/s390x $IMAGE \ +# bazel test --verbose_failures --test_output=errors \ +# --define engine=null --config=clang --test_timeout=1800 \ +# -- //test/... + +# Update base image +ARG UBUNTU_VERSION=22.04 +FROM ubuntu:${UBUNTU_VERSION} as build +RUN apt update && apt upgrade -y +RUN apt autoremove -y + +# Install Bazel deps +RUN apt install -y software-properties-common +RUN add-apt-repository ppa:openjdk-r/ppa +RUN apt install -y \ + build-essential \ + openjdk-11-jdk \ + python3 \ + curl \ + zip \ + unzip + +# Download Bazel source +ARG BAZEL_VERSION=6.5.0 +RUN cd ~ && mkdir bazel && cd bazel +RUN curl -LO https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-dist.zip +RUN unzip -q bazel-${BAZEL_VERSION}-dist.zip + +# Build Bazel +# NOTE: This step is flaky and frequently hangs for multiarch / buildx. +# If it takes more than 2 hours, restart the Docker build and try again. +ENV EXTRA_BAZEL_ARGS="--tool_java_runtime_version=local_jdk" +RUN bash ./compile.sh + +# Copy output to /usr/bin +RUN cp /output/bazel /usr/bin/bazel + +# Install ProxyWasm build deps +RUN apt install -y \ + git \ + python3-distutils \ + clang \ + libstdc++6 \ + libssl-dev \ + libz-dev diff --git a/bazel/external/bazel_clang_tidy.patch b/bazel/external/bazel_clang_tidy.patch new file mode 100644 index 000000000..82711d83e --- /dev/null +++ b/bazel/external/bazel_clang_tidy.patch @@ -0,0 +1,16 @@ +# 1. Treat .h files as C++ headers. + +diff --git a/clang_tidy/clang_tidy.bzl b/clang_tidy/clang_tidy.bzl +index 3a5ed07..5db5c6c 100644 +--- a/clang_tidy/clang_tidy.bzl ++++ b/clang_tidy/clang_tidy.bzl +@@ -16,6 +16,9 @@ def _run_tidy(ctx, exe, flags, compilation_context, infile, discriminator): + # add source to check + args.add(infile.path) + ++ # treat .h files as C++ headers ++ args.add("--extra-arg-before=-xc++") ++ + # start args passed to the compiler + args.add("--") + diff --git a/bazel/external/dragonbox.BUILD b/bazel/external/dragonbox.BUILD new file mode 100644 index 000000000..00f3ee074 --- /dev/null +++ b/bazel/external/dragonbox.BUILD @@ -0,0 +1,26 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +load("@rules_cc//cc:defs.bzl", "cc_library") + +licenses(["notice"]) # Apache 2 + +package(default_visibility = ["//visibility:public"]) + +cc_library( + name = "dragonbox", + srcs = [], + hdrs = ["include/dragonbox/dragonbox.h"], + includes = ["include/"], +) diff --git a/bazel/external/fp16.BUILD b/bazel/external/fp16.BUILD new file mode 100644 index 000000000..f82146cff --- /dev/null +++ b/bazel/external/fp16.BUILD @@ -0,0 +1,29 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +load("@rules_cc//cc:defs.bzl", "cc_library") + +licenses(["notice"]) # MIT + +package(default_visibility = ["//visibility:public"]) + +cc_library( + name = "FP16", + hdrs = [ + "include/fp16.h", + "include/fp16/bitcasts.h", + "include/fp16/fp16.h", + ], + includes = ["include/"], +) diff --git a/bazel/external/googletest.patch b/bazel/external/googletest.patch new file mode 100644 index 000000000..502ef58b3 --- /dev/null +++ b/bazel/external/googletest.patch @@ -0,0 +1,13 @@ +diff --git a/BUILD.bazel b/BUILD.bazel +index 8099642a85..3598661079 100644 +--- a/BUILD.bazel ++++ b/BUILD.bazel +@@ -40,7 +40,7 @@ exports_files(["LICENSE"]) + + config_setting( + name = "windows", +- constraint_values = ["@bazel_tools//platforms:windows"], ++ constraint_values = ["@platforms//os:windows"], + ) + + config_setting( diff --git a/bazel/external/intel_ittapi.BUILD b/bazel/external/intel_ittapi.BUILD new file mode 100644 index 000000000..cc867842f --- /dev/null +++ b/bazel/external/intel_ittapi.BUILD @@ -0,0 +1,35 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +load("@rules_cc//cc:defs.bzl", "cc_library") + +licenses(["notice"]) + +package(default_visibility = ["//visibility:public"]) + +cc_library( + name = "lib_ittapi", + srcs = [ + "include/ittnotify.h", + "include/jitprofiling.h", + "src/ittnotify/ittnotify_config.h", + "src/ittnotify/jitprofiling.c", + ], + hdrs = [ + "include/ittnotify.h", + "src/ittnotify/ittnotify_types.h", + ], + includes = ["include/"], + visibility = ["//visibility:public"], +) diff --git a/bazel/external/llvm.BUILD b/bazel/external/llvm.BUILD new file mode 100644 index 000000000..9dccf5c98 --- /dev/null +++ b/bazel/external/llvm.BUILD @@ -0,0 +1,130 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +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 = "llvm_lib", + cache_entries = { + # Disable both: BUILD and INCLUDE, since some of the INCLUDE + # targets build code instead of only generating build files. + "LLVM_BUILD_BENCHMARKS": "off", + "LLVM_INCLUDE_BENCHMARKS": "off", + "LLVM_BUILD_DOCS": "off", + "LLVM_INCLUDE_DOCS": "off", + "LLVM_BUILD_EXAMPLES": "off", + "LLVM_INCLUDE_EXAMPLES": "off", + "LLVM_BUILD_RUNTIME": "off", + "LLVM_BUILD_RUNTIMES": "off", + "LLVM_INCLUDE_RUNTIMES": "off", + "LLVM_BUILD_TESTS": "off", + "LLVM_INCLUDE_TESTS": "off", + "LLVM_BUILD_TOOLS": "off", + "LLVM_INCLUDE_TOOLS": "off", + "LLVM_BUILD_UTILS": "off", + "LLVM_INCLUDE_UTILS": "off", + "LLVM_ENABLE_IDE": "off", + "LLVM_ENABLE_LIBEDIT": "off", + "LLVM_ENABLE_LIBXML2": "off", + "LLVM_ENABLE_TERMINFO": "off", + "LLVM_ENABLE_ZLIB": "off", + "LLVM_TARGETS_TO_BUILD": "X86", + "CMAKE_CXX_FLAGS": "-Wno-unused-command-line-argument", + }, + generate_args = ["-GNinja"], + lib_source = ":srcs", + out_static_libs = [ + "libLLVMWindowsManifest.a", + "libLLVMXRay.a", + "libLLVMLibDriver.a", + "libLLVMDlltoolDriver.a", + "libLLVMCoverage.a", + "libLLVMLineEditor.a", + "libLLVMX86Disassembler.a", + "libLLVMX86AsmParser.a", + "libLLVMX86CodeGen.a", + "libLLVMX86Desc.a", + "libLLVMX86Info.a", + "libLLVMOrcJIT.a", + "libLLVMMCJIT.a", + "libLLVMJITLink.a", + "libLLVMOrcTargetProcess.a", + "libLLVMOrcShared.a", + "libLLVMInterpreter.a", + "libLLVMExecutionEngine.a", + "libLLVMRuntimeDyld.a", + "libLLVMSymbolize.a", + "libLLVMDebugInfoPDB.a", + "libLLVMDebugInfoGSYM.a", + "libLLVMOption.a", + "libLLVMObjectYAML.a", + "libLLVMMCA.a", + "libLLVMMCDisassembler.a", + "libLLVMLTO.a", + "libLLVMPasses.a", + "libLLVMCFGuard.a", + "libLLVMCoroutines.a", + "libLLVMObjCARCOpts.a", + "libLLVMHelloNew.a", + "libLLVMipo.a", + "libLLVMVectorize.a", + "libLLVMLinker.a", + "libLLVMInstrumentation.a", + "libLLVMFrontendOpenMP.a", + "libLLVMFrontendOpenACC.a", + "libLLVMExtensions.a", + "libLLVMDWARFLinker.a", + "libLLVMGlobalISel.a", + "libLLVMMIRParser.a", + "libLLVMAsmPrinter.a", + "libLLVMDebugInfoDWARF.a", + "libLLVMSelectionDAG.a", + "libLLVMCodeGen.a", + "libLLVMIRReader.a", + "libLLVMAsmParser.a", + "libLLVMInterfaceStub.a", + "libLLVMFileCheck.a", + "libLLVMFuzzMutate.a", + "libLLVMTarget.a", + "libLLVMScalarOpts.a", + "libLLVMInstCombine.a", + "libLLVMAggressiveInstCombine.a", + "libLLVMTransformUtils.a", + "libLLVMBitWriter.a", + "libLLVMAnalysis.a", + "libLLVMProfileData.a", + "libLLVMObject.a", + "libLLVMTextAPI.a", + "libLLVMMCParser.a", + "libLLVMMC.a", + "libLLVMDebugInfoCodeView.a", + "libLLVMDebugInfoMSF.a", + "libLLVMBitReader.a", + "libLLVMCore.a", + "libLLVMRemarks.a", + "libLLVMBitstreamReader.a", + "libLLVMBinaryFormat.a", + "libLLVMSupport.a", + "libLLVMDemangle.a", + ], +) diff --git a/bazel/external/llvm.patch b/bazel/external/llvm.patch new file mode 100644 index 000000000..710d27427 --- /dev/null +++ b/bazel/external/llvm.patch @@ -0,0 +1,22 @@ +# Workaround for different linkers used in cmake()'s generate and build steps. +# See: https://github.com/bazelbuild/rules_foreign_cc/issues/863 + +diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake +index 5d4d692a70ac..0a2e441b1b94 100644 +--- a/cmake/modules/HandleLLVMOptions.cmake ++++ b/cmake/modules/HandleLLVMOptions.cmake +@@ -843,14 +843,6 @@ if (UNIX AND + append("-fdiagnostics-color" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + endif() + +-# lld doesn't print colored diagnostics when invoked from Ninja +-if (UNIX AND CMAKE_GENERATOR STREQUAL "Ninja") +- include(CheckLinkerFlag) +- check_linker_flag("-Wl,--color-diagnostics" LINKER_SUPPORTS_COLOR_DIAGNOSTICS) +- append_if(LINKER_SUPPORTS_COLOR_DIAGNOSTICS "-Wl,--color-diagnostics" +- CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS) +-endif() +- + # Add flags for add_dead_strip(). + # FIXME: With MSVS, consider compiling with /Gy and linking with /OPT:REF? + # But MinSizeRel seems to add that automatically, so maybe disable these diff --git a/bazel/external/proxy-wasm-cpp-sdk.BUILD b/bazel/external/proxy-wasm-cpp-sdk.BUILD deleted file mode 100644 index 5df5ef81d..000000000 --- a/bazel/external/proxy-wasm-cpp-sdk.BUILD +++ /dev/null @@ -1,19 +0,0 @@ -licenses(["notice"]) # Apache 2 - -package(default_visibility = ["//visibility:public"]) - -cc_library( - name = "api_lib", - hdrs = ["proxy_wasm_api.h"], -) - -cc_library( - name = "common_lib", - hdrs = [ - "proxy_wasm_common.h", - "proxy_wasm_enums.h", - ], - deps = [ - "@com_google_protobuf//:protobuf_lite", - ], -) diff --git a/bazel/external/rules_rust.patch b/bazel/external/rules_rust.patch new file mode 100644 index 000000000..a9a57c931 --- /dev/null +++ b/bazel/external/rules_rust.patch @@ -0,0 +1,15 @@ +# https://github.com/bazelbuild/rules_rust/pull/1315 + +diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl +index bfd96ed9..d7e38658 100644 +--- a/rust/private/rustc.bzl ++++ b/rust/private/rustc.bzl +@@ -1507,7 +1507,7 @@ def rustc_compile_action( + }) + crate_info = rust_common.create_crate_info(**crate_info_dict) + +- if crate_info.type in ["staticlib", "cdylib"]: ++ if crate_info.type in ["staticlib", "cdylib"] and not out_binary: + # These rules are not supposed to be depended on by other rust targets, and + # as such they shouldn't provide a CrateInfo. However, one may still want to + # write a rust_test for them, so we provide the CrateInfo wrapped in a provider diff --git a/bazel/external/simdutf.BUILD b/bazel/external/simdutf.BUILD new file mode 100644 index 000000000..834467e35 --- /dev/null +++ b/bazel/external/simdutf.BUILD @@ -0,0 +1,25 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +load("@rules_cc//cc:defs.bzl", "cc_library") + +licenses(["notice"]) # Apache 2 + +package(default_visibility = ["//visibility:public"]) + +cc_library( + name = "simdutf", + srcs = ["simdutf.cpp"], + hdrs = ["simdutf.h"], +) diff --git a/bazel/external/v8.patch b/bazel/external/v8.patch new file mode 100644 index 000000000..a124cf9a5 --- /dev/null +++ b/bazel/external/v8.patch @@ -0,0 +1,346 @@ +From bc2a85e39fd55879b9baed51429c08b27d5514c8 Mon Sep 17 00:00:00 2001 +From: Matt Leon +Date: Wed, 16 Jul 2025 16:55:02 -0400 +Subject: [PATCH 1/7] Disable pointer compression + +Pointer compression limits the maximum number of WasmVMs. + +Signed-off-by: Matt Leon +--- + BUILD.bazel | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/BUILD.bazel b/BUILD.bazel +index 3f5a87d054e..0a693b7ee10 100644 +--- a/BUILD.bazel ++++ b/BUILD.bazel +@@ -292,7 +292,7 @@ v8_int( + # If no explicit value for v8_enable_pointer_compression, we set it to 'none'. + v8_string( + name = "v8_enable_pointer_compression", +- default = "none", ++ default = "False", + ) + + # Default setting for v8_enable_pointer_compression. +-- +2.50.0.727.gbf7dc18ff4-goog + + +From 61898e9a63ac89a37261c081b84714cfc400a4b1 Mon Sep 17 00:00:00 2001 +From: Matt Leon +Date: Wed, 16 Jul 2025 16:56:31 -0400 +Subject: [PATCH 2/7] Restore _allowlist_function_transition + +Reverts v8 commit b26554ec368e9553782012c96aa5e99b163eaff2, which removed use of +_allowlist_function_transition from v8 bazel/defs.bzl, since it is still required +by the version of Bazel we currently use (6.5.0). + +Signed-off-by: Matt Leon +--- + bazel/defs.bzl | 3 +++ + bazel/v8-non-pointer-compression.bzl | 11 +++++++++++ + 2 files changed, 14 insertions(+) + +diff --git a/bazel/defs.bzl b/bazel/defs.bzl +index 0539ea176ac..14d7ace5e59 100644 +--- a/bazel/defs.bzl ++++ b/bazel/defs.bzl +@@ -485,6 +485,9 @@ _v8_mksnapshot = rule( + cfg = "exec", + ), + "target_os": attr.string(mandatory = True), ++ "_allowlist_function_transition": attr.label( ++ default = "@bazel_tools//tools/allowlists/function_transition_allowlist", ++ ), + "prefix": attr.string(mandatory = True), + "suffix": attr.string(mandatory = True), + }, +diff --git a/bazel/v8-non-pointer-compression.bzl b/bazel/v8-non-pointer-compression.bzl +index 8c929454840..57336154cf7 100644 +--- a/bazel/v8-non-pointer-compression.bzl ++++ b/bazel/v8-non-pointer-compression.bzl +@@ -47,6 +47,17 @@ v8_binary_non_pointer_compression = rule( + # Note specificaly how it's configured with v8_target_cpu_transition, which + # ensures that setting propagates down the graph. + "binary": attr.label(cfg = v8_disable_pointer_compression), ++ # This is a stock Bazel requirement for any rule that uses Starlark ++ # transitions. It's okay to copy the below verbatim for all such rules. ++ # ++ # The purpose of this requirement is to give the ability to restrict ++ # which packages can invoke these rules, since Starlark transitions ++ # make much larger graphs possible that can have memory and performance ++ # consequences for your build. The whitelist defaults to "everything". ++ # But you can redefine it more strictly if you feel that's prudent. ++ "_allowlist_function_transition": attr.label( ++ default = "@bazel_tools//tools/allowlists/function_transition_allowlist", ++ ), + }, + # Making this executable means it works with "$ bazel run". + executable = True, +-- +2.50.0.727.gbf7dc18ff4-goog + + +From 4a6e7158fd4ca48c75c8e33ea15760c9beea1d2f Mon Sep 17 00:00:00 2001 +From: Matt Leon +Date: Wed, 16 Jul 2025 16:56:52 -0400 +Subject: [PATCH 3/7] Don't expose Wasm C API (only Wasm C++ API). + +Signed-off-by: Matt Leon +--- + src/wasm/c-api.cc | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/src/wasm/c-api.cc b/src/wasm/c-api.cc +index 05e4029f183..d705be96a16 100644 +--- a/src/wasm/c-api.cc ++++ b/src/wasm/c-api.cc +@@ -2472,6 +2472,8 @@ WASM_EXPORT auto Instance::exports() const -> ownvec { + + } // namespace wasm + ++#if 0 ++ + // BEGIN FILE wasm-c.cc + + extern "C" { +@@ -3518,3 +3520,5 @@ wasm_instance_t* wasm_frame_instance(const wasm_frame_t* frame) { + #undef WASM_DEFINE_SHARABLE_REF + + } // extern "C" ++ ++#endif +-- +2.50.0.727.gbf7dc18ff4-goog + + +From 7b593eb8086dcfe9012d4fa694d622f21dadb731 Mon Sep 17 00:00:00 2001 +From: Matt Leon +Date: Wed, 16 Jul 2025 16:58:02 -0400 +Subject: [PATCH 4/7] Stub out fast_float for bazel-supplied version + +Signed-off-by: Matt Leon +--- + BUILD.bazel | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/BUILD.bazel b/BUILD.bazel +index 0a693b7ee10..eafd9dad20c 100644 +--- a/BUILD.bazel ++++ b/BUILD.bazel +@@ -4438,7 +4438,7 @@ v8_library( + ], + deps = [ + ":lib_dragonbox", +- "//third_party/fast_float/src:fast_float", ++ "@fast_float//:fast_float", + ":lib_fp16", + ":simdutf", + ":v8_libbase", +-- +2.50.0.727.gbf7dc18ff4-goog + + +From b442d34b12dd513946f509d9db86839ce8aa4d7f Mon Sep 17 00:00:00 2001 +From: Matt Leon +Date: Wed, 16 Jul 2025 20:04:05 -0400 +Subject: [PATCH 5/7] Stub out vendored dependencies for bazel-sourced versions + +Signed-off-by: Matt Leon +--- + BUILD.bazel | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/BUILD.bazel b/BUILD.bazel +index eafd9dad20c..ce36666e36e 100644 +--- a/BUILD.bazel ++++ b/BUILD.bazel +@@ -4437,10 +4437,10 @@ v8_library( + ":noicu/generated_torque_definitions", + ], + deps = [ +- ":lib_dragonbox", ++ "@dragonbox//:dragonbox", + "@fast_float//:fast_float", +- ":lib_fp16", +- ":simdutf", ++ "@fp16//:FP16", ++ "@simdutf//:simdutf", + ":v8_libbase", + "@abseil-cpp//absl/container:btree", + "@abseil-cpp//absl/container:flat_hash_map", +-- +2.50.0.727.gbf7dc18ff4-goog + + +From e0b8f32cc057a3c0875437d5d54d012cabcab458 Mon Sep 17 00:00:00 2001 +From: Matt Leon +Date: Wed, 16 Jul 2025 20:29:10 -0400 +Subject: [PATCH 6/7] Add build flags to make V8 compile with GCC + +Signed-off-by: Matt Leon +--- + bazel/defs.bzl | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/bazel/defs.bzl b/bazel/defs.bzl +index 14d7ace5e59..c7a48d4e805 100644 +--- a/bazel/defs.bzl ++++ b/bazel/defs.bzl +@@ -117,6 +117,9 @@ def _default_args(): + "-Wno-implicit-int-float-conversion", + "-Wno-deprecated-copy", + "-Wno-non-virtual-dtor", ++ "-Wno-invalid-offsetof", ++ "-Wno-dangling-pointer", ++ "-Wno-dangling-reference", + "-isystem .", + ], + "//conditions:default": [], +-- +2.50.0.727.gbf7dc18ff4-goog + + +From 7ce2d6bd14b338ab91a8636a8694b9ef180b2f90 Mon Sep 17 00:00:00 2001 +From: Matt Leon +Date: Fri, 18 Jul 2025 17:28:42 -0400 +Subject: [PATCH 7/7] Hack out atomic simd support in V8. + +Atomic simdutf requires __cpp_lib_atomic_ref >= 201806, which is only +supported in clang libc++ 19+. The version of LLVM used in Envoy as of +2025-07-18 is libc++ 18, so this is not supported. + +The simdutf documentation indicates this atomic form is not tested and +is not recommended for use: +https://github.com/simdutf/simdutf/blob/5d1b6248f29a8ed0eb90f79be268be41730e39f8/include/simdutf/implementation.h#L3066-L3068 + +In addition, this is in the implementation of a JS array buffer. Since +proxy-wasm-cpp-host does not make use of JS array buffers or shared +memory between web workers, we're stubbing it out. + +Mostly reverts +https://github.com/v8/v8/commit/6d6c1e680c7b8ea5f62a76e9c3d88d3fb0a88df0. + +Signed-off-by: Matt Leon +--- + bazel/defs.bzl | 2 +- + src/builtins/builtins-typed-array.cc | 8 ++++++++ + src/objects/simd.cc | 10 ++++++++++ + 3 files changed, 19 insertions(+), 1 deletion(-) + +diff --git a/bazel/defs.bzl b/bazel/defs.bzl +index c7a48d4e805..a73b3812882 100644 +--- a/bazel/defs.bzl ++++ b/bazel/defs.bzl +@@ -180,7 +180,7 @@ def _default_args(): + "Advapi32.lib", + ], + "@v8//bazel/config:is_macos": ["-pthread"], +- "//conditions:default": ["-Wl,--no-as-needed -ldl -latomic -pthread"], ++ "//conditions:default": ["-Wl,--no-as-needed -ldl -pthread"], + }) + select({ + ":should_add_rdynamic": ["-rdynamic"], + "//conditions:default": [], +diff --git a/src/builtins/builtins-typed-array.cc b/src/builtins/builtins-typed-array.cc +index 918cb873481..bc933e8dc1d 100644 +--- a/src/builtins/builtins-typed-array.cc ++++ b/src/builtins/builtins-typed-array.cc +@@ -520,17 +520,21 @@ simdutf::result ArrayBufferSetFromBase64( + DirectHandle typed_array, size_t& output_length) { + output_length = array_length; + simdutf::result simd_result; ++#ifdef WANT_ATOMIC_REF + if (typed_array->buffer()->is_shared()) { + simd_result = simdutf::atomic_base64_to_binary_safe( + reinterpret_cast(input_vector), input_length, + reinterpret_cast(typed_array->DataPtr()), output_length, + alphabet, last_chunk_handling, /*decode_up_to_bad_char*/ true); + } else { ++#endif + simd_result = simdutf::base64_to_binary_safe( + reinterpret_cast(input_vector), input_length, + reinterpret_cast(typed_array->DataPtr()), output_length, + alphabet, last_chunk_handling, /*decode_up_to_bad_char*/ true); ++#ifdef WANT_ATOMIC_REF + } ++#endif + + return simd_result; + } +@@ -833,15 +837,19 @@ BUILTIN(Uint8ArrayPrototypeToBase64) { + // 11. Return CodePointsToString(outAscii). + + size_t simd_result_size; ++#ifdef WANT_ATOMIC_REF + if (uint8array->buffer()->is_shared()) { + simd_result_size = simdutf::atomic_binary_to_base64( + std::bit_cast(uint8array->DataPtr()), length, + reinterpret_cast(output->GetChars(no_gc)), alphabet); + } else { ++#endif + simd_result_size = simdutf::binary_to_base64( + std::bit_cast(uint8array->DataPtr()), length, + reinterpret_cast(output->GetChars(no_gc)), alphabet); ++#ifdef WANT_ATOMIC_REF + } ++#endif + DCHECK_EQ(simd_result_size, output_length); + USE(simd_result_size); + } +diff --git a/src/objects/simd.cc b/src/objects/simd.cc +index 0ef570ceb7d..9217fa76072 100644 +--- a/src/objects/simd.cc ++++ b/src/objects/simd.cc +@@ -477,6 +477,7 @@ void Uint8ArrayToHexSlow(const char* bytes, size_t length, + } + } + ++#ifdef WANT_ATOMIC_REF + void AtomicUint8ArrayToHexSlow(const char* bytes, size_t length, + DirectHandle string_output) { + int index = 0; +@@ -492,6 +493,7 @@ void AtomicUint8ArrayToHexSlow(const char* bytes, size_t length, + index += 2; + } + } ++#endif + + inline uint16_t ByteToHex(uint8_t byte) { + const uint16_t correction = (('a' - '0' - 10) << 8) + ('a' - '0' - 10); +@@ -645,11 +647,15 @@ Tagged Uint8ArrayToHex(const char* bytes, size_t length, bool is_shared, + } + #endif + ++#ifdef WANT_ATOMIC_REF + if (is_shared) { + AtomicUint8ArrayToHexSlow(bytes, length, string_output); + } else { ++#endif + Uint8ArrayToHexSlow(bytes, length, string_output); ++#ifdef WANT_ATOMIC_REF + } ++#endif + return *string_output; + } + +@@ -1082,12 +1088,16 @@ bool ArrayBufferFromHex(const base::Vector& input_vector, bool is_shared, + for (uint32_t i = 0; i < output_length * 2; i += 2) { + result = HandleRemainingHexValues(input_vector, i); + if (result.has_value()) { ++#ifdef WANT_ATOMIC_REF + if (is_shared) { + std::atomic_ref(buffer[index++]) + .store(result.value(), std::memory_order_relaxed); + } else { ++#endif + buffer[index++] = result.value(); ++#ifdef WANT_ATOMIC_REF + } ++#endif + } else { + return false; + } +-- +2.50.0.727.gbf7dc18ff4-goog + diff --git a/bazel/external/wamr.BUILD b/bazel/external/wamr.BUILD new file mode 100644 index 000000000..a3375e2cb --- /dev/null +++ b/bazel/external/wamr.BUILD @@ -0,0 +1,77 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +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 = "wamr_lib", + generate_args = [ + # disable WASI + "-DWAMR_BUILD_LIBC_WASI=0", + "-DWAMR_BUILD_LIBC_BUILTIN=0", + # MVP + "-DWAMR_BUILD_BULK_MEMORY=1", + "-DWAMR_BUILD_REF_TYPES=1", + "-DWAMR_BUILD_TAIL_CALL=1", + # WAMR private features + "-DWAMR_BUILD_MULTI_MODULE=0", + # Some tests have indicated that the following three factors have + # a minimal impact on performance. + # - Get function names from name section + "-DWAMR_BUILD_CUSTOM_NAME_SECTION=1", + "-DWAMR_BUILD_LOAD_CUSTOM_SECTION=1", + # - Show Wasm call stack if met a trap + "-DWAMR_BUILD_DUMP_CALL_STACK=1", + # Cache module files + "-DWAMR_BUILD_WASM_CACHE=0", + "-GNinja", + ] + select({ + "@proxy_wasm_cpp_host//bazel:engine_wamr_jit": [ + "-DLLVM_DIR=$EXT_BUILD_DEPS/copy_llvm-15_0_7/llvm/lib/cmake/llvm", + "-DWAMR_BUILD_AOT=1", + "-DWAMR_BUILD_FAST_INTERP=0", + "-DWAMR_BUILD_INTERP=0", + "-DWAMR_BUILD_JIT=1", + "-DWAMR_BUILD_SIMD=1", + # linux perf. only for jit and aot + # "-DWAMR_BUILD_LINUX_PERF=1", + ], + "//conditions:default": [ + "-DWAMR_BUILD_AOT=0", + "-DWAMR_BUILD_FAST_INTERP=1", + "-DWAMR_BUILD_INTERP=1", + "-DWAMR_BUILD_JIT=0", + "-DWAMR_BUILD_SIMD=0", + ], + }), + lib_source = ":srcs", + linkopts = select({ + "@proxy_wasm_cpp_host//bazel:engine_wamr_jit": ["-ldl"], + "//conditions:default": [], + }), + out_static_libs = ["libiwasm.a"], + deps = select({ + "@proxy_wasm_cpp_host//bazel:engine_wamr_jit": ["@llvm-15_0_7//:llvm_wamr_lib"], + "//conditions:default": [], + }), +) diff --git a/bazel/external/wamr_llvm.BUILD b/bazel/external/wamr_llvm.BUILD new file mode 100644 index 000000000..6fe496145 --- /dev/null +++ b/bazel/external/wamr_llvm.BUILD @@ -0,0 +1,147 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +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 = "llvm_wamr_lib", + cache_entries = { + # Disable both: BUILD and INCLUDE, since some of the INCLUDE + # targets build code instead of only generating build files. + "LLVM_BUILD_BENCHMARKS": "off", + "LLVM_INCLUDE_BENCHMARKS": "off", + "LLVM_BUILD_DOCS": "off", + "LLVM_INCLUDE_DOCS": "off", + "LLVM_BUILD_EXAMPLES": "off", + "LLVM_INCLUDE_EXAMPLES": "off", + "LLVM_BUILD_TESTS": "off", + "LLVM_INCLUDE_TESTS": "off", + "LLVM_BUILD_TOOLS": "off", + "LLVM_INCLUDE_TOOLS": "off", + "LLVM_ENABLE_IDE": "off", + "LLVM_ENABLE_LIBEDIT": "off", + "LLVM_ENABLE_LIBXML2": "off", + "LLVM_ENABLE_TERMINFO": "off", + "LLVM_ENABLE_ZLIB": "off", + "LLVM_ENABLE_ZSTD": "off", + "LLVM_TARGETS_TO_BUILD": "X86", + "CMAKE_CXX_FLAGS": "-Wno-unused-command-line-argument", + }, + # `lld` doesn't work on MacOS + generate_args = select({ + "@platforms//os:linux": [ + "-GNinja", + "-DLLVM_USE_LINKER=lld", + ], + "//conditions:default": [ + "-GNinja", + ], + }), + lib_source = ":srcs", + out_data_dirs = [ + "bin", + "include", + "lib", + "libexec", + "share", + ], + out_static_libs = [ + # How to get the library list: + # build LLVM with "-DLLVM_INCLUDE_TOOLS=ON" + # cd bin and run "./llvm-config --libnames" + "libLLVMWindowsManifest.a", + "libLLVMXRay.a", + "libLLVMLibDriver.a", + "libLLVMDlltoolDriver.a", + "libLLVMCoverage.a", + "libLLVMLineEditor.a", + "libLLVMX86Disassembler.a", + "libLLVMX86AsmParser.a", + "libLLVMX86CodeGen.a", + "libLLVMX86Desc.a", + "libLLVMX86Info.a", + "libLLVMOrcJIT.a", + "libLLVMMCJIT.a", + "libLLVMJITLink.a", + "libLLVMInterpreter.a", + "libLLVMExecutionEngine.a", + "libLLVMRuntimeDyld.a", + "libLLVMOrcTargetProcess.a", + "libLLVMOrcShared.a", + "libLLVMDWP.a", + "libLLVMSymbolize.a", + "libLLVMDebugInfoPDB.a", + "libLLVMDebugInfoGSYM.a", + "libLLVMOption.a", + "libLLVMObjectYAML.a", + "libLLVMMCA.a", + "libLLVMMCDisassembler.a", + "libLLVMLTO.a", + "libLLVMPasses.a", + "libLLVMCFGuard.a", + "libLLVMCoroutines.a", + "libLLVMObjCARCOpts.a", + "libLLVMipo.a", + "libLLVMVectorize.a", + "libLLVMLinker.a", + "libLLVMInstrumentation.a", + "libLLVMFrontendOpenMP.a", + "libLLVMFrontendOpenACC.a", + "libLLVMExtensions.a", + "libLLVMDWARFLinker.a", + "libLLVMGlobalISel.a", + "libLLVMMIRParser.a", + "libLLVMAsmPrinter.a", + "libLLVMDebugInfoMSF.a", + "libLLVMDebugInfoDWARF.a", + "libLLVMSelectionDAG.a", + "libLLVMCodeGen.a", + "libLLVMIRReader.a", + "libLLVMAsmParser.a", + "libLLVMInterfaceStub.a", + "libLLVMFileCheck.a", + "libLLVMFuzzMutate.a", + "libLLVMTarget.a", + "libLLVMScalarOpts.a", + "libLLVMInstCombine.a", + "libLLVMAggressiveInstCombine.a", + "libLLVMTransformUtils.a", + "libLLVMBitWriter.a", + "libLLVMAnalysis.a", + "libLLVMProfileData.a", + "libLLVMObject.a", + "libLLVMTextAPI.a", + "libLLVMMCParser.a", + "libLLVMMC.a", + "libLLVMDebugInfoCodeView.a", + "libLLVMBitReader.a", + "libLLVMCore.a", + "libLLVMRemarks.a", + "libLLVMBitstreamReader.a", + "libLLVMBinaryFormat.a", + "libLLVMTableGen.a", + "libLLVMSupport.a", + "libLLVMDemangle.a", + ], + working_directory = "llvm", +) diff --git a/bazel/external/wasmedge.BUILD b/bazel/external/wasmedge.BUILD new file mode 100644 index 000000000..e8fba783e --- /dev/null +++ b/bazel/external/wasmedge.BUILD @@ -0,0 +1,41 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +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 = "wasmedge_lib", + cache_entries = { + "WASMEDGE_BUILD_AOT_RUNTIME": "Off", + "WASMEDGE_BUILD_SHARED_LIB": "Off", + "WASMEDGE_BUILD_STATIC_LIB": "On", + "WASMEDGE_BUILD_TOOLS": "Off", + "WASMEDGE_FORCE_DISABLE_LTO": "On", + }, + env = { + "CXXFLAGS": "-Wno-error=dangling-reference -Wno-error=maybe-uninitialized -Wno-error=array-bounds= -Wno-error=deprecated-declarations -std=c++20", + }, + generate_args = ["-GNinja"], + lib_source = ":srcs", + out_static_libs = ["libwasmedge.a"], +) diff --git a/bazel/external/wasmtime.BUILD b/bazel/external/wasmtime.BUILD new file mode 100644 index 000000000..f359d9361 --- /dev/null +++ b/bazel/external/wasmtime.BUILD @@ -0,0 +1,93 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +load("@rules_cc//cc:defs.bzl", "cc_library") +load("@rules_rust//rust:defs.bzl", "rust_static_library") + +licenses(["notice"]) # Apache 2 + +package(default_visibility = ["//visibility:public"]) + +cc_library( + name = "wasmtime_lib", + hdrs = [ + "crates/c-api/include/wasm.h", + ], + deps = [ + ":rust_c_api", + ], +) + +genrule( + name = "prefixed_wasmtime_c_api_headers", + srcs = [ + "crates/c-api/include/wasm.h", + ], + outs = [ + "crates/c-api/include/prefixed_wasm.h", + ], + cmd = """ + sed -e 's/\\ wasm_/\\ wasmtime_wasm_/g' \ + -e 's/\\*wasm_/\\*wasmtime_wasm_/g' \ + -e 's/(wasm_/(wasmtime_wasm_/g' \ + $(<) >$@ + """, +) + +genrule( + name = "prefixed_wasmtime_c_api_lib", + srcs = [ + ":rust_c_api", + ], + outs = [ + "prefixed_wasmtime_c_api.a", + ], + cmd = """ + for symbol in $$(nm -P $(<) 2>/dev/null | grep -E ^_?wasm_ | cut -d" " -f1); do + echo $$symbol | sed -r 's/^(_?)(wasm_[a-z_]+)$$/\\1\\2 \\1wasmtime_\\2/' >>prefixed + done + # This should be OBJCOPY, but bazel-zig-cc doesn't define it. + objcopy --redefine-syms=prefixed $(<) $@ + """, + toolchains = ["@bazel_tools//tools/cpp:current_cc_toolchain"], +) + +cc_library( + name = "prefixed_wasmtime_lib", + srcs = [ + ":prefixed_wasmtime_c_api_lib", + ], + hdrs = [ + ":prefixed_wasmtime_c_api_headers", + ], + linkstatic = 1, +) + +rust_static_library( + name = "rust_c_api", + srcs = glob(["crates/c-api/src/**/*.rs"]), + crate_features = ["cranelift"], + crate_root = "crates/c-api/src/lib.rs", + edition = "2021", + proc_macro_deps = [ + "@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:wasmtime-c-api-macros", + ], + deps = [ + "@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:anyhow", + "@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:env_logger", + "@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:once_cell", + # buildifier: leave-alone + "@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:wasmtime", + ], +) diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl new file mode 100644 index 000000000..09939a706 --- /dev/null +++ b/bazel/repositories.bzl @@ -0,0 +1,326 @@ +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository", "new_git_repository") +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") + +def proxy_wasm_cpp_host_repositories(): + # Bazel extensions. + + # Update platforms for crate_universe. Can remove when we update Bazel version. + maybe( + http_archive, + name = "platforms", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.10/platforms-0.0.10.tar.gz", + "https://github.com/bazelbuild/platforms/releases/download/0.0.10/platforms-0.0.10.tar.gz", + ], + sha256 = "218efe8ee736d26a3572663b374a253c012b716d8af0c07e842e82f238a0a7ee", + ) + + maybe( + http_archive, + name = "bazel_skylib", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz", + "https://github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz", + ], + sha256 = "c6966ec828da198c5d9adbaa94c05e3a1c7f21bd012a0b29ba8ddbccb2c93b0d", + ) + + maybe( + http_archive, + name = "rules_cc", + sha256 = "2037875b9a4456dce4a79d112a8ae885bbc4aad968e6587dca6e64f3a0900cdf", + strip_prefix = "rules_cc-0.0.9", + urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.9/rules_cc-0.0.9.tar.gz"], + ) + + maybe( + http_archive, + name = "bazel_clang_tidy", + sha256 = "6ed23cbff9423a30ef10becf57210a26d54fe198a211f4037d931c06f843c023", + strip_prefix = "bazel_clang_tidy-c2fe98cfec0430e78bff4169e9ca0a43123e4c99", + url = "https://github.com/erenon/bazel_clang_tidy/archive/c2fe98cfec0430e78bff4169e9ca0a43123e4c99.tar.gz", + patches = ["@proxy_wasm_cpp_host//bazel/external:bazel_clang_tidy.patch"], + patch_args = ["-p1"], + ) + + maybe( + http_archive, + name = "envoy_toolshed", + sha256 = "e2252e46e64417d5cedd9f1eb34a622bce5e13b43837e5fe051c83066b0a400b", + strip_prefix = "toolshed-bazel-bins-v0.1.13/bazel", + url = "https://github.com/envoyproxy/toolshed/archive/refs/tags/bazel-bins-v0.1.13.tar.gz", + ) + maybe( + http_archive, + name = "toolchains_llvm", + sha256 = "b7cd301ef7b0ece28d20d3e778697a5e3b81828393150bed04838c0c52963a01", + strip_prefix = "toolchains_llvm-0.10.3", + canonical_id = "v0.10.3", + url = "https://github.com/grailbio/bazel-toolchain/releases/download/0.10.3/toolchains_llvm-0.10.3.tar.gz", + ) + + maybe( + http_archive, + name = "rules_foreign_cc", + sha256 = "bcd0c5f46a49b85b384906daae41d277b3dc0ff27c7c752cc51e43048a58ec83", + strip_prefix = "rules_foreign_cc-0.7.1", + url = "https://github.com/bazelbuild/rules_foreign_cc/archive/0.7.1.tar.gz", + ) + + maybe( + http_archive, + name = "rules_fuzzing", + sha256 = "3ec0eee05b243552cc4a784b30323d088bf73cb2177ddda02c827e68981933f1", + strip_prefix = "rules_fuzzing-0.5.2", + urls = ["https://github.com/bazelbuild/rules_fuzzing/archive/v0.5.2.tar.gz"], + ) + + maybe( + http_archive, + name = "rules_python", + sha256 = "778aaeab3e6cfd56d681c89f5c10d7ad6bf8d2f1a72de9de55b23081b2d31618", + strip_prefix = "rules_python-0.34.0", + url = "https://github.com/bazelbuild/rules_python/releases/download/0.34.0/rules_python-0.34.0.tar.gz", + ) + + # Keep at 0.42 one because https://github.com/bazelbuild/rules_rust/issues/2665 + # manifests at 0.43 + maybe( + http_archive, + name = "rules_rust", + integrity = "sha256-JLN47ZcAbx9wEr5Jiib4HduZATGLiDgK7oUi/fvotzU=", + # NOTE: Update Rust version in bazel/dependencies.bzl. + url = "https://github.com/bazelbuild/rules_rust/releases/download/0.42.1/rules_rust-v0.42.1.tar.gz", + patches = ["@proxy_wasm_cpp_host//bazel/external:rules_rust.patch"], + patch_args = ["-p1"], + ) + + # Core deps. Keep them updated. + + # Note: we depend on Abseil via rules_fuzzing. Remove this pin when we update that. + # + # This is the latest LTS release, which picks up: + # - Build fix: https://github.com/abseil/abseil-cpp/pull/1187 + # - A bugfix found in local fuzzing: + # https://github.com/abseil/abseil-cpp/commit/e7858c73279d81cbc005d9c76a385ab535520635 + maybe( + http_archive, + name = "com_google_absl", + sha256 = "733726b8c3a6d39a4120d7e45ea8b41a434cdacde401cba500f14236c49b39dc", + strip_prefix = "abseil-cpp-20240116.2", + urls = ["https://github.com/abseil/abseil-cpp/archive/20240116.2.tar.gz"], + ) + + maybe( + http_archive, + name = "boringssl", + # 2023-08-28 (master-with-bazel) + sha256 = "f1f421738e9ba39dd88daf8cf3096ddba9c53e2b6b41b32fff5a3ff82f4cd162", + strip_prefix = "boringssl-45cf810dbdbd767f09f8cb0b0fcccd342c39041f", + urls = ["https://github.com/google/boringssl/archive/45cf810dbdbd767f09f8cb0b0fcccd342c39041f.tar.gz"], + ) + + maybe( + http_archive, + name = "proxy_wasm_cpp_sdk", + sha256 = "26c4c0f9f645de7e789dc92f113d7352ee54ac43bb93ae3a8a22945f1ce71590", + strip_prefix = "proxy-wasm-cpp-sdk-7465dee8b2953beebff99f6dc3720ad0c79bab99", + urls = ["https://github.com/proxy-wasm/proxy-wasm-cpp-sdk/archive/7465dee8b2953beebff99f6dc3720ad0c79bab99.tar.gz"], + ) + + # Compile DB dependencies. + maybe( + http_archive, + name = "bazel_compdb", + sha256 = "acd2a9eaf49272bb1480c67d99b82662f005b596a8c11739046a4220ec73c4da", + strip_prefix = "bazel-compilation-database-40864791135333e1446a04553b63cbe744d358d0", + url = "https://github.com/grailbio/bazel-compilation-database/archive/40864791135333e1446a04553b63cbe744d358d0.tar.gz", + ) + + # Test dependencies. + + maybe( + http_archive, + name = "com_google_googletest", + sha256 = "65fab701d9829d38cb77c14acdc431d2108bfdbf8979e40eb8ae567edf10b27c", + strip_prefix = "googletest-1.17.0", + urls = ["https://github.com/google/googletest/releases/download/v1.17.0/googletest-1.17.0.tar.gz"], + ) + + # NullVM dependencies. + + maybe( + http_archive, + name = "com_google_protobuf", + sha256 = "77ad26d3f65222fd96ccc18b055632b0bfedf295cb748b712a98ba1ac0b704b2", + strip_prefix = "protobuf-3.17.3", + url = "https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/protobuf-all-3.17.3.tar.gz", + ) + + # V8 with dependencies. + + maybe( + git_repository, + name = "v8", + # 13.8.258.26 + commit = "de9d0f8b56ae61896e4d2ac577fc589efb14f87d", + remote = "https://chromium.googlesource.com/v8/v8", + shallow_since = "1752074621 -0400", + patches = [ + "@proxy_wasm_cpp_host//bazel/external:v8.patch", + ], + patch_args = ["-p1"], + patch_cmds = [ + "find ./src ./include -type f -exec sed -i.bak -e 's!#include \"third_party/simdutf/simdutf.h\"!#include \"simdutf.h\"!' {} \\;", + "find ./src ./include -type f -exec sed -i.bak -e 's!#include \"third_party/fp16/src/include/fp16.h\"!#include \"fp16.h\"!' {} \\;", + "find ./src ./include -type f -exec sed -i.bak -e 's!#include \"third_party/dragonbox/src/include/dragonbox/dragonbox.h\"!#include \"dragonbox/dragonbox.h\"!' {} \\;", + "find ./src ./include -type f -exec sed -i.bak -e 's!#include \"third_party/fast_float/src/include/fast_float/!#include \"fast_float/!' {} \\;", + ], + repo_mapping = { + "@abseil-cpp": "@com_google_absl", + }, + ) + + maybe( + http_archive, + name = "highway", + sha256 = "7e0be78b8318e8bdbf6fa545d2ecb4c90f947df03f7aadc42c1967f019e63343", + urls = [ + "https://github.com/google/highway/archive/refs/tags/1.2.0.tar.gz", + ], + strip_prefix = "highway-1.2.0", + ) + + maybe( + http_archive, + name = "fast_float", + sha256 = "d2a08e722f461fe699ba61392cd29e6b23be013d0f56e50c7786d0954bffcb17", + urls = [ + "https://github.com/fastfloat/fast_float/archive/refs/tags/v7.0.0.tar.gz", + ], + strip_prefix = "fast_float-7.0.0", + ) + + maybe( + http_archive, + name = "dragonbox", + urls = [ + "https://github.com/jk-jeon/dragonbox/archive/6c7c925b571d54486b9ffae8d9d18a822801cbda.zip", + ], + strip_prefix = "dragonbox-6c7c925b571d54486b9ffae8d9d18a822801cbda", + sha256 = "2f10448d665355b41f599e869ac78803f82f13b070ce7ef5ae7b5cceb8a178f3", + build_file = "@proxy_wasm_cpp_host//bazel/external:dragonbox.BUILD", + ) + + maybe( + http_archive, + name = "fp16", + urls = [ + "https://github.com/Maratyszcza/FP16/archive/0a92994d729ff76a58f692d3028ca1b64b145d91.zip", + ], + strip_prefix = "FP16-0a92994d729ff76a58f692d3028ca1b64b145d91", + sha256 = "e66e65515fa09927b348d3d584c68be4215cfe664100d01c9dbc7655a5716d70", + build_file = "@proxy_wasm_cpp_host//bazel/external:fp16.BUILD", + ) + + maybe( + http_archive, + name = "simdutf", + sha256 = "512374f8291d3daf102ccd0ad223b1a8318358f7c1295efd4d9a3abbb8e4b6ff", + urls = [ + "https://github.com/simdutf/simdutf/releases/download/v7.3.0/singleheader.zip", + ], + build_file = "@proxy_wasm_cpp_host//bazel/external:simdutf.BUILD", + ) + + maybe( + http_archive, + name = "intel_ittapi", + strip_prefix = "ittapi-a3911fff01a775023a06af8754f9ec1e5977dd97", + sha256 = "1d0dddfc5abb786f2340565c82c6edd1cff10c917616a18ce62ee0b94dbc2ed4", + urls = ["https://github.com/intel/ittapi/archive/a3911fff01a775023a06af8754f9ec1e5977dd97.tar.gz"], + build_file = "@proxy_wasm_cpp_host//bazel/external:intel_ittapi.BUILD", + ) + + native.bind( + name = "wee8", + actual = "@v8//:wee8", + ) + + # WAMR with dependencies. + + maybe( + http_archive, + name = "com_github_bytecodealliance_wasm_micro_runtime", + build_file = "@proxy_wasm_cpp_host//bazel/external:wamr.BUILD", + # WAMR-2.4.1 + sha256 = "ca18bbf304f47287bf43707564db63b8908dd6d0d6ac40bb39271a7144def4cc", + strip_prefix = "wasm-micro-runtime-WAMR-2.4.1", + url = "https://github.com/bytecodealliance/wasm-micro-runtime/archive/refs/tags/WAMR-2.4.1.zip", + ) + + native.bind( + name = "wamr", + actual = "@com_github_bytecodealliance_wasm_micro_runtime//:wamr_lib", + ) + + maybe( + http_archive, + name = "llvm-15_0_7", + build_file = "@proxy_wasm_cpp_host//bazel/external:wamr_llvm.BUILD", + sha256 = "8b5fcb24b4128cf04df1b0b9410ce8b1a729cb3c544e6da885d234280dedeac6", + strip_prefix = "llvm-project-15.0.7.src", + url = "https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.7/llvm-project-15.0.7.src.tar.xz", + ) + + # WasmEdge with dependencies. + + maybe( + http_archive, + name = "com_github_wasmedge_wasmedge", + build_file = "@proxy_wasm_cpp_host//bazel/external:wasmedge.BUILD", + sha256 = "7ab8a0df37c8d282ecff72d0f0bff8db63fd92df1645d5a014a9dbed4b7f9025", + strip_prefix = "WasmEdge-proxy-wasm-0.13.1", + url = "https://github.com/WasmEdge/WasmEdge/archive/refs/tags/proxy-wasm/0.13.1.tar.gz", + ) + + native.bind( + name = "wasmedge", + actual = "@com_github_wasmedge_wasmedge//:wasmedge_lib", + ) + + # Wasmtime with dependencies. + + maybe( + http_archive, + name = "com_github_bytecodealliance_wasmtime", + build_file = "@proxy_wasm_cpp_host//bazel/external:wasmtime.BUILD", + sha256 = "2ccb49bb3bfa4d86907ad4c80d1147aef6156c7b6e3f7f14ed02a39de9761155", + strip_prefix = "wasmtime-24.0.0", + url = "https://github.com/bytecodealliance/wasmtime/archive/v24.0.0.tar.gz", + ) + + native.bind( + name = "wasmtime", + actual = "@com_github_bytecodealliance_wasmtime//:wasmtime_lib", + ) + + native.bind( + name = "prefixed_wasmtime", + actual = "@com_github_bytecodealliance_wasmtime//:prefixed_wasmtime_lib", + ) diff --git a/bazel/select.bzl b/bazel/select.bzl new file mode 100644 index 000000000..cc4da38d1 --- /dev/null +++ b/bazel/select.bzl @@ -0,0 +1,49 @@ +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +def proxy_wasm_select_engine_null(xs): + return select({ + "@proxy_wasm_cpp_host//bazel:engine_null": xs, + "@proxy_wasm_cpp_host//bazel:multiengine": xs, + "//conditions:default": [], + }) + +def proxy_wasm_select_engine_v8(xs): + return select({ + "@proxy_wasm_cpp_host//bazel:engine_v8": xs, + "@proxy_wasm_cpp_host//bazel:multiengine": xs, + "//conditions:default": [], + }) + +def proxy_wasm_select_engine_wamr(xs): + return select({ + "@proxy_wasm_cpp_host//bazel:engine_wamr_interp": xs, + "@proxy_wasm_cpp_host//bazel:engine_wamr_jit": xs, + "@proxy_wasm_cpp_host//bazel:multiengine": xs, + "//conditions:default": [], + }) + +def proxy_wasm_select_engine_wasmtime(xs, xp): + return select({ + "@proxy_wasm_cpp_host//bazel:engine_wasmtime": xs, + "@proxy_wasm_cpp_host//bazel:multiengine": xp, + "//conditions:default": [], + }) + +def proxy_wasm_select_engine_wasmedge(xs): + return select({ + "@proxy_wasm_cpp_host//bazel:engine_wasmedge": xs, + "@proxy_wasm_cpp_host//bazel:multiengine": xs, + "//conditions:default": [], + }) diff --git a/bazel/tsan_suppressions.txt b/bazel/tsan_suppressions.txt new file mode 100644 index 000000000..8754c04f3 --- /dev/null +++ b/bazel/tsan_suppressions.txt @@ -0,0 +1,3 @@ +# False positive in V8 worker shutdown +race:v8::platform::DefaultJobHandle::Join +race:v8::platform::DefaultJobHandle::Cancel diff --git a/bazel/wasm.bzl b/bazel/wasm.bzl new file mode 100644 index 000000000..192823047 --- /dev/null +++ b/bazel/wasm.bzl @@ -0,0 +1,102 @@ +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +load("@rules_rust//rust:defs.bzl", "rust_binary") + +def _wasm_rust_transition_impl(settings, attr): + return { + "//command_line_option:platforms": "@rules_rust//rust/platform:wasm", + } + +def _wasi_rust_transition_impl(settings, attr): + return { + "//command_line_option:platforms": "@rules_rust//rust/platform:wasi", + } + +wasm_rust_transition = transition( + implementation = _wasm_rust_transition_impl, + inputs = [], + outputs = [ + "//command_line_option:platforms", + ], +) + +wasi_rust_transition = transition( + implementation = _wasi_rust_transition_impl, + inputs = [], + outputs = [ + "//command_line_option:platforms", + ], +) + +def _wasm_binary_impl(ctx): + out = ctx.actions.declare_file(ctx.label.name) + if ctx.attr.signing_key: + ctx.actions.run( + executable = ctx.executable._wasmsign_tool, + arguments = ["--sign", "--use-custom-section", "--sk-path", ctx.files.signing_key[0].path, "--pk-path", ctx.files.signing_key[1].path, "--input", ctx.files.binary[0].path, "--output", out.path], + outputs = [out], + inputs = ctx.files.binary + ctx.files.signing_key, + ) + else: + ctx.actions.run( + executable = "cp", + arguments = [ctx.files.binary[0].path, out.path], + outputs = [out], + inputs = ctx.files.binary, + ) + + return [DefaultInfo(files = depset([out]), runfiles = ctx.runfiles([out]))] + +def _wasm_attrs(transition): + return { + "binary": attr.label(mandatory = True, cfg = transition), + "signing_key": attr.label_list(allow_files = True), + "_wasmsign_tool": attr.label(default = "//bazel/cargo/wasmsign/remote:wasmsign__wasmsign", executable = True, cfg = "exec"), + "_whitelist_function_transition": attr.label(default = "@bazel_tools//tools/whitelists/function_transition_whitelist"), + } + +wasm_rust_binary_rule = rule( + implementation = _wasm_binary_impl, + attrs = _wasm_attrs(wasm_rust_transition), +) + +wasi_rust_binary_rule = rule( + implementation = _wasm_binary_impl, + attrs = _wasm_attrs(wasi_rust_transition), +) + +def wasm_rust_binary(name, tags = [], wasi = False, signing_key = [], **kwargs): + wasm_name = "_wasm_" + name.replace(".", "_") + kwargs.setdefault("visibility", ["//visibility:public"]) + + rust_binary( + name = wasm_name, + edition = "2018", + crate_type = "cdylib", + out_binary = True, + tags = ["manual"], + **kwargs + ) + + bin_rule = wasm_rust_binary_rule + if wasi: + bin_rule = wasi_rust_binary_rule + + bin_rule( + name = name, + binary = ":" + wasm_name, + signing_key = signing_key, + tags = tags + ["manual"], + ) diff --git a/include/proxy-wasm/bytecode_util.h b/include/proxy-wasm/bytecode_util.h new file mode 100644 index 000000000..f708780e7 --- /dev/null +++ b/include/proxy-wasm/bytecode_util.h @@ -0,0 +1,75 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#pragma once + +#include +#include +#include + +#include "include/proxy-wasm/wasm_vm.h" + +namespace proxy_wasm { + +// Utilitiy functions which directly operate on Wasm bytecodes. +class BytecodeUtil { +public: + /** + * checkWasmHeader validates Wasm header. + * @param bytecode is the target bytecode. + * @return indicates whether the bytecode has valid Wasm header. + */ + static bool checkWasmHeader(std::string_view bytecode); + + /** + * getAbiVersion extracts ABI version from the bytecode. + * @param bytecode is the target bytecode. + * @param ret is the reference to store the extracted ABI version or UnKnown if it doesn't exist. + * @return indicates whether parsing succeeded or not. + */ + static bool getAbiVersion(std::string_view bytecode, proxy_wasm::AbiVersion &ret); + + /** + * getCustomSection extract the view of the custom section for a given name. + * @param bytecode is the target bytecode. + * @param name is the name of the custom section. + * @param ret is the reference to store the resulting view to the custom section. + * @return indicates whether parsing succeeded or not. + */ + static bool getCustomSection(std::string_view bytecode, std::string_view name, + std::string_view &ret); + + /** + * getFunctionNameIndex constructs the map from function indexes to function names stored in + * the function name subsection in "name" custom section. + * See https://webassembly.github.io/spec/core/appendix/custom.html#binary-funcnamesec for detail. + * @param bytecode is the target bytecode. + * @param ret is the reference to store map from function indexes to function names. + * @return indicates whether parsing succeeded or not. + */ + static bool getFunctionNameIndex(std::string_view bytecode, + std::unordered_map &ret); + + /** + * getStrippedSource gets Wasm module without Custom Sections to save some memory in workers. + * @param bytecode is the original bytecode. + * @param ret is the reference to the stripped bytecode or a copy of the original bytecode. + * @return indicates whether parsing succeeded or not. + */ + static bool getStrippedSource(std::string_view bytecode, std::string &ret); + +private: + static bool parseVarint(const char *&pos, const char *end, uint32_t &ret); +}; + +} // namespace proxy_wasm diff --git a/include/proxy-wasm/context.h b/include/proxy-wasm/context.h index ddad88e83..208633acc 100644 --- a/include/proxy-wasm/context.h +++ b/include/proxy-wasm/context.h @@ -23,15 +23,15 @@ #include #include #include +#include #include +#include "include/proxy-wasm/sdk.h" #include "include/proxy-wasm/context_interface.h" namespace proxy_wasm { -#include "proxy_wasm_common.h" -#include "proxy_wasm_enums.h" - +class PluginHandleBase; class WasmBase; class WasmVm; @@ -44,26 +44,34 @@ class WasmVm; * @param vm_id is a string used to differentiate VMs with the same code and VM configuration. * @param plugin_configuration is configuration for this plugin. * @param fail_open if true the plugin will pass traffic as opposed to close all streams. + * @param key is used to uniquely identify this plugin instance. */ struct PluginBase { PluginBase(std::string_view name, std::string_view root_id, std::string_view vm_id, - std::string_view runtime, std::string_view plugin_configuration, bool fail_open) + std::string_view engine, std::string_view plugin_configuration, bool fail_open, + std::string_view key) : name_(std::string(name)), root_id_(std::string(root_id)), vm_id_(std::string(vm_id)), - runtime_(std::string(runtime)), plugin_configuration_(plugin_configuration), - fail_open_(fail_open) {} + engine_(std::string(engine)), plugin_configuration_(plugin_configuration), + fail_open_(fail_open), key_(makePluginKey(root_id, plugin_configuration, key)), + log_prefix_(makeLogPrefix()) {} const std::string name_; const std::string root_id_; const std::string vm_id_; - const std::string runtime_; - std::string plugin_configuration_; + const std::string engine_; + const std::string plugin_configuration_; const bool fail_open_; + + const std::string &key() const { return key_; } const std::string &log_prefix() const { return log_prefix_; } private: std::string makeLogPrefix() const; + static std::string makePluginKey(std::string_view root_id, std::string_view plugin_configuration, + std::string_view key); - std::string log_prefix_; + const std::string key_; + const std::string log_prefix_; }; struct BufferBase : public BufferInterface { @@ -135,21 +143,21 @@ class ContextBase : public RootInterface, public SharedQueueInterface, public GeneralInterface { public: - ContextBase(); // Testing. - ContextBase(WasmBase *wasm); // Vm Context. - ContextBase(WasmBase *wasm, std::shared_ptr plugin); // Root Context. + ContextBase(); // Testing. + ContextBase(WasmBase *wasm); // Vm Context. + ContextBase(WasmBase *wasm, const std::shared_ptr &plugin); // Root Context. ContextBase(WasmBase *wasm, uint32_t parent_context_id, - std::shared_ptr plugin); // Stream context. + const std::shared_ptr &plugin_handle); // Stream context. virtual ~ContextBase(); - WasmBase *wasm() const { return wasm_; } + virtual WasmBase *wasm() const { return wasm_; } uint32_t id() const { return id_; } // The VM Context used for calling "malloc" has an id_ == 0. bool isVmContext() const { return id_ == 0; } // Root Contexts have the VM Context as a parent. bool isRootContext() const { return parent_context_id_ == 0; } - ContextBase *parent_context() const { return parent_context_; } - ContextBase *root_context() const { + virtual ContextBase *parent_context() const { return parent_context_; } + virtual ContextBase *root_context() const { const ContextBase *previous = this; ContextBase *parent = parent_context_; while (parent != previous) { @@ -162,7 +170,7 @@ class ContextBase : public RootInterface, std::string_view log_prefix() const { return isRootContext() ? root_log_prefix_ : plugin_->log_prefix(); } - WasmVm *wasmVm() const; + virtual WasmVm *wasmVm() const; // Called before deleting the context. virtual void destroy(); @@ -188,11 +196,11 @@ class ContextBase : public RootInterface, // HTTP FilterHeadersStatus onRequestHeaders(uint32_t headers, bool end_of_stream) override; - FilterDataStatus onRequestBody(uint32_t body_buffer_length, bool end_of_stream) override; + FilterDataStatus onRequestBody(uint32_t body_length, bool end_of_stream) override; FilterTrailersStatus onRequestTrailers(uint32_t trailers) override; FilterMetadataStatus onRequestMetadata(uint32_t elements) override; FilterHeadersStatus onResponseHeaders(uint32_t headers, bool end_of_stream) override; - FilterDataStatus onResponseBody(uint32_t body_buffer_length, bool end_of_stream) override; + FilterDataStatus onResponseBody(uint32_t body_length, bool end_of_stream) override; FilterTrailersStatus onResponseTrailers(uint32_t trailers) override; FilterMetadataStatus onResponseMetadata(uint32_t elements) override; @@ -229,19 +237,17 @@ class ContextBase : public RootInterface, WasmResult log(uint32_t /* level */, std::string_view /* message */) override { return unimplemented(); } - uint32_t getLogLevel() override { return static_cast(LogLevel::info); } + uint32_t getLogLevel() override { + unimplemented(); + return 0; + } uint64_t getCurrentTimeNanoseconds() override { -#if !defined(_MSC_VER) - struct timespec tpe; - clock_gettime(CLOCK_REALTIME, &tpe); - uint64_t t = tpe.tv_sec; - t *= 1000000000; - t += tpe.tv_nsec; - return t; -#else unimplemented(); return 0; -#endif + } + uint64_t getMonotonicTimeNanoseconds() override { + unimplemented(); + return 0; } std::string_view getConfiguration() override { unimplemented(); @@ -332,12 +338,15 @@ class ContextBase : public RootInterface, WasmResult getSharedData(std::string_view key, std::pair *data) override; WasmResult setSharedData(std::string_view key, std::string_view value, uint32_t cas) override; + WasmResult getSharedDataKeys(std::vector *result) override; + WasmResult removeSharedDataKey(std::string_view key, uint32_t cas, + std::pair *result) override; // Shared Queue WasmResult registerSharedQueue(std::string_view queue_name, SharedQueueDequeueToken *token_ptr) override; WasmResult lookupSharedQueue(std::string_view vm_id, std::string_view queue_name, - SharedQueueEnqueueToken *token) override; + SharedQueueEnqueueToken *token_ptr) override; WasmResult dequeueSharedQueue(uint32_t token, std::string *data) override; WasmResult enqueueSharedQueue(uint32_t token, std::string_view value) override; @@ -373,18 +382,34 @@ class ContextBase : public RootInterface, protected: friend class WasmBase; - void initializeRootBase(WasmBase *wasm, std::shared_ptr plugin); std::string makeRootLogPrefix(std::string_view vm_id) const; WasmBase *wasm_{nullptr}; uint32_t id_{0}; - uint32_t parent_context_id_{0}; // 0 for roots and the general context. - ContextBase *parent_context_{nullptr}; // set in all contexts. - std::string root_id_; // set only in root context. - std::string root_log_prefix_; // set only in root context. - std::shared_ptr plugin_; + uint32_t parent_context_id_{0}; // 0 for roots and the general context. + ContextBase *parent_context_{nullptr}; // set in all contexts. + std::string root_id_; // set only in root context. + std::string root_log_prefix_; // set only in root context. + std::shared_ptr plugin_; // set in root and stream contexts. + std::shared_ptr plugin_handle_; // set only in stream context. + std::shared_ptr temp_plugin_; // Remove once ABI v0.1.0 is gone. bool in_vm_context_created_ = false; bool destroyed_ = false; + bool stream_failed_ = false; // Set true after failStream is called in case of VM failure. + + // If true, convertVmCallResultToFilterHeadersStatus() propagates + // FilterHeadersStatus::StopIteration unmodified to callers. If false, it + // translates FilterHeaderStatus::StopIteration to + // FilterHeadersStatus::StopAllIterationAndWatermark, which is the default + // behavior for v0.2.* of the Proxy-Wasm ABI. + bool allow_on_headers_stop_iteration_ = false; + +private: + // helper functions + FilterHeadersStatus convertVmCallResultToFilterHeadersStatus(uint64_t result); + FilterDataStatus convertVmCallResultToFilterDataStatus(uint64_t result); + FilterTrailersStatus convertVmCallResultToFilterTrailersStatus(uint64_t result); + FilterMetadataStatus convertVmCallResultToFilterMetadataStatus(uint64_t result); }; class DeferAfterCallActions { diff --git a/include/proxy-wasm/context_interface.h b/include/proxy-wasm/context_interface.h index 1a6f738d9..48fce76d9 100644 --- a/include/proxy-wasm/context_interface.h +++ b/include/proxy-wasm/context_interface.h @@ -25,10 +25,9 @@ #include #include -namespace proxy_wasm { +#include "include/proxy-wasm/sdk.h" -#include "proxy_wasm_common.h" -#include "proxy_wasm_enums.h" +namespace proxy_wasm { using Pairs = std::vector>; using PairsWithStringValues = std::vector>; @@ -206,7 +205,7 @@ struct HttpInterface { virtual FilterHeadersStatus onRequestHeaders(uint32_t headers, bool end_of_stream) = 0; // Call on a stream context to indicate that body data has arrived. - virtual FilterDataStatus onRequestBody(uint32_t body_buffer_length, bool end_of_stream) = 0; + virtual FilterDataStatus onRequestBody(uint32_t body_length, bool end_of_stream) = 0; // Call on a stream context to indicate that the request trailers have arrived. virtual FilterTrailersStatus onRequestTrailers(uint32_t trailers) = 0; @@ -218,7 +217,7 @@ struct HttpInterface { virtual FilterHeadersStatus onResponseHeaders(uint32_t trailers, bool end_of_stream) = 0; // Call on a stream context to indicate that body data has arrived. - virtual FilterDataStatus onResponseBody(uint32_t body_buffer_length, bool end_of_stream) = 0; + virtual FilterDataStatus onResponseBody(uint32_t body_length, bool end_of_stream) = 0; // Call on a stream context to indicate that the request trailers have arrived. virtual FilterTrailersStatus onResponseTrailers(uint32_t trailers) = 0; @@ -557,6 +556,9 @@ struct GeneralInterface { // Provides the current time in nanoseconds since the Unix epoch. virtual uint64_t getCurrentTimeNanoseconds() = 0; + // Provides the monotonic time in nanoseconds. + virtual uint64_t getMonotonicTimeNanoseconds() = 0; + // Returns plugin configuration. virtual std::string_view getConfiguration() = 0; @@ -593,7 +595,7 @@ struct GeneralInterface { }; /** - * SharedDataInterface is for shaing data between VMs. In general the VMs may be on different + * SharedDataInterface is for sharing data between VMs. In general the VMs may be on different * threads. Keys can have any format, but good practice would use reverse DNS and namespacing * prefixes to avoid conflicts. */ @@ -618,6 +620,23 @@ struct SharedDataInterface { * @param data is a location to store the returned value. */ virtual WasmResult setSharedData(std::string_view key, std::string_view value, uint32_t cas) = 0; + + /** + * Return all the keys from the data shraed between VMs + * @param data is a location to store the returned value. + */ + virtual WasmResult getSharedDataKeys(std::vector *result) = 0; + + /** + * Removes the given key from the data shared between VMs. + * @param key is a proxy-wide key mapping to the shared data value. + * @param cas is a compare-and-swap value. If it is zero it is ignored, otherwise it must match + * @param cas is a location to store value, and cas number, associated with the removed key + * the cas associated with the value. + */ + virtual WasmResult + removeSharedDataKey(std::string_view key, uint32_t cas, + std::pair *result) = 0; }; // namespace proxy_wasm struct SharedQueueInterface { diff --git a/include/proxy-wasm/exports.h b/include/proxy-wasm/exports.h index f0fa5dbf0..91c51150c 100644 --- a/include/proxy-wasm/exports.h +++ b/include/proxy-wasm/exports.h @@ -17,141 +17,202 @@ #include +#include "include/proxy-wasm/context.h" +#include "include/proxy-wasm/wasm_vm.h" #include "include/proxy-wasm/word.h" namespace proxy_wasm { class ContextBase; +// Any currently executing Wasm call context. +::proxy_wasm::ContextBase *contextOrEffectiveContext(); + extern thread_local ContextBase *current_context_; +/** + * WasmForeignFunction is used for registering host-specific host functions. + * A foreign function can be registered via RegisterForeignFunction and available + * to Wasm modules via proxy_call_foreign_function. + * @param wasm is the WasmBase which the Wasm module is running on. + * @param argument is the view to the argument to the function passed by the module. + * @param alloc_result is used to allocate the result data of this foreign function. + */ +using WasmForeignFunction = std::function alloc_result)>; + +/** + * Used to get the foreign function registered via RegisterForeignFunction for a given name. + * @param function_name is the name used to lookup the foreign function table. + * @return a WasmForeignFunction if registered. + */ +WasmForeignFunction getForeignFunction(std::string_view function_name); + +/** + * RegisterForeignFunction is used to register a foreign function in the lookup table + * used internally in getForeignFunction. + */ +struct RegisterForeignFunction { + /** + * @param function_name is the key for this foreign function. + * @param f is the function instance. + */ + RegisterForeignFunction(const std::string &function_name, WasmForeignFunction f); +}; + namespace exports { -template size_t pairsSize(const Pairs &result) { - size_t size = 4; // number of headers - for (auto &p : result) { - size += 8; // size of key, size of value - size += p.first.size() + 1; // null terminated key - size += p.second.size() + 1; // null terminated value - } - return size; -} - -template void marshalPairs(const Pairs &result, char *buffer) { - char *b = buffer; - *reinterpret_cast(b) = result.size(); - b += sizeof(uint32_t); - for (auto &p : result) { - *reinterpret_cast(b) = p.first.size(); - b += sizeof(uint32_t); - *reinterpret_cast(b) = p.second.size(); - b += sizeof(uint32_t); - } - for (auto &p : result) { - memcpy(b, p.first.data(), p.first.size()); - b += p.first.size(); - *b++ = 0; - memcpy(b, p.second.data(), p.second.size()); - b += p.second.size(); - *b++ = 0; - } -} - -// ABI functions exported from envoy to wasm. - -Word get_configuration(void *raw_context, Word address, Word size); -Word get_status(void *raw_context, Word status_code, Word address, Word size); -Word log(void *raw_context, Word level, Word address, Word size); -Word get_log_level(void *raw_context, Word result_level_uint32_ptr); -Word get_property(void *raw_context, Word path_ptr, Word path_size, Word value_ptr_ptr, - Word value_size_ptr); -Word set_property(void *raw_context, Word key_ptr, Word key_size, Word value_ptr, Word value_size); -Word continue_request(void *raw_context); -Word continue_response(void *raw_context); -Word continue_stream(void *raw_context, Word stream_type); -Word close_stream(void *raw_context, Word stream_type); -Word send_local_response(void *raw_context, Word response_code, Word response_code_details_ptr, +// ABI functions exported from host to wasm. + +Word get_configuration(Word value_ptr_ptr, Word value_size_ptr); +Word get_status(Word code_ptr, Word value_ptr_ptr, Word value_size_ptr); +Word log(Word level, Word address, Word size); +Word get_log_level(Word result_level_uint32_ptr); +Word get_property(Word path_ptr, Word path_size, Word value_ptr_ptr, Word value_size_ptr); +Word set_property(Word key_ptr, Word key_size, Word value_ptr, Word value_size); +Word continue_request(); +Word continue_response(); +Word continue_stream(Word stream_type); +Word close_stream(Word stream_type); +Word send_local_response(Word response_code, Word response_code_details_ptr, Word response_code_details_size, Word body_ptr, Word body_size, Word additional_response_header_pairs_ptr, Word additional_response_header_pairs_size, Word grpc_status); -Word clear_route_cache(void *raw_context); -Word get_shared_data(void *raw_context, Word key_ptr, Word key_size, Word value_ptr_ptr, - Word value_size_ptr, Word cas_ptr); -Word set_shared_data(void *raw_context, Word key_ptr, Word key_size, Word value_ptr, - Word value_size, Word cas); -Word register_shared_queue(void *raw_context, Word queue_name_ptr, Word queue_name_size, - Word token_ptr); -Word resolve_shared_queue(void *raw_context, Word vm_id_ptr, Word vm_id_size, Word queue_name_ptr, +Word clear_route_cache(); +Word get_shared_data(Word key_ptr, Word key_size, Word value_ptr_ptr, Word value_size_ptr, + Word cas_ptr); +Word set_shared_data(Word key_ptr, Word key_size, Word value_ptr, Word value_size, Word cas); +Word register_shared_queue(Word queue_name_ptr, Word queue_name_size, Word token_ptr); +Word resolve_shared_queue(Word vm_id_ptr, Word vm_id_size, Word queue_name_ptr, Word queue_name_size, Word token_ptr); -Word dequeue_shared_queue(void *raw_context, Word token, Word data_ptr_ptr, Word data_size_ptr); -Word enqueue_shared_queue(void *raw_context, Word token, Word data_ptr, Word data_size); -Word get_buffer_bytes(void *raw_context, Word type, Word start, Word length, Word ptr_ptr, - Word size_ptr); -Word get_buffer_status(void *raw_context, Word type, Word length_ptr, Word flags_ptr); -Word set_buffer_bytes(void *raw_context, Word type, Word start, Word length, Word data_ptr, - Word data_size); -Word add_header_map_value(void *raw_context, Word type, Word key_ptr, Word key_size, Word value_ptr, - Word value_size); -Word get_header_map_value(void *raw_context, Word type, Word key_ptr, Word key_size, - Word value_ptr_ptr, Word value_size_ptr); -Word replace_header_map_value(void *raw_context, Word type, Word key_ptr, Word key_size, - Word value_ptr, Word value_size); -Word remove_header_map_value(void *raw_context, Word type, Word key_ptr, Word key_size); -Word get_header_map_pairs(void *raw_context, Word type, Word ptr_ptr, Word size_ptr); -Word set_header_map_pairs(void *raw_context, Word type, Word ptr, Word size); -Word get_header_map_size(void *raw_context, Word type, Word result_ptr); -Word getRequestBodyBufferBytes(void *raw_context, Word start, Word length, Word ptr_ptr, - Word size_ptr); -Word get_response_body_buffer_bytes(void *raw_context, Word start, Word length, Word ptr_ptr, - Word size_ptr); -Word http_call(void *raw_context, Word uri_ptr, Word uri_size, Word header_pairs_ptr, - Word header_pairs_size, Word body_ptr, Word body_size, Word trailer_pairs_ptr, - Word trailer_pairs_size, Word timeout_milliseconds, Word token_ptr); -Word define_metric(void *raw_context, Word metric_type, Word name_ptr, Word name_size, - Word result_ptr); -Word increment_metric(void *raw_context, Word metric_id, int64_t offset); -Word record_metric(void *raw_context, Word metric_id, uint64_t value); -Word get_metric(void *raw_context, Word metric_id, Word result_uint64_ptr); -Word grpc_call(void *raw_context, Word service_ptr, Word service_size, Word service_name_ptr, - Word service_name_size, Word method_name_ptr, Word method_name_size, - Word initial_metadata_ptr, Word initial_metadata_size, Word request_ptr, - Word request_size, Word timeout_milliseconds, Word token_ptr); -Word grpc_stream(void *raw_context, Word service_ptr, Word service_size, Word service_name_ptr, - Word service_name_size, Word method_name_ptr, Word method_name_size, - Word initial_metadata_ptr, Word initial_metadata_size, Word token_ptr); -Word grpc_cancel(void *raw_context, Word token); -Word grpc_close(void *raw_context, Word token); -Word grpc_send(void *raw_context, Word token, Word message_ptr, Word message_size, Word end_stream); - -Word set_tick_period_milliseconds(void *raw_context, Word tick_period_milliseconds); -Word get_current_time_nanoseconds(void *raw_context, Word result_uint64_ptr); - -Word set_effective_context(void *raw_context, Word context_id); -Word done(void *raw_context); -Word call_foreign_function(void *raw_context, Word function_name, Word function_name_size, - Word arguments, Word warguments_size, Word results, Word results_size); +Word dequeue_shared_queue(Word token, Word data_ptr_ptr, Word data_size_ptr); +Word enqueue_shared_queue(Word token, Word data_ptr, Word data_size); +Word get_buffer_bytes(Word type, Word start, Word length, Word ptr_ptr, Word size_ptr); +Word get_buffer_status(Word type, Word length_ptr, Word flags_ptr); +Word set_buffer_bytes(Word type, Word start, Word length, Word data_ptr, Word data_size); +Word add_header_map_value(Word type, Word key_ptr, Word key_size, Word value_ptr, Word value_size); +Word get_header_map_value(Word type, Word key_ptr, Word key_size, Word value_ptr_ptr, + Word value_size_ptr); +Word replace_header_map_value(Word type, Word key_ptr, Word key_size, Word value_ptr, + Word value_size); +Word remove_header_map_value(Word type, Word key_ptr, Word key_size); +Word get_header_map_pairs(Word type, Word ptr_ptr, Word size_ptr); +Word set_header_map_pairs(Word type, Word ptr, Word size); +Word get_header_map_size(Word type, Word result_ptr); +Word getRequestBodyBufferBytes(Word start, Word length, Word ptr_ptr, Word size_ptr); +Word get_response_body_buffer_bytes(Word start, Word length, Word ptr_ptr, Word size_ptr); +Word http_call(Word uri_ptr, Word uri_size, Word header_pairs_ptr, Word header_pairs_size, + Word body_ptr, Word body_size, Word trailer_pairs_ptr, Word trailer_pairs_size, + Word timeout_milliseconds, Word token_ptr); +Word define_metric(Word metric_type, Word name_ptr, Word name_size, Word metric_id_ptr); +Word increment_metric(Word metric_id, int64_t offset); +Word record_metric(Word metric_id, uint64_t value); +Word get_metric(Word metric_id, Word result_uint64_ptr); +Word grpc_call(Word service_ptr, Word service_size, Word service_name_ptr, Word service_name_size, + Word method_name_ptr, Word method_name_size, Word initial_metadata_ptr, + Word initial_metadata_size, Word request_ptr, Word request_size, + Word timeout_milliseconds, Word token_ptr); +Word grpc_stream(Word service_ptr, Word service_size, Word service_name_ptr, Word service_name_size, + Word method_name_ptr, Word method_name_size, Word initial_metadata_ptr, + Word initial_metadata_size, Word token_ptr); +Word grpc_cancel(Word token); +Word grpc_close(Word token); +Word grpc_send(Word token, Word message_ptr, Word message_size, Word end_stream); + +Word set_tick_period_milliseconds(Word tick_period_milliseconds); +Word get_current_time_nanoseconds(Word result_uint64_ptr); + +Word set_effective_context(Word context_id); +Word done(); +Word call_foreign_function(Word function_name, Word function_name_size, Word arguments, + Word warguments_size, Word results, Word results_size); // Runtime environment functions exported from envoy to wasm. -Word wasi_unstable_fd_write(void *raw_context, Word fd, Word iovs, Word iovs_len, - Word nwritten_ptr); -Word wasi_unstable_fd_read(void *, Word, Word, Word, Word); -Word wasi_unstable_fd_seek(void *, Word, int64_t, Word, Word); -Word wasi_unstable_fd_close(void *, Word); -Word wasi_unstable_fd_fdstat_get(void *, Word fd, Word statOut); -Word wasi_unstable_environ_get(void *, Word, Word); -Word wasi_unstable_environ_sizes_get(void *raw_context, Word count_ptr, Word buf_size_ptr); -Word wasi_unstable_args_get(void *raw_context, Word argc_ptr, Word argv_buf_size_ptr); -Word wasi_unstable_args_sizes_get(void *raw_context, Word argc_ptr, Word argv_buf_size_ptr); -void wasi_unstable_proc_exit(void *, Word); -Word wasi_unstable_clock_time_get(void *, Word, uint64_t, Word); -Word wasi_unstable_random_get(void *, Word, Word); -Word pthread_equal(void *, Word left, Word right); +Word wasi_unstable_path_open(Word fd, Word dir_flags, Word path, Word path_len, Word oflags, + int64_t fs_rights_base, int64_t fg_rights_inheriting, Word fd_flags, + Word nwritten_ptr); +Word wasi_unstable_fd_prestat_get(Word fd, Word buf_ptr); +Word wasi_unstable_fd_prestat_dir_name(Word fd, Word path_ptr, Word path_len); +Word wasi_unstable_fd_write(Word fd, Word iovs, Word iovs_len, Word nwritten_ptr); +Word wasi_unstable_fd_read(Word, Word, Word, Word); +Word wasi_unstable_fd_seek(Word, int64_t, Word, Word); +Word wasi_unstable_fd_close(Word); +Word wasi_unstable_fd_fdstat_get(Word fd, Word statOut); +Word wasi_unstable_fd_fdstat_set_flags(Word fd, Word flags); +Word wasi_unstable_environ_get(Word, Word); +Word wasi_unstable_environ_sizes_get(Word count_ptr, Word buf_size_ptr); +Word wasi_unstable_args_get(Word argc_ptr, Word argv_buf_size_ptr); +Word wasi_unstable_args_sizes_get(Word argc_ptr, Word argv_buf_size_ptr); +Word wasi_unstable_sched_yield(); +Word wasi_unstable_poll_oneoff(Word in, Word out, Word nsubscriptions, Word nevents); +void wasi_unstable_proc_exit(Word); +Word wasi_unstable_clock_time_get(Word, uint64_t, Word); +Word wasi_unstable_random_get(Word, Word); +Word pthread_equal(Word left, Word right); +void emscripten_notify_memory_growth(Word); // Support for embedders, not exported to Wasm. -// Any currently executing Wasm call context. -::proxy_wasm::ContextBase *ContextOrEffectiveContext(::proxy_wasm::ContextBase *context); +#define FOR_ALL_HOST_FUNCTIONS(_f) \ + _f(log) _f(get_status) _f(set_property) _f(get_property) _f(send_local_response) \ + _f(get_shared_data) _f(set_shared_data) _f(register_shared_queue) _f(resolve_shared_queue) \ + _f(dequeue_shared_queue) _f(enqueue_shared_queue) _f(get_header_map_value) \ + _f(add_header_map_value) _f(replace_header_map_value) _f(remove_header_map_value) \ + _f(get_header_map_pairs) _f(set_header_map_pairs) _f(get_header_map_size) \ + _f(get_buffer_status) _f(get_buffer_bytes) _f(set_buffer_bytes) \ + _f(http_call) _f(grpc_call) _f(grpc_stream) _f(grpc_close) \ + _f(grpc_cancel) _f(grpc_send) _f(set_tick_period_milliseconds) \ + _f(get_current_time_nanoseconds) _f(define_metric) \ + _f(increment_metric) _f(record_metric) _f(get_metric) \ + _f(set_effective_context) _f(done) \ + _f(call_foreign_function) + +#define FOR_ALL_HOST_FUNCTIONS_ABI_SPECIFIC(_f) \ + _f(get_configuration) _f(continue_request) _f(continue_response) _f(clear_route_cache) \ + _f(continue_stream) _f(close_stream) _f(get_log_level) + +#define FOR_ALL_WASI_FUNCTIONS(_f) \ + _f(fd_write) _f(fd_read) _f(fd_seek) _f(fd_close) _f(fd_fdstat_get) _f(fd_fdstat_set_flags) \ + _f(environ_get) _f(environ_sizes_get) _f(args_get) _f(args_sizes_get) _f(clock_time_get) \ + _f(random_get) _f(sched_yield) _f(poll_oneoff) _f(proc_exit) _f(path_open) \ + _f(fd_prestat_get) _f(fd_prestat_dir_name) + +// Helpers to generate a stub to pass to VM, in place of a restricted proxy-wasm capability. +#define _CREATE_PROXY_WASM_STUB(_fn) \ + template struct _fn##Stub; \ + template struct _fn##Stub { \ + static Word stub(Args...) { \ + auto context = contextOrEffectiveContext(); \ + context->wasmVm()->integration()->error( \ + "Attempted call to restricted proxy-wasm capability: proxy_" #_fn); \ + return WasmResult::InternalFailure; \ + } \ + }; +FOR_ALL_HOST_FUNCTIONS(_CREATE_PROXY_WASM_STUB) +FOR_ALL_HOST_FUNCTIONS_ABI_SPECIFIC(_CREATE_PROXY_WASM_STUB) +#undef _CREATE_PROXY_WASM_STUB + +// Helpers to generate a stub to pass to VM, in place of a restricted WASI capability. +#define _CREATE_WASI_STUB(_fn) \ + template struct _fn##Stub; \ + template struct _fn##Stub { \ + static Word stub(Args...) { \ + auto context = contextOrEffectiveContext(); \ + context->wasmVm()->integration()->error( \ + "Attempted call to restricted WASI capability: " #_fn); \ + return 76; /* __WASI_ENOTCAPABLE */ \ + } \ + }; \ + template struct _fn##Stub { \ + static void stub(Args...) { \ + auto context = contextOrEffectiveContext(); \ + context->wasmVm()->integration()->error( \ + "Attempted call to restricted WASI capability: " #_fn); \ + } \ + }; +FOR_ALL_WASI_FUNCTIONS(_CREATE_WASI_STUB) +#undef _CREATE_WASI_STUB } // namespace exports } // namespace proxy_wasm diff --git a/include/proxy-wasm/limits.h b/include/proxy-wasm/limits.h new file mode 100644 index 000000000..9b9ac1cd3 --- /dev/null +++ b/include/proxy-wasm/limits.h @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +// Wasm memory page is always 64 KiB. +#define PROXY_WASM_HOST_WASM_MEMORY_PAGE_SIZE_BYTES (64 * 1024) + +// Maximum allowed Wasm memory size. +#ifndef PROXY_WASM_HOST_MAX_WASM_MEMORY_SIZE_BYTES +#define PROXY_WASM_HOST_MAX_WASM_MEMORY_SIZE_BYTES (1024 * 1024 * 1024) +#endif + +// Maximum allowed random_get buffer size. This value is consistent with +// the JavaScript Crypto.getRandomValues() maximum buffer size. +// See: https://w3c.github.io/webcrypto/#Crypto-method-getRandomValues +#ifndef PROXY_WASM_HOST_WASI_RANDOM_GET_MAX_SIZE_BYTES +#define PROXY_WASM_HOST_WASI_RANDOM_GET_MAX_SIZE_BYTES (64 * 1024) +#endif + +// Maximum allowed size of Pairs buffer to deserialize. +#ifndef PROXY_WASM_HOST_PAIRS_MAX_BYTES +#define PROXY_WASM_HOST_PAIRS_MAX_BYTES (1024 * 1024) +#endif + +// Maximum allowed number of pairs in a Pairs buffer to deserialize. +#ifndef PROXY_WASM_HOST_PAIRS_MAX_COUNT +#define PROXY_WASM_HOST_PAIRS_MAX_COUNT 1024 +#endif diff --git a/include/proxy-wasm/null_plugin.h b/include/proxy-wasm/null_plugin.h index 8385ee000..b33187ce0 100644 --- a/include/proxy-wasm/null_plugin.h +++ b/include/proxy-wasm/null_plugin.h @@ -17,17 +17,9 @@ #include -#include "google/protobuf/message.h" +#include "include/proxy-wasm/exports.h" #include "include/proxy-wasm/null_vm_plugin.h" #include "include/proxy-wasm/wasm.h" -#include "include/proxy-wasm/exports.h" - -namespace proxy_wasm { -namespace null_plugin { -#include "proxy_wasm_enums.h" -} // namespace null_plugin -} // namespace proxy_wasm - #include "include/proxy-wasm/wasm_api_impl.h" namespace proxy_wasm { @@ -79,7 +71,7 @@ class NullPlugin : public NullVmPlugin { void onForeignFunction(uint64_t root_context_id, uint64_t foreign_function_id, uint64_t data_size); - void onCreate(uint64_t context_id, uint64_t root_context_id); + void onCreate(uint64_t context_id, uint64_t parent_context_id); uint64_t onNewConnection(uint64_t context_id); uint64_t onDownstreamData(uint64_t context_id, uint64_t data_length, uint64_t end_of_stream); @@ -112,7 +104,7 @@ class NullPlugin : public NullVmPlugin { null_plugin::RootContext *getRoot(std::string_view root_id); null_plugin::Context *getContext(uint64_t context_id); - void error(std::string_view message) { wasm_vm_->error(message); } + void error(std::string_view message) { wasm_vm_->integration()->error(message); } null_plugin::Context *ensureContext(uint64_t context_id, uint64_t root_context_id); null_plugin::RootContext *ensureRootContext(uint64_t context_id); diff --git a/include/proxy-wasm/null_vm.h b/include/proxy-wasm/null_vm.h index bfa62d896..703266df3 100644 --- a/include/proxy-wasm/null_vm.h +++ b/include/proxy-wasm/null_vm.h @@ -32,18 +32,18 @@ struct NullVm : public WasmVm { NullVm(const NullVm &other) : plugin_name_(other.plugin_name_) {} // WasmVm - std::string_view runtime() override { return "null"; } + std::string_view getEngineName() override { return "null"; } Cloneable cloneable() override { return Cloneable::InstantiatedModule; }; std::unique_ptr clone() override; - bool load(const std::string &code, bool allow_precompiled) override; - AbiVersion getAbiVersion() override; + bool load(std::string_view plugin_name, std::string_view precompiled, + const std::unordered_map &function_names) override; bool link(std::string_view debug_name) override; uint64_t getMemorySize() override; std::optional getMemory(uint64_t pointer, uint64_t size) override; bool setMemory(uint64_t pointer, uint64_t size, const void *data) override; bool setWord(uint64_t pointer, Word data) override; bool getWord(uint64_t pointer, Word *data) override; - std::string_view getCustomSection(std::string_view name) override; + size_t getWordSize() override; std::string_view getPrecompiledSectionName() override; #define _FORWARD_GET_FUNCTION(_T) \ @@ -60,6 +60,11 @@ struct NullVm : public WasmVm { FOR_ALL_WASM_VM_IMPORTS(_REGISTER_CALLBACK) #undef _REGISTER_CALLBACK + void terminate() override {} + bool usesWasmByteOrder() override { return false; } + + void warm() override {} + std::string plugin_name_; std::unique_ptr plugin_; }; diff --git a/include/proxy-wasm/pairs_util.h b/include/proxy-wasm/pairs_util.h new file mode 100644 index 000000000..019c970ba --- /dev/null +++ b/include/proxy-wasm/pairs_util.h @@ -0,0 +1,64 @@ +// Copyright 2016-2019 Envoy Project Authors +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include +#include +#include +#include + +namespace proxy_wasm { + +using Pairs = std::vector>; +using StringPairs = std::vector>; + +class PairsUtil { +public: + /** + * pairsSize returns the buffer size required to serialize Pairs. + * @param pairs Pairs to serialize. + * @return size of the output buffer. + */ + static size_t pairsSize(const Pairs &pairs); + + static size_t pairsSize(const StringPairs &stringpairs) { + Pairs views(stringpairs.begin(), stringpairs.end()); + return pairsSize(views); + } + + /** + * marshalPairs serializes Pairs to output buffer. + * @param pairs Pairs to serialize. + * @param buffer output buffer. + * @param size size of the output buffer. + * @return indicates whether serialization succeeded or not. + */ + static bool marshalPairs(const Pairs &pairs, char *buffer, size_t size); + + static bool marshalPairs(const StringPairs &stringpairs, char *buffer, size_t size) { + Pairs views(stringpairs.begin(), stringpairs.end()); + return marshalPairs(views, buffer, size); + } + + /** + * toPairs deserializes input buffer to Pairs. + * @param buffer serialized input buffer. + * @return deserialized Pairs or an empty instance in case of deserialization failure. + */ + static Pairs toPairs(std::string_view buffer); +}; + +} // namespace proxy_wasm diff --git a/include/proxy-wasm/sdk.h b/include/proxy-wasm/sdk.h new file mode 100644 index 000000000..105854373 --- /dev/null +++ b/include/proxy-wasm/sdk.h @@ -0,0 +1,50 @@ +// Copyright 2016-2019 Envoy Project Authors +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include +#include + +namespace proxy_wasm { + +namespace internal { + +// isolate those includes to prevent ::proxy_wasm namespace pollution with std +// namespace definitions. +#include "proxy_wasm_common.h" +#include "proxy_wasm_enums.h" + +} // namespace internal + +// proxy_wasm_common.h +using WasmResult = internal::WasmResult; +using WasmHeaderMapType = internal::WasmHeaderMapType; +using WasmBufferType = internal::WasmBufferType; +using WasmBufferFlags = internal::WasmBufferFlags; +using WasmStreamType = internal::WasmStreamType; + +// proxy_wasm_enums.h +using LogLevel = internal::LogLevel; +using FilterStatus = internal::FilterStatus; +using FilterHeadersStatus = internal::FilterHeadersStatus; +using FilterMetadataStatus = internal::FilterMetadataStatus; +using FilterTrailersStatus = internal::FilterTrailersStatus; +using FilterDataStatus = internal::FilterDataStatus; +using GrpcStatus = internal::GrpcStatus; +using MetricType = internal::MetricType; +using CloseType = internal::CloseType; + +} // namespace proxy_wasm diff --git a/include/proxy-wasm/signature_util.h b/include/proxy-wasm/signature_util.h new file mode 100644 index 000000000..a5c9c39df --- /dev/null +++ b/include/proxy-wasm/signature_util.h @@ -0,0 +1,34 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include +#include + +namespace proxy_wasm { + +// Utility functions to verify Wasm signatures. +class SignatureUtil { +public: + /** + * verifySignature validates Wasm signature. + * @param bytecode is the source bytecode. + * @param message is the reference to store the message (success or error). + * @return indicates whether the bytecode has a valid Wasm signature. + */ + static bool verifySignature(std::string_view bytecode, std::string &message); +}; + +} // namespace proxy_wasm diff --git a/context_test.cc b/include/proxy-wasm/vm_id_handle.h similarity index 61% rename from context_test.cc rename to include/proxy-wasm/vm_id_handle.h index bd4b3283b..16ebb4bf0 100644 --- a/context_test.cc +++ b/include/proxy-wasm/vm_id_handle.h @@ -12,24 +12,27 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "include/proxy-wasm/context.h" +#pragma once -#include "gtest/gtest.h" +#include +#include +#include +#include +#include +#include namespace proxy_wasm { -namespace { -class Context : public ContextBase { +class VmIdHandle { public: - Context(std::function error_function) - : error_function_(error_function) {} - void error(std::string_view message) { error_function_(message); } + VmIdHandle(std::string_view vm_id) : vm_id_(std::string(vm_id)){}; + ~VmIdHandle(); private: - std::function error_function_; + std::string vm_id_; }; -TEST(Context, IncludeParses) {} +std::shared_ptr getVmIdHandle(std::string_view vm_id); +void registerVmIdHandleCallback(const std::function &f); -} // namespace } // namespace proxy_wasm diff --git a/include/proxy-wasm/wavm.h b/include/proxy-wasm/wamr.h similarity index 94% rename from include/proxy-wasm/wavm.h rename to include/proxy-wasm/wamr.h index 1ebbe8397..98ff72e31 100644 --- a/include/proxy-wasm/wavm.h +++ b/include/proxy-wasm/wamr.h @@ -21,6 +21,6 @@ namespace proxy_wasm { -std::unique_ptr createWavmVm(); +std::unique_ptr createWamrVm(); } // namespace proxy_wasm diff --git a/include/proxy-wasm/wasm.h b/include/proxy-wasm/wasm.h index 90347f6f0..9b85710bd 100644 --- a/include/proxy-wasm/wasm.h +++ b/include/proxy-wasm/wasm.h @@ -24,45 +24,48 @@ #include #include +#include "include/proxy-wasm/sdk.h" #include "include/proxy-wasm/context.h" #include "include/proxy-wasm/exports.h" #include "include/proxy-wasm/wasm_vm.h" +#include "include/proxy-wasm/vm_id_handle.h" namespace proxy_wasm { -#include "proxy_wasm_common.h" - class ContextBase; -class WasmBase; class WasmHandleBase; -using WasmForeignFunction = - std::function)>; using WasmVmFactory = std::function()>; using CallOnThreadFunction = std::function)>; +struct SanitizationConfig { + std::vector argument_list; + bool is_allowlist; +}; +using AllowedCapabilitiesMap = std::unordered_map; + // Wasm execution instance. Manages the host side of the Wasm interface. class WasmBase : public std::enable_shared_from_this { public: WasmBase(std::unique_ptr wasm_vm, std::string_view vm_id, - std::string_view vm_configuration, std::string_view vm_key); - WasmBase(const std::shared_ptr &other, WasmVmFactory factory); + std::string_view vm_configuration, std::string_view vm_key, + std::unordered_map envs, + AllowedCapabilitiesMap allowed_capabilities); + WasmBase(const std::shared_ptr &base_wasm_handle, const WasmVmFactory &factory); virtual ~WasmBase(); - bool initialize(const std::string &code, bool allow_precompiled = false); - void startVm(ContextBase *root_context); - bool configure(ContextBase *root_context, std::shared_ptr plugin); + virtual bool load(const std::string &code, bool allow_precompiled = false); + virtual bool initialize(); + virtual void startVm(ContextBase *root_context); + virtual bool configure(ContextBase *root_context, std::shared_ptr plugin); // Returns the root ContextBase or nullptr if onStart returns false. - ContextBase *start(std::shared_ptr plugin); + virtual ContextBase *start(const std::shared_ptr &plugin); std::string_view vm_id() const { return vm_id_; } std::string_view vm_key() const { return vm_key_; } WasmVm *wasm_vm() const { return wasm_vm_.get(); } - ContextBase *vm_context() const { return vm_context_.get(); } - ContextBase *getRootContext(std::string_view root_id) { - return root_contexts_[std::string(root_id)].get(); - } - ContextBase *getOrCreateRootContext(const std::shared_ptr &plugin); + virtual ContextBase *vm_context() const { return vm_context_.get(); } + virtual ContextBase *getRootContext(const std::shared_ptr &plugin, bool allow_closed); ContextBase *getContext(uint32_t id) { auto it = contexts_.find(id); if (it != contexts_.end()) @@ -73,13 +76,16 @@ class WasmBase : public std::enable_shared_from_this { bool isFailed() { return failed_ != FailState::Ok; } FailState fail_state() { return failed_; } - const std::string &code() const { return code_; } const std::string &vm_configuration() const; - bool allow_precompiled() const { return allow_precompiled_; } + + const std::string &moduleBytecode() const { return module_bytecode_; } + const std::string &modulePrecompiled() const { return module_precompiled_; } + const std::unordered_map functionNames() const { return function_names_; } void timerReady(uint32_t root_context_id); void queueReady(uint32_t root_context_id, uint32_t token); + void startShutdown(std::string_view plugin_key); void startShutdown(); WasmResult done(ContextBase *root_context); void finishShutdown(); @@ -93,6 +99,12 @@ class WasmBase : public std::enable_shared_from_this { return nullptr; } + // Capability restriction (restricting/exposing the ABI). + bool capabilityAllowed(std::string capability_name) { + return allowed_capabilities_.empty() || + allowed_capabilities_.find(capability_name) != allowed_capabilities_.end(); + } + virtual ContextBase *createVmContext() { return new ContextBase(this); } virtual ContextBase *createRootContext(const std::shared_ptr &plugin) { return new ContextBase(this, plugin); @@ -113,8 +125,6 @@ class WasmBase : public std::enable_shared_from_this { bool copyToPointerSize(std::string_view s, uint64_t ptr_ptr, uint64_t size_ptr); template bool setDatatype(uint64_t ptr, const T &t); - WasmForeignFunction getForeignFunction(std::string_view function_name); - void fail(FailState fail_state, std::string_view message) { error(message); failed_ = fail_state; @@ -122,21 +132,15 @@ class WasmBase : public std::enable_shared_from_this { virtual void error(std::string_view message) { std::cerr << message << "\n"; } virtual void unimplemented() { error("unimplemented proxy-wasm API"); } - AbiVersion abiVersion() { return abi_version_; } + AbiVersion abiVersion() const { return abi_version_; } - bool getEmscriptenVersion(uint32_t *emscripten_metadata_major_version, - uint32_t *emscripten_metadata_minor_version, - uint32_t *emscripten_abi_major_version, - uint32_t *emscripten_abi_minor_version) { - if (!is_emscripten_) { - return false; - } - *emscripten_metadata_major_version = emscripten_metadata_major_version_; - *emscripten_metadata_minor_version = emscripten_metadata_minor_version_; - *emscripten_abi_major_version = emscripten_abi_major_version_; - *emscripten_abi_minor_version = emscripten_abi_minor_version_; - return true; - } + const std::unordered_map &envs() { return envs_; } + + // Called to raise the flag which indicates that the context should stop iteration regardless of + // returned filter status from Proxy-Wasm extensions. For example, we ignore + // FilterHeadersStatus::Continue after a local reponse is sent by the host. + void stopNextIteration(bool stop) { stop_iteration_ = stop; }; + bool isNextIterationStopped() { return stop_iteration_; }; void addAfterVmCallAction(std::function f) { after_vm_call_actions_.push_back(f); } void doAfterVmCallActions() { @@ -166,6 +170,35 @@ class WasmBase : public std::enable_shared_from_this { uint32_t nextGaugeMetricId() { return next_gauge_metric_id_ += kMetricIdIncrement; } uint32_t nextHistogramMetricId() { return next_histogram_metric_id_ += kMetricIdIncrement; } + enum class CalloutType : uint32_t { + HttpCall = 0, + GrpcCall = 1, + GrpcStream = 2, + }; + static const uint32_t kCalloutTypeMask = 0x3; // Enough to cover the 3 types. + static const uint32_t kCalloutIncrement = 0x4; // Enough to cover the 3 types. + bool isHttpCallId(uint32_t callout_id) { + return (callout_id & kCalloutTypeMask) == static_cast(CalloutType::HttpCall); + } + bool isGrpcCallId(uint32_t callout_id) { + return (callout_id & kCalloutTypeMask) == static_cast(CalloutType::GrpcCall); + } + bool isGrpcStreamId(uint32_t callout_id) { + return (callout_id & kCalloutTypeMask) == static_cast(CalloutType::GrpcStream); + } + uint32_t nextHttpCallId() { + // TODO(PiotrSikora): re-add rollover protection (requires at least 1 billion callouts). + return next_http_call_id_ += kCalloutIncrement; + } + uint32_t nextGrpcCallId() { + // TODO(PiotrSikora): re-add rollover protection (requires at least 1 billion callouts). + return next_grpc_call_id_ += kCalloutIncrement; + } + uint32_t nextGrpcStreamId() { + // TODO(PiotrSikora): re-add rollover protection (requires at least 1 billion callouts). + return next_grpc_stream_id_ += kCalloutIncrement; + } + protected: friend class ContextBase; class ShutdownHandle; @@ -175,20 +208,24 @@ class WasmBase : public std::enable_shared_from_this { std::string vm_id_; // User-provided vm_id. std::string vm_key_; // vm_id + hash of code. std::unique_ptr wasm_vm_; - Cloneable started_from_{Cloneable::NotCloneable}; + std::optional started_from_; uint32_t next_context_id_ = 1; // 0 is reserved for the VM context. std::shared_ptr vm_context_; // Context unrelated to any specific root or stream // (e.g. for global constructors). - std::unordered_map> root_contexts_; + std::unordered_map> root_contexts_; // Root contexts. + std::unordered_map> pending_done_; // Root contexts. + std::unordered_set> pending_delete_; // Root contexts. std::unordered_map contexts_; // Contains all contexts. std::unordered_map timer_period_; // per root_id. std::unique_ptr shutdown_handle_; - std::unordered_set pending_done_; // Root contexts not done during shutdown. + std::unordered_map + envs_; // environment variables passed through wasi.environ_get - WasmCallVoid<0> _start_; /* Emscripten v1.39.0+ */ - WasmCallVoid<0> __wasm_call_ctors_; + WasmCallVoid<0> _initialize_; /* WASI reactor (Emscripten v1.39.17+, Rust nightly) */ + WasmCallVoid<0> _start_; /* WASI command (Emscripten v1.39.0+, TinyGo) */ + WasmCallWord<2> main_; WasmCallWord<1> malloc_; // Calls into the VM. @@ -232,69 +269,115 @@ class WasmBase : public std::enable_shared_from_this { WasmCallVoid<1> on_log_; WasmCallVoid<1> on_delete_; +#define FOR_ALL_MODULE_FUNCTIONS(_f) \ + _f(validate_configuration) _f(on_vm_start) _f(on_configure) _f(on_tick) _f(on_context_create) \ + _f(on_new_connection) _f(on_downstream_data) _f(on_upstream_data) \ + _f(on_downstream_connection_close) _f(on_upstream_connection_close) _f(on_request_body) \ + _f(on_request_trailers) _f(on_request_metadata) _f(on_response_body) \ + _f(on_response_trailers) _f(on_response_metadata) _f(on_http_call_response) \ + _f(on_grpc_receive) _f(on_grpc_close) _f(on_grpc_receive_initial_metadata) \ + _f(on_grpc_receive_trailing_metadata) _f(on_queue_ready) _f(on_done) \ + _f(on_log) _f(on_delete) + + // Capabilities which are allowed to be linked to the module. If this is empty, restriction + // is not enforced. + AllowedCapabilitiesMap allowed_capabilities_; + std::shared_ptr base_wasm_handle_; // Used by the base_wasm to enable non-clonable thread local Wasm(s) to be constructed. - std::string code_; - std::string vm_configuration_; - bool allow_precompiled_ = false; - FailState failed_ = FailState::Ok; // Wasm VM fatal error. + std::string module_bytecode_; + std::string module_precompiled_; + std::unordered_map function_names_; // ABI version. AbiVersion abi_version_ = AbiVersion::Unknown; - bool is_emscripten_ = false; - uint32_t emscripten_metadata_major_version_ = 0; - uint32_t emscripten_metadata_minor_version_ = 0; - uint32_t emscripten_abi_major_version_ = 0; - uint32_t emscripten_abi_minor_version_ = 0; - uint32_t emscripten_standalone_wasm_ = 0; + std::string vm_configuration_; + bool stop_iteration_ = false; + FailState failed_ = FailState::Ok; // Wasm VM fatal error. // Plugin Stats/Metrics uint32_t next_counter_metric_id_ = static_cast(MetricType::Counter); uint32_t next_gauge_metric_id_ = static_cast(MetricType::Gauge); uint32_t next_histogram_metric_id_ = static_cast(MetricType::Histogram); + // HTTP/gRPC callouts. + uint32_t next_http_call_id_ = static_cast(CalloutType::HttpCall); + uint32_t next_grpc_call_id_ = static_cast(CalloutType::GrpcCall); + uint32_t next_grpc_stream_id_ = static_cast(CalloutType::GrpcStream); + // Actions to be done after the call into the VM returns. std::deque> after_vm_call_actions_; + + std::shared_ptr vm_id_handle_; }; +using WasmHandleFactory = std::function(std::string_view vm_id)>; +using WasmHandleCloneFactory = + std::function(std::shared_ptr wasm)>; + // Handle which enables shutdown operations to run post deletion (e.g. post listener drain). class WasmHandleBase : public std::enable_shared_from_this { public: explicit WasmHandleBase(std::shared_ptr wasm_base) : wasm_base_(wasm_base) {} - ~WasmHandleBase() { + virtual ~WasmHandleBase() { if (wasm_base_) { wasm_base_->startShutdown(); } } + virtual bool canary(const std::shared_ptr &plugin, + const WasmHandleCloneFactory &clone_factory); + void kill() { wasm_base_ = nullptr; } std::shared_ptr &wasm() { return wasm_base_; } protected: std::shared_ptr wasm_base_; + std::unordered_map plugin_canary_cache_; }; std::string makeVmKey(std::string_view vm_id, std::string_view configuration, std::string_view code); -using WasmHandleFactory = std::function(std::string_view vm_id)>; -using WasmHandleCloneFactory = - std::function(std::shared_ptr wasm)>; - // Returns nullptr on failure (i.e. initialization of the VM fails). -std::shared_ptr -createWasm(std::string vm_key, std::string code, std::shared_ptr plugin, - WasmHandleFactory factory, WasmHandleCloneFactory clone_factory, bool allow_precompiled); -// Get an existing ThreadLocal VM matching 'vm_id' or nullptr if there isn't one. -std::shared_ptr getThreadLocalWasm(std::string_view vm_id); -// Get an existing ThreadLocal VM matching 'vm_id' or create one using 'base_wavm' by cloning or by +std::shared_ptr createWasm(const std::string &vm_key, const std::string &code, + const std::shared_ptr &plugin, + const WasmHandleFactory &factory, + const WasmHandleCloneFactory &clone_factory, + bool allow_precompiled); +// Get an existing ThreadLocal VM matching 'vm_key' or nullptr if there isn't one. +std::shared_ptr getThreadLocalWasm(std::string_view vm_key); + +class PluginHandleBase : public std::enable_shared_from_this { +public: + explicit PluginHandleBase(std::shared_ptr wasm_handle, + std::shared_ptr plugin) + : plugin_(plugin), wasm_handle_(wasm_handle) {} + virtual ~PluginHandleBase() { + if (wasm_handle_) { + wasm_handle_->wasm()->startShutdown(plugin_->key()); + } + } + + std::shared_ptr &plugin() { return plugin_; } + std::shared_ptr &wasm() { return wasm_handle_->wasm(); } + +protected: + std::shared_ptr plugin_; + std::shared_ptr wasm_handle_; +}; + +using PluginHandleFactory = std::function( + std::shared_ptr base_wasm, std::shared_ptr plugin)>; + +// Get an existing ThreadLocal VM matching 'vm_id' or create one using 'base_wasm' by cloning or by // using it it as a template. -std::shared_ptr -getOrCreateThreadLocalWasm(std::shared_ptr base_wasm, - std::shared_ptr plugin, WasmHandleCloneFactory factory); +std::shared_ptr getOrCreateThreadLocalPlugin( + const std::shared_ptr &base_handle, const std::shared_ptr &plugin, + const WasmHandleCloneFactory &clone_factory, const PluginHandleFactory &plugin_factory); // Clear Base Wasm cache and the thread-local Wasm sandbox cache for the calling thread. void clearWasmCachesForTesting(); @@ -309,7 +392,15 @@ inline void *WasmBase::allocMemory(uint64_t size, uint64_t *address) { if (!malloc_) { return nullptr; } + wasm_vm_->setRestrictedCallback( + true, {// logging (Proxy-Wasm) + "env.proxy_log", + // logging (stdout/stderr) + "wasi_unstable.fd_write", "wasi_snapshot_preview1.fd_write", + // time + "wasi_unstable.clock_time_get", "wasi_snapshot_preview1.clock_time_get"}); Word a = malloc_(vm_context(), size); + wasm_vm_->setRestrictedCallback(false); if (!a.u64_) { return nullptr; } @@ -325,7 +416,7 @@ inline uint64_t WasmBase::copyString(std::string_view s) { if (s.empty()) { return 0; // nullptr } - uint64_t pointer; + uint64_t pointer = 0; uint8_t *m = static_cast(allocMemory((s.size() + 1), &pointer)); memcpy(m, s.data(), s.size()); m[s.size()] = 0; @@ -356,8 +447,4 @@ template inline bool WasmBase::setDatatype(uint64_t ptr, const T &t return wasm_vm_->setMemory(ptr, sizeof(T), &t); } -struct RegisterForeignFunction { - RegisterForeignFunction(std::string name, WasmForeignFunction f); -}; - } // namespace proxy_wasm diff --git a/include/proxy-wasm/wasm_api_impl.h b/include/proxy-wasm/wasm_api_impl.h index 78518a7d6..899af7e41 100644 --- a/include/proxy-wasm/wasm_api_impl.h +++ b/include/proxy-wasm/wasm_api_impl.h @@ -15,6 +15,25 @@ #pragma once +// Required by "proxy_wasm_api.h" included within null_plugin namespace. + +#ifdef PROXY_WASM_PROTOBUF +#include "google/protobuf/message_lite.h" +#endif + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "include/proxy-wasm/sdk.h" +#include "include/proxy-wasm/exports.h" +#include "include/proxy-wasm/word.h" + namespace proxy_wasm { namespace null_plugin { @@ -27,55 +46,51 @@ inline WasmResult wordToWasmResult(Word w) { return static_cast(w.u6 inline WasmResult proxy_get_configuration(const char **configuration_ptr, size_t *configuration_size) { return wordToWasmResult( - exports::get_configuration(current_context_, WR(configuration_ptr), WR(configuration_size))); + exports::get_configuration(WR(configuration_ptr), WR(configuration_size))); } inline WasmResult proxy_get_status(uint32_t *code_ptr, const char **ptr, size_t *size) { - return wordToWasmResult(exports::get_status(current_context_, WR(code_ptr), WR(ptr), WR(size))); + return wordToWasmResult(exports::get_status(WR(code_ptr), WR(ptr), WR(size))); } // Logging inline WasmResult proxy_log(LogLevel level, const char *logMessage, size_t messageSize) { - return wordToWasmResult( - exports::log(current_context_, WS(level), WR(logMessage), WS(messageSize))); + return wordToWasmResult(exports::log(WS(level), WR(logMessage), WS(messageSize))); } inline WasmResult proxy_get_log_level(LogLevel *level) { - return wordToWasmResult(exports::get_log_level(current_context_, WR(level))); + return wordToWasmResult(exports::get_log_level(WR(level))); } // Timer inline WasmResult proxy_set_tick_period_milliseconds(uint64_t millisecond) { - return wordToWasmResult( - exports::set_tick_period_milliseconds(current_context_, Word(millisecond))); + return wordToWasmResult(exports::set_tick_period_milliseconds(Word(millisecond))); } inline WasmResult proxy_get_current_time_nanoseconds(uint64_t *result) { - return wordToWasmResult(exports::get_current_time_nanoseconds(current_context_, WR(result))); + return wordToWasmResult(exports::get_current_time_nanoseconds(WR(result))); } // State accessors inline WasmResult proxy_get_property(const char *path_ptr, size_t path_size, const char **value_ptr_ptr, size_t *value_size_ptr) { - return wordToWasmResult(exports::get_property(current_context_, WR(path_ptr), WS(path_size), - WR(value_ptr_ptr), WR(value_size_ptr))); + return wordToWasmResult( + exports::get_property(WR(path_ptr), WS(path_size), WR(value_ptr_ptr), WR(value_size_ptr))); } inline WasmResult proxy_set_property(const char *key_ptr, size_t key_size, const char *value_ptr, size_t value_size) { - return wordToWasmResult(exports::set_property(current_context_, WR(key_ptr), WS(key_size), - WR(value_ptr), WS(value_size))); + return wordToWasmResult( + exports::set_property(WR(key_ptr), WS(key_size), WR(value_ptr), WS(value_size))); } // Continue -inline WasmResult proxy_continue_request() { - return wordToWasmResult(exports::continue_request(current_context_)); -} +inline WasmResult proxy_continue_request() { return wordToWasmResult(exports::continue_request()); } inline WasmResult proxy_continue_response() { - return wordToWasmResult(exports::continue_response(current_context_)); + return wordToWasmResult(exports::continue_response()); } inline WasmResult proxy_continue_stream(WasmStreamType stream_type) { - return wordToWasmResult(exports::continue_stream(current_context_, WS(stream_type))); + return wordToWasmResult(exports::continue_stream(WS(stream_type))); } inline WasmResult proxy_close_stream(WasmStreamType stream_type) { - return wordToWasmResult(exports::close_stream(current_context_, WS(stream_type))); + return wordToWasmResult(exports::close_stream(WS(stream_type))); } inline WasmResult proxy_send_local_response(uint32_t response_code, const char *response_code_details_ptr, @@ -83,28 +98,27 @@ proxy_send_local_response(uint32_t response_code, const char *response_code_deta const char *additional_response_header_pairs_ptr, size_t additional_response_header_pairs_size, uint32_t grpc_status) { return wordToWasmResult(exports::send_local_response( - current_context_, WS(response_code), WR(response_code_details_ptr), - WS(response_code_details_size), WR(body_ptr), WS(body_size), - WR(additional_response_header_pairs_ptr), WS(additional_response_header_pairs_size), - WS(grpc_status))); + WS(response_code), WR(response_code_details_ptr), WS(response_code_details_size), + WR(body_ptr), WS(body_size), WR(additional_response_header_pairs_ptr), + WS(additional_response_header_pairs_size), WS(grpc_status))); } inline WasmResult proxy_clear_route_cache() { - return wordToWasmResult(exports::clear_route_cache(current_context_)); + return wordToWasmResult(exports::clear_route_cache()); } // SharedData inline WasmResult proxy_get_shared_data(const char *key_ptr, size_t key_size, const char **value_ptr, size_t *value_size, uint32_t *cas) { - return wordToWasmResult(exports::get_shared_data(current_context_, WR(key_ptr), WS(key_size), - WR(value_ptr), WR(value_size), WR(cas))); + return wordToWasmResult( + exports::get_shared_data(WR(key_ptr), WS(key_size), WR(value_ptr), WR(value_size), WR(cas))); } // If cas != 0 and cas != the current cas for 'key' return false, otherwise set the value and // return true. inline WasmResult proxy_set_shared_data(const char *key_ptr, size_t key_size, const char *value_ptr, size_t value_size, uint64_t cas) { - return wordToWasmResult(exports::set_shared_data(current_context_, WR(key_ptr), WS(key_size), - WR(value_ptr), WS(value_size), WS(cas))); + return wordToWasmResult( + exports::set_shared_data(WR(key_ptr), WS(key_size), WR(value_ptr), WS(value_size), WS(cas))); } // SharedQueue @@ -113,84 +127,77 @@ inline WasmResult proxy_set_shared_data(const char *key_ptr, size_t key_size, co // proxy_dequeue_shared_queue. Returns unique token for the queue. inline WasmResult proxy_register_shared_queue(const char *queue_name_ptr, size_t queue_name_size, uint32_t *token) { - return wordToWasmResult(exports::register_shared_queue(current_context_, WR(queue_name_ptr), - WS(queue_name_size), WR(token))); + return wordToWasmResult( + exports::register_shared_queue(WR(queue_name_ptr), WS(queue_name_size), WR(token))); } // Returns unique token for the queue. inline WasmResult proxy_resolve_shared_queue(const char *vm_id_ptr, size_t vm_id_size, const char *queue_name_ptr, size_t queue_name_size, uint32_t *token) { - return wordToWasmResult(exports::resolve_shared_queue(current_context_, WR(vm_id_ptr), - WS(vm_id_size), WR(queue_name_ptr), - WS(queue_name_size), WR(token))); + return wordToWasmResult(exports::resolve_shared_queue( + WR(vm_id_ptr), WS(vm_id_size), WR(queue_name_ptr), WS(queue_name_size), WR(token))); } // Returns true on end-of-stream (no more data available). inline WasmResult proxy_dequeue_shared_queue(uint32_t token, const char **data_ptr, size_t *data_size) { - return wordToWasmResult( - exports::dequeue_shared_queue(current_context_, WS(token), WR(data_ptr), WR(data_size))); + return wordToWasmResult(exports::dequeue_shared_queue(WS(token), WR(data_ptr), WR(data_size))); } // Returns false if the queue was not found and the data was not enqueued. inline WasmResult proxy_enqueue_shared_queue(uint32_t token, const char *data_ptr, size_t data_size) { - return wordToWasmResult( - exports::enqueue_shared_queue(current_context_, WS(token), WR(data_ptr), WS(data_size))); + return wordToWasmResult(exports::enqueue_shared_queue(WS(token), WR(data_ptr), WS(data_size))); } // Buffer inline WasmResult proxy_get_buffer_bytes(WasmBufferType type, uint64_t start, uint64_t length, const char **ptr, size_t *size) { - return wordToWasmResult(exports::get_buffer_bytes(current_context_, WS(type), WS(start), - WS(length), WR(ptr), WR(size))); + return wordToWasmResult( + exports::get_buffer_bytes(WS(type), WS(start), WS(length), WR(ptr), WR(size))); } inline WasmResult proxy_get_buffer_status(WasmBufferType type, size_t *length_ptr, uint32_t *flags_ptr) { - return wordToWasmResult( - exports::get_buffer_status(current_context_, WS(type), WR(length_ptr), WR(flags_ptr))); + return wordToWasmResult(exports::get_buffer_status(WS(type), WR(length_ptr), WR(flags_ptr))); } inline WasmResult proxy_set_buffer_bytes(WasmBufferType type, uint64_t start, uint64_t length, const char *data, size_t size) { - return wordToWasmResult(exports::set_buffer_bytes(current_context_, WS(type), WS(start), - WS(length), WR(data), WS(size))); + return wordToWasmResult( + exports::set_buffer_bytes(WS(type), WS(start), WS(length), WR(data), WS(size))); } // Headers/Trailers/Metadata Maps inline WasmResult proxy_add_header_map_value(WasmHeaderMapType type, const char *key_ptr, size_t key_size, const char *value_ptr, size_t value_size) { - return wordToWasmResult(exports::add_header_map_value( - current_context_, WS(type), WR(key_ptr), WS(key_size), WR(value_ptr), WS(value_size))); + return wordToWasmResult(exports::add_header_map_value(WS(type), WR(key_ptr), WS(key_size), + WR(value_ptr), WS(value_size))); } inline WasmResult proxy_get_header_map_value(WasmHeaderMapType type, const char *key_ptr, size_t key_size, const char **value_ptr, size_t *value_size) { - return wordToWasmResult(exports::get_header_map_value( - current_context_, WS(type), WR(key_ptr), WS(key_size), WR(value_ptr), WR(value_size))); + return wordToWasmResult(exports::get_header_map_value(WS(type), WR(key_ptr), WS(key_size), + WR(value_ptr), WR(value_size))); } inline WasmResult proxy_get_header_map_pairs(WasmHeaderMapType type, const char **ptr, size_t *size) { - return wordToWasmResult( - exports::get_header_map_pairs(current_context_, WS(type), WR(ptr), WR(size))); + return wordToWasmResult(exports::get_header_map_pairs(WS(type), WR(ptr), WR(size))); } inline WasmResult proxy_set_header_map_pairs(WasmHeaderMapType type, const char *ptr, size_t size) { - return wordToWasmResult( - exports::set_header_map_pairs(current_context_, WS(type), WR(ptr), WS(size))); + return wordToWasmResult(exports::set_header_map_pairs(WS(type), WR(ptr), WS(size))); } inline WasmResult proxy_replace_header_map_value(WasmHeaderMapType type, const char *key_ptr, size_t key_size, const char *value_ptr, size_t value_size) { - return wordToWasmResult(exports::replace_header_map_value( - current_context_, WS(type), WR(key_ptr), WS(key_size), WR(value_ptr), WS(value_size))); + return wordToWasmResult(exports::replace_header_map_value(WS(type), WR(key_ptr), WS(key_size), + WR(value_ptr), WS(value_size))); } inline WasmResult proxy_remove_header_map_value(WasmHeaderMapType type, const char *key_ptr, size_t key_size) { - return wordToWasmResult( - exports::remove_header_map_value(current_context_, WS(type), WR(key_ptr), WS(key_size))); + return wordToWasmResult(exports::remove_header_map_value(WS(type), WR(key_ptr), WS(key_size))); } inline WasmResult proxy_get_header_map_size(WasmHeaderMapType type, size_t *size) { - return wordToWasmResult(exports::get_header_map_size(current_context_, WS(type), WR(size))); + return wordToWasmResult(exports::get_header_map_size(WS(type), WR(size))); } // HTTP @@ -199,10 +206,10 @@ inline WasmResult proxy_http_call(const char *uri_ptr, size_t uri_size, void *he size_t header_pairs_size, const char *body_ptr, size_t body_size, void *trailer_pairs_ptr, size_t trailer_pairs_size, uint64_t timeout_milliseconds, uint32_t *token_ptr) { - return wordToWasmResult( - exports::http_call(current_context_, WR(uri_ptr), WS(uri_size), WR(header_pairs_ptr), - WS(header_pairs_size), WR(body_ptr), WS(body_size), WR(trailer_pairs_ptr), - WS(trailer_pairs_size), WS(timeout_milliseconds), WR(token_ptr))); + return wordToWasmResult(exports::http_call(WR(uri_ptr), WS(uri_size), WR(header_pairs_ptr), + WS(header_pairs_size), WR(body_ptr), WS(body_size), + WR(trailer_pairs_ptr), WS(trailer_pairs_size), + WS(timeout_milliseconds), WR(token_ptr))); } // gRPC // Returns token, used in gRPC callbacks (onGrpc...) @@ -213,7 +220,7 @@ inline WasmResult proxy_grpc_call(const char *service_ptr, size_t service_size, const char *request_ptr, size_t request_size, uint64_t timeout_milliseconds, uint32_t *token_ptr) { return wordToWasmResult( - exports::grpc_call(current_context_, WR(service_ptr), WS(service_size), WR(service_name_ptr), + exports::grpc_call(WR(service_ptr), WS(service_size), WR(service_name_ptr), WS(service_name_size), WR(method_name_ptr), WS(method_name_size), WR(initial_metadata_ptr), WS(initial_metadata_size), WR(request_ptr), WS(request_size), WS(timeout_milliseconds), WR(token_ptr))); @@ -223,52 +230,52 @@ inline WasmResult proxy_grpc_stream(const char *service_ptr, size_t service_size const char *method_name_ptr, size_t method_name_size, void *initial_metadata_ptr, size_t initial_metadata_size, uint32_t *token_ptr) { - return wordToWasmResult(exports::grpc_stream( - current_context_, WR(service_ptr), WS(service_size), WR(service_name_ptr), - WS(service_name_size), WR(method_name_ptr), WS(method_name_size), WR(initial_metadata_ptr), - WS(initial_metadata_size), WR(token_ptr))); + return wordToWasmResult( + exports::grpc_stream(WR(service_ptr), WS(service_size), WR(service_name_ptr), + WS(service_name_size), WR(method_name_ptr), WS(method_name_size), + WR(initial_metadata_ptr), WS(initial_metadata_size), WR(token_ptr))); } inline WasmResult proxy_grpc_cancel(uint64_t token) { - return wordToWasmResult(exports::grpc_cancel(current_context_, WS(token))); + return wordToWasmResult(exports::grpc_cancel(WS(token))); } inline WasmResult proxy_grpc_close(uint64_t token) { - return wordToWasmResult(exports::grpc_close(current_context_, WS(token))); + return wordToWasmResult(exports::grpc_close(WS(token))); } inline WasmResult proxy_grpc_send(uint64_t token, const char *message_ptr, size_t message_size, uint64_t end_stream) { - return wordToWasmResult(exports::grpc_send(current_context_, WS(token), WR(message_ptr), - WS(message_size), WS(end_stream))); + return wordToWasmResult( + exports::grpc_send(WS(token), WR(message_ptr), WS(message_size), WS(end_stream))); } // Metrics // Returns a metric_id which can be used to report a metric. On error returns 0. inline WasmResult proxy_define_metric(MetricType type, const char *name_ptr, size_t name_size, uint32_t *metric_id) { - return wordToWasmResult(exports::define_metric(current_context_, WS(type), WR(name_ptr), - WS(name_size), WR(metric_id))); + return wordToWasmResult( + exports::define_metric(WS(type), WR(name_ptr), WS(name_size), WR(metric_id))); } inline WasmResult proxy_increment_metric(uint32_t metric_id, int64_t offset) { - return wordToWasmResult(exports::increment_metric(current_context_, WS(metric_id), offset)); + return wordToWasmResult(exports::increment_metric(WS(metric_id), offset)); } inline WasmResult proxy_record_metric(uint32_t metric_id, uint64_t value) { - return wordToWasmResult(exports::record_metric(current_context_, WS(metric_id), value)); + return wordToWasmResult(exports::record_metric(WS(metric_id), value)); } inline WasmResult proxy_get_metric(uint32_t metric_id, uint64_t *value) { - return wordToWasmResult(exports::get_metric(current_context_, WS(metric_id), WR(value))); + return wordToWasmResult(exports::get_metric(WS(metric_id), WR(value))); } // System inline WasmResult proxy_set_effective_context(uint64_t context_id) { - return wordToWasmResult(exports::set_effective_context(current_context_, WS(context_id))); + return wordToWasmResult(exports::set_effective_context(WS(context_id))); } -inline WasmResult proxy_done() { return wordToWasmResult(exports::done(current_context_)); } +inline WasmResult proxy_done() { return wordToWasmResult(exports::done()); } inline WasmResult proxy_call_foreign_function(const char *function_name, size_t function_name_size, const char *arguments, size_t arguments_size, char **results, size_t *results_size) { - return wordToWasmResult(exports::call_foreign_function( - current_context_, WR(function_name), WS(function_name_size), WR(arguments), - WS(arguments_size), WR(results), WR(results_size))); + return wordToWasmResult(exports::call_foreign_function(WR(function_name), WS(function_name_size), + WR(arguments), WS(arguments_size), + WR(results), WR(results_size))); } #undef WS diff --git a/include/proxy-wasm/wasm_vm.h b/include/proxy-wasm/wasm_vm.h index 45119a0d9..9a2f0a6a0 100644 --- a/include/proxy-wasm/wasm_vm.h +++ b/include/proxy-wasm/wasm_vm.h @@ -19,46 +19,54 @@ #include #include #include +#include +#include +#include +#include +#include "include/proxy-wasm/sdk.h" #include "include/proxy-wasm/word.h" namespace proxy_wasm { -#include "proxy_wasm_enums.h" - class ContextBase; -// These are templates and its helper for constructing signatures of functions calling into and out -// of WASM VMs. -// - WasmFuncTypeHelper is a helper for WasmFuncType and shouldn't be used anywhere else than +// These are templates and its helper for constructing signatures of functions calling into Wasm +// VMs. +// - WasmCallInFuncTypeHelper is a helper for WasmFuncType and shouldn't be used anywhere else than // WasmFuncType definition. -// - WasmFuncType takes 4 template parameter which are number of argument, return type, context type -// and param type respectively, resolve to a function type. +// - WasmCallInFuncType takes 4 template parameter which are number of argument, return type, +// context type and param type respectively, resolve to a function type. // For example `WasmFuncType<3, void, Context*, Word>` resolves to `void(Context*, Word, Word, // Word)` template -struct WasmFuncTypeHelper {}; +struct WasmCallInFuncTypeHelper {}; template -struct WasmFuncTypeHelper { +struct WasmCallInFuncTypeHelper { // NOLINTNEXTLINE(readability-identifier-naming) - using type = typename WasmFuncTypeHelper::type; + using type = typename WasmCallInFuncTypeHelper::type; }; template -struct WasmFuncTypeHelper<0, ReturnType, ContextType, ParamType, ReturnType(ContextType, Args...)> { +struct WasmCallInFuncTypeHelper<0, ReturnType, ContextType, ParamType, + ReturnType(ContextType, Args...)> { using type = ReturnType(ContextType, Args...); // NOLINT(readability-identifier-naming) }; template -using WasmFuncType = typename WasmFuncTypeHelper::type; +using WasmCallInFuncType = + typename WasmCallInFuncTypeHelper::type; // Calls into the WASM VM. // 1st arg is always a pointer to Context (Context*). -template using WasmCallVoid = std::function>; -template using WasmCallWord = std::function>; +template +using WasmCallVoid = std::function>; +template +using WasmCallWord = std::function>; #define FOR_ALL_WASM_VM_EXPORTS(_f) \ _f(proxy_wasm::WasmCallVoid<0>) _f(proxy_wasm::WasmCallVoid<1>) _f(proxy_wasm::WasmCallVoid<2>) \ @@ -66,20 +74,46 @@ template using WasmCallWord = std::function) _f(proxy_wasm::WasmCallWord<2>) \ _f(proxy_wasm::WasmCallWord<3>) +// These are templates and its helper for constructing signatures of functions callbacks from Wasm +// VMs. +// - WasmCallbackFuncTypeHelper is a helper for WasmFuncType and shouldn't be used anywhere else +// than WasmFuncType definition. +// - WasmCallbackFuncType takes 3 template parameter which are number of argument, return type, and +// param type respectively, resolve to a function type. +// For example `WasmFuncType<3, Word>` resolves to `void(Word, Word, Word)` +template +struct WasmCallbackFuncTypeHelper {}; + +template +struct WasmCallbackFuncTypeHelper { + // NOLINTNEXTLINE(readability-identifier-naming) + using type = typename WasmCallbackFuncTypeHelper::type; +}; + +template +struct WasmCallbackFuncTypeHelper<0, ReturnType, ParamType, ReturnType(Args...)> { + using type = ReturnType(Args...); // NOLINT(readability-identifier-naming) +}; + +template +using WasmCallbackFuncType = typename WasmCallbackFuncTypeHelper::type; + // Calls out of the WASM VM. -// 1st arg is always a pointer to raw_context (void*). -template using WasmCallbackVoid = WasmFuncType *; -template using WasmCallbackWord = WasmFuncType *; +template using WasmCallbackVoid = WasmCallbackFuncType *; +template using WasmCallbackWord = WasmCallbackFuncType *; // Using the standard g++/clang mangling algorithm: // https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling-builtin // Extended with W = Word // Z = void, j = uint32_t, l = int64_t, m = uint64_t -using WasmCallback_WWl = Word (*)(void *, Word, int64_t); -using WasmCallback_WWlWW = Word (*)(void *, Word, int64_t, Word, Word); -using WasmCallback_WWm = Word (*)(void *, Word, uint64_t); -using WasmCallback_WWmW = Word (*)(void *, Word, uint64_t, Word); -using WasmCallback_dd = double (*)(void *, double); +using WasmCallback_WWl = Word (*)(Word, int64_t); +using WasmCallback_WWlWW = Word (*)(Word, int64_t, Word, Word); +using WasmCallback_WWm = Word (*)(Word, uint64_t); +using WasmCallback_WWmW = Word (*)(Word, uint64_t, Word); +using WasmCallback_WWWWWWllWW = Word (*)(Word, Word, Word, Word, Word, int64_t, int64_t, Word, + Word); +using WasmCallback_dd = double (*)(double); #define FOR_ALL_WASM_VM_IMPORTS(_f) \ _f(proxy_wasm::WasmCallbackVoid<0>) _f(proxy_wasm::WasmCallbackVoid<1>) \ @@ -96,7 +130,8 @@ using WasmCallback_dd = double (*)(void *, double); _f(proxy_wasm::WasmCallback_WWlWW) \ _f(proxy_wasm::WasmCallback_WWm) \ _f(proxy_wasm::WasmCallback_WWmW) \ - _f(proxy_wasm::WasmCallback_dd) + _f(proxy_wasm::WasmCallback_WWWWWWllWW) \ + _f(proxy_wasm::WasmCallback_dd) enum class Cloneable { NotCloneable, // VMs can not be cloned and should be created from scratch. @@ -108,11 +143,26 @@ enum class AbiVersion { ProxyWasm_0_1_0, ProxyWasm_0_2_0, ProxyWasm_0_2_1, Unkno class NullPlugin; +enum class FailState : int { + Ok = 0, + UnableToCreateVm = 1, + UnableToCloneVm = 2, + MissingFunction = 3, + UnableToInitializeCode = 4, + StartFailed = 5, + ConfigureFailed = 6, + RuntimeError = 7, +}; + // Integrator specific WasmVm operations. struct WasmVmIntegration { virtual ~WasmVmIntegration() {} virtual WasmVmIntegration *clone() = 0; + virtual proxy_wasm::LogLevel getLogLevel() = 0; virtual void error(std::string_view message) = 0; + // Allow integrations to handle specific FailStates differently. + virtual void error(FailState fail_state, std::string_view message) { error(message); } + virtual void trace(std::string_view message) = 0; // Get a NullVm implementation of a function. // @param function_name is the name of the function with the implementation specific prefix. // @param returns_word is true if the function returns a Word and false if it returns void. @@ -128,34 +178,22 @@ struct WasmVmIntegration { void *ptr_to_function_return) = 0; }; -enum class FailState : int { - Ok = 0, - UnableToCreateVM = 1, - UnableToCloneVM = 2, - MissingFunction = 3, - UnableToInitializeCode = 4, - StartFailed = 5, - ConfigureFailed = 6, - RuntimeError = 7, -}; - // Wasm VM instance. Provides the low level WASM interface. class WasmVm { public: virtual ~WasmVm() = default; /** - * Return the runtime identifier. - * @return one of WasmRuntimeValues from well_known_names.h (e.g. "v8"). + * Identify the Wasm engine. + * @return the name of the underlying Wasm engine. */ - virtual std::string_view runtime() = 0; + virtual std::string_view getEngineName() = 0; /** * Whether or not the VM implementation supports cloning. Cloning is VM system dependent. * When a VM is configured a single VM is instantiated to check that the .wasm file is valid and - * to do VM system specific initialization. In the case of WAVM this is potentially ahead-of-time - * compilation. Then, if cloning is supported, we clone that VM for each worker, potentially - * copying and sharing the initialized data structures for efficiency. Otherwise we create an new - * VM from scratch for each worker. + * to do VM system specific initialization. Then, if cloning is supported, we clone that VM for + * each worker, potentially copying and sharing the initialized data structures for efficiency. + * Otherwise we create an new VM from scratch for each worker. * @return one of enum Cloneable with the VMs cloneability. */ virtual Cloneable cloneable() = 0; @@ -172,14 +210,13 @@ class WasmVm { * Load the WASM code from a file. Return true on success. Once the module is loaded it can be * queried, e.g. to see which version of emscripten support is required. After loading, the * appropriate ABI callbacks can be registered and then the module can be link()ed (see below). - * @param code the WASM binary code (or registered NullVm plugin name). - * @param allow_precompiled if true, allows supporting VMs (e.g. WAVM) to load the binary - * machine code from a user-defined section of the WASM file. Because that code is not verified by - * the proxy process it is up to the user to ensure that the code is both safe and is built for - * the linked in version of WAVM. + * @param bytecode the Wasm bytecode or registered NullVm plugin name. + * @param precompiled (optional) the precompiled Wasm module. + * @param function_names (optional) an index-to-name mapping for the functions. * @return whether or not the load was successful. */ - virtual bool load(const std::string &code, bool allow_precompiled) = 0; + virtual bool load(std::string_view bytecode, std::string_view precompiled, + const std::unordered_map &function_names) = 0; /** * Link the WASM code to the host-provided functions, e.g. the ABI. Prior to linking, the module @@ -190,12 +227,6 @@ class WasmVm { */ virtual bool link(std::string_view debug_name) = 0; - /** - * Get ABI version of the module. - * @return the ABI version. - */ - virtual AbiVersion getAbiVersion() = 0; - /** * Get size of the currently allocated memory in the VM. * @return the size of memory in bytes. @@ -242,12 +273,9 @@ class WasmVm { virtual bool setWord(uint64_t pointer, Word data) = 0; /** - * Get the contents of the custom section with the given name or "" if it does not exist. - * @param name the name of the custom section to get. - * @return the contents of the custom section (if any). The result will be empty if there - * is no such section. + * @return the Word size in this VM. */ - virtual std::string_view getCustomSection(std::string_view name) = 0; + virtual size_t getWordSize() = 0; /** * Get the name of the custom section that contains precompiled module. @@ -271,26 +299,53 @@ class WasmVm { FOR_ALL_WASM_VM_IMPORTS(_REGISTER_CALLBACK) #undef _REGISTER_CALLBACK + /** + * Terminate execution of this WasmVM. It shouldn't be used after being terminated. + */ + virtual void terminate() = 0; + + /** + * Byte order flag (host or wasm). + * @return 'false' for a null VM and 'true' for a wasm VM. + */ + virtual bool usesWasmByteOrder() = 0; + + virtual void warm() {} + bool isFailed() { return failed_ != FailState::Ok; } void fail(FailState fail_state, std::string_view message) { - error(message); + integration()->error(fail_state, message); failed_ = fail_state; - if (fail_callback_) { - fail_callback_(fail_state); + for (auto &callback : fail_callbacks_) { + callback(fail_state); } } - void setFailCallback(std::function fail_callback) { - fail_callback_ = fail_callback; + void addFailCallback(std::function fail_callback) { + fail_callbacks_.push_back(fail_callback); + } + + bool isHostFunctionAllowed(const std::string &name) { + return !restricted_callback_ || allowed_hostcalls_.find(name) != allowed_hostcalls_.end(); + } + + void setRestrictedCallback(bool restricted, + std::unordered_set allowed_hostcalls = {}) { + restricted_callback_ = restricted; + allowed_hostcalls_ = std::move(allowed_hostcalls); } // Integrator operations. std::unique_ptr &integration() { return integration_; } - void error(std::string_view message) { integration()->error(message); } + bool cmpLogLevel(proxy_wasm::LogLevel level) { return integration_->getLogLevel() <= level; } protected: std::unique_ptr integration_; FailState failed_ = FailState::Ok; - std::function fail_callback_; + std::vector> fail_callbacks_; + +private: + bool restricted_callback_{false}; + std::unordered_set allowed_hostcalls_{}; }; // Thread local state set during a call into a WASM VM so that calls coming out of the diff --git a/include/proxy-wasm/wasmedge.h b/include/proxy-wasm/wasmedge.h new file mode 100644 index 000000000..f0b2141ce --- /dev/null +++ b/include/proxy-wasm/wasmedge.h @@ -0,0 +1,26 @@ +// Copyright 2016-2019 Envoy Project Authors +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include + +#include "include/proxy-wasm/wasm_vm.h" + +namespace proxy_wasm { + +std::unique_ptr createWasmEdgeVm(); + +} // namespace proxy_wasm diff --git a/include/proxy-wasm/wasmtime.h b/include/proxy-wasm/wasmtime.h new file mode 100644 index 000000000..e3fe4b48c --- /dev/null +++ b/include/proxy-wasm/wasmtime.h @@ -0,0 +1,23 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include "include/proxy-wasm/wasm_vm.h" + +namespace proxy_wasm { + +std::unique_ptr createWasmtimeVm(); + +} // namespace proxy_wasm diff --git a/include/proxy-wasm/word.h b/include/proxy-wasm/word.h index e96fdfb94..bc0d23a8c 100644 --- a/include/proxy-wasm/word.h +++ b/include/proxy-wasm/word.h @@ -17,9 +17,19 @@ #include +#include "include/proxy-wasm/sdk.h" + namespace proxy_wasm { -#include "proxy_wasm_common.h" +// Use byteswap functions only when compiling for big-endian platforms. +#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \ + __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ +#define htowasm(x, vm_uses_wasm_byte_order) ((vm_uses_wasm_byte_order) ? __builtin_bswap32(x) : (x)) +#define wasmtoh(x, vm_uses_wasm_byte_order) ((vm_uses_wasm_byte_order) ? __builtin_bswap32(x) : (x)) +#else +#define htowasm(x, vm_uses_wasm_byte_order) (x) +#define wasmtoh(x, vm_uses_wasm_byte_order) (x) +#endif // Represents a Wasm-native word-sized datum. On 32-bit VMs, the high bits are always zero. // The Wasm/VM API treats all bits as significant. diff --git a/src/bytecode_util.cc b/src/bytecode_util.cc new file mode 100644 index 000000000..70a373e01 --- /dev/null +++ b/src/bytecode_util.cc @@ -0,0 +1,277 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "include/proxy-wasm/bytecode_util.h" + +#if !defined(_MSC_VER) +#include +#endif + +#include + +namespace proxy_wasm { + +bool BytecodeUtil::checkWasmHeader(std::string_view bytecode) { + // Wasm file header is 8 bytes (magic number + version). + static const uint8_t wasm_magic_number[4] = {0x00, 0x61, 0x73, 0x6d}; + return (bytecode.size() < 8 || ::memcmp(bytecode.data(), wasm_magic_number, 4) == 0); +} + +bool BytecodeUtil::getAbiVersion(std::string_view bytecode, proxy_wasm::AbiVersion &ret) { + ret = proxy_wasm::AbiVersion::Unknown; + // Check Wasm header. + if (!checkWasmHeader(bytecode)) { + return false; + } + + // Skip the Wasm header. + const char *pos = bytecode.data() + 8; + const char *end = bytecode.data() + bytecode.size(); + while (pos < end) { + if (pos + 1 > end) { + return false; + } + const auto section_type = *pos++; + uint32_t section_len = 0; + if (!parseVarint(pos, end, section_len) || pos + section_len > end) { + return false; + } + if (section_type == 7 /* export section */) { + const char *section_end = pos + section_len; + uint32_t export_vector_size = 0; + if (!parseVarint(pos, section_end, export_vector_size) || + pos + export_vector_size > section_end) { + return false; + } + // Search thourgh exports. + for (uint32_t i = 0; i < export_vector_size; i++) { + // Parse name of the export. + uint32_t export_name_size = 0; + if (!parseVarint(pos, section_end, export_name_size) || + pos + export_name_size > section_end) { + return false; + } + const auto *const name_begin = pos; + pos += export_name_size; + if (pos + 1 > end) { + return false; + } + // Check if it is a function type export + if (*pos++ == 0x00 /* function */) { + const std::string export_name = {name_begin, export_name_size}; + // Check the name of the function. + if (export_name == "proxy_abi_version_0_1_0") { + ret = AbiVersion::ProxyWasm_0_1_0; + return true; + } + if (export_name == "proxy_abi_version_0_2_0") { + ret = AbiVersion::ProxyWasm_0_2_0; + return true; + } + if (export_name == "proxy_abi_version_0_2_1") { + ret = AbiVersion::ProxyWasm_0_2_1; + return true; + } + } + // Skip export's index. + if (!parseVarint(pos, end, export_name_size)) { + return false; + } + } + return true; + } + pos += section_len; + } + return true; +} + +bool BytecodeUtil::getCustomSection(std::string_view bytecode, std::string_view name, + std::string_view &ret) { + // Check Wasm header. + if (!checkWasmHeader(bytecode)) { + return false; + } + + // Skip the Wasm header. + const char *pos = bytecode.data() + 8; + const char *end = bytecode.data() + bytecode.size(); + while (pos < end) { + if (pos + 1 > end) { + return false; + } + const auto section_type = *pos++; + uint32_t section_len = 0; + if (!parseVarint(pos, end, section_len) || pos + section_len > end) { + return false; + } + if (section_type == 0) { + // Custom section. + const char *section_end = pos + section_len; + uint32_t section_name_len = 0; + if (!BytecodeUtil::parseVarint(pos, section_end, section_name_len) || + pos + section_name_len > section_end) { + return false; + } + if (section_name_len == name.size() && ::memcmp(pos, name.data(), section_name_len) == 0) { + pos += section_name_len; + ret = {pos, static_cast(section_end - pos)}; + return true; + } + pos = section_end; + } else { + // Skip other sections. + pos += section_len; + } + } + return true; +} + +bool BytecodeUtil::getFunctionNameIndex(std::string_view bytecode, + std::unordered_map &ret) { + std::string_view name_section = {}; + if (!BytecodeUtil::getCustomSection(bytecode, "name", name_section)) { + return false; + }; + if (!name_section.empty()) { + const char *pos = name_section.data(); + const char *end = name_section.data() + name_section.size(); + while (pos < end) { + const auto subsection_id = *pos++; + uint32_t subsection_size = 0; + if (!parseVarint(pos, end, subsection_size) || pos + subsection_size > end) { + return false; + } + + if (subsection_id != 1) { + // Skip other subsctions. + pos += subsection_size; + } else { + // Enters function name subsection. + const auto *const start = pos; + uint32_t namemap_vector_size = 0; + if (!parseVarint(pos, end, namemap_vector_size) || pos + namemap_vector_size > end) { + return false; + } + for (uint32_t i = 0; i < namemap_vector_size; i++) { + uint32_t func_index = 0; + if (!parseVarint(pos, end, func_index)) { + return false; + } + + uint32_t func_name_size = 0; + if (!parseVarint(pos, end, func_name_size) || pos + func_name_size > end) { + return false; + } + auto func_name = std::string(pos, func_name_size); +#if !defined(_MSC_VER) + int status; + char *data = abi::__cxa_demangle(func_name.c_str(), nullptr, nullptr, &status); + if (data != nullptr) { + func_name = std::string(data); + ::free(data); + } +#endif + ret.insert({func_index, func_name}); + pos += func_name_size; + } + if (start + subsection_size != pos) { + return false; + } + } + } + } + return true; +} + +bool BytecodeUtil::getStrippedSource(std::string_view bytecode, std::string &ret) { + // Check Wasm header. + if (!checkWasmHeader(bytecode)) { + return false; + } + + // Skip the Wasm header. + const char *pos = bytecode.data() + 8; + const char *end = bytecode.data() + bytecode.size(); + while (pos < end) { + const auto *const section_start = pos; + if (pos + 1 > end) { + return false; + } + const auto section_type = *pos++; + uint32_t section_len = 0; + if (!parseVarint(pos, end, section_len) || pos + section_len > end) { + return false; + } + if (section_type == 0 /* custom section */) { + const auto *const section_data_start = pos; + uint32_t section_name_len = 0; + if (!parseVarint(pos, end, section_name_len) || pos + section_name_len > end) { + return false; + } + auto section_name = std::string_view(pos, section_name_len); + if (section_name.find("precompiled_") != std::string::npos) { + // If this is the first "precompiled_" section, then save everything + // before it, otherwise skip it. + if (ret.empty()) { + const char *start = bytecode.data(); + ret.append(start, section_start); + } + } + pos = section_data_start + section_len; + } else { + pos += section_len; + // Save this section if we already saw a custom "precompiled_" section. + if (!ret.empty()) { + ret.append(section_start, pos); + } + } + } + if (ret.empty()) { + // Copy the original source code if it is empty. + ret = std::string(bytecode); + } + return true; +} + +bool BytecodeUtil::parseVarint(const char *&pos, const char *end, uint32_t &ret) { + uint32_t shift = 0; + uint32_t total = 0; + uint32_t v; + char b; + while (pos < end) { + if (pos + 1 > end) { + // overread + return false; + } + b = *pos++; + v = (b & 0x7f); + if (shift == 28 && v > 3) { + // overflow + return false; + } + total += v << shift; + if ((b & 0x80) == 0) { + ret = total; + return true; + } + shift += 7; + if (shift > 28) { + // overflow + return false; + } + } + return false; +} + +} // namespace proxy_wasm diff --git a/src/common/types.h b/src/common/types.h new file mode 100644 index 000000000..0ac4c13aa --- /dev/null +++ b/src/common/types.h @@ -0,0 +1,38 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include + +namespace proxy_wasm::common { + +template +class CSmartPtr : public std::unique_ptr { +public: + CSmartPtr() : std::unique_ptr(nullptr, deleter) {} + CSmartPtr(T *object) : std::unique_ptr(object, deleter) {} +}; + +template class CSmartType { +public: + CSmartType() { initializer(&item); } + ~CSmartType() { deleter(&item); } + T *get() { return &item; } + +private: + T item; +}; + +} // namespace proxy_wasm::common diff --git a/src/context.cc b/src/context.cc index c1929e14a..d8dbc9a2a 100644 --- a/src/context.cc +++ b/src/context.cc @@ -22,210 +22,34 @@ #include "include/proxy-wasm/context.h" #include "include/proxy-wasm/wasm.h" +#include "src/hash.h" +#include "src/shared_data.h" +#include "src/shared_queue.h" -#define CHECK_FAIL(_call, _stream_type, _return_open, _return_closed) \ +#define CHECK_FAIL(_stream_type, _stream_type2, _return_open, _return_closed) \ if (isFailed()) { \ if (plugin_->fail_open_) { \ return _return_open; \ - } else { \ - failStream(_stream_type); \ - return _return_closed; \ - } \ - } else { \ - if (!wasm_->_call) { \ - return _return_open; \ } \ - } - -#define CHECK_FAIL2(_call1, _call2, _stream_type, _return_open, _return_closed) \ - if (isFailed()) { \ - if (plugin_->fail_open_) { \ - return _return_open; \ - } else { \ + if (!stream_failed_) { \ failStream(_stream_type); \ - return _return_closed; \ - } \ - } else { \ - if (!wasm_->_call1 && !wasm_->_call2) { \ - return _return_open; \ + failStream(_stream_type2); \ + stream_failed_ = true; \ } \ + return _return_closed; \ } -#define CHECK_HTTP(_call, _return_open, _return_closed) \ - CHECK_FAIL(_call, WasmStreamType::Request, _return_open, _return_closed) -#define CHECK_HTTP2(_call1, _call2, _return_open, _return_closed) \ - CHECK_FAIL2(_call1, _call2, WasmStreamType::Request, _return_open, _return_closed) -#define CHECK_NET(_call, _return_open, _return_closed) \ - CHECK_FAIL(_call, WasmStreamType::Downstream, _return_open, _return_closed) +#define CHECK_FAIL_HTTP(_return_open, _return_closed) \ + CHECK_FAIL(WasmStreamType::Request, WasmStreamType::Response, _return_open, _return_closed) +#define CHECK_FAIL_NET(_return_open, _return_closed) \ + CHECK_FAIL(WasmStreamType::Downstream, WasmStreamType::Upstream, _return_open, _return_closed) namespace proxy_wasm { -namespace { - -using CallOnThreadFunction = std::function)>; - -class SharedData { -public: - WasmResult get(std::string_view vm_id, const std::string_view key, - std::pair *result) { - std::lock_guard lock(mutex_); - auto map = data_.find(std::string(vm_id)); - if (map == data_.end()) { - return WasmResult::NotFound; - } - auto it = map->second.find(std::string(key)); - if (it != map->second.end()) { - *result = it->second; - return WasmResult::Ok; - } - return WasmResult::NotFound; - } - - WasmResult set(std::string_view vm_id, std::string_view key, std::string_view value, - uint32_t cas) { - std::lock_guard lock(mutex_); - std::unordered_map> *map; - auto map_it = data_.find(std::string(vm_id)); - if (map_it == data_.end()) { - map = &data_[std::string(vm_id)]; - } else { - map = &map_it->second; - } - auto it = map->find(std::string(key)); - if (it != map->end()) { - if (cas && cas != it->second.second) { - return WasmResult::CasMismatch; - } - it->second = std::make_pair(std::string(value), nextCas()); - } else { - map->emplace(key, std::make_pair(std::string(value), nextCas())); - } - return WasmResult::Ok; - } - - uint32_t registerQueue(std::string_view vm_id, std::string_view queue_name, uint32_t context_id, - CallOnThreadFunction call_on_thread, std::string_view vm_key) { - std::lock_guard lock(mutex_); - auto key = std::make_pair(std::string(vm_id), std::string(queue_name)); - auto it = queue_tokens_.insert(std::make_pair(key, static_cast(0))); - if (it.second) { - it.first->second = nextQueueToken(); - queue_token_set_.insert(it.first->second); - } - uint32_t token = it.first->second; - auto &q = queues_[token]; - q.vm_key = std::string(vm_key); - q.context_id = context_id; - q.call_on_thread = std::move(call_on_thread); - // Preserve any existing data. - return token; - } - - uint32_t resolveQueue(std::string_view vm_id, std::string_view queue_name) { - std::lock_guard lock(mutex_); - auto key = std::make_pair(std::string(vm_id), std::string(queue_name)); - auto it = queue_tokens_.find(key); - if (it != queue_tokens_.end()) { - return it->second; - } - return 0; // N.B. zero indicates that the queue was not found. - } - - WasmResult dequeue(uint32_t token, std::string *data) { - std::lock_guard lock(mutex_); - auto it = queues_.find(token); - if (it == queues_.end()) { - return WasmResult::NotFound; - } - if (it->second.queue.empty()) { - return WasmResult::Empty; - } - *data = it->second.queue.front(); - it->second.queue.pop_front(); - return WasmResult::Ok; - } - - WasmResult enqueue(uint32_t token, std::string_view value) { - std::string vm_key; - uint32_t context_id; - CallOnThreadFunction call_on_thread; - - { - std::lock_guard lock(mutex_); - auto it = queues_.find(token); - if (it == queues_.end()) { - return WasmResult::NotFound; - } - Queue *target_queue = &(it->second); - vm_key = target_queue->vm_key; - context_id = target_queue->context_id; - call_on_thread = target_queue->call_on_thread; - target_queue->queue.push_back(std::string(value)); - } - - call_on_thread([vm_key, context_id, token] { - // This code may or may not execute in another thread. - // Make sure that the lock is no longer held here. - auto wasm = getThreadLocalWasm(vm_key); - if (wasm) { - auto context = wasm->wasm()->getContext(context_id); - if (context) { - context->onQueueReady(token); - } - } - }); - return WasmResult::Ok; - } - - uint32_t nextCas() { - auto result = cas_; - cas_++; - if (!cas_) { // 0 is not a valid CAS value. - cas_++; - } - return result; - } - -private: - uint32_t nextQueueToken() { - while (true) { - uint32_t token = next_queue_token_++; - if (token == 0) { - continue; // 0 is an illegal token. - } - if (queue_token_set_.find(token) == queue_token_set_.end()) { - return token; - } - } - } - - struct Queue { - std::string vm_key; - uint32_t context_id; - CallOnThreadFunction call_on_thread; - std::deque queue; - }; - - // TODO: use std::shared_mutex in C++17. - std::mutex mutex_; - uint32_t cas_ = 1; - uint32_t next_queue_token_ = 1; - std::map>> data_; - std::map queues_; - struct pair_hash { - template std::size_t operator()(const std::pair &pair) const { - return std::hash()(pair.first) ^ std::hash()(pair.second); - } - }; - std::unordered_map, uint32_t, pair_hash> queue_tokens_; - std::unordered_set queue_token_set_; -}; - -SharedData global_shared_data; - -} // namespace - -DeferAfterCallActions::~DeferAfterCallActions() { wasm_->doAfterVmCallActions(); } +DeferAfterCallActions::~DeferAfterCallActions() { + wasm_->stopNextIteration(false); + wasm_->doAfterVmCallActions(); +} WasmResult BufferBase::copyTo(WasmBase *wasm, size_t start, size_t length, uint64_t ptr_ptr, uint64_t size_ptr) const { @@ -244,9 +68,8 @@ WasmResult BufferBase::copyTo(WasmBase *wasm, size_t start, size_t length, uint6 } // Test support. - uint32_t resolveQueueForTest(std::string_view vm_id, std::string_view queue_name) { - return global_shared_data.resolveQueue(vm_id, queue_name); + return getGlobalSharedQueue().resolveQueue(vm_id, queue_name); } std::string PluginBase::makeLogPrefix() const { @@ -257,28 +80,36 @@ std::string PluginBase::makeLogPrefix() const { if (!root_id_.empty()) { prefix = prefix + " " + std::string(root_id_); } - if (vm_id_.empty()) { + if (!vm_id_.empty()) { prefix = prefix + " " + std::string(vm_id_); } return prefix; } +std::string PluginBase::makePluginKey(std::string_view root_id, + std::string_view plugin_configuration, std::string_view key) { + return Sha256String({root_id, "||", plugin_configuration, "||", key}); +} + ContextBase::ContextBase() : parent_context_(this) {} ContextBase::ContextBase(WasmBase *wasm) : wasm_(wasm), parent_context_(this) { wasm_->contexts_[id_] = this; } -ContextBase::ContextBase(WasmBase *wasm, std::shared_ptr plugin) { - initializeRootBase(wasm, plugin); +ContextBase::ContextBase(WasmBase *wasm, const std::shared_ptr &plugin) + : wasm_(wasm), id_(wasm->allocContextId()), parent_context_(this), root_id_(plugin->root_id_), + root_log_prefix_(makeRootLogPrefix(plugin->vm_id_)), plugin_(plugin) { + wasm_->contexts_[id_] = this; } // NB: wasm can be nullptr if it failed to be created successfully. ContextBase::ContextBase(WasmBase *wasm, uint32_t parent_context_id, - std::shared_ptr plugin) - : wasm_(wasm), id_(wasm ? wasm->allocContextId() : 0), parent_context_id_(parent_context_id), - plugin_(plugin) { - if (wasm_) { + const std::shared_ptr &plugin_handle) + : wasm_(wasm), id_(wasm != nullptr ? wasm->allocContextId() : 0), + parent_context_id_(parent_context_id), plugin_(plugin_handle->plugin()), + plugin_handle_(plugin_handle) { + if (wasm_ != nullptr) { wasm_->contexts_[id_] = this; parent_context_ = wasm_->contexts_[parent_context_id_]; } @@ -286,23 +117,14 @@ ContextBase::ContextBase(WasmBase *wasm, uint32_t parent_context_id, WasmVm *ContextBase::wasmVm() const { return wasm_->wasm_vm(); } -bool ContextBase::isFailed() { return !wasm_ || wasm_->isFailed(); } - -void ContextBase::initializeRootBase(WasmBase *wasm, std::shared_ptr plugin) { - wasm_ = wasm; - id_ = wasm->allocContextId(); - root_id_ = plugin->root_id_; - root_log_prefix_ = makeRootLogPrefix(plugin->vm_id_); - parent_context_ = this; - wasm_->contexts_[id_] = this; -} +bool ContextBase::isFailed() { return (wasm_ == nullptr || wasm_->isFailed()); } std::string ContextBase::makeRootLogPrefix(std::string_view vm_id) const { std::string prefix; if (!root_id_.empty()) { prefix = prefix + " " + std::string(root_id_); } - if (vm_id.empty()) { + if (!vm_id.empty()) { prefix = prefix + " " + std::string(vm_id); } return prefix; @@ -315,10 +137,10 @@ bool ContextBase::onStart(std::shared_ptr plugin) { DeferAfterCallActions actions(this); bool result = true; if (wasm_->on_context_create_) { - plugin_ = plugin; + temp_plugin_ = plugin; wasm_->on_context_create_(this, id_, 0); in_vm_context_created_ = true; - plugin_.reset(); + temp_plugin_.reset(); } if (wasm_->on_vm_start_) { // Do not set plugin_ as the on_vm_start handler should be independent of the plugin since the @@ -350,18 +172,18 @@ bool ContextBase::onConfigure(std::shared_ptr plugin) { } DeferAfterCallActions actions(this); - plugin_ = plugin; + temp_plugin_ = plugin; auto result = wasm_->on_configure_(this, id_, static_cast(plugin->plugin_configuration_.size())) .u64_ != 0; - plugin_.reset(); + temp_plugin_.reset(); return result; } void ContextBase::onCreate() { if (!isFailed() && !in_vm_context_created_ && wasm_->on_context_create_) { DeferAfterCallActions actions(this); - wasm_->on_context_create_(this, id_, parent_context_ ? parent_context()->id() : 0); + wasm_->on_context_create_(this, id_, parent_context_ != nullptr ? parent_context()->id() : 0); } // NB: If no on_context_create function is registered the in-VM SDK is responsible for // managing any required in-VM state. @@ -371,29 +193,39 @@ void ContextBase::onCreate() { // Shared Data WasmResult ContextBase::getSharedData(std::string_view key, std::pair *data) { - return global_shared_data.get(wasm_->vm_id(), key, data); + return getGlobalSharedData().get(wasm_->vm_id(), key, data); } WasmResult ContextBase::setSharedData(std::string_view key, std::string_view value, uint32_t cas) { - return global_shared_data.set(wasm_->vm_id(), key, value, cas); + return getGlobalSharedData().set(wasm_->vm_id(), key, value, cas); +} + +WasmResult ContextBase::getSharedDataKeys(std::vector *result) { + return getGlobalSharedData().keys(wasm_->vm_id(), result); +} + +WasmResult ContextBase::removeSharedDataKey(std::string_view key, uint32_t cas, + std::pair *result) { + return getGlobalSharedData().remove(wasm_->vm_id(), key, cas, result); } // Shared Queue WasmResult ContextBase::registerSharedQueue(std::string_view queue_name, - SharedQueueDequeueToken *result) { + SharedQueueDequeueToken *token_ptr) { // Get the id of the root context if this is a stream context because onQueueReady is on the // root. - *result = global_shared_data.registerQueue(wasm_->vm_id(), queue_name, - isRootContext() ? id_ : parent_context_id_, - wasm_->callOnThreadFunction(), wasm_->vm_key()); + *token_ptr = getGlobalSharedQueue().registerQueue(wasm_->vm_id(), queue_name, + isRootContext() ? id_ : parent_context_id_, + wasm_->callOnThreadFunction(), wasm_->vm_key()); return WasmResult::Ok; } WasmResult ContextBase::lookupSharedQueue(std::string_view vm_id, std::string_view queue_name, - uint32_t *token_ptr) { - uint32_t token = global_shared_data.resolveQueue(vm_id, queue_name); - if (isFailed() || !token) { + SharedQueueDequeueToken *token_ptr) { + SharedQueueDequeueToken token = + getGlobalSharedQueue().resolveQueue(vm_id.empty() ? wasm_->vm_id() : vm_id, queue_name); + if (isFailed() || token == 0U) { return WasmResult::NotFound; } *token_ptr = token; @@ -401,11 +233,11 @@ WasmResult ContextBase::lookupSharedQueue(std::string_view vm_id, std::string_vi } WasmResult ContextBase::dequeueSharedQueue(uint32_t token, std::string *data) { - return global_shared_data.dequeue(token, data); + return getGlobalSharedQueue().dequeue(token, data); } WasmResult ContextBase::enqueueSharedQueue(uint32_t token, std::string_view value) { - return global_shared_data.enqueue(token, value); + return getGlobalSharedQueue().enqueue(token, value); } void ContextBase::destroy() { if (destroyed_) { @@ -415,7 +247,7 @@ void ContextBase::destroy() { onDone(); } -void ContextBase::onTick(uint32_t) { +void ContextBase::onTick(uint32_t /*token*/) { if (!isFailed() && wasm_->on_tick_) { DeferAfterCallActions actions(this); wasm_->on_tick_(this, id_); @@ -430,30 +262,40 @@ void ContextBase::onForeignFunction(uint32_t foreign_function_id, uint32_t data_ } FilterStatus ContextBase::onNetworkNewConnection() { - CHECK_NET(on_new_connection_, FilterStatus::Continue, FilterStatus::StopIteration); - DeferAfterCallActions actions(this); - if (wasm_->on_new_connection_(this, id_).u64_ == 0) { + CHECK_FAIL_NET(FilterStatus::Continue, FilterStatus::StopIteration); + if (!wasm_->on_new_connection_) { return FilterStatus::Continue; } - return FilterStatus::StopIteration; + DeferAfterCallActions actions(this); + const auto result = wasm_->on_new_connection_(this, id_); + CHECK_FAIL_NET(FilterStatus::Continue, FilterStatus::StopIteration); + return result == 0 ? FilterStatus::Continue : FilterStatus::StopIteration; } FilterStatus ContextBase::onDownstreamData(uint32_t data_length, bool end_of_stream) { - CHECK_NET(on_downstream_data_, FilterStatus::Continue, FilterStatus::StopIteration); + CHECK_FAIL_NET(FilterStatus::Continue, FilterStatus::StopIteration); + if (!wasm_->on_downstream_data_) { + return FilterStatus::Continue; + } DeferAfterCallActions actions(this); auto result = wasm_->on_downstream_data_(this, id_, static_cast(data_length), static_cast(end_of_stream)); // TODO(PiotrSikora): pull Proxy-WASM's FilterStatus values. - return result.u64_ == 0 ? FilterStatus::Continue : FilterStatus::StopIteration; + CHECK_FAIL_NET(FilterStatus::Continue, FilterStatus::StopIteration); + return result == 0 ? FilterStatus::Continue : FilterStatus::StopIteration; } FilterStatus ContextBase::onUpstreamData(uint32_t data_length, bool end_of_stream) { - CHECK_NET(on_upstream_data_, FilterStatus::Continue, FilterStatus::StopIteration); + CHECK_FAIL_NET(FilterStatus::Continue, FilterStatus::StopIteration); + if (!wasm_->on_upstream_data_) { + return FilterStatus::Continue; + } DeferAfterCallActions actions(this); auto result = wasm_->on_upstream_data_(this, id_, static_cast(data_length), static_cast(end_of_stream)); // TODO(PiotrSikora): pull Proxy-WASM's FilterStatus values. - return result.u64_ == 0 ? FilterStatus::Continue : FilterStatus::StopIteration; + CHECK_FAIL_NET(FilterStatus::Continue, FilterStatus::StopIteration); + return result == 0 ? FilterStatus::Continue : FilterStatus::StopIteration; } void ContextBase::onDownstreamConnectionClose(CloseType close_type) { @@ -474,96 +316,99 @@ void ContextBase::onUpstreamConnectionClose(CloseType close_type) { template static uint32_t headerSize(const P &p) { return p ? p->size() : 0; } FilterHeadersStatus ContextBase::onRequestHeaders(uint32_t headers, bool end_of_stream) { - CHECK_HTTP2(on_request_headers_abi_01_, on_request_headers_abi_02_, FilterHeadersStatus::Continue, - FilterHeadersStatus::StopIteration); + CHECK_FAIL_HTTP(FilterHeadersStatus::Continue, FilterHeadersStatus::StopAllIterationAndWatermark); + if (!wasm_->on_request_headers_abi_01_ && !wasm_->on_request_headers_abi_02_) { + return FilterHeadersStatus::Continue; + } DeferAfterCallActions actions(this); - auto result = wasm_->on_request_headers_abi_01_ - ? wasm_->on_request_headers_abi_01_(this, id_, headers).u64_ - : wasm_ - ->on_request_headers_abi_02_(this, id_, headers, - static_cast(end_of_stream)) - .u64_; - if (result > static_cast(FilterHeadersStatus::StopAllIterationAndWatermark)) - return FilterHeadersStatus::StopAllIterationAndWatermark; - return static_cast(result); + const auto result = wasm_->on_request_headers_abi_01_ + ? wasm_->on_request_headers_abi_01_(this, id_, headers) + : wasm_->on_request_headers_abi_02_(this, id_, headers, + static_cast(end_of_stream)); + CHECK_FAIL_HTTP(FilterHeadersStatus::Continue, FilterHeadersStatus::StopAllIterationAndWatermark); + return convertVmCallResultToFilterHeadersStatus(result); } -FilterDataStatus ContextBase::onRequestBody(uint32_t data_length, bool end_of_stream) { - CHECK_HTTP(on_request_body_, FilterDataStatus::Continue, FilterDataStatus::StopIterationNoBuffer); +FilterDataStatus ContextBase::onRequestBody(uint32_t body_length, bool end_of_stream) { + CHECK_FAIL_HTTP(FilterDataStatus::Continue, FilterDataStatus::StopIterationNoBuffer); + if (!wasm_->on_request_body_) { + return FilterDataStatus::Continue; + } DeferAfterCallActions actions(this); - auto result = - wasm_->on_request_body_(this, id_, data_length, static_cast(end_of_stream)).u64_; - if (result > static_cast(FilterDataStatus::StopIterationNoBuffer)) - return FilterDataStatus::StopIterationNoBuffer; - return static_cast(result); + const auto result = + wasm_->on_request_body_(this, id_, body_length, static_cast(end_of_stream)); + CHECK_FAIL_HTTP(FilterDataStatus::Continue, FilterDataStatus::StopIterationNoBuffer); + return convertVmCallResultToFilterDataStatus(result); } FilterTrailersStatus ContextBase::onRequestTrailers(uint32_t trailers) { - CHECK_HTTP(on_request_trailers_, FilterTrailersStatus::Continue, - FilterTrailersStatus::StopIteration); - DeferAfterCallActions actions(this); - if (static_cast(wasm_->on_request_trailers_(this, id_, trailers).u64_) == - FilterTrailersStatus::Continue) { + CHECK_FAIL_HTTP(FilterTrailersStatus::Continue, FilterTrailersStatus::StopIteration); + if (!wasm_->on_request_trailers_) { return FilterTrailersStatus::Continue; } - return FilterTrailersStatus::StopIteration; + DeferAfterCallActions actions(this); + const auto result = wasm_->on_request_trailers_(this, id_, trailers); + CHECK_FAIL_HTTP(FilterTrailersStatus::Continue, FilterTrailersStatus::StopIteration); + return convertVmCallResultToFilterTrailersStatus(result); } FilterMetadataStatus ContextBase::onRequestMetadata(uint32_t elements) { - CHECK_HTTP(on_request_metadata_, FilterMetadataStatus::Continue, FilterMetadataStatus::Continue); - DeferAfterCallActions actions(this); - if (static_cast(wasm_->on_request_metadata_(this, id_, elements).u64_) == - FilterMetadataStatus::Continue) { + CHECK_FAIL_HTTP(FilterMetadataStatus::Continue, FilterMetadataStatus::Continue); + if (!wasm_->on_request_metadata_) { return FilterMetadataStatus::Continue; } - return FilterMetadataStatus::Continue; // This is currently the only return code. + DeferAfterCallActions actions(this); + const auto result = wasm_->on_request_metadata_(this, id_, elements); + CHECK_FAIL_HTTP(FilterMetadataStatus::Continue, FilterMetadataStatus::Continue); + return convertVmCallResultToFilterMetadataStatus(result); } FilterHeadersStatus ContextBase::onResponseHeaders(uint32_t headers, bool end_of_stream) { - CHECK_HTTP2(on_response_headers_abi_01_, on_response_headers_abi_02_, - FilterHeadersStatus::Continue, FilterHeadersStatus::StopIteration); + CHECK_FAIL_HTTP(FilterHeadersStatus::Continue, FilterHeadersStatus::StopAllIterationAndWatermark); + if (!wasm_->on_response_headers_abi_01_ && !wasm_->on_response_headers_abi_02_) { + return FilterHeadersStatus::Continue; + } DeferAfterCallActions actions(this); - auto result = wasm_->on_response_headers_abi_01_ - ? wasm_->on_response_headers_abi_01_(this, id_, headers).u64_ - : wasm_ - ->on_response_headers_abi_02_(this, id_, headers, - static_cast(end_of_stream)) - .u64_; - if (result > static_cast(FilterHeadersStatus::StopAllIterationAndWatermark)) - return FilterHeadersStatus::StopAllIterationAndWatermark; - return static_cast(result); + const auto result = wasm_->on_response_headers_abi_01_ + ? wasm_->on_response_headers_abi_01_(this, id_, headers) + : wasm_->on_response_headers_abi_02_( + this, id_, headers, static_cast(end_of_stream)); + CHECK_FAIL_HTTP(FilterHeadersStatus::Continue, FilterHeadersStatus::StopAllIterationAndWatermark); + return convertVmCallResultToFilterHeadersStatus(result); } FilterDataStatus ContextBase::onResponseBody(uint32_t body_length, bool end_of_stream) { - CHECK_HTTP(on_response_body_, FilterDataStatus::Continue, - FilterDataStatus::StopIterationNoBuffer); + CHECK_FAIL_HTTP(FilterDataStatus::Continue, FilterDataStatus::StopIterationNoBuffer); + if (!wasm_->on_response_body_) { + return FilterDataStatus::Continue; + } DeferAfterCallActions actions(this); - auto result = - wasm_->on_response_body_(this, id_, body_length, static_cast(end_of_stream)).u64_; - if (result > static_cast(FilterDataStatus::StopIterationNoBuffer)) - return FilterDataStatus::StopIterationNoBuffer; - return static_cast(result); + const auto result = + wasm_->on_response_body_(this, id_, body_length, static_cast(end_of_stream)); + CHECK_FAIL_HTTP(FilterDataStatus::Continue, FilterDataStatus::StopIterationNoBuffer); + return convertVmCallResultToFilterDataStatus(result); } FilterTrailersStatus ContextBase::onResponseTrailers(uint32_t trailers) { - CHECK_HTTP(on_response_trailers_, FilterTrailersStatus::Continue, - FilterTrailersStatus::StopIteration); - DeferAfterCallActions actions(this); - if (static_cast(wasm_->on_response_trailers_(this, id_, trailers).u64_) == - FilterTrailersStatus::Continue) { + CHECK_FAIL_HTTP(FilterTrailersStatus::Continue, FilterTrailersStatus::StopIteration); + if (!wasm_->on_response_trailers_) { return FilterTrailersStatus::Continue; } - return FilterTrailersStatus::StopIteration; + DeferAfterCallActions actions(this); + const auto result = wasm_->on_response_trailers_(this, id_, trailers); + CHECK_FAIL_HTTP(FilterTrailersStatus::Continue, FilterTrailersStatus::StopIteration); + return convertVmCallResultToFilterTrailersStatus(result); } FilterMetadataStatus ContextBase::onResponseMetadata(uint32_t elements) { - CHECK_HTTP(on_response_metadata_, FilterMetadataStatus::Continue, FilterMetadataStatus::Continue); - DeferAfterCallActions actions(this); - if (static_cast(wasm_->on_response_metadata_(this, id_, elements).u64_) == - FilterMetadataStatus::Continue) { + CHECK_FAIL_HTTP(FilterMetadataStatus::Continue, FilterMetadataStatus::Continue); + if (!wasm_->on_response_metadata_) { return FilterMetadataStatus::Continue; } - return FilterMetadataStatus::Continue; // This is currently the only return code. + DeferAfterCallActions actions(this); + const auto result = wasm_->on_response_metadata_(this, id_, elements); + CHECK_FAIL_HTTP(FilterMetadataStatus::Continue, FilterMetadataStatus::Continue); + return convertVmCallResultToFilterMetadataStatus(result); } void ContextBase::onHttpCallResponse(uint32_t token, uint32_t headers, uint32_t body_size, @@ -643,9 +488,48 @@ WasmResult ContextBase::setTimerPeriod(std::chrono::milliseconds period, return WasmResult::Ok; } +FilterHeadersStatus ContextBase::convertVmCallResultToFilterHeadersStatus(uint64_t result) { + if (wasm()->isNextIterationStopped() || + result > static_cast(FilterHeadersStatus::StopAllIterationAndWatermark)) { + return FilterHeadersStatus::StopAllIterationAndWatermark; + } + if (result == static_cast(FilterHeadersStatus::StopIteration) && + !allow_on_headers_stop_iteration_) { + // Default behavior for Proxy-Wasm 0.2.* ABI is to translate StopIteration + // (pause processing headers, but continue processing body) to + // StopAllIterationAndWatermark (pause all processing), as described in + // https://github.com/proxy-wasm/proxy-wasm-cpp-host/issues/143. + return FilterHeadersStatus::StopAllIterationAndWatermark; + } + return static_cast(result); +} + +FilterDataStatus ContextBase::convertVmCallResultToFilterDataStatus(uint64_t result) { + if (wasm()->isNextIterationStopped() || + result > static_cast(FilterDataStatus::StopIterationNoBuffer)) { + return FilterDataStatus::StopIterationNoBuffer; + } + return static_cast(result); +} + +FilterTrailersStatus ContextBase::convertVmCallResultToFilterTrailersStatus(uint64_t result) { + if (wasm()->isNextIterationStopped() || + result > static_cast(FilterTrailersStatus::StopIteration)) { + return FilterTrailersStatus::StopIteration; + } + return static_cast(result); +} + +FilterMetadataStatus ContextBase::convertVmCallResultToFilterMetadataStatus(uint64_t result) { + if (static_cast(result) == FilterMetadataStatus::Continue) { + return FilterMetadataStatus::Continue; + } + return FilterMetadataStatus::Continue; // This is currently the only return code. +} + ContextBase::~ContextBase() { - // Do not remove vm or root contexts which have the same lifetime as wasm_. - if (parent_context_id_) { + // Do not remove vm context which has the same lifetime as wasm_. + if (id_ != 0U) { wasm_->contexts_.erase(id_); } } diff --git a/src/exports.cc b/src/exports.cc index cda125140..25ca06c9d 100644 --- a/src/exports.cc +++ b/src/exports.cc @@ -13,86 +13,56 @@ // See the License for the specific language governing permissions and // limitations under the License. // +#include "include/proxy-wasm/limits.h" +#include "include/proxy-wasm/pairs_util.h" #include "include/proxy-wasm/wasm.h" #include -#define WASM_CONTEXT(_c) \ - (ContextOrEffectiveContext(static_cast((void)_c, current_context_))) +#include namespace proxy_wasm { -// The id of the context which should be used for calls out of the VM in place -// of current_context_. -extern thread_local uint32_t effective_context_id_; +thread_local ContextBase *current_context_; +thread_local uint32_t effective_context_id_ = 0; -namespace exports { - -ContextBase *ContextOrEffectiveContext(ContextBase *context) { +// Any currently executing Wasm call context. +ContextBase *contextOrEffectiveContext() { if (effective_context_id_ == 0) { - return context; + return current_context_; } - auto effective_context = context->wasm()->getContext(effective_context_id_); - if (effective_context) { + auto *effective_context = current_context_->wasm()->getContext(effective_context_id_); + if (effective_context != nullptr) { return effective_context; } // The effective_context_id_ no longer exists, revert to the true context. - return context; -} + return current_context_; +}; -namespace { +std::unordered_map &foreignFunctions() { + static auto *ptr = new std::unordered_map; + return *ptr; +} -Pairs toPairs(std::string_view buffer) { - Pairs result; - const char *b = buffer.data(); - if (buffer.size() < sizeof(uint32_t)) { - return {}; +WasmForeignFunction getForeignFunction(std::string_view function_name) { + auto foreign_functions = foreignFunctions(); + auto it = foreign_functions.find(std::string(function_name)); + if (it != foreign_functions.end()) { + return it->second; } - auto size = *reinterpret_cast(b); - b += sizeof(uint32_t); - if (sizeof(uint32_t) + size * 2 * sizeof(uint32_t) > buffer.size()) { - return {}; - } - result.resize(size); - for (uint32_t i = 0; i < size; i++) { - result[i].first = std::string_view(nullptr, *reinterpret_cast(b)); - b += sizeof(uint32_t); - result[i].second = std::string_view(nullptr, *reinterpret_cast(b)); - b += sizeof(uint32_t); - } - for (auto &p : result) { - p.first = std::string_view(b, p.first.size()); - b += p.first.size() + 1; - p.second = std::string_view(b, p.second.size()); - b += p.second.size() + 1; - } - return result; + return nullptr; } -template -bool getPairs(ContextBase *context, const Pairs &result, uint64_t ptr_ptr, uint64_t size_ptr) { - if (result.empty()) { - return context->wasm()->copyToPointerSize("", ptr_ptr, size_ptr); - } - uint64_t size = pairsSize(result); - uint64_t ptr; - char *buffer = static_cast(context->wasm()->allocMemory(size, &ptr)); - marshalPairs(result, buffer); - if (!context->wasmVm()->setWord(ptr_ptr, Word(ptr))) { - return false; - } - if (!context->wasmVm()->setWord(size_ptr, Word(size))) { - return false; - } - return true; +RegisterForeignFunction::RegisterForeignFunction(const std::string &name, WasmForeignFunction f) { + foreignFunctions()[name] = std::move(f); } -} // namespace +namespace exports { // General ABI. -Word set_property(void *raw_context, Word key_ptr, Word key_size, Word value_ptr, Word value_size) { - auto context = WASM_CONTEXT(raw_context); +Word set_property(Word key_ptr, Word key_size, Word value_ptr, Word value_size) { + auto *context = contextOrEffectiveContext(); auto key = context->wasmVm()->getMemory(key_ptr, key_size); auto value = context->wasmVm()->getMemory(value_ptr, value_size); if (!key || !value) { @@ -102,9 +72,8 @@ Word set_property(void *raw_context, Word key_ptr, Word key_size, Word value_ptr } // Generic selector -Word get_property(void *raw_context, Word path_ptr, Word path_size, Word value_ptr_ptr, - Word value_size_ptr) { - auto context = WASM_CONTEXT(raw_context); +Word get_property(Word path_ptr, Word path_size, Word value_ptr_ptr, Word value_size_ptr) { + auto *context = contextOrEffectiveContext(); auto path = context->wasmVm()->getMemory(path_ptr, path_size); if (!path.has_value()) { return WasmResult::InvalidMemoryAccess; @@ -120,8 +89,8 @@ Word get_property(void *raw_context, Word path_ptr, Word path_size, Word value_p return WasmResult::Ok; } -Word get_configuration(void *raw_context, Word value_ptr_ptr, Word value_size_ptr) { - auto context = WASM_CONTEXT(raw_context); +Word get_configuration(Word value_ptr_ptr, Word value_size_ptr) { + auto *context = contextOrEffectiveContext(); auto value = context->getConfiguration(); if (!context->wasm()->copyToPointerSize(value, value_ptr_ptr, value_size_ptr)) { return WasmResult::InvalidMemoryAccess; @@ -129,8 +98,8 @@ Word get_configuration(void *raw_context, Word value_ptr_ptr, Word value_size_pt return WasmResult::Ok; } -Word get_status(void *raw_context, Word code_ptr, Word value_ptr_ptr, Word value_size_ptr) { - auto context = WASM_CONTEXT(raw_context); +Word get_status(Word code_ptr, Word value_ptr_ptr, Word value_size_ptr) { + auto *context = contextOrEffectiveContext()->root_context(); auto status = context->getStatus(); if (!context->wasm()->setDatatype(code_ptr, status.first)) { return WasmResult::InvalidMemoryAccess; @@ -144,37 +113,37 @@ Word get_status(void *raw_context, Word code_ptr, Word value_ptr_ptr, Word value // HTTP // Continue/Reply/Route -Word continue_request(void *raw_context) { - auto context = WASM_CONTEXT(raw_context); +Word continue_request() { + auto *context = contextOrEffectiveContext(); return context->continueStream(WasmStreamType::Request); } -Word continue_response(void *raw_context) { - auto context = WASM_CONTEXT(raw_context); +Word continue_response() { + auto *context = contextOrEffectiveContext(); return context->continueStream(WasmStreamType::Response); } -Word continue_stream(void *raw_context, Word type) { - auto context = WASM_CONTEXT(raw_context); +Word continue_stream(Word type) { + auto *context = contextOrEffectiveContext(); if (type > static_cast(WasmStreamType::MAX)) { return WasmResult::BadArgument; } return context->continueStream(static_cast(type.u64_)); } -Word close_stream(void *raw_context, Word type) { - auto context = WASM_CONTEXT(raw_context); +Word close_stream(Word type) { + auto *context = contextOrEffectiveContext(); if (type > static_cast(WasmStreamType::MAX)) { return WasmResult::BadArgument; } return context->closeStream(static_cast(type.u64_)); } -Word send_local_response(void *raw_context, Word response_code, Word response_code_details_ptr, +Word send_local_response(Word response_code, Word response_code_details_ptr, Word response_code_details_size, Word body_ptr, Word body_size, Word additional_response_header_pairs_ptr, - Word additional_response_header_pairs_size, Word grpc_code) { - auto context = WASM_CONTEXT(raw_context); + Word additional_response_header_pairs_size, Word grpc_status) { + auto *context = contextOrEffectiveContext(); auto details = context->wasmVm()->getMemory(response_code_details_ptr, response_code_details_size); auto body = context->wasmVm()->getMemory(body_ptr, body_size); @@ -183,37 +152,38 @@ Word send_local_response(void *raw_context, Word response_code, Word response_co if (!details || !body || !additional_response_header_pairs) { return WasmResult::InvalidMemoryAccess; } - auto additional_headers = toPairs(additional_response_header_pairs.value()); - context->sendLocalResponse(response_code, body.value(), std::move(additional_headers), grpc_code, - details.value()); + auto additional_headers = PairsUtil::toPairs(additional_response_header_pairs.value()); + context->sendLocalResponse(response_code, body.value(), std::move(additional_headers), + grpc_status, details.value()); + context->wasm()->stopNextIteration(true); return WasmResult::Ok; } -Word clear_route_cache(void *raw_context) { - auto context = WASM_CONTEXT(raw_context); +Word clear_route_cache() { + auto *context = contextOrEffectiveContext(); context->clearRouteCache(); return WasmResult::Ok; } -Word set_effective_context(void *raw_context, Word context_id) { - auto context = WASM_CONTEXT(raw_context); - uint32_t cid = static_cast(context_id); - auto c = context->wasm()->getContext(cid); - if (!c) { +Word set_effective_context(Word context_id) { + auto *context = contextOrEffectiveContext(); + auto cid = static_cast(context_id); + auto *c = context->wasm()->getContext(cid); + if (c == nullptr) { return WasmResult::BadArgument; } effective_context_id_ = cid; return WasmResult::Ok; } -Word done(void *raw_context) { - auto context = WASM_CONTEXT(raw_context); +Word done() { + auto *context = contextOrEffectiveContext(); return context->wasm()->done(context); } -Word call_foreign_function(void *raw_context, Word function_name, Word function_name_size, - Word arguments, Word arguments_size, Word results, Word results_size) { - auto context = WASM_CONTEXT(raw_context); +Word call_foreign_function(Word function_name, Word function_name_size, Word arguments, + Word arguments_size, Word results, Word results_size) { + auto *context = contextOrEffectiveContext(); auto function = context->wasmVm()->getMemory(function_name, function_name_size); if (!function) { return WasmResult::InvalidMemoryAccess; @@ -222,7 +192,7 @@ Word call_foreign_function(void *raw_context, Word function_name, Word function_ if (!args_opt) { return WasmResult::InvalidMemoryAccess; } - auto f = context->wasm()->getForeignFunction(function.value()); + auto f = getForeignFunction(function.value()); if (!f) { return WasmResult::NotFound; } @@ -232,7 +202,7 @@ Word call_foreign_function(void *raw_context, Word function_name, Word function_ void *result = nullptr; size_t result_size = 0; auto res = f(wasm, args, [&wasm, &address, &result, &result_size, results](size_t s) -> void * { - if (results) { + if (results != 0U) { result = wasm.allocMemory(s, &address); } else { // If the caller does not want the results, allocate a temporary buffer for them. @@ -241,22 +211,22 @@ Word call_foreign_function(void *raw_context, Word function_name, Word function_ result_size = s; return result; }); - if (results && !context->wasmVm()->setWord(results, Word(address))) { + if (results != 0U && !context->wasmVm()->setWord(results, Word(address))) { return WasmResult::InvalidMemoryAccess; } - if (results_size && !context->wasmVm()->setWord(results_size, Word(result_size))) { + if (results_size != 0U && !context->wasmVm()->setWord(results_size, Word(result_size))) { return WasmResult::InvalidMemoryAccess; } - if (!results) { + if (results == 0U) { ::free(result); } return res; } // SharedData -Word get_shared_data(void *raw_context, Word key_ptr, Word key_size, Word value_ptr_ptr, - Word value_size_ptr, Word cas_ptr) { - auto context = WASM_CONTEXT(raw_context); +Word get_shared_data(Word key_ptr, Word key_size, Word value_ptr_ptr, Word value_size_ptr, + Word cas_ptr) { + auto *context = contextOrEffectiveContext(); auto key = context->wasmVm()->getMemory(key_ptr, key_size); if (!key) { return WasmResult::InvalidMemoryAccess; @@ -275,9 +245,8 @@ Word get_shared_data(void *raw_context, Word key_ptr, Word key_size, Word value_ return WasmResult::Ok; } -Word set_shared_data(void *raw_context, Word key_ptr, Word key_size, Word value_ptr, - Word value_size, Word cas) { - auto context = WASM_CONTEXT(raw_context); +Word set_shared_data(Word key_ptr, Word key_size, Word value_ptr, Word value_size, Word cas) { + auto *context = contextOrEffectiveContext(); auto key = context->wasmVm()->getMemory(key_ptr, key_size); auto value = context->wasmVm()->getMemory(value_ptr, value_size); if (!key || !value) { @@ -286,9 +255,8 @@ Word set_shared_data(void *raw_context, Word key_ptr, Word key_size, Word value_ return context->setSharedData(key.value(), value.value(), cas); } -Word register_shared_queue(void *raw_context, Word queue_name_ptr, Word queue_name_size, - Word token_ptr) { - auto context = WASM_CONTEXT(raw_context); +Word register_shared_queue(Word queue_name_ptr, Word queue_name_size, Word token_ptr) { + auto *context = contextOrEffectiveContext(); auto queue_name = context->wasmVm()->getMemory(queue_name_ptr, queue_name_size); if (!queue_name) { return WasmResult::InvalidMemoryAccess; @@ -304,8 +272,8 @@ Word register_shared_queue(void *raw_context, Word queue_name_ptr, Word queue_na return WasmResult::Ok; } -Word dequeue_shared_queue(void *raw_context, Word token, Word data_ptr_ptr, Word data_size_ptr) { - auto context = WASM_CONTEXT(raw_context); +Word dequeue_shared_queue(Word token, Word data_ptr_ptr, Word data_size_ptr) { + auto *context = contextOrEffectiveContext(); std::string data; WasmResult result = context->dequeueSharedQueue(token.u32(), &data); if (result != WasmResult::Ok) { @@ -317,9 +285,9 @@ Word dequeue_shared_queue(void *raw_context, Word token, Word data_ptr_ptr, Word return WasmResult::Ok; } -Word resolve_shared_queue(void *raw_context, Word vm_id_ptr, Word vm_id_size, Word queue_name_ptr, +Word resolve_shared_queue(Word vm_id_ptr, Word vm_id_size, Word queue_name_ptr, Word queue_name_size, Word token_ptr) { - auto context = WASM_CONTEXT(raw_context); + auto *context = contextOrEffectiveContext(); auto vm_id = context->wasmVm()->getMemory(vm_id_ptr, vm_id_size); auto queue_name = context->wasmVm()->getMemory(queue_name_ptr, queue_name_size); if (!vm_id || !queue_name) { @@ -336,8 +304,8 @@ Word resolve_shared_queue(void *raw_context, Word vm_id_ptr, Word vm_id_size, Wo return WasmResult::Ok; } -Word enqueue_shared_queue(void *raw_context, Word token, Word data_ptr, Word data_size) { - auto context = WASM_CONTEXT(raw_context); +Word enqueue_shared_queue(Word token, Word data_ptr, Word data_size) { + auto *context = contextOrEffectiveContext(); auto data = context->wasmVm()->getMemory(data_ptr, data_size); if (!data) { return WasmResult::InvalidMemoryAccess; @@ -346,12 +314,11 @@ Word enqueue_shared_queue(void *raw_context, Word token, Word data_ptr, Word dat } // Header/Trailer/Metadata Maps -Word add_header_map_value(void *raw_context, Word type, Word key_ptr, Word key_size, Word value_ptr, - Word value_size) { +Word add_header_map_value(Word type, Word key_ptr, Word key_size, Word value_ptr, Word value_size) { if (type > static_cast(WasmHeaderMapType::MAX)) { return WasmResult::BadArgument; } - auto context = WASM_CONTEXT(raw_context); + auto *context = contextOrEffectiveContext(); auto key = context->wasmVm()->getMemory(key_ptr, key_size); auto value = context->wasmVm()->getMemory(value_ptr, value_size); if (!key || !value) { @@ -361,12 +328,12 @@ Word add_header_map_value(void *raw_context, Word type, Word key_ptr, Word key_s value.value()); } -Word get_header_map_value(void *raw_context, Word type, Word key_ptr, Word key_size, - Word value_ptr_ptr, Word value_size_ptr) { +Word get_header_map_value(Word type, Word key_ptr, Word key_size, Word value_ptr_ptr, + Word value_size_ptr) { if (type > static_cast(WasmHeaderMapType::MAX)) { return WasmResult::BadArgument; } - auto context = WASM_CONTEXT(raw_context); + auto *context = contextOrEffectiveContext(); auto key = context->wasmVm()->getMemory(key_ptr, key_size); if (!key) { return WasmResult::InvalidMemoryAccess; @@ -383,12 +350,12 @@ Word get_header_map_value(void *raw_context, Word type, Word key_ptr, Word key_s return WasmResult::Ok; } -Word replace_header_map_value(void *raw_context, Word type, Word key_ptr, Word key_size, - Word value_ptr, Word value_size) { +Word replace_header_map_value(Word type, Word key_ptr, Word key_size, Word value_ptr, + Word value_size) { if (type > static_cast(WasmHeaderMapType::MAX)) { return WasmResult::BadArgument; } - auto context = WASM_CONTEXT(raw_context); + auto *context = contextOrEffectiveContext(); auto key = context->wasmVm()->getMemory(key_ptr, key_size); auto value = context->wasmVm()->getMemory(value_ptr, value_size); if (!key || !value) { @@ -398,11 +365,11 @@ Word replace_header_map_value(void *raw_context, Word type, Word key_ptr, Word k value.value()); } -Word remove_header_map_value(void *raw_context, Word type, Word key_ptr, Word key_size) { +Word remove_header_map_value(Word type, Word key_ptr, Word key_size) { if (type > static_cast(WasmHeaderMapType::MAX)) { return WasmResult::BadArgument; } - auto context = WASM_CONTEXT(raw_context); + auto *context = contextOrEffectiveContext(); auto key = context->wasmVm()->getMemory(key_ptr, key_size); if (!key) { return WasmResult::InvalidMemoryAccess; @@ -410,40 +377,58 @@ Word remove_header_map_value(void *raw_context, Word type, Word key_ptr, Word ke return context->removeHeaderMapValue(static_cast(type.u64_), key.value()); } -Word get_header_map_pairs(void *raw_context, Word type, Word ptr_ptr, Word size_ptr) { +Word get_header_map_pairs(Word type, Word ptr_ptr, Word size_ptr) { if (type > static_cast(WasmHeaderMapType::MAX)) { return WasmResult::BadArgument; } - auto context = WASM_CONTEXT(raw_context); + auto *context = contextOrEffectiveContext(); Pairs pairs; auto result = context->getHeaderMapPairs(static_cast(type.u64_), &pairs); if (result != WasmResult::Ok) { return result; } - if (!getPairs(context, pairs, ptr_ptr, size_ptr)) { + if (pairs.empty()) { + if (!context->wasm()->copyToPointerSize("", ptr_ptr, size_ptr)) { + return WasmResult::InvalidMemoryAccess; + } + return WasmResult::Ok; + } + uint64_t size = PairsUtil::pairsSize(pairs); + uint64_t ptr = 0; + char *buffer = static_cast(context->wasm()->allocMemory(size, &ptr)); + if (buffer == nullptr) { + return WasmResult::InvalidMemoryAccess; + } + if (!PairsUtil::marshalPairs(pairs, buffer, size)) { + return WasmResult::InvalidMemoryAccess; + } + if (!context->wasmVm()->setWord(ptr_ptr, Word(ptr))) { + return WasmResult::InvalidMemoryAccess; + } + if (!context->wasmVm()->setWord(size_ptr, Word(size))) { return WasmResult::InvalidMemoryAccess; } return WasmResult::Ok; } -Word set_header_map_pairs(void *raw_context, Word type, Word ptr, Word size) { +Word set_header_map_pairs(Word type, Word ptr, Word size) { if (type > static_cast(WasmHeaderMapType::MAX)) { return WasmResult::BadArgument; } - auto context = WASM_CONTEXT(raw_context); + auto *context = contextOrEffectiveContext(); auto data = context->wasmVm()->getMemory(ptr, size); if (!data) { return WasmResult::InvalidMemoryAccess; } return context->setHeaderMapPairs(static_cast(type.u64_), - toPairs(data.value())); + PairsUtil::toPairs(data.value())); } -Word get_header_map_size(void *raw_context, Word type, Word result_ptr) { +Word get_header_map_size(Word type, Word result_ptr) { if (type > static_cast(WasmHeaderMapType::MAX)) { return WasmResult::BadArgument; } - auto context = WASM_CONTEXT(raw_context); + auto *context = contextOrEffectiveContext(); uint32_t size; auto result = context->getHeaderMapSize(static_cast(type.u64_), &size); if (result != WasmResult::Ok) { @@ -456,14 +441,13 @@ Word get_header_map_size(void *raw_context, Word type, Word result_ptr) { } // Buffer -Word get_buffer_bytes(void *raw_context, Word type, Word start, Word length, Word ptr_ptr, - Word size_ptr) { +Word get_buffer_bytes(Word type, Word start, Word length, Word ptr_ptr, Word size_ptr) { if (type > static_cast(WasmBufferType::MAX)) { return WasmResult::BadArgument; } - auto context = WASM_CONTEXT(raw_context); - auto buffer = context->getBuffer(static_cast(type.u64_)); - if (!buffer) { + auto *context = contextOrEffectiveContext(); + auto *buffer = context->getBuffer(static_cast(type.u64_)); + if (buffer == nullptr) { return WasmResult::NotFound; } // Check for overflow. @@ -471,22 +455,30 @@ Word get_buffer_bytes(void *raw_context, Word type, Word start, Word length, Wor return WasmResult::BadArgument; } // Don't overread. - if (start + length > buffer->size()) { + if (start > buffer->size()) { + length = 0; + } else if (start + length > buffer->size()) { length = buffer->size() - start; } - if (length > 0) { - return buffer->copyTo(context->wasm(), start, length, ptr_ptr, size_ptr); + if (length == 0) { + if (!context->wasmVm()->setWord(ptr_ptr, Word(0))) { + return WasmResult::InvalidMemoryAccess; + } + if (!context->wasmVm()->setWord(size_ptr, Word(0))) { + return WasmResult::InvalidMemoryAccess; + } + return WasmResult::Ok; } - return WasmResult::Ok; + return buffer->copyTo(context->wasm(), start, length, ptr_ptr, size_ptr); } -Word get_buffer_status(void *raw_context, Word type, Word length_ptr, Word flags_ptr) { +Word get_buffer_status(Word type, Word length_ptr, Word flags_ptr) { if (type > static_cast(WasmBufferType::MAX)) { return WasmResult::BadArgument; } - auto context = WASM_CONTEXT(raw_context); - auto buffer = context->getBuffer(static_cast(type.u64_)); - if (!buffer) { + auto *context = contextOrEffectiveContext(); + auto *buffer = context->getBuffer(static_cast(type.u64_)); + if (buffer == nullptr) { return WasmResult::NotFound; } auto length = buffer->size(); @@ -500,14 +492,13 @@ Word get_buffer_status(void *raw_context, Word type, Word length_ptr, Word flags return WasmResult::Ok; } -Word set_buffer_bytes(void *raw_context, Word type, Word start, Word length, Word data_ptr, - Word data_size) { +Word set_buffer_bytes(Word type, Word start, Word length, Word data_ptr, Word data_size) { if (type > static_cast(WasmBufferType::MAX)) { return WasmResult::BadArgument; } - auto context = WASM_CONTEXT(raw_context); - auto buffer = context->getBuffer(static_cast(type.u64_)); - if (!buffer) { + auto *context = contextOrEffectiveContext(); + auto *buffer = context->getBuffer(static_cast(type.u64_)); + if (buffer == nullptr) { return WasmResult::NotFound; } auto data = context->wasmVm()->getMemory(data_ptr, data_size); @@ -517,10 +508,10 @@ Word set_buffer_bytes(void *raw_context, Word type, Word start, Word length, Wor return buffer->copyFrom(start, length, data.value()); } -Word http_call(void *raw_context, Word uri_ptr, Word uri_size, Word header_pairs_ptr, - Word header_pairs_size, Word body_ptr, Word body_size, Word trailer_pairs_ptr, - Word trailer_pairs_size, Word timeout_milliseconds, Word token_ptr) { - auto context = WASM_CONTEXT(raw_context)->root_context(); +Word http_call(Word uri_ptr, Word uri_size, Word header_pairs_ptr, Word header_pairs_size, + Word body_ptr, Word body_size, Word trailer_pairs_ptr, Word trailer_pairs_size, + Word timeout_milliseconds, Word token_ptr) { + auto *context = contextOrEffectiveContext()->root_context(); auto uri = context->wasmVm()->getMemory(uri_ptr, uri_size); auto body = context->wasmVm()->getMemory(body_ptr, body_size); auto header_pairs = context->wasmVm()->getMemory(header_pairs_ptr, header_pairs_size); @@ -528,8 +519,8 @@ Word http_call(void *raw_context, Word uri_ptr, Word uri_size, Word header_pairs if (!uri || !body || !header_pairs || !trailer_pairs) { return WasmResult::InvalidMemoryAccess; } - auto headers = toPairs(header_pairs.value()); - auto trailers = toPairs(trailer_pairs.value()); + auto headers = PairsUtil::toPairs(header_pairs.value()); + auto trailers = PairsUtil::toPairs(trailer_pairs.value()); uint32_t token = 0; // NB: try to write the token to verify the memory before starting the async // operation. @@ -542,9 +533,8 @@ Word http_call(void *raw_context, Word uri_ptr, Word uri_size, Word header_pairs return result; } -Word define_metric(void *raw_context, Word metric_type, Word name_ptr, Word name_size, - Word metric_id_ptr) { - auto context = WASM_CONTEXT(raw_context); +Word define_metric(Word metric_type, Word name_ptr, Word name_size, Word metric_id_ptr) { + auto *context = contextOrEffectiveContext(); auto name = context->wasmVm()->getMemory(name_ptr, name_size); if (!name) { return WasmResult::InvalidMemoryAccess; @@ -561,18 +551,18 @@ Word define_metric(void *raw_context, Word metric_type, Word name_ptr, Word name return WasmResult::Ok; } -Word increment_metric(void *raw_context, Word metric_id, int64_t offset) { - auto context = WASM_CONTEXT(raw_context); +Word increment_metric(Word metric_id, int64_t offset) { + auto *context = contextOrEffectiveContext(); return context->incrementMetric(metric_id, offset); } -Word record_metric(void *raw_context, Word metric_id, uint64_t value) { - auto context = WASM_CONTEXT(raw_context); +Word record_metric(Word metric_id, uint64_t value) { + auto *context = contextOrEffectiveContext(); return context->recordMetric(metric_id, value); } -Word get_metric(void *raw_context, Word metric_id, Word result_uint64_ptr) { - auto context = WASM_CONTEXT(raw_context); +Word get_metric(Word metric_id, Word result_uint64_ptr) { + auto *context = contextOrEffectiveContext(); uint64_t value = 0; auto result = context->getMetric(metric_id, &value); if (result != WasmResult::Ok) { @@ -584,11 +574,11 @@ Word get_metric(void *raw_context, Word metric_id, Word result_uint64_ptr) { return WasmResult::Ok; } -Word grpc_call(void *raw_context, Word service_ptr, Word service_size, Word service_name_ptr, - Word service_name_size, Word method_name_ptr, Word method_name_size, - Word initial_metadata_ptr, Word initial_metadata_size, Word request_ptr, - Word request_size, Word timeout_milliseconds, Word token_ptr) { - auto context = WASM_CONTEXT(raw_context)->root_context(); +Word grpc_call(Word service_ptr, Word service_size, Word service_name_ptr, Word service_name_size, + Word method_name_ptr, Word method_name_size, Word initial_metadata_ptr, + Word initial_metadata_size, Word request_ptr, Word request_size, + Word timeout_milliseconds, Word token_ptr) { + auto *context = contextOrEffectiveContext()->root_context(); auto service = context->wasmVm()->getMemory(service_ptr, service_size); auto service_name = context->wasmVm()->getMemory(service_name_ptr, service_name_size); auto method_name = context->wasmVm()->getMemory(method_name_ptr, method_name_size); @@ -599,7 +589,7 @@ Word grpc_call(void *raw_context, Word service_ptr, Word service_size, Word serv return WasmResult::InvalidMemoryAccess; } uint32_t token = 0; - auto initial_metadata = toPairs(initial_metadata_pairs.value()); + auto initial_metadata = PairsUtil::toPairs(initial_metadata_pairs.value()); auto result = context->grpcCall(service.value(), service_name.value(), method_name.value(), initial_metadata, request.value(), std::chrono::milliseconds(timeout_milliseconds), &token); @@ -612,10 +602,10 @@ Word grpc_call(void *raw_context, Word service_ptr, Word service_size, Word serv return WasmResult::Ok; } -Word grpc_stream(void *raw_context, Word service_ptr, Word service_size, Word service_name_ptr, - Word service_name_size, Word method_name_ptr, Word method_name_size, - Word initial_metadata_ptr, Word initial_metadata_size, Word token_ptr) { - auto context = WASM_CONTEXT(raw_context)->root_context(); +Word grpc_stream(Word service_ptr, Word service_size, Word service_name_ptr, Word service_name_size, + Word method_name_ptr, Word method_name_size, Word initial_metadata_ptr, + Word initial_metadata_size, Word token_ptr) { + auto *context = contextOrEffectiveContext()->root_context(); auto service = context->wasmVm()->getMemory(service_ptr, service_size); auto service_name = context->wasmVm()->getMemory(service_name_ptr, service_name_size); auto method_name = context->wasmVm()->getMemory(method_name_ptr, method_name_size); @@ -625,7 +615,7 @@ Word grpc_stream(void *raw_context, Word service_ptr, Word service_size, Word se return WasmResult::InvalidMemoryAccess; } uint32_t token = 0; - auto initial_metadata = toPairs(initial_metadata_pairs.value()); + auto initial_metadata = PairsUtil::toPairs(initial_metadata_pairs.value()); auto result = context->grpcStream(service.value(), service_name.value(), method_name.value(), initial_metadata, &token); if (result != WasmResult::Ok) { @@ -637,30 +627,52 @@ Word grpc_stream(void *raw_context, Word service_ptr, Word service_size, Word se return WasmResult::Ok; } -Word grpc_cancel(void *raw_context, Word token) { - auto context = WASM_CONTEXT(raw_context)->root_context(); +Word grpc_cancel(Word token) { + auto *context = contextOrEffectiveContext()->root_context(); return context->grpcCancel(token); } -Word grpc_close(void *raw_context, Word token) { - auto context = WASM_CONTEXT(raw_context)->root_context(); +Word grpc_close(Word token) { + auto *context = contextOrEffectiveContext()->root_context(); return context->grpcClose(token); } -Word grpc_send(void *raw_context, Word token, Word message_ptr, Word message_size, - Word end_stream) { - auto context = WASM_CONTEXT(raw_context)->root_context(); +Word grpc_send(Word token, Word message_ptr, Word message_size, Word end_stream) { + auto *context = contextOrEffectiveContext()->root_context(); auto message = context->wasmVm()->getMemory(message_ptr, message_size); if (!message) { return WasmResult::InvalidMemoryAccess; } - return context->grpcSend(token, message.value(), end_stream); + return context->grpcSend(token, message.value(), end_stream != 0U); +} + +// WASIp1 typings in comments sourced from +// https://github.com/WebAssembly/wasi-libc/blob/446cb3f1aa21f9b1a1eab372f82d65d19003e924/libc-bottom-half/headers/public/wasi/api.h + +// __wasi_errno_t path_open(__wasi_fd_t fd, __wasi_lookupflags_t dirflags, const char *path, +// size_t path_len, __wasi_oflags_t oflags, __wasi_rights_t fs_rights_base, __wasi_rights_t +// fs_rights_inheriting, __wasi_fdflags_t fdflags, __wasi_fd_t *retptr0) +Word wasi_unstable_path_open(Word /*fd*/, Word /*dir_flags*/, Word /*path*/, Word /*path_len*/, + Word /*oflags*/, int64_t /*fs_rights_base*/, + int64_t /*fg_rights_inheriting*/, Word /*fd_flags*/, + Word /*nwritten_ptr*/) { + return 44; // __WASI_ERRNO_NOENT +} + +// __wasi_errno_t __wasi_fd_prestat_get(__wasi_fd_t fd, __wasi_prestat_t *retptr0) +Word wasi_unstable_fd_prestat_get(Word /*fd*/, Word /*buf_ptr*/) { + return 8; // __WASI_ERRNO_BADF +} + +// __wasi_errno_t __wasi_fd_prestat_dir_name(__wasi_fd_t fd, uint8_t * path, __wasi_size_t path_len) +Word wasi_unstable_fd_prestat_dir_name(Word /*fd*/, Word /*path_ptr*/, Word /*path_len*/) { + return 52; // __WASI_ERRNO_ENOSYS } // Implementation of writev-like() syscall that redirects stdout/stderr to Envoy // logs. -Word writevImpl(void *raw_context, Word fd, Word iovs, Word iovs_len, Word *nwritten_ptr) { - auto context = WASM_CONTEXT(raw_context); +Word writevImpl(Word fd, Word iovs, Word iovs_len, Word *nwritten_ptr) { + auto *context = contextOrEffectiveContext(); // Read syscall args. uint64_t log_level; @@ -682,9 +694,11 @@ Word writevImpl(void *raw_context, Word fd, Word iovs, Word iovs_len, Word *nwri if (!memslice) { return 21; // __WASI_EFAULT } - const uint32_t *iovec = reinterpret_cast(memslice.value().data()); - if (iovec[1] /* buf_len */) { - memslice = context->wasmVm()->getMemory(iovec[0] /* buf */, iovec[1] /* buf_len */); + const auto *iovec = reinterpret_cast(memslice.value().data()); + if (iovec[1] != 0U /* buf_len */) { + const auto buf = wasmtoh(iovec[0], context->wasmVm()->usesWasmByteOrder()); + const auto buf_len = wasmtoh(iovec[1], context->wasmVm()->usesWasmByteOrder()); + memslice = context->wasmVm()->getMemory(buf, buf_len); if (!memslice) { return 21; // __WASI_EFAULT } @@ -693,7 +707,7 @@ Word writevImpl(void *raw_context, Word fd, Word iovs, Word iovs_len, Word *nwri } size_t written = s.size(); - if (written) { + if (written != 0U) { // Remove trailing newline from the logs, if any. if (s[written - 1] == '\n') { s.erase(written - 1); @@ -708,12 +722,11 @@ Word writevImpl(void *raw_context, Word fd, Word iovs, Word iovs_len, Word *nwri // __wasi_errno_t __wasi_fd_write(_wasi_fd_t fd, const _wasi_ciovec_t *iov, // size_t iovs_len, size_t* nwritten); -Word wasi_unstable_fd_write(void *raw_context, Word fd, Word iovs, Word iovs_len, - Word nwritten_ptr) { - auto context = WASM_CONTEXT(raw_context); +Word wasi_unstable_fd_write(Word fd, Word iovs, Word iovs_len, Word nwritten_ptr) { + auto *context = contextOrEffectiveContext(); Word nwritten(0); - auto result = writevImpl(raw_context, fd, iovs, iovs_len, &nwritten); + auto result = writevImpl(fd, iovs, iovs_len, &nwritten); if (result != 0) { // __WASI_ESUCCESS return result; } @@ -725,28 +738,29 @@ Word wasi_unstable_fd_write(void *raw_context, Word fd, Word iovs, Word iovs_len // __wasi_errno_t __wasi_fd_read(_wasi_fd_t fd, const __wasi_iovec_t *iovs, // size_t iovs_len, __wasi_size_t *nread); -Word wasi_unstable_fd_read(void *, Word, Word, Word, Word) { +Word wasi_unstable_fd_read(Word /*fd*/, Word /*iovs_ptr*/, Word /*iovs_len*/, Word /*nread_ptr*/) { // Don't support reading of any files. return 52; // __WASI_ERRNO_ENOSYS } // __wasi_errno_t __wasi_fd_seek(__wasi_fd_t fd, __wasi_filedelta_t offset, // __wasi_whence_t whence,__wasi_filesize_t *newoffset); -Word wasi_unstable_fd_seek(void *raw_context, Word, int64_t, Word, Word) { - auto context = WASM_CONTEXT(raw_context); +Word wasi_unstable_fd_seek(Word /*fd*/, int64_t /*offset*/, Word /*whence*/, + Word /*newoffset_ptr*/) { + auto *context = contextOrEffectiveContext(); context->error("wasi_unstable fd_seek"); return 0; } // __wasi_errno_t __wasi_fd_close(__wasi_fd_t fd); -Word wasi_unstable_fd_close(void *raw_context, Word) { - auto context = WASM_CONTEXT(raw_context); +Word wasi_unstable_fd_close(Word /*fd*/) { + auto *context = contextOrEffectiveContext(); context->error("wasi_unstable fd_close"); return 0; } // __wasi_errno_t __wasi_fd_fdstat_get(__wasi_fd_t fd, __wasi_fdstat_t *stat) -Word wasi_unstable_fd_fdstat_get(void *raw_context, Word fd, Word statOut) { +Word wasi_unstable_fd_fdstat_get(Word fd, Word statOut) { // We will only support this interface on stdout and stderr if (fd != 1 && fd != 2) { return 8; // __WASI_EBADF; @@ -759,38 +773,73 @@ Word wasi_unstable_fd_fdstat_get(void *raw_context, Word fd, Word statOut) { wasi_fdstat[1] = 64; // This sets "fs_rights_base" to __WASI_RIGHTS_FD_WRITE wasi_fdstat[2] = 0; - auto context = WASM_CONTEXT(raw_context); + auto *context = contextOrEffectiveContext(); context->wasmVm()->setMemory(statOut, 3 * sizeof(uint64_t), &wasi_fdstat); return 0; // __WASI_ESUCCESS } +// __wasi_errno_t __wasi_fd_fdstat_set_flags(__wasi_fd_t fd, __wasi_fdflags_t flags) +Word wasi_unstable_fd_fdstat_set_flags(Word /*fd*/, Word /*flags*/) { + // Flags that can be specified: append, dsync, nonblock, rsync, and sync. Proxy-wasm only supports + // STDOUT and STDERR, but none of these flags have any effect in Proxy-Wasm. + return 52; // __WASI_ERRNO_ENOSYS +} + // __wasi_errno_t __wasi_environ_get(char **environ, char *environ_buf); -Word wasi_unstable_environ_get(void *, Word, Word) { +Word wasi_unstable_environ_get(Word environ_array_ptr, Word environ_buf) { + auto *context = contextOrEffectiveContext(); + auto word_size = context->wasmVm()->getWordSize(); + const auto &envs = context->wasm()->envs(); + for (const auto &e : envs) { + if (!context->wasmVm()->setWord(environ_array_ptr, environ_buf)) { + return 21; // __WASI_EFAULT + } + + std::string data; + data.reserve(e.first.size() + e.second.size() + 2); + data.append(e.first); + data.append("="); + data.append(e.second); + data.append({0x0}); + if (!context->wasmVm()->setMemory(environ_buf, data.size(), data.c_str())) { + return 21; // __WASI_EFAULT + } + environ_buf = environ_buf.u64_ + data.size(); + environ_array_ptr = environ_array_ptr.u64_ + word_size; + } + return 0; // __WASI_ESUCCESS } // __wasi_errno_t __wasi_environ_sizes_get(size_t *environ_count, size_t // *environ_buf_size); -Word wasi_unstable_environ_sizes_get(void *raw_context, Word count_ptr, Word buf_size_ptr) { - auto context = WASM_CONTEXT(raw_context); - if (!context->wasmVm()->setWord(count_ptr, Word(0))) { +Word wasi_unstable_environ_sizes_get(Word count_ptr, Word buf_size_ptr) { + auto *context = contextOrEffectiveContext(); + const auto &envs = context->wasm()->envs(); + if (!context->wasmVm()->setWord(count_ptr, Word(envs.size()))) { return 21; // __WASI_EFAULT } - if (!context->wasmVm()->setWord(buf_size_ptr, Word(0))) { + + size_t size = 0; + for (const auto &e : envs) { + // len(key) + len(value) + 1('=') + 1(null terminator) + size += e.first.size() + e.second.size() + 2; + } + if (!context->wasmVm()->setWord(buf_size_ptr, Word(size))) { return 21; // __WASI_EFAULT } return 0; // __WASI_ESUCCESS } -// __wasi_errno_t __wasi_args_get(size_t **argv, size_t *argv_buf); -Word wasi_unstable_args_get(void *, Word, Word) { +// __wasi_errno_t __wasi_args_get(uint8_t **argv, uint8_t *argv_buf); +Word wasi_unstable_args_get(Word /*argv_array_ptr*/, Word /*argv_buf_ptr*/) { return 0; // __WASI_ESUCCESS } // __wasi_errno_t __wasi_args_sizes_get(size_t *argc, size_t *argv_buf_size); -Word wasi_unstable_args_sizes_get(void *raw_context, Word argc_ptr, Word argv_buf_size_ptr) { - auto context = WASM_CONTEXT(raw_context); +Word wasi_unstable_args_sizes_get(Word argc_ptr, Word argv_buf_size_ptr) { + auto *context = contextOrEffectiveContext(); if (!context->wasmVm()->setWord(argc_ptr, Word(0))) { return 21; // __WASI_EFAULT } @@ -801,15 +850,22 @@ Word wasi_unstable_args_sizes_get(void *raw_context, Word argc_ptr, Word argv_bu } // __wasi_errno_t __wasi_clock_time_get(uint32_t id, uint64_t precision, uint64_t* time); -Word wasi_unstable_clock_time_get(void *raw_context, Word clock_id, uint64_t precision, +Word wasi_unstable_clock_time_get(Word clock_id, uint64_t /*precision*/, Word result_time_uint64_ptr) { - if (clock_id != 0 /* realtime */) { + uint64_t result = 0; + auto *context = contextOrEffectiveContext(); + switch (clock_id) { + case 0 /* realtime */: + result = context->getCurrentTimeNanoseconds(); + break; + case 1 /* monotonic */: + result = context->getMonotonicTimeNanoseconds(); + break; + default: + // process_cputime_id and thread_cputime_id are not supported yet. return 58; // __WASI_ENOTSUP } - - auto context = WASM_CONTEXT(raw_context); - uint64_t result = context->getCurrentTimeNanoseconds(); if (!context->wasm()->setDatatype(result_time_uint64_ptr, result)) { return 21; // __WASI_EFAULT } @@ -817,8 +873,14 @@ Word wasi_unstable_clock_time_get(void *raw_context, Word clock_id, uint64_t pre } // __wasi_errno_t __wasi_random_get(uint8_t *buf, size_t buf_len); -Word wasi_unstable_random_get(void *raw_context, Word result_buf_ptr, Word buf_len) { - auto context = WASM_CONTEXT(raw_context); +Word wasi_unstable_random_get(Word result_buf_ptr, Word buf_len) { + if (buf_len > PROXY_WASM_HOST_WASI_RANDOM_GET_MAX_SIZE_BYTES) { + return 28; // __WASI_EINVAL + } + if (buf_len == 0) { + return 0; // __WASI_ESUCCESS + } + auto *context = contextOrEffectiveContext(); std::vector random(buf_len); RAND_bytes(random.data(), random.size()); if (!context->wasmVm()->setMemory(result_buf_ptr, random.size(), random.data())) { @@ -827,22 +889,39 @@ Word wasi_unstable_random_get(void *raw_context, Word result_buf_ptr, Word buf_l return 0; // __WASI_ESUCCESS } +// __wasi_errno_t __wasi_sched_yield() +Word wasi_unstable_sched_yield() { + // Per POSIX man pages, it is valid to return success if the calling thread is the only thread in + // the highest priority list. This is vacuously true for wasm without threads. There are no valid + // error cases defined. + return 0; // __WASI_ESUCCESS +} + +// __wasi_errno_t __wasi_poll_oneoff(const __wasi_subscription_t *in, __wasi_event_t *out, +// __wasi_size_t nsubscriptions, __wasi_size_t *nevents) +Word wasi_unstable_poll_oneoff(Word /*in*/, Word /*out*/, Word /*nsubscriptions*/, + Word /*nevents_ptr*/) { + return 52; // __WASI_ERRNO_ENOSYS +} + // void __wasi_proc_exit(__wasi_exitcode_t rval); -void wasi_unstable_proc_exit(void *raw_context, Word) { - auto context = WASM_CONTEXT(raw_context); +void wasi_unstable_proc_exit(Word /*exit_code*/) { + auto *context = contextOrEffectiveContext(); context->error("wasi_unstable proc_exit"); } -Word pthread_equal(void *, Word left, Word right) { return left == right; } +Word pthread_equal(Word left, Word right) { return static_cast(left == right); } + +void emscripten_notify_memory_growth(Word /*memory_index*/) {} -Word set_tick_period_milliseconds(void *raw_context, Word period_milliseconds) { +Word set_tick_period_milliseconds(Word period_milliseconds) { TimerToken token = 0; - return WASM_CONTEXT(raw_context) - ->setTimerPeriod(std::chrono::milliseconds(period_milliseconds), &token); + return contextOrEffectiveContext()->setTimerPeriod(std::chrono::milliseconds(period_milliseconds), + &token); } -Word get_current_time_nanoseconds(void *raw_context, Word result_uint64_ptr) { - auto context = WASM_CONTEXT(raw_context); +Word get_current_time_nanoseconds(Word result_uint64_ptr) { + auto *context = contextOrEffectiveContext(); uint64_t result = context->getCurrentTimeNanoseconds(); if (!context->wasm()->setDatatype(result_uint64_ptr, result)) { return WasmResult::InvalidMemoryAccess; @@ -850,11 +929,11 @@ Word get_current_time_nanoseconds(void *raw_context, Word result_uint64_ptr) { return WasmResult::Ok; } -Word log(void *raw_context, Word level, Word address, Word size) { +Word log(Word level, Word address, Word size) { if (level > static_cast(LogLevel::Max)) { return WasmResult::BadArgument; } - auto context = WASM_CONTEXT(raw_context); + auto *context = contextOrEffectiveContext(); auto message = context->wasmVm()->getMemory(address, size); if (!message) { return WasmResult::InvalidMemoryAccess; @@ -862,8 +941,8 @@ Word log(void *raw_context, Word level, Word address, Word size) { return context->log(level, message.value()); } -Word get_log_level(void *raw_context, Word result_level_uint32_ptr) { - auto context = WASM_CONTEXT(raw_context); +Word get_log_level(Word result_level_uint32_ptr) { + auto *context = contextOrEffectiveContext(); uint32_t level = context->getLogLevel(); if (!context->wasm()->setDatatype(result_level_uint32_ptr, level)) { return WasmResult::InvalidMemoryAccess; diff --git a/src/foreign.cc b/src/foreign.cc deleted file mode 100644 index 34335697c..000000000 --- a/src/foreign.cc +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2016-2019 Envoy Project Authors -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "include/proxy-wasm/wasm.h" - -#ifndef WITHOUT_ZLIB -#include "zlib.h" -#endif - -namespace proxy_wasm { -namespace { - -#ifndef WITHOUT_ZLIB -RegisterForeignFunction compressFunction( - "compress", - [](WasmBase &, std::string_view arguments, - std::function alloc_result) -> WasmResult { - unsigned long dest_len = compressBound(arguments.size()); - std::unique_ptr b(new unsigned char[dest_len]); - if (compress(b.get(), &dest_len, reinterpret_cast(arguments.data()), - arguments.size()) != Z_OK) { - return WasmResult::SerializationFailure; - } - auto result = alloc_result(dest_len); - memcpy(result, b.get(), dest_len); - return WasmResult::Ok; - }); - -RegisterForeignFunction - uncompressFunction("uncompress", - [](WasmBase &, std::string_view arguments, - std::function alloc_result) -> WasmResult { - unsigned long dest_len = arguments.size() * 2 + 2; // output estimate. - while (1) { - std::unique_ptr b(new unsigned char[dest_len]); - auto r = - uncompress(b.get(), &dest_len, - reinterpret_cast(arguments.data()), - arguments.size()); - if (r == Z_OK) { - auto result = alloc_result(dest_len); - memcpy(result, b.get(), dest_len); - return WasmResult::Ok; - } - if (r != Z_MEM_ERROR) { - return WasmResult::SerializationFailure; - } - dest_len = dest_len * 2; - } - }); -#endif - -} // namespace -} // namespace proxy_wasm diff --git a/src/hash.cc b/src/hash.cc new file mode 100644 index 000000000..f2d1ded13 --- /dev/null +++ b/src/hash.cc @@ -0,0 +1,54 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "src/hash.h" + +#include +#include + +#include + +namespace proxy_wasm { + +namespace { + +std::string BytesToHex(const std::vector &bytes) { + static const char *const hex = "0123456789ABCDEF"; + std::string result; + result.reserve(bytes.size() * 2); + for (auto byte : bytes) { + result.push_back(hex[byte >> 4]); + result.push_back(hex[byte & 0xf]); + } + return result; +} + +} // namespace + +std::vector Sha256(const std::vector &parts) { + uint8_t sha256[SHA256_DIGEST_LENGTH]; + SHA256_CTX sha_ctx; + SHA256_Init(&sha_ctx); + for (auto part : parts) { + SHA256_Update(&sha_ctx, part.data(), part.size()); + } + SHA256_Final(sha256, &sha_ctx); + return std::vector(std::begin(sha256), std::end(sha256)); +} + +std::string Sha256String(const std::vector &parts) { + return BytesToHex(Sha256(parts)); +} + +} // namespace proxy_wasm \ No newline at end of file diff --git a/src/third_party/base64.h b/src/hash.h similarity index 66% rename from src/third_party/base64.h rename to src/hash.h index 1340ed768..40d03e9d4 100644 --- a/src/third_party/base64.h +++ b/src/hash.h @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,14 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Original source Public Domain: -// https://en.wikibooks.org/wiki/Algorithm_Implementation/Miscellaneous/Base64 - #pragma once -#include #include #include -std::string base64Encode(const uint8_t *start, const uint8_t *end); -bool base64Decode(const std::string &input, std::vector *output); +#include + +namespace proxy_wasm { + +std::vector Sha256(const std::vector &parts); +std::string Sha256String(const std::vector &parts); + +} // namespace proxy_wasm diff --git a/src/null/null_plugin.cc b/src/null/null_plugin.cc index cea740707..689225687 100644 --- a/src/null/null_plugin.cc +++ b/src/null/null_plugin.cc @@ -15,9 +15,9 @@ #include "include/proxy-wasm/null_plugin.h" +#include +#include #include -#include -#include #include #include @@ -26,16 +26,15 @@ #include #include -#include "include/proxy-wasm/null_plugin.h" #include "include/proxy-wasm/null_vm.h" #include "include/proxy-wasm/wasm.h" namespace proxy_wasm { void NullPlugin::getFunction(std::string_view function_name, WasmCallVoid<0> *f) { - if (function_name == "_start") { + if (function_name == "_initialize") { *f = nullptr; - } else if (function_name == "__wasm_call_ctors") { + } else if (function_name == "_start") { *f = nullptr; } else if (!wasm_vm_->integration()->getNullVmFunction(function_name, false, 0, this, f)) { error("Missing getFunction for: " + std::string(function_name)); @@ -44,7 +43,7 @@ void NullPlugin::getFunction(std::string_view function_name, WasmCallVoid<0> *f) } void NullPlugin::getFunction(std::string_view function_name, WasmCallVoid<1> *f) { - auto plugin = this; + auto *plugin = this; if (function_name == "proxy_on_tick") { *f = [plugin](ContextBase *context, Word context_id) { SaveRestoreContext saved_context(context); @@ -67,7 +66,7 @@ void NullPlugin::getFunction(std::string_view function_name, WasmCallVoid<1> *f) } void NullPlugin::getFunction(std::string_view function_name, WasmCallVoid<2> *f) { - auto plugin = this; + auto *plugin = this; if (function_name == "proxy_on_context_create") { *f = [plugin](ContextBase *context, Word context_id, Word parent_context_id) { SaveRestoreContext saved_context(context); @@ -95,7 +94,7 @@ void NullPlugin::getFunction(std::string_view function_name, WasmCallVoid<2> *f) } void NullPlugin::getFunction(std::string_view function_name, WasmCallVoid<3> *f) { - auto plugin = this; + auto *plugin = this; if (function_name == "proxy_on_grpc_close") { *f = [plugin](ContextBase *context, Word context_id, Word token, Word status_code) { SaveRestoreContext saved_context(context); @@ -128,7 +127,7 @@ void NullPlugin::getFunction(std::string_view function_name, WasmCallVoid<3> *f) } void NullPlugin::getFunction(std::string_view function_name, WasmCallVoid<5> *f) { - auto plugin = this; + auto *plugin = this; if (function_name == "proxy_on_http_call_response") { *f = [plugin](ContextBase *context, Word context_id, Word token, Word headers, Word body_size, Word trailers) { @@ -142,9 +141,9 @@ void NullPlugin::getFunction(std::string_view function_name, WasmCallVoid<5> *f) } void NullPlugin::getFunction(std::string_view function_name, WasmCallWord<1> *f) { - auto plugin = this; + auto *plugin = this; if (function_name == "malloc") { - *f = [](ContextBase *, Word size) -> Word { + *f = [](ContextBase * /*context*/, Word size) -> Word { return Word(reinterpret_cast(::malloc(size))); }; } else if (function_name == "proxy_on_new_connection") { @@ -164,21 +163,24 @@ void NullPlugin::getFunction(std::string_view function_name, WasmCallWord<1> *f) } void NullPlugin::getFunction(std::string_view function_name, WasmCallWord<2> *f) { - auto plugin = this; - if (function_name == "proxy_on_vm_start") { + auto *plugin = this; + if (function_name == "main") { + *f = nullptr; + } else if (function_name == "proxy_on_vm_start") { *f = [plugin](ContextBase *context, Word context_id, Word configuration_size) { SaveRestoreContext saved_context(context); - return Word(plugin->onStart(context_id, configuration_size)); + return Word(static_cast(plugin->onStart(context_id, configuration_size))); }; } else if (function_name == "proxy_on_configure") { *f = [plugin](ContextBase *context, Word context_id, Word configuration_size) { SaveRestoreContext saved_context(context); - return Word(plugin->onConfigure(context_id, configuration_size)); + return Word(static_cast(plugin->onConfigure(context_id, configuration_size))); }; } else if (function_name == "proxy_validate_configuration") { *f = [plugin](ContextBase *context, Word context_id, Word configuration_size) { SaveRestoreContext saved_context(context); - return Word(plugin->validateConfiguration(context_id, configuration_size)); + return Word( + static_cast(plugin->validateConfiguration(context_id, configuration_size))); }; } else if (function_name == "proxy_on_request_trailers") { *f = [plugin](ContextBase *context, Word context_id, Word trailers) -> Word { @@ -207,7 +209,7 @@ void NullPlugin::getFunction(std::string_view function_name, WasmCallWord<2> *f) } void NullPlugin::getFunction(std::string_view function_name, WasmCallWord<3> *f) { - auto plugin = this; + auto *plugin = this; if (function_name == "proxy_on_downstream_data") { *f = [plugin](ContextBase *context, Word context_id, Word body_buffer_length, Word end_of_stream) -> Word { @@ -251,9 +253,9 @@ void NullPlugin::getFunction(std::string_view function_name, WasmCallWord<3> *f) null_plugin::Context *NullPlugin::ensureContext(uint64_t context_id, uint64_t root_context_id) { auto e = context_map_.insert(std::make_pair(context_id, nullptr)); if (e.second) { - auto root_base = context_map_[root_context_id].get(); - null_plugin::RootContext *root = root_base ? root_base->asRoot() : nullptr; - std::string root_id = root ? std::string(root->root_id()) : ""; + auto *root_base = context_map_[root_context_id].get(); + null_plugin::RootContext *root = (root_base != nullptr) ? root_base->asRoot() : nullptr; + std::string root_id = (root != nullptr) ? std::string(root->root_id()) : ""; auto factory = registry_->context_factories[root_id]; if (!factory) { error("no context factory for root_id: " + root_id); @@ -295,7 +297,8 @@ null_plugin::RootContext *NullPlugin::ensureRootContext(uint64_t context_id) { null_plugin::ContextBase *NullPlugin::getContextBase(uint64_t context_id) { auto it = context_map_.find(context_id); - if (it == context_map_.end() || !(it->second->asContext() || it->second->asRoot())) { + if (it == context_map_.end() || + !(it->second->asContext() != nullptr || it->second->asRoot() != nullptr)) { error("no base context context_id: " + std::to_string(context_id)); return nullptr; } @@ -304,7 +307,7 @@ null_plugin::ContextBase *NullPlugin::getContextBase(uint64_t context_id) { null_plugin::Context *NullPlugin::getContext(uint64_t context_id) { auto it = context_map_.find(context_id); - if (it == context_map_.end() || !it->second->asContext()) { + if (it == context_map_.end() || (it->second->asContext() == nullptr)) { error("no context context_id: " + std::to_string(context_id)); return nullptr; } @@ -313,7 +316,7 @@ null_plugin::Context *NullPlugin::getContext(uint64_t context_id) { null_plugin::RootContext *NullPlugin::getRootContext(uint64_t context_id) { auto it = context_map_.find(context_id); - if (it == context_map_.end() || !it->second->asRoot()) { + if (it == context_map_.end() || (it->second->asRoot() == nullptr)) { error("no root context_id: " + std::to_string(context_id)); return nullptr; } @@ -333,32 +336,32 @@ bool NullPlugin::validateConfiguration(uint64_t root_context_id, uint64_t config } bool NullPlugin::onStart(uint64_t root_context_id, uint64_t vm_configuration_size) { - if (registry_->proxy_on_vm_start_) { - return registry_->proxy_on_vm_start_(root_context_id, vm_configuration_size); + if (registry_->proxy_on_vm_start_ != nullptr) { + return registry_->proxy_on_vm_start_(root_context_id, vm_configuration_size) != 0U; } - return getRootContext(root_context_id)->onStart(vm_configuration_size) != 0; + return getRootContext(root_context_id)->onStart(vm_configuration_size); } bool NullPlugin::onConfigure(uint64_t root_context_id, uint64_t plugin_configuration_size) { - if (registry_->proxy_on_configure_) { - return registry_->proxy_on_configure_(root_context_id, plugin_configuration_size); + if (registry_->proxy_on_configure_ != nullptr) { + return registry_->proxy_on_configure_(root_context_id, plugin_configuration_size) != 0U; } return getRootContext(root_context_id)->onConfigure(plugin_configuration_size); } void NullPlugin::onTick(uint64_t root_context_id) { - if (registry_->proxy_on_tick_) { + if (registry_->proxy_on_tick_ != nullptr) { return registry_->proxy_on_tick_(root_context_id); } getRootContext(root_context_id)->onTick(); } void NullPlugin::onCreate(uint64_t context_id, uint64_t parent_context_id) { - if (registry_->proxy_on_context_create_) { + if (registry_->proxy_on_context_create_ != nullptr) { registry_->proxy_on_context_create_(context_id, parent_context_id); return; } - if (parent_context_id) { + if (parent_context_id != 0U) { ensureContext(context_id, parent_context_id)->onCreate(); } else { ensureRootContext(context_id)->onCreate(); @@ -461,14 +464,14 @@ void NullPlugin::onQueueReady(uint64_t context_id, uint64_t token) { void NullPlugin::onForeignFunction(uint64_t context_id, uint64_t foreign_function_id, uint64_t data_size) { - if (registry_->proxy_on_foreign_function_) { + if (registry_->proxy_on_foreign_function_ != nullptr) { return registry_->proxy_on_foreign_function_(context_id, foreign_function_id, data_size); } getContextBase(context_id)->onForeignFunction(foreign_function_id, data_size); } void NullPlugin::onLog(uint64_t context_id) { - if (registry_->proxy_on_log_) { + if (registry_->proxy_on_log_ != nullptr) { registry_->proxy_on_log_(context_id); return; } @@ -476,14 +479,14 @@ void NullPlugin::onLog(uint64_t context_id) { } uint64_t NullPlugin::onDone(uint64_t context_id) { - if (registry_->proxy_on_done_) { + if (registry_->proxy_on_done_ != nullptr) { return registry_->proxy_on_done_(context_id); } return getContextBase(context_id)->onDoneBase() ? 1 : 0; } void NullPlugin::onDelete(uint64_t context_id) { - if (registry_->proxy_on_delete_) { + if (registry_->proxy_on_delete_ != nullptr) { registry_->proxy_on_delete_(context_id); return; } @@ -494,13 +497,13 @@ void NullPlugin::onDelete(uint64_t context_id) { namespace null_plugin { RootContext *nullVmGetRoot(std::string_view root_id) { - auto null_vm = static_cast(current_context_->wasmVm()); - return static_cast(null_vm->plugin_.get())->getRoot(root_id); + auto *null_vm = dynamic_cast(current_context_->wasmVm()); + return dynamic_cast(null_vm->plugin_.get())->getRoot(root_id); } Context *nullVmGetContext(uint32_t context_id) { - auto null_vm = static_cast(current_context_->wasmVm()); - return static_cast(null_vm->plugin_.get())->getContext(context_id); + auto *null_vm = dynamic_cast(current_context_->wasmVm()); + return dynamic_cast(null_vm->plugin_.get())->getContext(context_id); } RootContext *getRoot(std::string_view root_id) { return nullVmGetRoot(root_id); } diff --git a/src/null/null_vm.cc b/src/null/null_vm.cc index 2159c1223..9772b58ef 100644 --- a/src/null/null_vm.cc +++ b/src/null/null_vm.cc @@ -15,8 +15,9 @@ #include "include/proxy-wasm/null_vm.h" -#include +#include +#include #include #include #include @@ -30,34 +31,37 @@ std::unordered_map *null_vm_plugin_factories_ RegisterNullVmPluginFactory::RegisterNullVmPluginFactory(std::string_view name, NullVmPluginFactory factory) { - if (!null_vm_plugin_factories_) + if (null_vm_plugin_factories_ == nullptr) { null_vm_plugin_factories_ = new std::remove_reference::type; - (*null_vm_plugin_factories_)[std::string(name)] = factory; + } + (*null_vm_plugin_factories_)[std::string(name)] = std::move(factory); } std::unique_ptr NullVm::clone() { auto cloned_null_vm = std::make_unique(*this); - if (integration()) + if (integration()) { cloned_null_vm->integration().reset(integration()->clone()); - cloned_null_vm->load(plugin_name_, false /* unused */); + } + cloned_null_vm->load(plugin_name_, {} /* unused */, {} /* unused */); return cloned_null_vm; } // "Load" the plugin by obtaining a pointer to it from the factory. -bool NullVm::load(const std::string &name, bool /* allow_precompiled */) { - if (!null_vm_plugin_factories_) +bool NullVm::load(std::string_view plugin_name, std::string_view /*precompiled*/, + const std::unordered_map & /*function_names*/) { + if (null_vm_plugin_factories_ == nullptr) { return false; - auto factory = (*null_vm_plugin_factories_)[name]; - if (!factory) + } + auto factory = (*null_vm_plugin_factories_)[std::string(plugin_name)]; + if (!factory) { return false; - plugin_name_ = name; + } + plugin_name_ = plugin_name; plugin_ = factory(); plugin_->wasm_vm_ = this; return true; -} - -AbiVersion NullVm::getAbiVersion() { return AbiVersion::ProxyWasm_0_2_1; } +} // namespace proxy_wasm bool NullVm::link(std::string_view /* name */) { return true; } @@ -72,14 +76,13 @@ std::optional NullVm::getMemory(uint64_t pointer, uint64_t siz } bool NullVm::setMemory(uint64_t pointer, uint64_t size, const void *data) { - if ((pointer == 0 || data == nullptr)) { + if (pointer == 0 || data == nullptr) { if (size != 0) { return false; - } else { - return true; } + return true; } - auto p = reinterpret_cast(pointer); + auto *p = reinterpret_cast(pointer); memcpy(p, data, size); return true; } @@ -88,7 +91,7 @@ bool NullVm::setWord(uint64_t pointer, Word data) { if (pointer == 0) { return false; } - auto p = reinterpret_cast(pointer); + auto *p = reinterpret_cast(pointer); memcpy(p, &data.u64_, sizeof(data.u64_)); return true; } @@ -97,15 +100,12 @@ bool NullVm::getWord(uint64_t pointer, Word *data) { if (pointer == 0) { return false; } - auto p = reinterpret_cast(pointer); + auto *p = reinterpret_cast(pointer); memcpy(&data->u64_, p, sizeof(data->u64_)); return true; } -std::string_view NullVm::getCustomSection(std::string_view /* name */) { - // Return nothing: there is no WASM file. - return {}; -} +size_t NullVm::getWordSize() { return sizeof(uint64_t); } std::string_view NullVm::getPrecompiledSectionName() { // Return nothing: there is no WASM file. diff --git a/src/pairs_util.cc b/src/pairs_util.cc new file mode 100644 index 000000000..b8121882f --- /dev/null +++ b/src/pairs_util.cc @@ -0,0 +1,205 @@ +// Copyright 2016-2019 Envoy Project Authors +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "include/proxy-wasm/pairs_util.h" + +#include +#include +#include +#include + +#include "include/proxy-wasm/exports.h" +#include "include/proxy-wasm/limits.h" +#include "include/proxy-wasm/word.h" + +namespace proxy_wasm { + +namespace { + +// Read trivially copyable type from char buffer and return value. Does not +// check if char buffer is large enough to contain instance of `T`. +template inline T unalignedLoad(const char *buffer) { + // Checking for undefined behaviour wrt std::memcpy. + static_assert(std::is_trivially_copyable_v, + "type must be trivially copyable to use std::memcpy"); + T result; + // Use std::memcpy to get around strict type aliasing rules. + std::memcpy(&result, buffer, sizeof(T)); + + return result; +} + +} // namespace + +using Sizes = std::vector>; + +size_t PairsUtil::pairsSize(const Pairs &pairs) { + size_t size = sizeof(uint32_t); // number of headers + for (const auto &p : pairs) { + size += 2 * sizeof(uint32_t); // size of name, size of value + size += p.first.size() + 1; // NULL-terminated name + size += p.second.size() + 1; // NULL-terminated value + } + return size; +} + +bool PairsUtil::marshalPairs(const Pairs &pairs, char *buffer, size_t size) { + if (buffer == nullptr) { + return false; + } + + char *pos = buffer; + const char *end = buffer + size; + + // Write number of pairs. + uint32_t num_pairs = + htowasm(pairs.size(), contextOrEffectiveContext() != nullptr + ? contextOrEffectiveContext()->wasmVm()->usesWasmByteOrder() + : false); + if (pos + sizeof(uint32_t) > end) { + return false; + } + ::memcpy(pos, &num_pairs, sizeof(uint32_t)); + pos += sizeof(uint32_t); + + for (const auto &p : pairs) { + // Write name length. + uint32_t name_len = + htowasm(p.first.size(), contextOrEffectiveContext() != nullptr + ? contextOrEffectiveContext()->wasmVm()->usesWasmByteOrder() + : false); + if (pos + sizeof(uint32_t) > end) { + return false; + } + ::memcpy(pos, &name_len, sizeof(uint32_t)); + pos += sizeof(uint32_t); + + // Write value length. + uint32_t value_len = + htowasm(p.second.size(), contextOrEffectiveContext() != nullptr + ? contextOrEffectiveContext()->wasmVm()->usesWasmByteOrder() + : false); + if (pos + sizeof(uint32_t) > end) { + return false; + } + ::memcpy(pos, &value_len, sizeof(uint32_t)); + pos += sizeof(uint32_t); + } + + for (const auto &p : pairs) { + // Write name. + if (pos + p.first.size() + 1 > end) { + return false; + } + ::memcpy(pos, p.first.data(), p.first.size()); + pos += p.first.size(); + *pos++ = '\0'; // NULL-terminated string. + + // Write value. + if (pos + p.second.size() + 1 > end) { + return false; + } + ::memcpy(pos, p.second.data(), p.second.size()); + pos += p.second.size(); + *pos++ = '\0'; // NULL-terminated string. + } + + return pos == end; +} + +Pairs PairsUtil::toPairs(std::string_view buffer) { + if (buffer.data() == nullptr || buffer.size() > PROXY_WASM_HOST_PAIRS_MAX_BYTES) { + return {}; + } + + const char *pos = buffer.data(); + const char *end = buffer.data() + buffer.size(); + + // Read number of pairs. + if (pos + sizeof(uint32_t) > end) { + return {}; + } + + // clang complains that this is unused when the wasmtoh macro drops its + // second argument on non-big-endian platforms. + [[maybe_unused]] const bool uses_wasm_byte_order = + contextOrEffectiveContext() != nullptr && + contextOrEffectiveContext()->wasmVm()->usesWasmByteOrder(); + uint32_t num_pairs = wasmtoh(unalignedLoad(pos), uses_wasm_byte_order); + pos += sizeof(uint32_t); + + // Check if we're not going to exceed the limit. + if (num_pairs > PROXY_WASM_HOST_PAIRS_MAX_COUNT) { + return {}; + } + if (pos + num_pairs * 2 * sizeof(uint32_t) > end) { + return {}; + } + + Sizes sizes; + sizes.resize(num_pairs); + + for (auto &s : sizes) { + // Read name length. + if (pos + sizeof(uint32_t) > end) { + return {}; + } + s.first = wasmtoh(unalignedLoad(pos), uses_wasm_byte_order); + pos += sizeof(uint32_t); + + // Read value length. + if (pos + sizeof(uint32_t) > end) { + return {}; + } + s.second = wasmtoh(unalignedLoad(pos), uses_wasm_byte_order); + pos += sizeof(uint32_t); + } + + Pairs pairs; + pairs.resize(num_pairs); + + for (uint32_t i = 0; i < num_pairs; i++) { + auto &s = sizes[i]; + auto &p = pairs[i]; + + // Don't overread. + if (pos + s.first + 1 > end) { + return {}; + } + p.first = std::string_view(pos, s.first); + pos += s.first; + if (*pos++ != '\0') { // NULL-terminated string. + return {}; + } + + // Don't overread. + if (pos + s.second + 1 > end) { + return {}; + } + p.second = std::string_view(pos, s.second); + pos += s.second; + if (*pos++ != '\0') { // NULL-terminated string. + return {}; + } + } + + if (pos != end) { + return {}; + } + + return pairs; +} + +} // namespace proxy_wasm diff --git a/src/shared_data.cc b/src/shared_data.cc new file mode 100644 index 000000000..0a91da58c --- /dev/null +++ b/src/shared_data.cc @@ -0,0 +1,120 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "src/shared_data.h" + +#include +#include +#include +#include +#include +#include + +#include "include/proxy-wasm/vm_id_handle.h" + +namespace proxy_wasm { + +SharedData &getGlobalSharedData() { + static auto *ptr = new SharedData; + return *ptr; +}; + +SharedData::SharedData(bool register_vm_id_callback) { + if (register_vm_id_callback) { + registerVmIdHandleCallback([this](std::string_view vm_id) { this->deleteByVmId(vm_id); }); + } +} + +void SharedData::deleteByVmId(std::string_view vm_id) { + std::lock_guard lock(mutex_); + data_.erase(std::string(vm_id)); +} + +WasmResult SharedData::get(std::string_view vm_id, const std::string_view key, + std::pair *result) { + std::lock_guard lock(mutex_); + auto map = data_.find(std::string(vm_id)); + if (map == data_.end()) { + return WasmResult::NotFound; + } + auto it = map->second.find(std::string(key)); + if (it != map->second.end()) { + *result = it->second; + return WasmResult::Ok; + } + return WasmResult::NotFound; +} + +WasmResult SharedData::keys(std::string_view vm_id, std::vector *result) { + result->clear(); + + std::lock_guard lock(mutex_); + auto map = data_.find(std::string(vm_id)); + if (map == data_.end()) { + return WasmResult::Ok; + } + + for (const auto &kv : map->second) { + result->push_back(kv.first); + } + + return WasmResult::Ok; +} + +WasmResult SharedData::set(std::string_view vm_id, std::string_view key, std::string_view value, + uint32_t cas) { + std::lock_guard lock(mutex_); + std::unordered_map> *map; + auto map_it = data_.find(std::string(vm_id)); + if (map_it == data_.end()) { + map = &data_[std::string(vm_id)]; + } else { + map = &map_it->second; + } + auto it = map->find(std::string(key)); + if (it != map->end()) { + if (cas != 0U && cas != it->second.second) { + return WasmResult::CasMismatch; + } + it->second = std::make_pair(std::string(value), nextCas()); + } else { + map->emplace(key, std::make_pair(std::string(value), nextCas())); + } + return WasmResult::Ok; +} + +WasmResult SharedData::remove(std::string_view vm_id, std::string_view key, uint32_t cas, + std::pair *result) { + std::lock_guard lock(mutex_); + std::unordered_map> *map; + auto map_it = data_.find(std::string(vm_id)); + if (map_it == data_.end()) { + return WasmResult::NotFound; + } + map = &map_it->second; + auto it = map->find(std::string(key)); + if (it != map->end()) { + if (cas != 0U && cas != it->second.second) { + return WasmResult::CasMismatch; + } + if (result != nullptr) { + *result = it->second; + } + map->erase(it); + return WasmResult::Ok; + } + return WasmResult::NotFound; +} + +} // namespace proxy_wasm diff --git a/src/shared_data.h b/src/shared_data.h new file mode 100644 index 000000000..0067afb46 --- /dev/null +++ b/src/shared_data.h @@ -0,0 +1,53 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include + +#include "include/proxy-wasm/wasm.h" + +namespace proxy_wasm { + +class SharedData { +public: + SharedData(bool register_vm_id_callback = true); + WasmResult get(std::string_view vm_id, std::string_view key, + std::pair *result); + WasmResult keys(std::string_view vm_id, std::vector *result); + WasmResult set(std::string_view vm_id, std::string_view key, std::string_view value, + uint32_t cas); + WasmResult remove(std::string_view vm_id, std::string_view key, uint32_t cas, + std::pair *result); + void deleteByVmId(std::string_view vm_id); + +private: + uint32_t nextCas() { + auto result = cas_; + cas_++; + if (cas_ == 0U) { // 0 is not a valid CAS value. + cas_++; + } + return result; + } + + // TODO: use std::shared_mutex in C++17. + std::mutex mutex_; + uint32_t cas_ = 1; + std::map>> data_; +}; + +SharedData &getGlobalSharedData(); + +} // namespace proxy_wasm diff --git a/src/shared_queue.cc b/src/shared_queue.cc new file mode 100644 index 000000000..bfb3a7023 --- /dev/null +++ b/src/shared_queue.cc @@ -0,0 +1,154 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "src/shared_queue.h" + +#include +#include +#include +#include +#include +#include + +#include "include/proxy-wasm/vm_id_handle.h" + +namespace proxy_wasm { + +SharedQueue &getGlobalSharedQueue() { + static auto *ptr = new SharedQueue; + return *ptr; +} + +SharedQueue::SharedQueue(bool register_vm_id_callback) { + if (register_vm_id_callback) { + registerVmIdHandleCallback([this](std::string_view vm_id) { this->deleteByVmId(vm_id); }); + } +} + +void SharedQueue::deleteByVmId(std::string_view vm_id) { + std::lock_guard lock(mutex_); + auto queue_keys = vm_queue_keys_.find(std::string(vm_id)); + if (queue_keys != vm_queue_keys_.end()) { + for (const auto &queue_key : queue_keys->second) { + auto token = queue_tokens_.find(queue_key); + if (token != queue_tokens_.end()) { + queues_.erase(token->second); + queue_tokens_.erase(token); + } + } + vm_queue_keys_.erase(queue_keys); + } +} + +uint32_t SharedQueue::nextQueueToken() { + // TODO(@mathetake): Should we handle the case where the queue overflows, i.e. the number of used + // tokens exceeds the max of uint32? If it overflows, the following loop never exits. + while (true) { + uint32_t token = next_queue_token_++; + if (token == 0) { + continue; // 0 is an illegal token. + } + + if (queues_.find(token) == queues_.end()) { + return token; + } + } +} + +uint32_t SharedQueue::registerQueue(std::string_view vm_id, std::string_view queue_name, + uint32_t context_id, CallOnThreadFunction call_on_thread, + std::string_view vm_key) { + std::lock_guard lock(mutex_); + auto key = std::make_pair(std::string(vm_id), std::string(queue_name)); + auto it = queue_tokens_.insert(std::make_pair(key, static_cast(0))); + if (it.second) { + it.first->second = nextQueueToken(); + + auto vid = std::string(vm_id); + QueueKeySet *queue_keys; + auto map_it = vm_queue_keys_.find(vid); + if (map_it == vm_queue_keys_.end()) { + queue_keys = &vm_queue_keys_[vid]; + } else { + queue_keys = &map_it->second; + } + queue_keys->insert(key); + } + + uint32_t token = it.first->second; + auto &q = queues_[token]; + q.vm_key = std::string(vm_key); + q.context_id = context_id; + q.call_on_thread = std::move(call_on_thread); + // Preserve any existing data. + return token; +} + +uint32_t SharedQueue::resolveQueue(std::string_view vm_id, std::string_view queue_name) { + std::lock_guard lock(mutex_); + auto key = std::make_pair(std::string(vm_id), std::string(queue_name)); + auto it = queue_tokens_.find(key); + if (it != queue_tokens_.end()) { + return it->second; + } + return 0; // N.B. zero indicates that the queue was not found. +} + +WasmResult SharedQueue::dequeue(uint32_t token, std::string *data) { + std::lock_guard lock(mutex_); + auto it = queues_.find(token); + if (it == queues_.end()) { + return WasmResult::NotFound; + } + if (it->second.queue.empty()) { + return WasmResult::Empty; + } + *data = it->second.queue.front(); + it->second.queue.pop_front(); + return WasmResult::Ok; +} + +WasmResult SharedQueue::enqueue(uint32_t token, std::string_view value) { + std::string vm_key; + uint32_t context_id; + CallOnThreadFunction call_on_thread; + + { + std::lock_guard lock(mutex_); + auto it = queues_.find(token); + if (it == queues_.end()) { + return WasmResult::NotFound; + } + Queue *target_queue = &(it->second); + vm_key = target_queue->vm_key; + context_id = target_queue->context_id; + call_on_thread = target_queue->call_on_thread; + target_queue->queue.emplace_back(value); + } + + call_on_thread([vm_key, context_id, token] { + // This code may or may not execute in another thread. + // Make sure that the lock is no longer held here. + auto wasm = getThreadLocalWasm(vm_key); + if (wasm) { + auto *context = wasm->wasm()->getContext(context_id); + if (context != nullptr) { + context->onQueueReady(token); + } + } + }); + return WasmResult::Ok; +} + +} // namespace proxy_wasm diff --git a/src/shared_queue.h b/src/shared_queue.h new file mode 100644 index 000000000..1b66e3575 --- /dev/null +++ b/src/shared_queue.h @@ -0,0 +1,66 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include + +#include "include/proxy-wasm/wasm.h" + +namespace proxy_wasm { + +class SharedQueue { +public: + SharedQueue(bool register_vm_id_callback = true); + + uint32_t registerQueue(std::string_view vm_id, std::string_view queue_name, uint32_t context_id, + CallOnThreadFunction call_on_thread, std::string_view vm_key); + uint32_t resolveQueue(std::string_view vm_id, std::string_view queue_name); + WasmResult dequeue(uint32_t token, std::string *data); + WasmResult enqueue(uint32_t token, std::string_view value); + + void deleteByVmId(std::string_view vm_id); + uint32_t nextQueueToken(); + +private: + struct Queue { + std::string vm_key; + uint32_t context_id; + CallOnThreadFunction call_on_thread; + std::deque queue; + }; + + // TODO: use std::shared_mutex in C++17. + std::mutex mutex_; + uint32_t next_queue_token_ = 1; + + struct pair_hash { + template std::size_t operator()(const std::pair &pair) const { + return std::hash()(pair.first) ^ std::hash()(pair.second); + } + }; + + using QueueKeySet = std::unordered_set, pair_hash>; + + // vm_id -> queue keys + std::unordered_map vm_queue_keys_; + // queue key -> token + std::unordered_map, uint32_t, pair_hash> queue_tokens_; + // token -> queue + std::unordered_map queues_; +}; + +SharedQueue &getGlobalSharedQueue(); + +} // namespace proxy_wasm diff --git a/src/signature_util.cc b/src/signature_util.cc new file mode 100644 index 000000000..46b9d3333 --- /dev/null +++ b/src/signature_util.cc @@ -0,0 +1,144 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "include/proxy-wasm/signature_util.h" + +#include +#include + +#ifdef PROXY_WASM_VERIFY_WITH_ED25519_PUBKEY +#include +#include +#endif + +#include "include/proxy-wasm/bytecode_util.h" + +namespace { + +#ifdef PROXY_WASM_VERIFY_WITH_ED25519_PUBKEY + +uint8_t hex2dec(const unsigned char c) { + if (c >= '0' && c <= '9') { + return c - '0'; + } + if (c >= 'a' && c <= 'f') { + return c - 'a' + 10; + } + if (c >= 'A' && c <= 'F') { + return c - 'A' + 10; + } + throw std::logic_error{"invalid hex character"}; +} + +template constexpr std::array hex2pubkey(const char (&hex)[2 * N + 1]) { + std::array pubkey{}; + for (size_t i = 0; i < pubkey.size(); i++) { + pubkey[i] = hex2dec(hex[2 * i]) << 4 | hex2dec(hex[2 * i + 1]); + } + return pubkey; +} + +#endif + +} // namespace + +namespace proxy_wasm { + +bool SignatureUtil::verifySignature(std::string_view bytecode, std::string &message) { + +#ifdef PROXY_WASM_VERIFY_WITH_ED25519_PUBKEY + + /* + * Ed25519 signature generated using https://github.com/jedisct1/wasmsign + */ + + std::string_view payload; + if (!BytecodeUtil::getCustomSection(bytecode, "signature_wasmsign", payload)) { + message = "Failed to parse corrupted Wasm module"; + return false; + } + + if (payload.empty()) { + message = "Custom Section \"signature_wasmsign\" not found"; + return false; + } + + if (bytecode.data() + bytecode.size() != payload.data() + payload.size()) { + message = "Custom Section \"signature_wasmsign\" not at the end of Wasm module"; + return false; + } + + if (payload.size() != 68) { + message = "Signature has a wrong size (want: 68, is: " + std::to_string(payload.size()) + ")"; + return false; + } + + uint32_t alg_id; + std::memcpy(&alg_id, payload.data(), sizeof(uint32_t)); + alg_id = wasmtoh(alg_id, true); + + if (alg_id != 2) { + message = "Signature has a wrong alg_id (want: 2, is: " + std::to_string(alg_id) + ")"; + return false; + } + + const auto *signature = reinterpret_cast(payload.data()) + sizeof(uint32_t); + + SHA512_CTX ctx; + SHA512_Init(&ctx); + SHA512_Update(&ctx, "WasmSignature", sizeof("WasmSignature") - 1); + const uint32_t ad_len = 0; + SHA512_Update(&ctx, &ad_len, sizeof(uint32_t)); + const size_t section_len = 3 + sizeof("signature_wasmsign") - 1 + 68; + SHA512_Update(&ctx, bytecode.data(), bytecode.size() - section_len); + uint8_t hash[SHA512_DIGEST_LENGTH]; + SHA512_Final(hash, &ctx); + + static const auto ed25519_pubkey = hex2pubkey<32>(PROXY_WASM_VERIFY_WITH_ED25519_PUBKEY); + + EVP_PKEY *pubkey = EVP_PKEY_new_raw_public_key(EVP_PKEY_ED25519, nullptr, ed25519_pubkey.data(), + 32 /* ED25519_PUBLIC_KEY_LEN */); + if (pubkey == nullptr) { + message = "Failed to load the public key"; + return false; + } + + EVP_MD_CTX *mdctx = EVP_MD_CTX_new(); + if (mdctx == nullptr) { + message = "Failed to allocate memory for EVP_MD_CTX"; + EVP_PKEY_free(pubkey); + return false; + } + + bool ok = + (EVP_DigestVerifyInit(mdctx, nullptr, nullptr, nullptr, pubkey) != 0) && + (EVP_DigestVerify(mdctx, signature, 64 /* ED25519_SIGNATURE_LEN */, hash, sizeof(hash)) != 0); + + EVP_MD_CTX_free(mdctx); + EVP_PKEY_free(pubkey); + + if (!ok) { + message = "Signature mismatch"; + return false; + } + + message = "Wasm signature OK (Ed25519)"; + return true; + +#endif + + return true; +} + +} // namespace proxy_wasm diff --git a/src/third_party/base64.cc b/src/third_party/base64.cc deleted file mode 100644 index 8e65962e9..000000000 --- a/src/third_party/base64.cc +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Original source Public Domain: -// https://en.wikibooks.org/wiki/Algorithm_Implementation/Miscellaneous/Base64 -#include "base64.h" - -const static char encodeLookup[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -const static char padCharacter = '='; - -std::string base64Encode(const uint8_t *start, const uint8_t *end) { - std::string encodedString; - size_t size = end - start; - encodedString.reserve(((size / 3) + (size % 3 > 0)) * 4); - uint32_t temp; - auto cursor = start; - for (size_t idx = 0; idx < size / 3; idx++) { - temp = (*cursor++) << 16; // Convert to big endian - temp += (*cursor++) << 8; - temp += (*cursor++); - encodedString.append(1, encodeLookup[(temp & 0x00FC0000) >> 18]); - encodedString.append(1, encodeLookup[(temp & 0x0003F000) >> 12]); - encodedString.append(1, encodeLookup[(temp & 0x00000FC0) >> 6]); - encodedString.append(1, encodeLookup[(temp & 0x0000003F)]); - } - switch (size % 3) { - case 1: - temp = (*cursor++) << 16; // Convert to big endian - encodedString.append(1, encodeLookup[(temp & 0x00FC0000) >> 18]); - encodedString.append(1, encodeLookup[(temp & 0x0003F000) >> 12]); - encodedString.append(2, padCharacter); - break; - case 2: - temp = (*cursor++) << 16; // Convert to big endian - temp += (*cursor++) << 8; - encodedString.append(1, encodeLookup[(temp & 0x00FC0000) >> 18]); - encodedString.append(1, encodeLookup[(temp & 0x0003F000) >> 12]); - encodedString.append(1, encodeLookup[(temp & 0x00000FC0) >> 6]); - encodedString.append(1, padCharacter); - break; - } - return encodedString; -} - -bool base64Decode(const std::basic_string &input, std::vector *output) { - if (input.length() % 4) - return false; - size_t padding = 0; - if (input.length()) { - if (input[input.length() - 1] == padCharacter) - padding++; - if (input[input.length() - 2] == padCharacter) - padding++; - } - // Setup a vector to hold the result - std::vector decodedBytes; - decodedBytes.reserve(((input.length() / 4) * 3) - padding); - uint32_t temp = 0; // Holds decoded quanta - std::basic_string::const_iterator cursor = input.begin(); - while (cursor < input.end()) { - for (size_t quantumPosition = 0; quantumPosition < 4; quantumPosition++) { - temp <<= 6; - if (*cursor >= 0x41 && *cursor <= 0x5A) // This area will need tweaking if - temp |= *cursor - 0x41; // you are using an alternate alphabet - else if (*cursor >= 0x61 && *cursor <= 0x7A) - temp |= *cursor - 0x47; - else if (*cursor >= 0x30 && *cursor <= 0x39) - temp |= *cursor + 0x04; - else if (*cursor == 0x2B) - temp |= 0x3E; // change to 0x2D for URL alphabet - else if (*cursor == 0x2F) - temp |= 0x3F; // change to 0x5F for URL alphabet - else if (*cursor == padCharacter) { // pad - switch (input.end() - cursor) { - case 1: // One pad character - decodedBytes.push_back((temp >> 16) & 0x000000FF); - decodedBytes.push_back((temp >> 8) & 0x000000FF); - goto Ldone; - case 2: // Two pad characters - decodedBytes.push_back((temp >> 10) & 0x000000FF); - goto Ldone; - default: - return false; - } - } else - return false; - cursor++; - } - decodedBytes.push_back((temp >> 16) & 0x000000FF); - decodedBytes.push_back((temp >> 8) & 0x000000FF); - decodedBytes.push_back((temp)&0x000000FF); - } -Ldone: - *output = std::move(decodedBytes); - return true; -} diff --git a/src/third_party/picosha2.h b/src/third_party/picosha2.h deleted file mode 100644 index 6da12b6f4..000000000 --- a/src/third_party/picosha2.h +++ /dev/null @@ -1,355 +0,0 @@ -/* -The MIT License (MIT) - -Copyright (C) 2017 okdshin - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ -#ifndef PICOSHA2_H -#define PICOSHA2_H -// picosha2:20140213 - -#ifndef PICOSHA2_BUFFER_SIZE_FOR_INPUT_ITERATOR -#define PICOSHA2_BUFFER_SIZE_FOR_INPUT_ITERATOR 1048576 //=1024*1024: default is 1MB memory -#endif - -#include -#include -#include -#include -#include -#include -namespace picosha2 { -typedef unsigned long word_t; -typedef unsigned char byte_t; - -static const size_t k_digest_size = 32; - -namespace detail { -inline byte_t mask_8bit(byte_t x) { return x & 0xff; } - -inline word_t mask_32bit(word_t x) { return x & 0xffffffff; } - -const word_t add_constant[64] = { - 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, - 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, - 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, - 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, - 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, - 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, - 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, - 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2}; - -const word_t initial_message_digest[8] = {0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, - 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19}; - -inline word_t ch(word_t x, word_t y, word_t z) { return (x & y) ^ ((~x) & z); } - -inline word_t maj(word_t x, word_t y, word_t z) { return (x & y) ^ (x & z) ^ (y & z); } - -inline word_t rotr(word_t x, std::size_t n) { - assert(n < 32); - return mask_32bit((x >> n) | (x << (32 - n))); -} - -inline word_t bsig0(word_t x) { return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22); } - -inline word_t bsig1(word_t x) { return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25); } - -inline word_t shr(word_t x, std::size_t n) { - assert(n < 32); - return x >> n; -} - -inline word_t ssig0(word_t x) { return rotr(x, 7) ^ rotr(x, 18) ^ shr(x, 3); } - -inline word_t ssig1(word_t x) { return rotr(x, 17) ^ rotr(x, 19) ^ shr(x, 10); } - -template -void hash256_block(RaIter1 message_digest, RaIter2 first, RaIter2 last) { - assert(first + 64 == last); - static_cast(last); // for avoiding unused-variable warning - word_t w[64]; - std::fill(w, w + 64, 0); - for (std::size_t i = 0; i < 16; ++i) { - w[i] = (static_cast(mask_8bit(*(first + i * 4))) << 24) | - (static_cast(mask_8bit(*(first + i * 4 + 1))) << 16) | - (static_cast(mask_8bit(*(first + i * 4 + 2))) << 8) | - (static_cast(mask_8bit(*(first + i * 4 + 3)))); - } - for (std::size_t i = 16; i < 64; ++i) { - w[i] = mask_32bit(ssig1(w[i - 2]) + w[i - 7] + ssig0(w[i - 15]) + w[i - 16]); - } - - word_t a = *message_digest; - word_t b = *(message_digest + 1); - word_t c = *(message_digest + 2); - word_t d = *(message_digest + 3); - word_t e = *(message_digest + 4); - word_t f = *(message_digest + 5); - word_t g = *(message_digest + 6); - word_t h = *(message_digest + 7); - - for (std::size_t i = 0; i < 64; ++i) { - word_t temp1 = h + bsig1(e) + ch(e, f, g) + add_constant[i] + w[i]; - word_t temp2 = bsig0(a) + maj(a, b, c); - h = g; - g = f; - f = e; - e = mask_32bit(d + temp1); - d = c; - c = b; - b = a; - a = mask_32bit(temp1 + temp2); - } - *message_digest += a; - *(message_digest + 1) += b; - *(message_digest + 2) += c; - *(message_digest + 3) += d; - *(message_digest + 4) += e; - *(message_digest + 5) += f; - *(message_digest + 6) += g; - *(message_digest + 7) += h; - for (std::size_t i = 0; i < 8; ++i) { - *(message_digest + i) = mask_32bit(*(message_digest + i)); - } -} - -} // namespace detail - -template void output_hex(InIter first, InIter last, std::ostream &os) { - os.setf(std::ios::hex, std::ios::basefield); - while (first != last) { - os.width(2); - os.fill('0'); - os << static_cast(*first); - ++first; - } - os.setf(std::ios::dec, std::ios::basefield); -} - -template -void bytes_to_hex_string(InIter first, InIter last, std::string &hex_str) { - std::ostringstream oss; - output_hex(first, last, oss); - hex_str.assign(oss.str()); -} - -template -void bytes_to_hex_string(const InContainer &bytes, std::string &hex_str) { - bytes_to_hex_string(bytes.begin(), bytes.end(), hex_str); -} - -template std::string bytes_to_hex_string(InIter first, InIter last) { - std::string hex_str; - bytes_to_hex_string(first, last, hex_str); - return hex_str; -} - -template std::string bytes_to_hex_string(const InContainer &bytes) { - std::string hex_str; - bytes_to_hex_string(bytes, hex_str); - return hex_str; -} - -class hash256_one_by_one { -public: - hash256_one_by_one() { init(); } - - void init() { - buffer_.clear(); - std::fill(data_length_digits_, data_length_digits_ + 4, 0); - std::copy(detail::initial_message_digest, detail::initial_message_digest + 8, h_); - } - - template void process(RaIter first, RaIter last) { - add_to_data_length(static_cast(std::distance(first, last))); - std::copy(first, last, std::back_inserter(buffer_)); - std::size_t i = 0; - for (; i + 64 <= buffer_.size(); i += 64) { - detail::hash256_block(h_, buffer_.begin() + i, buffer_.begin() + i + 64); - } - buffer_.erase(buffer_.begin(), buffer_.begin() + i); - } - - void finish() { - byte_t temp[64]; - std::fill(temp, temp + 64, 0); - std::size_t remains = buffer_.size(); - std::copy(buffer_.begin(), buffer_.end(), temp); - temp[remains] = 0x80; - - if (remains > 55) { - std::fill(temp + remains + 1, temp + 64, 0); - detail::hash256_block(h_, temp, temp + 64); - std::fill(temp, temp + 64 - 4, 0); - } else { - std::fill(temp + remains + 1, temp + 64 - 4, 0); - } - - write_data_bit_length(&(temp[56])); - detail::hash256_block(h_, temp, temp + 64); - } - - template void get_hash_bytes(OutIter first, OutIter last) const { - for (const word_t *iter = h_; iter != h_ + 8; ++iter) { - for (std::size_t i = 0; i < 4 && first != last; ++i) { - *(first++) = detail::mask_8bit(static_cast((*iter >> (24 - 8 * i)))); - } - } - } - -private: - void add_to_data_length(word_t n) { - word_t carry = 0; - data_length_digits_[0] += n; - for (std::size_t i = 0; i < 4; ++i) { - data_length_digits_[i] += carry; - if (data_length_digits_[i] >= 65536u) { - carry = data_length_digits_[i] >> 16; - data_length_digits_[i] &= 65535u; - } else { - break; - } - } - } - void write_data_bit_length(byte_t *begin) { - word_t data_bit_length_digits[4]; - std::copy(data_length_digits_, data_length_digits_ + 4, data_bit_length_digits); - - // convert byte length to bit length (multiply 8 or shift 3 times left) - word_t carry = 0; - for (std::size_t i = 0; i < 4; ++i) { - word_t before_val = data_bit_length_digits[i]; - data_bit_length_digits[i] <<= 3; - data_bit_length_digits[i] |= carry; - data_bit_length_digits[i] &= 65535u; - carry = (before_val >> (16 - 3)) & 65535u; - } - - // write data_bit_length - for (int i = 3; i >= 0; --i) { - (*begin++) = static_cast(data_bit_length_digits[i] >> 8); - (*begin++) = static_cast(data_bit_length_digits[i]); - } - } - std::vector buffer_; - word_t data_length_digits_[4]; // as 64bit integer (16bit x 4 integer) - word_t h_[8]; -}; - -inline void get_hash_hex_string(const hash256_one_by_one &hasher, std::string &hex_str) { - byte_t hash[k_digest_size]; - hasher.get_hash_bytes(hash, hash + k_digest_size); - return bytes_to_hex_string(hash, hash + k_digest_size, hex_str); -} - -inline std::string get_hash_hex_string(const hash256_one_by_one &hasher) { - std::string hex_str; - get_hash_hex_string(hasher, hex_str); - return hex_str; -} - -namespace impl { -template -void hash256_impl(RaIter first, RaIter last, OutIter first2, OutIter last2, int, - std::random_access_iterator_tag) { - hash256_one_by_one hasher; - // hasher.init(); - hasher.process(first, last); - hasher.finish(); - hasher.get_hash_bytes(first2, last2); -} - -template -void hash256_impl(InputIter first, InputIter last, OutIter first2, OutIter last2, int buffer_size, - std::input_iterator_tag) { - std::vector buffer(buffer_size); - hash256_one_by_one hasher; - // hasher.init(); - while (first != last) { - int size = buffer_size; - for (int i = 0; i != buffer_size; ++i, ++first) { - if (first == last) { - size = i; - break; - } - buffer[i] = *first; - } - hasher.process(buffer.begin(), buffer.begin() + size); - } - hasher.finish(); - hasher.get_hash_bytes(first2, last2); -} -} // namespace impl - -template -void hash256(InIter first, InIter last, OutIter first2, OutIter last2, - int buffer_size = PICOSHA2_BUFFER_SIZE_FOR_INPUT_ITERATOR) { - picosha2::impl::hash256_impl(first, last, first2, last2, buffer_size, - typename std::iterator_traits::iterator_category()); -} - -template -void hash256(InIter first, InIter last, OutContainer &dst) { - hash256(first, last, dst.begin(), dst.end()); -} - -template -void hash256(const InContainer &src, OutIter first, OutIter last) { - hash256(src.begin(), src.end(), first, last); -} - -template -void hash256(const InContainer &src, OutContainer &dst) { - hash256(src.begin(), src.end(), dst.begin(), dst.end()); -} - -template -void hash256_hex_string(InIter first, InIter last, std::string &hex_str) { - byte_t hashed[k_digest_size]; - hash256(first, last, hashed, hashed + k_digest_size); - std::ostringstream oss; - output_hex(hashed, hashed + k_digest_size, oss); - hex_str.assign(oss.str()); -} - -template std::string hash256_hex_string(InIter first, InIter last) { - std::string hex_str; - hash256_hex_string(first, last, hex_str); - return hex_str; -} - -inline void hash256_hex_string(const std::string &src, std::string &hex_str) { - hash256_hex_string(src.begin(), src.end(), hex_str); -} - -template -void hash256_hex_string(const InContainer &src, std::string &hex_str) { - hash256_hex_string(src.begin(), src.end(), hex_str); -} - -template std::string hash256_hex_string(const InContainer &src) { - return hash256_hex_string(src.begin(), src.end()); -} -template void hash256(std::ifstream &f, OutIter first, OutIter last) { - hash256(std::istreambuf_iterator(f), std::istreambuf_iterator(), first, last); -} -} // namespace picosha2 -#endif // PICOSHA2_H diff --git a/src/v8/v8.cc b/src/v8/v8.cc index 0de616757..f5a73b130 100644 --- a/src/v8/v8.cc +++ b/src/v8/v8.cc @@ -16,23 +16,43 @@ #include "include/proxy-wasm/v8.h" #include - +#include #include +#include #include +#include +#include +#include #include #include -#include "v8-version.h" -#include "wasm-api/wasm.hh" +#include "include/proxy-wasm/limits.h" -// TODO remove absl dependency -#include "absl/container/flat_hash_map.h" +#include "absl/strings/str_format.h" +#include "include/v8-initialization.h" +#include "include/v8-version.h" +#include "include/v8.h" +#include "src/wasm/c-api.h" +#include "wasm-api/wasm.hh" namespace proxy_wasm { -namespace { +namespace v8 { wasm::Engine *engine() { - static const auto engine = wasm::Engine::make(); + static std::once_flag init; + static wasm::own engine; + + std::call_once(init, []() { + // Disable the Liftoff compiler to force optimized JIT up-front. + std::string args = absl::StrFormat("--wasm_max_mem_pages=%u --no-liftoff", + PROXY_WASM_HOST_MAX_WASM_MEMORY_SIZE_BYTES / + PROXY_WASM_HOST_WASM_MEMORY_PAGE_SIZE_BYTES); + ::v8::V8::SetFlagsFromString(args.c_str(), args.size()); + ::v8::V8::EnableWebAssemblyTrapHandler(true); + + engine = wasm::Engine::make(); + }); + return engine.get(); } @@ -41,21 +61,21 @@ struct FuncData { std::string name_; wasm::own callback_; - void *raw_func_; + void *raw_func_{}; + WasmVm *vm_{}; }; using FuncDataPtr = std::unique_ptr; class V8 : public WasmVm { public: - V8() {} + V8() = default; // WasmVm - std::string_view runtime() override { return "v8"; } + std::string_view getEngineName() override { return "v8"; } - bool load(const std::string &code, bool allow_precompiled) override; - AbiVersion getAbiVersion() override; - std::string_view getCustomSection(std::string_view name) override; + bool load(std::string_view bytecode, std::string_view precompiled, + const std::unordered_map &function_names) override; std::string_view getPrecompiledSectionName() override; bool link(std::string_view debug_name) override; @@ -67,6 +87,7 @@ class V8 : public WasmVm { bool setMemory(uint64_t pointer, uint64_t size, const void *data) override; bool getWord(uint64_t pointer, Word *word) override; bool setWord(uint64_t pointer, Word word) override; + size_t getWordSize() override { return sizeof(uint32_t); }; #define _REGISTER_HOST_FUNCTION(T) \ void registerCallback(std::string_view module_name, std::string_view function_name, T, \ @@ -83,16 +104,23 @@ class V8 : public WasmVm { FOR_ALL_WASM_VM_EXPORTS(_GET_MODULE_FUNCTION) #undef _GET_MODULE_FUNCTION + void terminate() override; + bool usesWasmByteOrder() override { return true; } + + void warm() override; + private: - wasm::vec getStrippedSource(); + wasm::own trap(std::string message); + + std::string getFailMessage(std::string_view function_name, wasm::own trap); template void registerHostFunctionImpl(std::string_view module_name, std::string_view function_name, - void (*function)(void *, Args...)); + void (*function)(Args...)); template void registerHostFunctionImpl(std::string_view module_name, std::string_view function_name, - R (*function)(void *, Args...)); + R (*function)(Args...)); template void getModuleFunctionImpl(std::string_view function_name, @@ -102,7 +130,9 @@ class V8 : public WasmVm { void getModuleFunctionImpl(std::string_view function_name, std::function *function); - wasm::vec source_ = wasm::vec::invalid(); + // Initialize the V8 engine and store if necessary. + void initStore(); + wasm::own store_; wasm::own module_; wasm::own> shared_module_; @@ -110,25 +140,56 @@ class V8 : public WasmVm { wasm::own memory_; wasm::own table_; - absl::flat_hash_map host_functions_; - absl::flat_hash_map> module_functions_; + std::unordered_map host_functions_; + std::unordered_map> module_functions_; + std::unordered_map function_names_index_; }; // Helper functions. +static std::string printValue(const wasm::Val &value) { + switch (value.kind()) { + case wasm::ValKind::I32: + return std::to_string(value.get()); + case wasm::ValKind::I64: + return std::to_string(value.get()); + case wasm::ValKind::F32: + return std::to_string(value.get()); + case wasm::ValKind::F64: + return std::to_string(value.get()); + default: + return "unknown"; + } +} + +static std::string printValues(const wasm::vec &values, size_t size) { + if (size == 0) { + return ""; + } + + std::string s; + for (size_t i = 0; i < size; i++) { + if (i != 0U) { + s.append(", "); + } + s.append(printValue(values[i])); + } + return s; +} + static const char *printValKind(wasm::ValKind kind) { switch (kind) { - case wasm::I32: + case wasm::ValKind::I32: return "i32"; - case wasm::I64: + case wasm::ValKind::I64: return "i64"; - case wasm::F32: + case wasm::ValKind::F32: return "f32"; - case wasm::F64: + case wasm::ValKind::F64: return "f64"; - case wasm::ANYREF: - return "anyref"; - case wasm::FUNCREF: + case wasm::ValKind::EXTERNREF: + return "externref"; + case wasm::ValKind::FUNCREF: return "funcref"; default: return "unknown"; @@ -143,7 +204,7 @@ static std::string printValTypes(const wasm::ownvec &types) { std::string s; s.reserve(types.size() * 8 /* max size + " " */ - 1); for (size_t i = 0; i < types.size(); i++) { - if (i) { + if (i != 0U) { s.append(" "); } s.append(printValKind(types[i]->kind())); @@ -164,21 +225,6 @@ static bool equalValTypes(const wasm::ownvec &left, return true; } -static uint32_t parseVarint(const byte_t *&pos, const byte_t *end) { - uint32_t n = 0; - uint32_t shift = 0; - byte_t b; - do { - if (pos + 1 > end) { - abort(); - } - b = *pos++; - n += (b & 0x7f) << shift; - shift += 7; - } while ((b & 0x80) != 0); - return n; -} - // Template magic. template struct ConvertWordType { @@ -192,24 +238,24 @@ template wasm::Val makeVal(T t) { return wasm::Val::make(t); } template <> wasm::Val makeVal(Word t) { return wasm::Val::make(static_cast(t.u64_)); } template constexpr auto convertArgToValKind(); -template <> constexpr auto convertArgToValKind() { return wasm::I32; }; -template <> constexpr auto convertArgToValKind() { return wasm::I32; }; -template <> constexpr auto convertArgToValKind() { return wasm::I64; }; -template <> constexpr auto convertArgToValKind() { return wasm::I64; }; -template <> constexpr auto convertArgToValKind() { return wasm::F64; }; +template <> constexpr auto convertArgToValKind() { return wasm::ValKind::I32; }; +template <> constexpr auto convertArgToValKind() { return wasm::ValKind::I32; }; +template <> constexpr auto convertArgToValKind() { return wasm::ValKind::I64; }; +template <> constexpr auto convertArgToValKind() { return wasm::ValKind::I64; }; +template <> constexpr auto convertArgToValKind() { return wasm::ValKind::F64; }; template -constexpr auto convertArgsTupleToValTypesImpl(absl::index_sequence) { +constexpr auto convertArgsTupleToValTypesImpl(std::index_sequence /*comptime*/) { return wasm::ownvec::make( wasm::ValType::make(convertArgToValKind::type>())...); } template constexpr auto convertArgsTupleToValTypes() { - return convertArgsTupleToValTypesImpl(absl::make_index_sequence::value>()); + return convertArgsTupleToValTypesImpl(std::make_index_sequence::value>()); } template -constexpr T convertValTypesToArgsTupleImpl(const U &arr, absl::index_sequence) { +constexpr T convertValTypesToArgsTupleImpl(const U &arr, std::index_sequence /*comptime*/) { return std::make_tuple( (arr[I] .template get< @@ -218,137 +264,79 @@ constexpr T convertValTypesToArgsTupleImpl(const U &arr, absl::index_sequence constexpr T convertValTypesToArgsTuple(const U &arr) { return convertValTypesToArgsTupleImpl(arr, - absl::make_index_sequence::value>()); + std::make_index_sequence::value>()); } // V8 implementation. -bool V8::load(const std::string &code, bool allow_precompiled) { +void V8::initStore() { + if (store_ != nullptr) { + return; + } store_ = wasm::Store::make(engine()); +} - // Wasm file header is 8 bytes (magic number + version). - static const uint8_t magic_number[4] = {0x00, 0x61, 0x73, 0x6d}; - if (code.size() < 8 || ::memcmp(code.data(), magic_number, 4) != 0) { +bool V8::load(std::string_view bytecode, std::string_view precompiled, + const std::unordered_map &function_names) { + initStore(); + if (store_ == nullptr) { return false; } - source_ = wasm::vec::make_uninitialized(code.size()); - ::memcpy(source_.get(), code.data(), code.size()); - - if (allow_precompiled) { - const auto section_name = getPrecompiledSectionName(); - if (!section_name.empty()) { - const auto precompiled = getCustomSection(section_name); - if (!precompiled.empty()) { - auto vec = wasm::vec::make_uninitialized(precompiled.size()); - ::memcpy(vec.get(), precompiled.data(), precompiled.size()); + if (!precompiled.empty()) { + auto vec = wasm::vec::make_uninitialized(precompiled.size()); + ::memcpy(vec.get(), precompiled.data(), precompiled.size()); + module_ = wasm::Module::deserialize(store_.get(), vec); + if (module_ == nullptr) { + return false; + } - module_ = wasm::Module::deserialize(store_.get(), vec); - if (!module_) { - // Precompiled module that cannot be loaded is considered a hard error, - // so don't fallback to compiling the bytecode. - return false; - } - } + } else { + auto vec = wasm::vec::make_uninitialized(bytecode.size()); + ::memcpy(vec.get(), bytecode.data(), bytecode.size()); + module_ = wasm::Module::make(store_.get(), vec); + if (module_ == nullptr) { + return false; } } - if (!module_) { - const auto stripped_source = getStrippedSource(); - module_ = wasm::Module::make(store_.get(), stripped_source ? stripped_source : source_); + shared_module_ = module_->share(); + if (shared_module_ == nullptr) { + return false; } - if (module_) { - shared_module_ = module_->share(); - assert((shared_module_ != nullptr)); - } + function_names_index_ = function_names; - return module_ != nullptr; + return true; } std::unique_ptr V8::clone() { assert(shared_module_ != nullptr); auto clone = std::make_unique(); - clone->integration().reset(integration()->clone()); + if (clone == nullptr) { + return nullptr; + } + clone->store_ = wasm::Store::make(engine()); + if (clone->store_ == nullptr) { + return nullptr; + } clone->module_ = wasm::Module::obtain(clone->store_.get(), shared_module_.get()); - - return clone; -} - -// Get Wasm module without Custom Sections to save some memory in workers. -wasm::vec V8::getStrippedSource() { - assert(source_.get() != nullptr); - - std::vector stripped; - - const byte_t *pos = source_.get() + 8 /* Wasm header */; - const byte_t *end = source_.get() + source_.size(); - while (pos < end) { - const auto section_start = pos; - if (pos + 1 > end) { - return wasm::vec::invalid(); - } - const auto section_type = *pos++; - const auto section_len = parseVarint(pos, end); - if (section_len == static_cast(-1) || pos + section_len > end) { - return wasm::vec::invalid(); - } - pos += section_len; - if (section_type == 0 /* custom section */) { - if (stripped.empty()) { - const byte_t *start = source_.get(); - stripped.insert(stripped.end(), start, section_start); - } - } else if (!stripped.empty()) { - stripped.insert(stripped.end(), section_start, pos /* section end */); - } + if (clone->module_ == nullptr) { + return nullptr; } - // No custom sections found, use the original source. - if (stripped.empty()) { - return wasm::vec::invalid(); + auto *integration_clone = integration()->clone(); + if (integration_clone == nullptr) { + return nullptr; } + clone->integration().reset(integration_clone); - // Return stripped source, without custom sections. - return wasm::vec::make(stripped.size(), stripped.data()); -} - -std::string_view V8::getCustomSection(std::string_view name) { - assert(source_.get() != nullptr); + clone->function_names_index_ = function_names_index_; - const byte_t *pos = source_.get() + 8 /* Wasm header */; - const byte_t *end = source_.get() + source_.size(); - while (pos < end) { - if (pos + 1 > end) { - fail(FailState::UnableToInitializeCode, "Failed to parse corrupted Wasm module"); - return ""; - } - const auto section_type = *pos++; - const auto section_len = parseVarint(pos, end); - if (section_len == static_cast(-1) || pos + section_len > end) { - fail(FailState::UnableToInitializeCode, "Failed to parse corrupted Wasm module"); - return ""; - } - if (section_type == 0 /* custom section */) { - const auto section_data_start = pos; - const auto section_name_len = parseVarint(pos, end); - if (section_name_len == static_cast(-1) || pos + section_name_len > end) { - fail(FailState::UnableToInitializeCode, "Failed to parse corrupted Wasm module"); - return ""; - } - if (section_name_len == name.size() && ::memcmp(pos, name.data(), section_name_len) == 0) { - pos += section_name_len; - return {pos, static_cast(section_data_start + section_len - pos)}; - } - pos = section_data_start + section_len; - } else { - pos += section_len; - } - } - return ""; + return clone; } #if defined(__linux__) && defined(__x86_64__) @@ -367,48 +355,29 @@ std::string_view V8::getPrecompiledSectionName() { return name; } -AbiVersion V8::getAbiVersion() { - assert(module_ != nullptr); - - const auto export_types = module_.get()->exports(); - for (size_t i = 0; i < export_types.size(); i++) { - if (export_types[i]->type()->kind() == wasm::EXTERN_FUNC) { - std::string_view name(export_types[i]->name().get(), export_types[i]->name().size()); - if (name == "proxy_abi_version_0_1_0") { - return AbiVersion::ProxyWasm_0_1_0; - } else if (name == "proxy_abi_version_0_2_0") { - return AbiVersion::ProxyWasm_0_2_0; - } else if (name == "proxy_abi_version_0_2_1") { - return AbiVersion::ProxyWasm_0_2_1; - } - } - } - - return AbiVersion::Unknown; -} - -bool V8::link(std::string_view debug_name) { +bool V8::link(std::string_view /*debug_name*/) { assert(module_ != nullptr); const auto import_types = module_.get()->imports(); - std::vector imports; + wasm::vec imports = + wasm::vec::make_uninitialized(import_types.size()); for (size_t i = 0; i < import_types.size(); i++) { std::string_view module(import_types[i]->module().get(), import_types[i]->module().size()); std::string_view name(import_types[i]->name().get(), import_types[i]->name().size()); - auto import_type = import_types[i]->type(); + const auto *import_type = import_types[i]->type(); switch (import_type->kind()) { - case wasm::EXTERN_FUNC: { + case wasm::ExternKind::FUNC: { auto it = host_functions_.find(std::string(module) + "." + std::string(name)); if (it == host_functions_.end()) { fail(FailState::UnableToInitializeCode, std::string("Failed to load Wasm module due to a missing import: ") + std::string(module) + "." + std::string(name)); - break; + return false; } - auto func = it->second.get()->callback_.get(); + auto *func = it->second->callback_.get(); if (!equalValTypes(import_type->func()->params(), func->type()->params()) || !equalValTypes(import_type->func()->results(), func->type()->results())) { fail(FailState::UnableToInitializeCode, @@ -418,81 +387,102 @@ bool V8::link(std::string_view debug_name) { printValTypes(import_type->func()->results()) + ", but host exports: " + printValTypes(func->type()->params()) + " -> " + printValTypes(func->type()->results())); - break; + return false; } - imports.push_back(func); + imports[i] = func; } break; - case wasm::EXTERN_GLOBAL: { + case wasm::ExternKind::GLOBAL: { // TODO(PiotrSikora): add support when/if needed. fail(FailState::UnableToInitializeCode, "Failed to load Wasm module due to a missing import: " + std::string(module) + "." + std::string(name)); + return false; } break; - case wasm::EXTERN_MEMORY: { + case wasm::ExternKind::MEMORY: { assert(memory_ == nullptr); auto type = wasm::MemoryType::make(import_type->memory()->limits()); + if (type == nullptr) { + return false; + } memory_ = wasm::Memory::make(store_.get(), type.get()); - imports.push_back(memory_.get()); + if (memory_ == nullptr) { + return false; + } + imports[i] = memory_.get(); } break; - case wasm::EXTERN_TABLE: { + case wasm::ExternKind::TABLE: { assert(table_ == nullptr); auto type = wasm::TableType::make(wasm::ValType::make(import_type->table()->element()->kind()), import_type->table()->limits()); + if (type == nullptr) { + return false; + } table_ = wasm::Table::make(store_.get(), type.get()); - imports.push_back(table_.get()); + if (table_ == nullptr) { + return false; + } + imports[i] = table_.get(); } break; } } - if (import_types.size() != imports.size()) { + instance_ = wasm::Instance::make(store_.get(), module_.get(), imports); + if (instance_ == nullptr) { + fail(FailState::UnableToInitializeCode, "Failed to create new Wasm instance"); return false; } - instance_ = wasm::Instance::make(store_.get(), module_.get(), imports.data()); - const auto export_types = module_.get()->exports(); const auto exports = instance_.get()->exports(); assert(export_types.size() == exports.size()); for (size_t i = 0; i < export_types.size(); i++) { std::string_view name(export_types[i]->name().get(), export_types[i]->name().size()); - auto export_type = export_types[i]->type(); - auto export_item = exports[i].get(); + const auto *export_type = export_types[i]->type(); + auto *export_item = exports[i].get(); assert(export_type->kind() == export_item->kind()); switch (export_type->kind()) { - case wasm::EXTERN_FUNC: { + case wasm::ExternKind::FUNC: { assert(export_item->func() != nullptr); - module_functions_.insert_or_assign(name, export_item->func()->copy()); + module_functions_.insert_or_assign(std::string(name), export_item->func()->copy()); } break; - case wasm::EXTERN_GLOBAL: { + case wasm::ExternKind::GLOBAL: { // TODO(PiotrSikora): add support when/if needed. } break; - case wasm::EXTERN_MEMORY: { + case wasm::ExternKind::MEMORY: { assert(export_item->memory() != nullptr); assert(memory_ == nullptr); memory_ = exports[i]->memory()->copy(); + if (memory_ == nullptr) { + return false; + } } break; - case wasm::EXTERN_TABLE: { + case wasm::ExternKind::TABLE: { // TODO(PiotrSikora): add support when/if needed. } break; } } - return !isFailed(); + + return true; } uint64_t V8::getMemorySize() { return memory_->data_size(); } std::optional V8::getMemory(uint64_t pointer, uint64_t size) { assert(memory_ != nullptr); + // Make sure we're operating in a wasm32 memory space. + if (pointer > UINT32_MAX || size > UINT32_MAX || pointer + size > UINT32_MAX) { + return std::nullopt; + } if (pointer + size > memory_->data_size()) { return std::nullopt; } @@ -501,6 +491,10 @@ std::optional V8::getMemory(uint64_t pointer, uint64_t size) { bool V8::setMemory(uint64_t pointer, uint64_t size, const void *data) { assert(memory_ != nullptr); + // Make sure we're operating in a wasm32 memory space. + if (pointer > UINT32_MAX || size > UINT32_MAX || pointer + size > UINT32_MAX) { + return false; + } if (pointer + size > memory_->data_size()) { return false; } @@ -510,43 +504,68 @@ bool V8::setMemory(uint64_t pointer, uint64_t size, const void *data) { bool V8::getWord(uint64_t pointer, Word *word) { constexpr auto size = sizeof(uint32_t); + // Make sure we're operating in a wasm32 memory space. + if (pointer > UINT32_MAX || pointer + size > UINT32_MAX) { + return false; + } if (pointer + size > memory_->data_size()) { return false; } uint32_t word32; ::memcpy(&word32, memory_->data() + pointer, size); - word->u64_ = word32; + word->u64_ = wasmtoh(word32, true); return true; } bool V8::setWord(uint64_t pointer, Word word) { constexpr auto size = sizeof(uint32_t); + // Make sure we're operating in a wasm32 memory space. + if (pointer > UINT32_MAX || pointer + size > UINT32_MAX) { + return false; + } if (pointer + size > memory_->data_size()) { return false; } - uint32_t word32 = word.u32(); + uint32_t word32 = htowasm(word.u32(), true); ::memcpy(memory_->data() + pointer, &word32, size); return true; } +wasm::own V8::trap(std::string message) { + return wasm::Trap::make(store_.get(), wasm::Message::make(std::move(message))); +} + template void V8::registerHostFunctionImpl(std::string_view module_name, std::string_view function_name, - void (*function)(void *, Args...)) { + void (*function)(Args...)) { auto data = std::make_unique(std::string(module_name) + "." + std::string(function_name)); auto type = wasm::FuncType::make(convertArgsTupleToValTypes>(), convertArgsTupleToValTypes>()); auto func = wasm::Func::make( store_.get(), type.get(), - [](void *data, const wasm::Val params[], wasm::Val[]) -> wasm::own { - auto func_data = reinterpret_cast(data); - auto args_tuple = convertValTypesToArgsTuple>(params); - auto args = std::tuple_cat(std::make_tuple(current_context_), args_tuple); - auto function = reinterpret_cast(func_data->raw_func_); - absl::apply(function, args); + [](void *data, const wasm::vec ¶ms, + wasm::vec & /*results*/) -> wasm::own { + auto *func_data = reinterpret_cast(data); + const bool log = func_data->vm_->cmpLogLevel(LogLevel::trace); + if (log) { + func_data->vm_->integration()->trace("[vm->host] " + func_data->name_ + "(" + + printValues(params, sizeof...(Args)) + ")"); + } + if (!func_data->vm_->isHostFunctionAllowed(func_data->name_)) { + return dynamic_cast(func_data->vm_)->trap("restricted_callback"); + } + auto args = convertValTypesToArgsTuple>(params); + auto function = reinterpret_cast(func_data->raw_func_); + std::apply(function, args); + if (log) { + func_data->vm_->integration()->trace("[vm<-host] " + func_data->name_ + " return: void"); + } return nullptr; }, data.get()); + + data->vm_ = this; data->callback_ = std::move(func); data->raw_func_ = reinterpret_cast(function); host_functions_.insert_or_assign(std::string(module_name) + "." + std::string(function_name), @@ -555,23 +574,37 @@ void V8::registerHostFunctionImpl(std::string_view module_name, std::string_view template void V8::registerHostFunctionImpl(std::string_view module_name, std::string_view function_name, - R (*function)(void *, Args...)) { + R (*function)(Args...)) { auto data = std::make_unique(std::string(module_name) + "." + std::string(function_name)); auto type = wasm::FuncType::make(convertArgsTupleToValTypes>(), convertArgsTupleToValTypes>()); auto func = wasm::Func::make( store_.get(), type.get(), - [](void *data, const wasm::Val params[], wasm::Val results[]) -> wasm::own { - auto func_data = reinterpret_cast(data); - auto args_tuple = convertValTypesToArgsTuple>(params); - auto args = std::tuple_cat(std::make_tuple(current_context_), args_tuple); - auto function = reinterpret_cast(func_data->raw_func_); - R rvalue = absl::apply(function, args); + [](void *data, const wasm::vec ¶ms, + wasm::vec &results) -> wasm::own { + auto *func_data = reinterpret_cast(data); + const bool log = func_data->vm_->cmpLogLevel(LogLevel::trace); + if (log) { + func_data->vm_->integration()->trace("[vm->host] " + func_data->name_ + "(" + + printValues(params, sizeof...(Args)) + ")"); + } + if (!func_data->vm_->isHostFunctionAllowed(func_data->name_)) { + return dynamic_cast(func_data->vm_)->trap("restricted_callback"); + } + auto args = convertValTypesToArgsTuple>(params); + auto function = reinterpret_cast(func_data->raw_func_); + R rvalue = std::apply(function, args); results[0] = makeVal(rvalue); + if (log) { + func_data->vm_->integration()->trace("[vm<-host] " + func_data->name_ + + " return: " + std::to_string(rvalue)); + } return nullptr; }, data.get()); + + data->vm_ = this; data->callback_ = std::move(func); data->raw_func_ = reinterpret_cast(function); host_functions_.insert_or_assign(std::string(module_name) + "." + std::string(function_name), @@ -587,20 +620,45 @@ void V8::getModuleFunctionImpl(std::string_view function_name, return; } const wasm::Func *func = it->second.get(); - if (!equalValTypes(func->type()->params(), convertArgsTupleToValTypes>()) || - !equalValTypes(func->type()->results(), convertArgsTupleToValTypes>())) { + auto arg_valtypes = convertArgsTupleToValTypes>(); + auto result_valtypes = convertArgsTupleToValTypes>(); + if (!equalValTypes(func->type()->params(), arg_valtypes) || + !equalValTypes(func->type()->results(), result_valtypes)) { fail(FailState::UnableToInitializeCode, - std::string("Bad function signature for: ") + std::string(function_name)); + "Bad function signature for: " + std::string(function_name) + + ", want: " + printValTypes(arg_valtypes) + " -> " + printValTypes(result_valtypes) + + ", but the module exports: " + printValTypes(func->type()->params()) + " -> " + + printValTypes(func->type()->results())); *function = nullptr; return; } *function = [func, function_name, this](ContextBase *context, Args... args) -> void { - wasm::Val params[] = {makeVal(args)...}; + const bool log = cmpLogLevel(LogLevel::trace); SaveRestoreContext saved_context(context); - auto trap = func->call(params, nullptr); + wasm::own trap = nullptr; + wasm::vec results = wasm::vec::make_uninitialized(); + + // Workaround for MSVC++ not supporting zero-sized arrays. + if constexpr (sizeof...(args) > 0) { + wasm::vec params = wasm::vec::make(makeVal(args)...); + if (log) { + integration()->trace("[host->vm] " + std::string(function_name) + "(" + + printValues(params, sizeof...(Args)) + ")"); + } + trap = func->call(params, results); + } else { + if (log) { + integration()->trace("[host->vm] " + std::string(function_name) + "()"); + } + trap = func->call(wasm::vec::make_uninitialized(), results); + } + if (trap) { - fail(FailState::RuntimeError, "Function: " + std::string(function_name) + " failed: " + - std::string(trap->message().get(), trap->message().size())); + fail(FailState::RuntimeError, getFailMessage(std::string(function_name), std::move(trap))); + return; + } + if (log) { + integration()->trace("[host<-vm] " + std::string(function_name) + " return: void"); } }; } @@ -614,30 +672,93 @@ void V8::getModuleFunctionImpl(std::string_view function_name, return; } const wasm::Func *func = it->second.get(); - if (!equalValTypes(func->type()->params(), convertArgsTupleToValTypes>()) || - !equalValTypes(func->type()->results(), convertArgsTupleToValTypes>())) { + auto arg_valtypes = convertArgsTupleToValTypes>(); + auto result_valtypes = convertArgsTupleToValTypes>(); + if (!equalValTypes(func->type()->params(), arg_valtypes) || + !equalValTypes(func->type()->results(), result_valtypes)) { fail(FailState::UnableToInitializeCode, - "Bad function signature for: " + std::string(function_name)); + "Bad function signature for: " + std::string(function_name) + + ", want: " + printValTypes(arg_valtypes) + " -> " + printValTypes(result_valtypes) + + ", but the module exports: " + printValTypes(func->type()->params()) + " -> " + + printValTypes(func->type()->results())); *function = nullptr; return; } *function = [func, function_name, this](ContextBase *context, Args... args) -> R { - wasm::Val params[] = {makeVal(args)...}; - wasm::Val results[1]; + const bool log = cmpLogLevel(LogLevel::trace); SaveRestoreContext saved_context(context); - auto trap = func->call(params, results); + wasm::vec results = wasm::vec::make_uninitialized(1); + wasm::own trap = nullptr; + + // Workaround for MSVC++ not supporting zero-sized arrays. + if constexpr (sizeof...(args) > 0) { + wasm::vec params = wasm::vec::make(makeVal(args)...); + if (log) { + integration()->trace("[host->vm] " + std::string(function_name) + "(" + + printValues(params, sizeof...(Args)) + ")"); + } + trap = func->call(params, results); + } else { + if (log) { + integration()->trace("[host->vm] " + std::string(function_name) + "()"); + } + trap = func->call(wasm::vec::make_uninitialized(), results); + } + if (trap) { - fail(FailState::RuntimeError, "Function: " + std::string(function_name) + " failed: " + - std::string(trap->message().get(), trap->message().size())); + fail(FailState::RuntimeError, getFailMessage(std::string(function_name), std::move(trap))); return R{}; } R rvalue = results[0].get::type>(); + if (log) { + integration()->trace("[host<-vm] " + std::string(function_name) + + " return: " + std::to_string(rvalue)); + } return rvalue; }; } -} // namespace +void V8::terminate() { + auto *store_impl = reinterpret_cast(store_.get()); + auto *isolate = store_impl->isolate(); + isolate->TerminateExecution(); +} + +void V8::warm() { initStore(); } + +std::string V8::getFailMessage(std::string_view function_name, wasm::own trap) { + auto message = "Function: " + std::string(function_name) + " failed: "; + message += std::string(trap->message().get(), trap->message().size()); + + if (function_names_index_.empty()) { + return message; + } + + auto trace = trap->trace(); + message += "\nProxy-Wasm plugin in-VM backtrace:"; + for (size_t i = 0; i < trace.size(); ++i) { + auto *frame = trace[i].get(); + std::ostringstream oss; + oss << std::setw(3) << std::setfill(' ') << std::to_string(i); + message += "\n" + oss.str() + ": "; + + std::stringstream address; + address << std::hex << frame->module_offset(); + message += " 0x" + address.str() + " - "; + + auto func_index = frame->func_index(); + auto it = function_names_index_.find(func_index); + if (it != function_names_index_.end()) { + message += it->second; + } else { + message += "unknown(function index:" + std::to_string(func_index) + ")"; + } + } + return message; +} + +} // namespace v8 -std::unique_ptr createV8Vm() { return std::make_unique(); } +std::unique_ptr createV8Vm() { return std::make_unique(); } } // namespace proxy_wasm diff --git a/src/vm_id_handle.cc b/src/vm_id_handle.cc new file mode 100644 index 000000000..d4eeef8d7 --- /dev/null +++ b/src/vm_id_handle.cc @@ -0,0 +1,73 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "include/proxy-wasm/vm_id_handle.h" + +#include +#include +#include +#include +#include +#include + +namespace proxy_wasm { + +std::mutex &getGlobalIdHandleMutex() { + static auto *ptr = new std::mutex; + return *ptr; +} + +std::vector> &getVmIdHandlesCallbacks() { + static auto *ptr = new std::vector>; + return *ptr; +} + +std::unordered_map> &getVmIdHandles() { + static auto *ptr = new std::unordered_map>; + return *ptr; +} + +std::shared_ptr getVmIdHandle(std::string_view vm_id) { + std::lock_guard lock(getGlobalIdHandleMutex()); + auto key = std::string(vm_id); + auto &handles = getVmIdHandles(); + + auto it = handles.find(key); + if (it != handles.end()) { + auto handle = it->second.lock(); + if (handle) { + return handle; + } + handles.erase(key); + } + + auto handle = std::make_shared(key); + handles[key] = handle; + return handle; +}; + +void registerVmIdHandleCallback(const std::function &f) { + std::lock_guard lock(getGlobalIdHandleMutex()); + getVmIdHandlesCallbacks().push_back(f); +} + +VmIdHandle::~VmIdHandle() { + std::lock_guard lock(getGlobalIdHandleMutex()); + for (const auto &f : getVmIdHandlesCallbacks()) { + f(vm_id_); + } + getVmIdHandles().erase(vm_id_); +} + +} // namespace proxy_wasm diff --git a/src/wamr/types.h b/src/wamr/types.h new file mode 100644 index 000000000..7252c5c3d --- /dev/null +++ b/src/wamr/types.h @@ -0,0 +1,43 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "src/common/types.h" +#include "wasm_c_api.h" + +namespace proxy_wasm::wamr { + +using WasmEnginePtr = common::CSmartPtr; +using WasmFuncPtr = common::CSmartPtr; +using WasmStorePtr = common::CSmartPtr; +using WasmModulePtr = common::CSmartPtr; +using WasmSharedModulePtr = common::CSmartPtr; +using WasmMemoryPtr = common::CSmartPtr; +using WasmTablePtr = common::CSmartPtr; +using WasmInstancePtr = common::CSmartPtr; +using WasmFunctypePtr = common::CSmartPtr; +using WasmTrapPtr = common::CSmartPtr; +using WasmExternPtr = common::CSmartPtr; + +using WasmByteVec = + common::CSmartType; +using WasmImporttypeVec = common::CSmartType; +using WasmExportTypeVec = common::CSmartType; +using WasmExternVec = + common::CSmartType; +using WasmValtypeVec = + common::CSmartType; + +} // namespace proxy_wasm::wamr diff --git a/src/wamr/wamr.cc b/src/wamr/wamr.cc new file mode 100644 index 000000000..8eef73590 --- /dev/null +++ b/src/wamr/wamr.cc @@ -0,0 +1,718 @@ +// Copyright 2016-2019 Envoy Project Authors +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "include/proxy-wasm/wamr.h" +#include "include/proxy-wasm/wasm_vm.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "src/wamr/types.h" +#include "wasm_c_api.h" + +namespace proxy_wasm { +namespace wamr { + +struct HostFuncData { + HostFuncData(std::string name) : name_(std::move(name)) {} + + std::string name_; + WasmFuncPtr callback_; + void *raw_func_{}; + WasmVm *vm_{}; +}; + +using HostFuncDataPtr = std::unique_ptr; + +wasm_engine_t *engine() { + static const auto engine = WasmEnginePtr(wasm_engine_new()); + return engine.get(); +} + +class Wamr : public WasmVm { +public: + Wamr() = default; + + std::string_view getEngineName() override { return "wamr"; } + // must use the exact name given by test-tools/append-aot-to-wasm/append_aot_to_wasm.py + std::string_view getPrecompiledSectionName() override { return "wamr-aot"; } + + Cloneable cloneable() override { return Cloneable::CompiledBytecode; } + std::unique_ptr clone() override; + + bool load(std::string_view bytecode, std::string_view precompiled, + const std::unordered_map &function_names) override; + bool link(std::string_view debug_name) override; + uint64_t getMemorySize() override; + std::optional getMemory(uint64_t pointer, uint64_t size) override; + bool setMemory(uint64_t pointer, uint64_t size, const void *data) override; + bool getWord(uint64_t pointer, Word *word) override; + bool setWord(uint64_t pointer, Word word) override; + size_t getWordSize() override { return sizeof(uint32_t); }; + +#define _REGISTER_HOST_FUNCTION(T) \ + void registerCallback(std::string_view module_name, std::string_view function_name, T, \ + typename ConvertFunctionTypeWordToUint32::type f) override { \ + registerHostFunctionImpl(module_name, function_name, f); \ + }; + FOR_ALL_WASM_VM_IMPORTS(_REGISTER_HOST_FUNCTION) +#undef _REGISTER_HOST_FUNCTION + +#define _GET_MODULE_FUNCTION(T) \ + void getFunction(std::string_view function_name, T *f) override { \ + getModuleFunctionImpl(function_name, f); \ + }; + FOR_ALL_WASM_VM_EXPORTS(_GET_MODULE_FUNCTION) +#undef _GET_MODULE_FUNCTION + + void terminate() override {} + bool usesWasmByteOrder() override { return true; } + + void warm() override; + +private: + template + void registerHostFunctionImpl(std::string_view module_name, std::string_view function_name, + void (*function)(Args...)); + + template + void registerHostFunctionImpl(std::string_view module_name, std::string_view function_name, + R (*function)(Args...)); + + template + void getModuleFunctionImpl(std::string_view function_name, + std::function *function); + + template + void getModuleFunctionImpl(std::string_view function_name, + std::function *function); + + // Initialize the Wamr store if necessary. + void initStore(); + + WasmStorePtr store_; + WasmModulePtr module_; + WasmSharedModulePtr shared_module_; + WasmInstancePtr instance_; + + WasmMemoryPtr memory_; + WasmTablePtr table_; + + std::unordered_map host_functions_; + std::unordered_map module_functions_; +}; + +void Wamr::initStore() { + if (store_ != nullptr) { + return; + } + store_ = wasm_store_new(engine()); +} + +bool Wamr::load(std::string_view bytecode, std::string_view precompiled, + const std::unordered_map & /*function_names*/) { + initStore(); + if (store_ == nullptr) { + return false; + } + + wasm_byte_vec_t binary = {0}; + if (precompiled.empty()) { + binary.size = bytecode.size(); + binary.data = const_cast(bytecode.data()); + binary.num_elems = bytecode.size(); + binary.size_of_elem = sizeof(byte_t); + binary.lock = nullptr; + } else { + // skip leading paddings + auto padding_count = static_cast(precompiled[0]); + precompiled.remove_prefix(padding_count + 1); + + binary.size = precompiled.size(); + binary.data = const_cast(precompiled.data()); + binary.num_elems = precompiled.size(); + binary.size_of_elem = sizeof(byte_t); + binary.lock = nullptr; + } + + module_ = wasm_module_new(store_.get(), &binary); + if (module_ == nullptr) { + return false; + } + + shared_module_ = wasm_module_share(module_.get()); + if (shared_module_ == nullptr) { + return false; + } + + return true; +} + +std::unique_ptr Wamr::clone() { + assert(module_ != nullptr); + + auto vm = std::make_unique(); + if (vm == nullptr) { + return nullptr; + } + + vm->store_ = wasm_store_new(engine()); + if (vm->store_ == nullptr) { + return nullptr; + } + + vm->module_ = wasm_module_obtain(vm->store_.get(), shared_module_.get()); + if (vm->module_ == nullptr) { + return nullptr; + } + + auto *integration_clone = integration()->clone(); + if (integration_clone == nullptr) { + return nullptr; + } + vm->integration().reset(integration_clone); + + return vm; +} + +static bool equalValTypes(const wasm_valtype_vec_t *left, const wasm_valtype_vec_t *right) { + if (left->size != right->size) { + return false; + } + + for (size_t i = 0; i < left->size; i++) { + if (wasm_valtype_kind(left->data[i]) != wasm_valtype_kind(right->data[i])) { + return false; + } + } + + return true; +} + +static std::string printValue(const wasm_val_t &value) { + switch (value.kind) { + case WASM_I32: + return std::to_string(value.of.i32); + case WASM_I64: + return std::to_string(value.of.i64); + case WASM_F32: + return std::to_string(value.of.f32); + case WASM_F64: + return std::to_string(value.of.f64); + default: + return "unknown"; + } +} + +static std::string printValues(const wasm_val_vec_t *values) { + if (values->size == 0) { + return ""; + } + + std::string s; + for (size_t i = 0; i < values->size; i++) { + if (i != 0U) { + s.append(", "); + } + s.append(printValue(values->data[i])); + } + return s; +} + +static const char *printValKind(wasm_valkind_t kind) { + switch (kind) { + case WASM_I32: + return "i32"; + case WASM_I64: + return "i64"; + case WASM_F32: + return "f32"; + case WASM_F64: + return "f64"; + case WASM_EXTERNREF: + return "externref"; + case WASM_FUNCREF: + return "funcref"; + default: + return "unknown"; + } +} + +static std::string printValTypes(const wasm_valtype_vec_t *types) { + if (types->size == 0) { + return "void"; + } + + std::string s; + s.reserve(types->size * 8 /* max size + " " */ - 1); + for (size_t i = 0; i < types->size; i++) { + if (i != 0U) { + s.append(" "); + } + s.append(printValKind(wasm_valtype_kind(types->data[i]))); + } + return s; +} + +bool Wamr::link(std::string_view /*debug_name*/) { + assert(module_ != nullptr); + + WasmImporttypeVec import_types; + wasm_module_imports(module_.get(), import_types.get()); + + std::vector imports; + for (size_t i = 0; i < import_types.get()->size; i++) { + const wasm_name_t *module_name_ptr = wasm_importtype_module(import_types.get()->data[i]); + const wasm_name_t *name_ptr = wasm_importtype_name(import_types.get()->data[i]); + const wasm_externtype_t *extern_type = wasm_importtype_type(import_types.get()->data[i]); + + if (std::strlen(name_ptr->data) == 0) { + fail(FailState::UnableToInitializeCode, std::string("The name field of import_types[") + + std::to_string(i) + std::string("] is empty")); + return false; + } + + std::string_view module_name(module_name_ptr->data); + std::string_view name(name_ptr->data); + + switch (wasm_externtype_kind(extern_type)) { + case WASM_EXTERN_FUNC: { + auto it = host_functions_.find(std::string(module_name) + "." + std::string(name)); + if (it == host_functions_.end()) { + fail(FailState::UnableToInitializeCode, + std::string("Failed to load Wasm module due to a missing import: ") + + std::string(module_name) + "." + std::string(name)); + return false; + } + + auto *func = it->second->callback_.get(); + const wasm_functype_t *exp_type = wasm_externtype_as_functype_const(extern_type); + WasmFunctypePtr actual_type = wasm_func_type(it->second->callback_.get()); + if (!equalValTypes(wasm_functype_params(exp_type), wasm_functype_params(actual_type.get())) || + !equalValTypes(wasm_functype_results(exp_type), + wasm_functype_results(actual_type.get()))) { + fail( + FailState::UnableToInitializeCode, + std::string("Failed to load Wasm module due to an import type mismatch for function ") + + std::string(module_name) + "." + std::string(name) + + ", want: " + printValTypes(wasm_functype_params(exp_type)) + " -> " + + printValTypes(wasm_functype_results(exp_type)) + + ", but host exports: " + printValTypes(wasm_functype_params(actual_type.get())) + + " -> " + printValTypes(wasm_functype_results(actual_type.get()))); + return false; + } + imports.push_back(wasm_func_as_extern(func)); + } break; + case WASM_EXTERN_GLOBAL: { + // TODO(mathetake): add support when/if needed. + fail(FailState::UnableToInitializeCode, + "Failed to load Wasm module due to a missing import: " + std::string(module_name) + "." + + std::string(name)); + return false; + } break; + case WASM_EXTERN_MEMORY: { + assert(memory_ == nullptr); + const wasm_memorytype_t *memory_type = + wasm_externtype_as_memorytype_const(extern_type); // owned by `extern_type` + if (memory_type == nullptr) { + return false; + } + memory_ = wasm_memory_new(store_.get(), memory_type); + if (memory_ == nullptr) { + return false; + } + imports.push_back(wasm_memory_as_extern(memory_.get())); + } break; + case WASM_EXTERN_TABLE: { + assert(table_ == nullptr); + const wasm_tabletype_t *table_type = + wasm_externtype_as_tabletype_const(extern_type); // owned by `extern_type` + if (table_type == nullptr) { + return false; + } + table_ = wasm_table_new(store_.get(), table_type, nullptr); + if (table_ == nullptr) { + return false; + } + imports.push_back(wasm_table_as_extern(table_.get())); + } break; + } + } + + if (import_types.get()->size != imports.size()) { + return false; + } + + wasm_extern_vec_t imports_vec = {imports.size(), imports.data(), imports.size()}; + instance_ = wasm_instance_new(store_.get(), module_.get(), &imports_vec, nullptr); + if (instance_ == nullptr) { + fail(FailState::UnableToInitializeCode, "Failed to create new Wasm instance"); + return false; + } + + WasmExportTypeVec export_types; + wasm_module_exports(module_.get(), export_types.get()); + + WasmExternVec exports; + wasm_instance_exports(instance_.get(), exports.get()); + + for (size_t i = 0; i < export_types.get()->size; i++) { + wasm_extern_t *actual_extern = exports.get()->data[i]; + + wasm_externkind_t kind = wasm_extern_kind(actual_extern); + assert(kind == wasm_externtype_kind(wasm_exporttype_type(export_types.get()->data[i]))); + switch (kind) { + case WASM_EXTERN_FUNC: { + WasmFuncPtr func = wasm_func_copy(wasm_extern_as_func(actual_extern)); + const wasm_name_t *name_ptr = wasm_exporttype_name(export_types.get()->data[i]); + module_functions_.insert_or_assign(std::string(name_ptr->data), std::move(func)); + } break; + case WASM_EXTERN_GLOBAL: { + // TODO(mathetake): add support when/if needed. + } break; + case WASM_EXTERN_MEMORY: { + assert(memory_ == nullptr); + memory_ = wasm_memory_copy(wasm_extern_as_memory(actual_extern)); + if (memory_ == nullptr) { + return false; + } + } break; + case WASM_EXTERN_TABLE: { + // TODO(mathetake): add support when/if needed. + } break; + } + } + return true; +} + +uint64_t Wamr::getMemorySize() { return wasm_memory_data_size(memory_.get()); } + +std::optional Wamr::getMemory(uint64_t pointer, uint64_t size) { + assert(memory_ != nullptr); + if (pointer + size > wasm_memory_data_size(memory_.get())) { + return std::nullopt; + } + return std::string_view(wasm_memory_data(memory_.get()) + pointer, size); +} + +bool Wamr::setMemory(uint64_t pointer, uint64_t size, const void *data) { + assert(memory_ != nullptr); + if (pointer + size > wasm_memory_data_size(memory_.get())) { + return false; + } + ::memcpy(wasm_memory_data(memory_.get()) + pointer, data, size); + return true; +} + +bool Wamr::getWord(uint64_t pointer, Word *word) { + assert(memory_ != nullptr); + constexpr auto size = sizeof(uint32_t); + if (pointer + size > wasm_memory_data_size(memory_.get())) { + return false; + } + + uint32_t word32; + ::memcpy(&word32, wasm_memory_data(memory_.get()) + pointer, size); + word->u64_ = wasmtoh(word32, true); + return true; +} + +bool Wamr::setWord(uint64_t pointer, Word word) { + constexpr auto size = sizeof(uint32_t); + if (pointer + size > wasm_memory_data_size(memory_.get())) { + return false; + } + uint32_t word32 = htowasm(word.u32(), true); + ::memcpy(wasm_memory_data(memory_.get()) + pointer, &word32, size); + return true; +} + +template void assignVal(T t, wasm_val_t &val); +template <> void assignVal(Word t, wasm_val_t &val) { + val.kind = WASM_I32; + val.of.i32 = static_cast(t.u64_); +} +template <> void assignVal(uint32_t t, wasm_val_t &val) { + val.kind = WASM_I32; + val.of.i32 = static_cast(t); +} +template <> void assignVal(uint64_t t, wasm_val_t &val) { + val.kind = WASM_I64; + val.of.i64 = static_cast(t); +} +template <> void assignVal(double t, wasm_val_t &val) { + val.kind = WASM_F64; + val.of.f64 = t; +} + +template wasm_val_t makeVal(T t) { + wasm_val_t val{}; + assignVal(t, val); + return val; +} + +template struct ConvertWordType { + using type = T; // NOLINT(readability-identifier-naming) +}; +template <> struct ConvertWordType { + using type = uint32_t; // NOLINT(readability-identifier-naming) +}; + +template auto convertArgToValTypePtr(); +template <> auto convertArgToValTypePtr() { return wasm_valtype_new_i32(); }; +template <> auto convertArgToValTypePtr() { return wasm_valtype_new_i32(); }; +template <> auto convertArgToValTypePtr() { return wasm_valtype_new_i64(); }; +template <> auto convertArgToValTypePtr() { return wasm_valtype_new_i64(); }; +template <> auto convertArgToValTypePtr() { return wasm_valtype_new_f64(); }; + +template T convertValueTypeToArg(wasm_val_t val); +template <> uint32_t convertValueTypeToArg(wasm_val_t val) { + return static_cast(val.of.i32); +} +template <> Word convertValueTypeToArg(wasm_val_t val) { return val.of.i32; } +template <> int64_t convertValueTypeToArg(wasm_val_t val) { return val.of.i64; } +template <> uint64_t convertValueTypeToArg(wasm_val_t val) { + return static_cast(val.of.i64); +} +template <> double convertValueTypeToArg(wasm_val_t val) { return val.of.f64; } + +template +constexpr T convertValTypesToArgsTuple(const U &vec, std::index_sequence /*comptime*/) { + return std::make_tuple( + convertValueTypeToArg>::type>( + vec->data[I])...); +} + +template +void convertArgsTupleToValTypesImpl(wasm_valtype_vec_t *types, + std::index_sequence /*comptime*/) { + auto size = std::tuple_size::value; + auto ps = std::array::value>{ + convertArgToValTypePtr::type>()...}; + wasm_valtype_vec_new(types, size, ps.data()); +} + +template ::value>> +void convertArgsTupleToValTypes(wasm_valtype_vec_t *types) { + convertArgsTupleToValTypesImpl(types, Is()); +} + +template WasmFunctypePtr newWasmNewFuncType() { + wasm_valtype_vec_t params; + wasm_valtype_vec_t results; + convertArgsTupleToValTypes(¶ms); + convertArgsTupleToValTypes>(&results); + return wasm_functype_new(¶ms, &results); +} + +template WasmFunctypePtr newWasmNewFuncType() { + wasm_valtype_vec_t params; + wasm_valtype_vec_t results; + convertArgsTupleToValTypes(¶ms); + convertArgsTupleToValTypes>(&results); + return wasm_functype_new(¶ms, &results); +} + +template +void Wamr::registerHostFunctionImpl(std::string_view module_name, std::string_view function_name, + void (*function)(Args...)) { + auto data = + std::make_unique(std::string(module_name) + "." + std::string(function_name)); + + WasmFunctypePtr type = newWasmNewFuncType>(); + WasmFuncPtr func = wasm_func_new_with_env( + store_.get(), type.get(), + [](void *data, const wasm_val_vec_t *params, wasm_val_vec_t * /*results*/) -> wasm_trap_t * { + auto *func_data = reinterpret_cast(data); + const bool log = func_data->vm_->cmpLogLevel(LogLevel::trace); + if (log) { + func_data->vm_->integration()->trace("[vm->host] " + func_data->name_ + "(" + + printValues(params) + ")"); + } + auto args = convertValTypesToArgsTuple>( + params, std::make_index_sequence{}); + auto fn = reinterpret_cast(func_data->raw_func_); + std::apply(fn, args); + if (log) { + func_data->vm_->integration()->trace("[vm<-host] " + func_data->name_ + " return: void"); + } + return nullptr; + }, + data.get(), nullptr); + + data->vm_ = this; + data->callback_ = std::move(func); + data->raw_func_ = reinterpret_cast(function); + host_functions_.insert_or_assign(std::string(module_name) + "." + std::string(function_name), + std::move(data)); +}; + +template +void Wamr::registerHostFunctionImpl(std::string_view module_name, std::string_view function_name, + R (*function)(Args...)) { + auto data = + std::make_unique(std::string(module_name) + "." + std::string(function_name)); + WasmFunctypePtr type = newWasmNewFuncType>(); + WasmFuncPtr func = wasm_func_new_with_env( + store_.get(), type.get(), + [](void *data, const wasm_val_vec_t *params, wasm_val_vec_t *results) -> wasm_trap_t * { + auto *func_data = reinterpret_cast(data); + const bool log = func_data->vm_->cmpLogLevel(LogLevel::trace); + if (log) { + func_data->vm_->integration()->trace("[vm->host] " + func_data->name_ + "(" + + printValues(params) + ")"); + } + auto args = convertValTypesToArgsTuple>( + params, std::make_index_sequence{}); + auto fn = reinterpret_cast(func_data->raw_func_); + R res = std::apply(fn, args); + assignVal(res, results->data[0]); + if (log) { + func_data->vm_->integration()->trace("[vm<-host] " + func_data->name_ + + " return: " + std::to_string(res)); + } + return nullptr; + }, + data.get(), nullptr); + + data->vm_ = this; + data->callback_ = std::move(func); + data->raw_func_ = reinterpret_cast(function); + host_functions_.insert_or_assign(std::string(module_name) + "." + std::string(function_name), + std::move(data)); +}; + +template +void Wamr::getModuleFunctionImpl(std::string_view function_name, + std::function *function) { + + auto it = module_functions_.find(std::string(function_name)); + if (it == module_functions_.end()) { + *function = nullptr; + return; + } + + WasmValtypeVec exp_args; + WasmValtypeVec exp_returns; + convertArgsTupleToValTypes>(exp_args.get()); + convertArgsTupleToValTypes>(exp_returns.get()); + wasm_func_t *func = it->second.get(); + WasmFunctypePtr func_type = wasm_func_type(func); + + if (!equalValTypes(wasm_functype_params(func_type.get()), exp_args.get()) || + !equalValTypes(wasm_functype_results(func_type.get()), exp_returns.get())) { + fail(FailState::UnableToInitializeCode, + "Bad function signature for: " + std::string(function_name) + ", want: " + + printValTypes(exp_args.get()) + " -> " + printValTypes(exp_returns.get()) + + ", but the module exports: " + printValTypes(wasm_functype_params(func_type.get())) + + " -> " + printValTypes(wasm_functype_results(func_type.get()))); + return; + } + + *function = [func, function_name, this](ContextBase *context, Args... args) -> void { + wasm_val_t params_arr[] = {makeVal(args)...}; + const wasm_val_vec_t params = WASM_ARRAY_VEC(params_arr); + wasm_val_vec_t results = WASM_EMPTY_VEC; + const bool log = cmpLogLevel(LogLevel::trace); + if (log) { + integration()->trace("[host->vm] " + std::string(function_name) + "(" + printValues(¶ms) + + ")"); + } + SaveRestoreContext saved_context(context); + WasmTrapPtr trap{wasm_func_call(func, ¶ms, &results)}; + if (trap) { + WasmByteVec error_message; + wasm_trap_message(trap.get(), error_message.get()); + std::string message(error_message.get()->data); // NULL-terminated + fail(FailState::RuntimeError, + "Function: " + std::string(function_name) + " failed: " + message); + return; + } + if (log) { + integration()->trace("[host<-vm] " + std::string(function_name) + " return: void"); + } + }; +}; + +template +void Wamr::getModuleFunctionImpl(std::string_view function_name, + std::function *function) { + auto it = module_functions_.find(std::string(function_name)); + if (it == module_functions_.end()) { + *function = nullptr; + return; + } + WasmValtypeVec exp_args; + WasmValtypeVec exp_returns; + convertArgsTupleToValTypes>(exp_args.get()); + convertArgsTupleToValTypes>(exp_returns.get()); + wasm_func_t *func = it->second.get(); + WasmFunctypePtr func_type = wasm_func_type(func); + if (!equalValTypes(wasm_functype_params(func_type.get()), exp_args.get()) || + !equalValTypes(wasm_functype_results(func_type.get()), exp_returns.get())) { + fail(FailState::UnableToInitializeCode, + "Bad function signature for: " + std::string(function_name) + ", want: " + + printValTypes(exp_args.get()) + " -> " + printValTypes(exp_returns.get()) + + ", but the module exports: " + printValTypes(wasm_functype_params(func_type.get())) + + " -> " + printValTypes(wasm_functype_results(func_type.get()))); + return; + } + + *function = [func, function_name, this](ContextBase *context, Args... args) -> R { + wasm_val_t params_arr[] = {makeVal(args)...}; + const wasm_val_vec_t params = WASM_ARRAY_VEC(params_arr); + wasm_val_t results_arr[1]; + wasm_val_vec_t results = WASM_ARRAY_VEC(results_arr); + const bool log = cmpLogLevel(LogLevel::trace); + if (log) { + integration()->trace("[host->vm] " + std::string(function_name) + "(" + printValues(¶ms) + + ")"); + } + SaveRestoreContext saved_context(context); + WasmTrapPtr trap{wasm_func_call(func, ¶ms, &results)}; + if (trap) { + WasmByteVec error_message; + wasm_trap_message(trap.get(), error_message.get()); + std::string message(error_message.get()->data); // NULL-terminated + fail(FailState::RuntimeError, + "Function: " + std::string(function_name) + " failed: " + message); + return R{}; + } + R ret = convertValueTypeToArg(results.data[0]); + if (log) { + integration()->trace("[host<-vm] " + std::string(function_name) + + " return: " + std::to_string(ret)); + } + return ret; + }; +}; + +void Wamr::warm() { initStore(); } + +} // namespace wamr + +std::unique_ptr createWamrVm() { return std::make_unique(); } + +} // namespace proxy_wasm diff --git a/src/wasm.cc b/src/wasm.cc index 3a055c522..a1b4c1836 100644 --- a/src/wasm.cc +++ b/src/wasm.cc @@ -14,96 +14,95 @@ // limitations under the License. #include "include/proxy-wasm/wasm.h" -#include "src/third_party/base64.h" -#include "src/third_party/picosha2.h" #include -#include +#include #include #include #include #include #include +#include #include #include +#include -namespace proxy_wasm { +#include "include/proxy-wasm/bytecode_util.h" +#include "include/proxy-wasm/signature_util.h" +#include "include/proxy-wasm/vm_id_handle.h" +#include "src/hash.h" -thread_local ContextBase *current_context_; -thread_local uint32_t effective_context_id_ = 0; +namespace proxy_wasm { namespace { -// Map from Wasm Key to the local Wasm instance. +// Map from Wasm key to the thread-local Wasm instance. thread_local std::unordered_map> local_wasms; +// Wasm key queue to track stale entries in `local_wasms`. +thread_local std::queue local_wasms_keys; + +// Map from plugin key to the thread-local plugin instance. +thread_local std::unordered_map> local_plugins; +// Plugin key queue to track stale entries in `local_plugins`. +thread_local std::queue local_plugins_keys; + +// Check no more than `MAX_LOCAL_CACHE_GC_CHUNK_SIZE` cache entries at a time during stale entries +// cleanup. +const size_t MAX_LOCAL_CACHE_GC_CHUNK_SIZE = 64; + // Map from Wasm Key to the base Wasm instance, using a pointer to avoid the initialization fiasco. std::mutex base_wasms_mutex; std::unordered_map> *base_wasms = nullptr; -std::unordered_map *foreign_functions = nullptr; - -const std::string INLINE_STRING = ""; -const uint8_t *decodeVarint(const uint8_t *pos, const uint8_t *end, uint32_t *out) { - uint32_t ret = 0; - int shift = 0; - while (pos < end && (*pos & 0x80)) { - ret |= (*pos & 0x7f) << shift; - shift += 7; - pos++; - } - if (pos < end) { - ret |= *pos << shift; - pos++; - } - *out = ret; - return pos; +void cacheLocalWasm(const std::string &key, const std::shared_ptr &wasm_handle) { + local_wasms[key] = wasm_handle; + local_wasms_keys.emplace(key); } -std::string Sha256(std::string_view data) { - std::vector hash(picosha2::k_digest_size); - picosha2::hash256(data.begin(), data.end(), hash.begin(), hash.end()); - return std::string(reinterpret_cast(&hash[0]), hash.size()); +void cacheLocalPlugin(const std::string &key, + const std::shared_ptr &plugin_handle) { + local_plugins[key] = plugin_handle; + local_plugins_keys.emplace(key); } -std::string Xor(std::string_view a, std::string_view b) { - assert(a.size() == b.size()); - std::string result; - result.reserve(a.size()); - for (size_t i = 0; i < a.size(); i++) { - result.push_back(a[i] ^ b[i]); +template +void removeStaleLocalCacheEntries(std::unordered_map> &cache, + std::queue &keys) { + auto num_keys_to_check = std::min(MAX_LOCAL_CACHE_GC_CHUNK_SIZE, keys.size()); + for (size_t i = 0; i < num_keys_to_check; i++) { + std::string key(keys.front()); + keys.pop(); + + const auto it = cache.find(key); + if (it == cache.end()) { + continue; + } + + if (it->second.expired()) { + cache.erase(it); + } else { + keys.push(std::move(key)); + } } - return result; } } // namespace std::string makeVmKey(std::string_view vm_id, std::string_view vm_configuration, std::string_view code) { - std::string vm_key = Sha256(vm_id); - vm_key = Xor(vm_key, Sha256(vm_configuration)); - vm_key = Xor(vm_key, Sha256(code)); - auto start = reinterpret_cast(&*vm_key.begin()); - auto end = start + vm_key.size(); - return base64Encode(start, end); + return Sha256String({vm_id, "||", vm_configuration, "||", code}); } class WasmBase::ShutdownHandle { public: ~ShutdownHandle() { wasm_->finishShutdown(); } - ShutdownHandle(std::shared_ptr wasm) : wasm_(wasm) {} + ShutdownHandle(std::shared_ptr wasm) : wasm_(std::move(wasm)) {} private: std::shared_ptr wasm_; }; -RegisterForeignFunction::RegisterForeignFunction(std::string name, WasmForeignFunction f) { - if (!foreign_functions) { - foreign_functions = new std::remove_reference::type; - } - (*foreign_functions)[name] = f; -} - void WasmBase::registerCallbacks() { #define _REGISTER(_fn) \ wasm_vm_->registerCallback( \ @@ -111,85 +110,33 @@ void WasmBase::registerCallbacks() { &ConvertFunctionWordToUint32::convertFunctionWordToUint32) _REGISTER(pthread_equal); + _REGISTER(emscripten_notify_memory_growth); #undef _REGISTER -#define _REGISTER_WASI(_fn) \ - wasm_vm_->registerCallback( \ - "wasi_unstable", #_fn, &exports::wasi_unstable_##_fn, \ - &ConvertFunctionWordToUint32::convertFunctionWordToUint32); \ - wasm_vm_->registerCallback( \ - "wasi_snapshot_preview1", #_fn, &exports::wasi_unstable_##_fn, \ - &ConvertFunctionWordToUint32::convertFunctionWordToUint32) - _REGISTER_WASI(fd_write); - _REGISTER_WASI(fd_read); - _REGISTER_WASI(fd_seek); - _REGISTER_WASI(fd_close); - _REGISTER_WASI(fd_fdstat_get); - _REGISTER_WASI(environ_get); - _REGISTER_WASI(environ_sizes_get); - _REGISTER_WASI(args_get); - _REGISTER_WASI(args_sizes_get); - _REGISTER_WASI(clock_time_get); - _REGISTER_WASI(random_get); - _REGISTER_WASI(proc_exit); -#undef _REGISTER_WASI - - // Calls with the "proxy_" prefix. -#define _REGISTER_PROXY(_fn) \ - wasm_vm_->registerCallback( \ - "env", "proxy_" #_fn, &exports::_fn, \ - &ConvertFunctionWordToUint32::convertFunctionWordToUint32); - _REGISTER_PROXY(log); - - _REGISTER_PROXY(get_status); - - _REGISTER_PROXY(set_property); - _REGISTER_PROXY(get_property); - - _REGISTER_PROXY(send_local_response); - - _REGISTER_PROXY(get_shared_data); - _REGISTER_PROXY(set_shared_data); - - _REGISTER_PROXY(register_shared_queue); - _REGISTER_PROXY(resolve_shared_queue); - _REGISTER_PROXY(dequeue_shared_queue); - _REGISTER_PROXY(enqueue_shared_queue); - - _REGISTER_PROXY(get_header_map_value); - _REGISTER_PROXY(add_header_map_value); - _REGISTER_PROXY(replace_header_map_value); - _REGISTER_PROXY(remove_header_map_value); - _REGISTER_PROXY(get_header_map_pairs); - _REGISTER_PROXY(set_header_map_pairs); - _REGISTER_PROXY(get_header_map_size); - - _REGISTER_PROXY(get_buffer_status); - _REGISTER_PROXY(get_buffer_bytes); - _REGISTER_PROXY(set_buffer_bytes); - - _REGISTER_PROXY(http_call); - - _REGISTER_PROXY(grpc_call); - _REGISTER_PROXY(grpc_stream); - _REGISTER_PROXY(grpc_close); - _REGISTER_PROXY(grpc_cancel); - _REGISTER_PROXY(grpc_send); - - _REGISTER_PROXY(set_tick_period_milliseconds); - _REGISTER_PROXY(get_current_time_nanoseconds); - - _REGISTER_PROXY(define_metric); - _REGISTER_PROXY(increment_metric); - _REGISTER_PROXY(record_metric); - _REGISTER_PROXY(get_metric); - - _REGISTER_PROXY(set_effective_context); - _REGISTER_PROXY(done); - _REGISTER_PROXY(call_foreign_function); + // Register the capability with the VM if it has been allowed, otherwise register a stub. +#define _REGISTER(module_name, name_prefix, export_prefix, _fn) \ + if (capabilityAllowed(name_prefix #_fn)) { \ + wasm_vm_->registerCallback( \ + module_name, name_prefix #_fn, &exports::export_prefix##_fn, \ + &ConvertFunctionWordToUint32::convertFunctionWordToUint32); \ + } else { \ + typedef decltype(exports::export_prefix##_fn) export_type; \ + constexpr export_type *stub = &exports::_fn##Stub::stub; \ + wasm_vm_->registerCallback( \ + module_name, name_prefix #_fn, stub, \ + &ConvertFunctionWordToUint32::convertFunctionWordToUint32); \ + } + +#define _REGISTER_WASI_UNSTABLE(_fn) _REGISTER("wasi_unstable", , wasi_unstable_, _fn) +#define _REGISTER_WASI_SNAPSHOT(_fn) _REGISTER("wasi_snapshot_preview1", , wasi_unstable_, _fn) + FOR_ALL_WASI_FUNCTIONS(_REGISTER_WASI_UNSTABLE); + FOR_ALL_WASI_FUNCTIONS(_REGISTER_WASI_SNAPSHOT); +#undef _REGISTER_WASI_UNSTABLE +#undef _REGISTER_WASI_SNAPSHOT + +#define _REGISTER_PROXY(_fn) _REGISTER("env", "proxy_", , _fn) + FOR_ALL_HOST_FUNCTIONS(_REGISTER_PROXY); if (abiVersion() == AbiVersion::ProxyWasm_0_1_0) { _REGISTER_PROXY(get_configuration); @@ -205,49 +152,45 @@ void WasmBase::registerCallbacks() { _REGISTER_PROXY(get_log_level); } #undef _REGISTER_PROXY + +#undef _REGISTER } void WasmBase::getFunctions() { #define _GET(_fn) wasm_vm_->getFunction(#_fn, &_fn##_); - _GET(_start); - _GET(__wasm_call_ctors); +#define _GET_ALIAS(_fn, _alias) wasm_vm_->getFunction(#_alias, &_fn##_); + _GET(_initialize); + if (_initialize_) { + _GET(main); + } else { + _GET(_start); + } _GET(malloc); + if (!malloc_) { + _GET_ALIAS(malloc, proxy_on_memory_allocate); + } if (!malloc_) { fail(FailState::MissingFunction, "Wasm module is missing malloc function."); } +#undef _GET_ALIAS #undef _GET -#define _GET_PROXY(_fn) wasm_vm_->getFunction("proxy_" #_fn, &_fn##_); -#define _GET_PROXY_ABI(_fn, _abi) wasm_vm_->getFunction("proxy_" #_fn, &_fn##_abi##_); - _GET_PROXY(validate_configuration); - _GET_PROXY(on_vm_start); - _GET_PROXY(on_configure); - _GET_PROXY(on_tick); - - _GET_PROXY(on_context_create); - - _GET_PROXY(on_new_connection); - _GET_PROXY(on_downstream_data); - _GET_PROXY(on_upstream_data); - _GET_PROXY(on_downstream_connection_close); - _GET_PROXY(on_upstream_connection_close); - - _GET_PROXY(on_request_body); - _GET_PROXY(on_request_trailers); - _GET_PROXY(on_request_metadata); - _GET_PROXY(on_response_body); - _GET_PROXY(on_response_trailers); - _GET_PROXY(on_response_metadata); - _GET_PROXY(on_http_call_response); - _GET_PROXY(on_grpc_receive); - _GET_PROXY(on_grpc_close); - _GET_PROXY(on_grpc_receive_initial_metadata); - _GET_PROXY(on_grpc_receive_trailing_metadata); - _GET_PROXY(on_queue_ready); - _GET_PROXY(on_done); - _GET_PROXY(on_log); - _GET_PROXY(on_delete); + // Try to point the capability to one of the module exports, if the capability has been allowed. +#define _GET_PROXY(_fn) \ + if (capabilityAllowed("proxy_" #_fn)) { \ + wasm_vm_->getFunction("proxy_" #_fn, &_fn##_); \ + } else { \ + _fn##_ = nullptr; \ + } +#define _GET_PROXY_ABI(_fn, _abi) \ + if (capabilityAllowed("proxy_" #_fn)) { \ + wasm_vm_->getFunction("proxy_" #_fn, &_fn##_abi##_); \ + } else { \ + _fn##_abi##_ = nullptr; \ + } + + FOR_ALL_MODULE_FUNCTIONS(_GET_PROXY); if (abiVersion() == AbiVersion::ProxyWasm_0_1_0) { _GET_PROXY_ABI(on_request_headers, _abi_01); @@ -262,10 +205,13 @@ void WasmBase::getFunctions() { #undef _GET_PROXY } -WasmBase::WasmBase(const std::shared_ptr &base_wasm_handle, WasmVmFactory factory) +WasmBase::WasmBase(const std::shared_ptr &base_wasm_handle, + const WasmVmFactory &factory) : std::enable_shared_from_this(*base_wasm_handle->wasm()), vm_id_(base_wasm_handle->wasm()->vm_id_), vm_key_(base_wasm_handle->wasm()->vm_key_), started_from_(base_wasm_handle->wasm()->wasm_vm()->cloneable()), + envs_(base_wasm_handle->wasm()->envs()), + allowed_capabilities_(base_wasm_handle->wasm()->allowed_capabilities_), base_wasm_handle_(base_wasm_handle) { if (started_from_ != Cloneable::NotCloneable) { wasm_vm_ = base_wasm_handle->wasm()->wasm_vm()->clone(); @@ -273,74 +219,129 @@ WasmBase::WasmBase(const std::shared_ptr &base_wasm_handle, Wasm wasm_vm_ = factory(); } if (!wasm_vm_) { - failed_ = FailState::UnableToCreateVM; + failed_ = FailState::UnableToCreateVm; } else { - wasm_vm_->setFailCallback([this](FailState fail_state) { failed_ = fail_state; }); + wasm_vm_->addFailCallback([this](FailState fail_state) { failed_ = fail_state; }); } } WasmBase::WasmBase(std::unique_ptr wasm_vm, std::string_view vm_id, - std::string_view vm_configuration, std::string_view vm_key) + std::string_view vm_configuration, std::string_view vm_key, + std::unordered_map envs, + AllowedCapabilitiesMap allowed_capabilities) : vm_id_(std::string(vm_id)), vm_key_(std::string(vm_key)), wasm_vm_(std::move(wasm_vm)), - vm_configuration_(std::string(vm_configuration)) { + envs_(std::move(envs)), allowed_capabilities_(std::move(allowed_capabilities)), + vm_configuration_(std::string(vm_configuration)), vm_id_handle_(getVmIdHandle(vm_id)) { if (!wasm_vm_) { - failed_ = FailState::UnableToCreateVM; + failed_ = FailState::UnableToCreateVm; } else { - wasm_vm_->setFailCallback([this](FailState fail_state) { failed_ = fail_state; }); + wasm_vm_->addFailCallback([this](FailState fail_state) { failed_ = fail_state; }); } } -WasmBase::~WasmBase() {} +WasmBase::~WasmBase() { + root_contexts_.clear(); + pending_done_.clear(); + pending_delete_.clear(); +} + +bool WasmBase::load(const std::string &code, bool allow_precompiled) { + assert(!started_from_.has_value()); -bool WasmBase::initialize(const std::string &code, bool allow_precompiled) { if (!wasm_vm_) { return false; } - if (started_from_ == Cloneable::NotCloneable) { - auto ok = wasm_vm_->load(code, allow_precompiled); + if (wasm_vm_->getEngineName() == "null") { + auto ok = wasm_vm_->load(code, {}, {}); if (!ok) { + fail(FailState::UnableToInitializeCode, "Failed to load NullVM plugin"); return false; } - auto metadata = wasm_vm_->getCustomSection("emscripten_metadata"); - if (!metadata.empty()) { - // See https://github.com/emscripten-core/emscripten/blob/incoming/tools/shared.py#L3059 - is_emscripten_ = true; - auto start = reinterpret_cast(metadata.data()); - auto end = reinterpret_cast(metadata.data() + metadata.size()); - start = decodeVarint(start, end, &emscripten_metadata_major_version_); - start = decodeVarint(start, end, &emscripten_metadata_minor_version_); - start = decodeVarint(start, end, &emscripten_abi_major_version_); - start = decodeVarint(start, end, &emscripten_abi_minor_version_); - uint32_t temp; - if (emscripten_metadata_major_version_ > 0 || emscripten_metadata_minor_version_ > 1) { - // metadata 0.2 - added: wasm_backend. - start = decodeVarint(start, end, &temp); - } - start = decodeVarint(start, end, &temp); - start = decodeVarint(start, end, &temp); - if (emscripten_metadata_major_version_ > 0 || emscripten_metadata_minor_version_ > 0) { - // metadata 0.1 - added: global_base, dynamic_base, dynamictop_ptr and tempdouble_ptr. - start = decodeVarint(start, end, &temp); - start = decodeVarint(start, end, &temp); - start = decodeVarint(start, end, &temp); - decodeVarint(start, end, &temp); - if (emscripten_metadata_major_version_ > 0 || emscripten_metadata_minor_version_ > 2) { - // metadata 0.3 - added: standalone_wasm. - start = decodeVarint(start, end, &emscripten_standalone_wasm_); - } + abi_version_ = AbiVersion::ProxyWasm_0_2_1; + return true; + } + + // Verify signature. + std::string message; + if (!SignatureUtil::verifySignature(code, message)) { + fail(FailState::UnableToInitializeCode, message); + return false; + } + if (!message.empty()) { + wasm_vm_->integration()->trace(message); + } + + // Get ABI version from the module. + if (!BytecodeUtil::getAbiVersion(code, abi_version_)) { + fail(FailState::UnableToInitializeCode, "Failed to parse corrupted Wasm module"); + return false; + } + if (abi_version_ == AbiVersion::Unknown) { + fail(FailState::UnableToInitializeCode, "Missing or unknown Proxy-Wasm ABI version"); + return false; + } + + // Get function names from the module. + if (!BytecodeUtil::getFunctionNameIndex(code, function_names_)) { + fail(FailState::UnableToInitializeCode, "Failed to parse corrupted Wasm module"); + return false; + } + + std::string_view precompiled = {}; + + if (allow_precompiled) { + // Check if precompiled module exists. + const auto section_name = wasm_vm_->getPrecompiledSectionName(); + if (!section_name.empty()) { + if (!BytecodeUtil::getCustomSection(code, section_name, precompiled)) { + fail(FailState::UnableToInitializeCode, "Failed to parse corrupted Wasm module"); + return false; } } + } + + // Get original bytecode (possibly stripped). + std::string stripped; + if (!BytecodeUtil::getStrippedSource(code, stripped)) { + fail(FailState::UnableToInitializeCode, "Failed to parse corrupted Wasm module"); + return false; + } - code_ = code; - allow_precompiled_ = allow_precompiled; + auto ok = wasm_vm_->load(stripped, precompiled, function_names_); + if (!ok) { + fail(FailState::UnableToInitializeCode, "Failed to load Wasm bytecode"); + return false; } - abi_version_ = wasm_vm_->getAbiVersion(); - if (abi_version_ == AbiVersion::Unknown) { + // Store for future use in non-cloneable Wasm engines. + if (wasm_vm_->cloneable() == Cloneable::NotCloneable) { + module_bytecode_ = stripped; + module_precompiled_ = precompiled; + } + + return true; +} + +bool WasmBase::initialize() { + if (!wasm_vm_) { return false; } + if (started_from_ == Cloneable::NotCloneable) { + auto ok = wasm_vm_->load(base_wasm_handle_->wasm()->moduleBytecode(), + base_wasm_handle_->wasm()->modulePrecompiled(), + base_wasm_handle_->wasm()->functionNames()); + if (!ok) { + fail(FailState::UnableToInitializeCode, "Failed to load Wasm module from base Wasm"); + return false; + } + } + + if (started_from_.has_value()) { + abi_version_ = base_wasm_handle_->wasm()->abiVersion(); + } + if (started_from_ != Cloneable::InstantiatedModule) { registerCallbacks(); if (!wasm_vm_->link(vm_id_)) { @@ -359,39 +360,77 @@ bool WasmBase::initialize(const std::string &code, bool allow_precompiled) { return !isFailed(); } -ContextBase *WasmBase::getOrCreateRootContext(const std::shared_ptr &plugin) { - auto root_context = getRootContext(plugin->root_id_); - if (!root_context) { - auto context = std::unique_ptr(createRootContext(plugin)); - root_context = context.get(); - root_contexts_[plugin->root_id_] = std::move(context); +ContextBase *WasmBase::getRootContext(const std::shared_ptr &plugin, + bool allow_closed) { + auto it = root_contexts_.find(plugin->key()); + if (it != root_contexts_.end()) { + return it->second.get(); + } + if (allow_closed) { + it = pending_done_.find(plugin->key()); + if (it != pending_done_.end()) { + return it->second.get(); + } } - return root_context; + return nullptr; } void WasmBase::startVm(ContextBase *root_context) { - /* Call "_start" function, and fallback to "__wasm_call_ctors" if the former is not available. */ - if (_start_) { + // wasi_snapshot_preview1.clock_time_get + wasm_vm_->setRestrictedCallback( + true, {// emscripten + "env.emscripten_notify_memory_growth", + // logging (Proxy-Wasm) + "env.proxy_log", + // logging (stdout/stderr) + "wasi_unstable.fd_write", "wasi_snapshot_preview1.fd_write", + // args + "wasi_unstable.args_sizes_get", "wasi_snapshot_preview1.args_sizes_get", + "wasi_unstable.args_get", "wasi_snapshot_preview1.args_get", + // environment variables + "wasi_unstable.environ_sizes_get", "wasi_snapshot_preview1.environ_sizes_get", + "wasi_unstable.environ_get", "wasi_snapshot_preview1.environ_get", + // preopened files/directories + "wasi_unstable.fd_prestat_get", "wasi_snapshot_preview1.fd_prestat_get", + "wasi_unstable.fd_prestat_dir_name", "wasi_snapshot_preview1.fd_prestat_dir_name", + // time + "wasi_unstable.clock_time_get", "wasi_snapshot_preview1.clock_time_get", + // random + "wasi_unstable.random_get", "wasi_snapshot_preview1.random_get", + // Go runtime initialization + "wasi_unstable.fd_fdstat_get", "wasi_snapshot_preview1.fd_fdstat_get", + "wasi_unstable.fd_fdstat_set_flags", "wasi_snapshot_preview1.fd_fdstat_set_flags"}); + if (_initialize_) { + // WASI reactor. + _initialize_(root_context); + if (main_) { + // Call main() if it exists in WASI reactor, to allow module to + // do early initialization (e.g. configure SDK). + // + // Re-using main() keeps this consistent when switching between + // WASI command (that calls main()) and reactor (that doesn't). + main_(root_context, Word(0), Word(0)); + } + } else if (_start_) { + // WASI command. _start_(root_context); - } else if (__wasm_call_ctors_) { - __wasm_call_ctors_(root_context); } + wasm_vm_->setRestrictedCallback(false); } bool WasmBase::configure(ContextBase *root_context, std::shared_ptr plugin) { - return root_context->onConfigure(plugin); + return root_context->onConfigure(std::move(plugin)); } -ContextBase *WasmBase::start(std::shared_ptr plugin) { - auto root_id = plugin->root_id_; - auto it = root_contexts_.find(root_id); +ContextBase *WasmBase::start(const std::shared_ptr &plugin) { + auto it = root_contexts_.find(plugin->key()); if (it != root_contexts_.end()) { it->second->onStart(plugin); return it->second.get(); } auto context = std::unique_ptr(createRootContext(plugin)); - auto context_ptr = context.get(); - root_contexts_[root_id] = std::move(context); + auto *context_ptr = context.get(); + root_contexts_[plugin->key()] = std::move(context); if (!context_ptr->onStart(plugin)) { return nullptr; } @@ -408,58 +447,96 @@ uint32_t WasmBase::allocContextId() { } } -void WasmBase::startShutdown() { - bool all_done = true; - for (auto &p : root_contexts_) { - if (!p.second->onDone()) { - all_done = false; - pending_done_.insert(p.second.get()); +void WasmBase::startShutdown(std::string_view plugin_key) { + auto it = root_contexts_.find(std::string(plugin_key)); + if (it != root_contexts_.end()) { + if (it->second->onDone()) { + it->second->onDelete(); + } else { + pending_done_[it->first] = std::move(it->second); } + root_contexts_.erase(it); } - if (!all_done) { - shutdown_handle_ = std::make_unique(shared_from_this()); - } else { - finishShutdown(); +} + +void WasmBase::startShutdown() { + auto it = root_contexts_.begin(); + while (it != root_contexts_.end()) { + if (it->second->onDone()) { + it->second->onDelete(); + } else { + pending_done_[it->first] = std::move(it->second); + } + it = root_contexts_.erase(it); } } WasmResult WasmBase::done(ContextBase *root_context) { - auto it = pending_done_.find(root_context); + auto it = pending_done_.find(root_context->plugin_->key()); if (it == pending_done_.end()) { return WasmResult::NotFound; } + pending_delete_.insert(std::move(it->second)); pending_done_.erase(it); - if (pending_done_.empty() && shutdown_handle_) { - // Defer the delete so that onDelete is not called from within the done() handler. - addAfterVmCallAction( - [shutdown_handle = shutdown_handle_.release()]() { delete shutdown_handle; }); - } + // Defer the delete so that onDelete is not called from within the done() handler. + shutdown_handle_ = std::make_unique(shared_from_this()); + addAfterVmCallAction( + [shutdown_handle = shutdown_handle_.release()]() { delete shutdown_handle; }); return WasmResult::Ok; } void WasmBase::finishShutdown() { - for (auto &p : root_contexts_) { - p.second->onDelete(); + auto it = pending_delete_.begin(); + while (it != pending_delete_.end()) { + (*it)->onDelete(); + it = pending_delete_.erase(it); } } -WasmForeignFunction WasmBase::getForeignFunction(std::string_view function_name) { - auto it = foreign_functions->find(std::string(function_name)); - if (it != foreign_functions->end()) { +bool WasmHandleBase::canary(const std::shared_ptr &plugin, + const WasmHandleCloneFactory &clone_factory) { + if (this->wasm() == nullptr) { + return false; + } + auto it = plugin_canary_cache_.find(plugin->key()); + if (it != plugin_canary_cache_.end()) { return it->second; } - return nullptr; + auto configuration_canary_handle = clone_factory(shared_from_this()); + if (!configuration_canary_handle) { + this->wasm()->fail(FailState::UnableToCloneVm, "Failed to clone Base Wasm"); + return false; + } + if (!configuration_canary_handle->wasm()->initialize()) { + configuration_canary_handle->wasm()->fail(FailState::UnableToInitializeCode, + "Failed to initialize Wasm code"); + return false; + } + auto *root_context = configuration_canary_handle->wasm()->start(plugin); + if (root_context == nullptr) { + configuration_canary_handle->wasm()->fail(FailState::StartFailed, "Failed to start base Wasm"); + return false; + } + if (!configuration_canary_handle->wasm()->configure(root_context, plugin)) { + configuration_canary_handle->wasm()->fail(FailState::ConfigureFailed, + "Failed to configure base Wasm plugin"); + plugin_canary_cache_[plugin->key()] = false; + return false; + } + configuration_canary_handle->kill(); + plugin_canary_cache_[plugin->key()] = true; + return true; } -std::shared_ptr createWasm(std::string vm_key, std::string code, - std::shared_ptr plugin, - WasmHandleFactory factory, - WasmHandleCloneFactory clone_factory, +std::shared_ptr createWasm(const std::string &vm_key, const std::string &code, + const std::shared_ptr &plugin, + const WasmHandleFactory &factory, + const WasmHandleCloneFactory &clone_factory, bool allow_precompiled) { std::shared_ptr wasm_handle; { std::lock_guard guard(base_wasms_mutex); - if (!base_wasms) { + if (base_wasms == nullptr) { base_wasms = new std::remove_reference::type; } auto it = base_wasms->find(vm_key); @@ -469,106 +546,153 @@ std::shared_ptr createWasm(std::string vm_key, std::string code, base_wasms->erase(it); } } - if (wasm_handle) { - return wasm_handle; - } - wasm_handle = factory(vm_key); if (!wasm_handle) { - return nullptr; + // If no cached base_wasm, creates a new base_wasm, loads the code and initializes it. + wasm_handle = factory(vm_key); + if (!wasm_handle) { + return nullptr; + } + if (!wasm_handle->wasm()->load(code, allow_precompiled)) { + wasm_handle->wasm()->fail(FailState::UnableToInitializeCode, "Failed to load Wasm code"); + return nullptr; + } + if (!wasm_handle->wasm()->initialize()) { + wasm_handle->wasm()->fail(FailState::UnableToInitializeCode, + "Failed to initialize Wasm code"); + return nullptr; + } + (*base_wasms)[vm_key] = wasm_handle; } - (*base_wasms)[vm_key] = wasm_handle; } - if (!wasm_handle->wasm()->initialize(code, allow_precompiled)) { - wasm_handle->wasm()->fail(FailState::UnableToInitializeCode, "Failed to initialize Wasm code"); + // Either creating new one or reusing the existing one, apply canary for each plugin. + if (!wasm_handle->canary(plugin, clone_factory)) { return nullptr; } - auto configuration_canary_handle = clone_factory(wasm_handle); - if (!configuration_canary_handle) { - wasm_handle->wasm()->fail(FailState::UnableToCloneVM, "Failed to clone Base Wasm"); - return nullptr; + return wasm_handle; +}; + +std::shared_ptr getThreadLocalWasm(std::string_view vm_key) { + auto it = local_wasms.find(std::string(vm_key)); + if (it != local_wasms.end()) { + auto wasm = it->second.lock(); + if (wasm) { + return wasm; + } + local_wasms.erase(it); } - if (!configuration_canary_handle->wasm()->initialize(code, allow_precompiled)) { - wasm_handle->wasm()->fail(FailState::UnableToInitializeCode, "Failed to initialize Wasm code"); - return nullptr; + removeStaleLocalCacheEntries(local_wasms, local_wasms_keys); + return nullptr; +} + +static std::shared_ptr +getOrCreateThreadLocalWasm(const std::shared_ptr &base_handle, + const WasmHandleCloneFactory &clone_factory) { + std::string vm_key(base_handle->wasm()->vm_key()); + // Get existing thread-local WasmVM. + auto it = local_wasms.find(vm_key); + if (it != local_wasms.end()) { + auto wasm_handle = it->second.lock(); + if (wasm_handle) { + return wasm_handle; + } + local_wasms.erase(it); } - auto root_context = configuration_canary_handle->wasm()->start(plugin); - if (!root_context) { - configuration_canary_handle->wasm()->fail(FailState::StartFailed, "Failed to start base Wasm"); + removeStaleLocalCacheEntries(local_wasms, local_wasms_keys); + // Create and initialize new thread-local WasmVM. + auto wasm_handle = clone_factory(base_handle); + if (!wasm_handle) { + base_handle->wasm()->fail(FailState::UnableToCloneVm, "Failed to clone Base Wasm"); return nullptr; } - if (!configuration_canary_handle->wasm()->configure(root_context, plugin)) { - configuration_canary_handle->wasm()->fail(FailState::ConfigureFailed, - "Failed to configure base Wasm plugin"); + + if (!wasm_handle->wasm()->initialize()) { + base_handle->wasm()->fail(FailState::UnableToInitializeCode, "Failed to initialize Wasm code"); return nullptr; } - configuration_canary_handle->kill(); + cacheLocalWasm(vm_key, wasm_handle); + wasm_handle->wasm()->wasm_vm()->addFailCallback([vm_key](proxy_wasm::FailState fail_state) { + if (fail_state == proxy_wasm::FailState::RuntimeError) { + // If VM failed, erase the entry so that: + // 1) we can recreate the new thread local VM from the same base_wasm. + // 2) we wouldn't reuse the failed VM for new plugins accidentally. + local_wasms.erase(vm_key); + }; + }); return wasm_handle; -}; +} -static std::shared_ptr -createThreadLocalWasm(std::shared_ptr &base_wasm, - std::shared_ptr plugin, WasmHandleCloneFactory clone_factory) { - auto wasm_handle = clone_factory(base_wasm); - if (!wasm_handle) { - wasm_handle->wasm()->fail(FailState::UnableToCloneVM, "Failed to clone Base Wasm"); - return nullptr; +std::shared_ptr getOrCreateThreadLocalPlugin( + const std::shared_ptr &base_handle, const std::shared_ptr &plugin, + const WasmHandleCloneFactory &clone_factory, const PluginHandleFactory &plugin_factory) { + std::string key(std::string(base_handle->wasm()->vm_key()) + "||" + plugin->key()); + // Get existing thread-local Plugin handle. + auto it = local_plugins.find(key); + if (it != local_plugins.end()) { + auto plugin_handle = it->second.lock(); + if (plugin_handle) { + return plugin_handle; + } + local_plugins.erase(it); } - if (!wasm_handle->wasm()->initialize(base_wasm->wasm()->code(), - base_wasm->wasm()->allow_precompiled())) { - wasm_handle->wasm()->fail(FailState::UnableToInitializeCode, "Failed to initialize Wasm code"); + removeStaleLocalCacheEntries(local_plugins, local_plugins_keys); + // Get thread-local WasmVM. + auto wasm_handle = getOrCreateThreadLocalWasm(base_handle, clone_factory); + if (!wasm_handle) { return nullptr; } - ContextBase *root_context = wasm_handle->wasm()->start(plugin); - if (!root_context) { - base_wasm->wasm()->fail(FailState::StartFailed, "Failed to start thread-local Wasm"); + // Create and initialize new thread-local Plugin. + auto *plugin_context = wasm_handle->wasm()->start(plugin); + if (plugin_context == nullptr) { + base_handle->wasm()->fail(FailState::StartFailed, "Failed to start thread-local Wasm"); return nullptr; } - if (!wasm_handle->wasm()->configure(root_context, plugin)) { - base_wasm->wasm()->fail(FailState::ConfigureFailed, - "Failed to configure thread-local Wasm plugin"); + if (!wasm_handle->wasm()->configure(plugin_context, plugin)) { + base_handle->wasm()->fail(FailState::ConfigureFailed, + "Failed to configure thread-local Wasm plugin"); return nullptr; } - local_wasms[std::string(wasm_handle->wasm()->vm_key())] = wasm_handle; - return wasm_handle; + auto plugin_handle = plugin_factory(wasm_handle, plugin); + cacheLocalPlugin(key, plugin_handle); + wasm_handle->wasm()->wasm_vm()->addFailCallback([key](proxy_wasm::FailState fail_state) { + if (fail_state == proxy_wasm::FailState::RuntimeError) { + // If VM failed, erase the entry so that: + // 1) we can recreate the new thread local plugin from the same base_wasm. + // 2) we wouldn't reuse the failed VM for new plugin configs accidentally. + local_plugins.erase(key); + }; + }); + return plugin_handle; } -std::shared_ptr getThreadLocalWasm(std::string_view vm_key) { - auto it = local_wasms.find(std::string(vm_key)); - if (it == local_wasms.end()) { - return nullptr; - } - auto wasm = it->second.lock(); - if (!wasm) { - local_wasms.erase(std::string(vm_key)); +void clearWasmCachesForTesting() { + local_plugins.clear(); + local_wasms.clear(); + std::lock_guard guard(base_wasms_mutex); + if (base_wasms != nullptr) { + delete base_wasms; + base_wasms = nullptr; } - return wasm; } -std::shared_ptr -getOrCreateThreadLocalWasm(std::shared_ptr base_wasm, - std::shared_ptr plugin, - WasmHandleCloneFactory clone_factory) { - auto wasm_handle = getThreadLocalWasm(base_wasm->wasm()->vm_key()); - if (wasm_handle) { - auto root_context = wasm_handle->wasm()->getOrCreateRootContext(plugin); - if (!wasm_handle->wasm()->configure(root_context, plugin)) { - base_wasm->wasm()->fail(FailState::ConfigureFailed, - "Failed to configure thread-local Wasm code"); - return nullptr; +std::vector staleLocalPluginsKeysForTesting() { + std::vector keys; + for (const auto &kv : local_plugins) { + if (kv.second.expired()) { + keys.push_back(kv.first); } - return wasm_handle; } - return createThreadLocalWasm(base_wasm, plugin, clone_factory); + return keys; } -void clearWasmCachesForTesting() { - local_wasms.clear(); - std::lock_guard guard(base_wasms_mutex); - if (base_wasms) { - delete base_wasms; - base_wasms = nullptr; +std::vector staleLocalWasmsKeysForTesting() { + std::vector keys; + for (const auto &kv : local_wasms) { + if (kv.second.expired()) { + keys.push_back(kv.first); + } } + return keys; } } // namespace proxy_wasm diff --git a/src/wasm.h b/src/wasm.h new file mode 100644 index 000000000..882dbcd99 --- /dev/null +++ b/src/wasm.h @@ -0,0 +1,25 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include +#include + +namespace proxy_wasm { + +std::vector staleLocalWasmsKeysForTesting(); +std::vector staleLocalPluginsKeysForTesting(); + +} // namespace proxy_wasm diff --git a/src/wasmedge/types.h b/src/wasmedge/types.h new file mode 100644 index 000000000..b6cd21952 --- /dev/null +++ b/src/wasmedge/types.h @@ -0,0 +1,29 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "src/common/types.h" +#include "wasmedge/wasmedge.h" + +namespace proxy_wasm::WasmEdge { + +using WasmEdgeStorePtr = common::CSmartPtr; +using WasmEdgeVMPtr = common::CSmartPtr; +using WasmEdgeLoaderPtr = common::CSmartPtr; +using WasmEdgeValidatorPtr = common::CSmartPtr; +using WasmEdgeExecutorPtr = common::CSmartPtr; +using WasmEdgeASTModulePtr = common::CSmartPtr; +using WasmEdgeModulePtr = + common::CSmartPtr; + +} // namespace proxy_wasm::WasmEdge diff --git a/src/wasmedge/wasmedge.cc b/src/wasmedge/wasmedge.cc new file mode 100644 index 000000000..30fe78f5e --- /dev/null +++ b/src/wasmedge/wasmedge.cc @@ -0,0 +1,630 @@ +// Copyright 2016-2019 Envoy Project Authors +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "include/proxy-wasm/wasmedge.h" +#include "include/proxy-wasm/wasm_vm.h" +#include "src/wasmedge/types.h" + +#include "wasmedge/wasmedge.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace proxy_wasm { +namespace WasmEdge { + +// Helper templates to make values. +template WasmEdge_Value makeVal(T t); +template <> WasmEdge_Value makeVal(Word t) { + return WasmEdge_ValueGenI32(static_cast(t.u64_)); +} +template <> WasmEdge_Value makeVal(uint32_t t) { + return WasmEdge_ValueGenI32(static_cast(t)); +} +template <> WasmEdge_Value makeVal(uint64_t t) { + return WasmEdge_ValueGenI64(static_cast(t)); +} +template <> WasmEdge_Value makeVal(double t) { return WasmEdge_ValueGenF64(t); } + +// Helper function to print values. +std::string printValue(const WasmEdge_Value &value) { + switch (value.Type) { + case WasmEdge_ValType_I32: + return std::to_string(WasmEdge_ValueGetI32(value)); + case WasmEdge_ValType_I64: + return std::to_string(WasmEdge_ValueGetI64(value)); + case WasmEdge_ValType_F32: + return std::to_string(WasmEdge_ValueGetF32(value)); + case WasmEdge_ValType_F64: + return std::to_string(WasmEdge_ValueGetF64(value)); + default: + return "unknown"; + } +} + +std::string printValues(const WasmEdge_Value *values, size_t size) { + if (size == 0) { + return ""; + } + + std::string s; + for (size_t i = 0; i < size; i++) { + if (i != 0U) { + s.append(", "); + } + s.append(printValue(values[i])); + } + return s; +} + +// Helper function to print valtype. +const char *printValType(WasmEdge_ValType kind) { + switch (kind) { + case WasmEdge_ValType_I32: + return "i32"; + case WasmEdge_ValType_I64: + return "i64"; + case WasmEdge_ValType_F32: + return "f32"; + case WasmEdge_ValType_F64: + return "f64"; + case WasmEdge_ValType_ExternRef: + return "anyref"; + case WasmEdge_ValType_FuncRef: + return "funcref"; + default: + return "unknown"; + } +} + +// Helper function to print valtype array. +std::string printValTypes(const WasmEdge_ValType *types, size_t size) { + if (size == 0) { + return "void"; + } + + std::string s; + s.reserve(size * 8 /* max size + " " */ - 1); + for (size_t i = 0; i < size; i++) { + if (i != 0U) { + s.append(" "); + } + s.append(printValType(types[i])); + } + return s; +} + +template struct ConvertWordType { + using type = T; // NOLINT(readability-identifier-naming) +}; +template <> struct ConvertWordType { + using type = uint32_t; // NOLINT(readability-identifier-naming) +}; + +// Helper templates to convert arg to valtype. +template enum WasmEdge_ValType convArgToValType(); +template <> enum WasmEdge_ValType convArgToValType() { return WasmEdge_ValType_I32; } +template <> enum WasmEdge_ValType convArgToValType() { return WasmEdge_ValType_I32; } +template <> enum WasmEdge_ValType convArgToValType() { return WasmEdge_ValType_I64; } +template <> enum WasmEdge_ValType convArgToValType() { return WasmEdge_ValType_I64; } +template <> enum WasmEdge_ValType convArgToValType() { return WasmEdge_ValType_F64; } + +// Helper templates to convert valtype to arg. +template T convValTypeToArg(WasmEdge_Value val); +template <> uint32_t convValTypeToArg(WasmEdge_Value val) { + return static_cast(WasmEdge_ValueGetI32(val)); +} +template <> Word convValTypeToArg(WasmEdge_Value val) { return WasmEdge_ValueGetI32(val); } +template <> int64_t convValTypeToArg(WasmEdge_Value val) { + return WasmEdge_ValueGetI64(val); +} +template <> uint64_t convValTypeToArg(WasmEdge_Value val) { + return static_cast(WasmEdge_ValueGetI64(val)); +} +template <> double convValTypeToArg(WasmEdge_Value val) { + return WasmEdge_ValueGetF64(val); +} + +// Helper templates to convert valtypes to args tuple. +template +constexpr T convValTypesToArgsTupleImpl(const WasmEdge_Value *arr, + std::index_sequence /*comptime*/) { + return std::make_tuple( + convValTypeToArg>::type>(arr[I])...); +} + +template ::value>> +constexpr T convValTypesToArgsTuple(const WasmEdge_Value *arr) { + return convValTypesToArgsTupleImpl(arr, Is()); +} + +// Helper templates to convert args tuple to valtypes. +template +uint32_t convArgsTupleToValTypesImpl(std::vector &types, + std::index_sequence /*comptime*/) { + auto size = std::tuple_size::value; + if (size > 0) { + auto ps = std::array::value>{ + convArgToValType::type>()...}; + types.resize(size); + std::copy_n(ps.data(), size, types.data()); + } + return size; +} + +template ::value>> +uint32_t convArgsTupleToValTypes(std::vector &types) { + return convArgsTupleToValTypesImpl(types, Is()); +} + +// Helper templates to create WasmEdge_FunctionTypeContext. +template WasmEdge_FunctionTypeContext *newWasmEdgeFuncType() { + std::vector params; + std::vector returns; + uint32_t param_nums = convArgsTupleToValTypes(params); + uint32_t return_nums = convArgsTupleToValTypes>(returns); + auto *ftype = WasmEdge_FunctionTypeCreate(params.data(), param_nums, returns.data(), return_nums); + return ftype; +} + +template WasmEdge_FunctionTypeContext *newWasmEdgeFuncType() { + std::vector params; + uint32_t param_nums = convArgsTupleToValTypes(params); + auto *ftype = WasmEdge_FunctionTypeCreate(params.data(), param_nums, nullptr, 0); + return ftype; +} + +struct HostFuncData { + HostFuncData(const std::string_view modname, const std::string_view name) + : modname_(modname), name_(name), callback_(nullptr), raw_func_(nullptr), vm_(nullptr) {} + ~HostFuncData() = default; + + std::string modname_, name_; + WasmEdge_HostFunc_t callback_; + void *raw_func_; + WasmVm *vm_; +}; + +using HostFuncDataPtr = std::unique_ptr; + +struct HostModuleData { + HostModuleData(const std::string_view modname) { + cxt_ = WasmEdge_ModuleInstanceCreate(WasmEdge_StringWrap(modname.data(), modname.length())); + } + ~HostModuleData() { WasmEdge_ModuleInstanceDelete(cxt_); } + + WasmEdge_ModuleInstanceContext *cxt_; +}; + +using HostModuleDataPtr = std::unique_ptr; + +class WasmEdge : public WasmVm { +public: + WasmEdge() { + store_ = nullptr; + ast_module_ = nullptr; + module_ = nullptr; + memory_ = nullptr; + } + + std::string_view getEngineName() override { return "wasmedge"; } + std::string_view getPrecompiledSectionName() override { return ""; } + + Cloneable cloneable() override { return Cloneable::NotCloneable; } + std::unique_ptr clone() override { return nullptr; } + + bool load(std::string_view bytecode, std::string_view precompiled, + const std::unordered_map &function_names) override; + bool link(std::string_view debug_name) override; + uint64_t getMemorySize() override; + std::optional getMemory(uint64_t pointer, uint64_t size) override; + bool setMemory(uint64_t pointer, uint64_t size, const void *data) override; + bool getWord(uint64_t pointer, Word *word) override; + bool setWord(uint64_t pointer, Word word) override; + size_t getWordSize() override { return sizeof(uint32_t); }; + +#define _REGISTER_HOST_FUNCTION(T) \ + void registerCallback(std::string_view module_name, std::string_view function_name, T, \ + typename ConvertFunctionTypeWordToUint32::type f) override { \ + registerHostFunctionImpl(module_name, function_name, f); \ + }; + FOR_ALL_WASM_VM_IMPORTS(_REGISTER_HOST_FUNCTION) +#undef _REGISTER_HOST_FUNCTION + +#define _GET_MODULE_FUNCTION(T) \ + void getFunction(std::string_view function_name, T *f) override { \ + getModuleFunctionImpl(function_name, f); \ + }; + FOR_ALL_WASM_VM_EXPORTS(_GET_MODULE_FUNCTION) +#undef _GET_MODULE_FUNCTION + + void warm() override; + +private: + template + void registerHostFunctionImpl(std::string_view module_name, std::string_view function_name, + void (*function)(Args...)); + + template + void registerHostFunctionImpl(std::string_view module_name, std::string_view function_name, + R (*function)(Args...)); + + template + void getModuleFunctionImpl(std::string_view function_name, + std::function *function); + + template + void getModuleFunctionImpl(std::string_view function_name, + std::function *function); + + void terminate() override {} + bool usesWasmByteOrder() override { return true; } + + // Initialize the WasmEdge store if necessary. + void initStore(); + + WasmEdgeLoaderPtr loader_; + WasmEdgeValidatorPtr validator_; + WasmEdgeExecutorPtr executor_; + WasmEdgeStorePtr store_; + WasmEdgeASTModulePtr ast_module_; + WasmEdgeModulePtr module_; + WasmEdge_MemoryInstanceContext *memory_; + + std::unordered_map host_functions_; + std::unordered_map host_modules_; + std::unordered_set module_functions_; +}; + +bool WasmEdge::load(std::string_view bytecode, std::string_view /*precompiled*/, + const std::unordered_map & /*function_names*/) { + initStore(); + WasmEdge_ASTModuleContext *mod = nullptr; + WasmEdge_Result res = WasmEdge_LoaderParseFromBuffer( + loader_.get(), &mod, reinterpret_cast(bytecode.data()), bytecode.size()); + if (!WasmEdge_ResultOK(res)) { + return false; + } + res = WasmEdge_ValidatorValidate(validator_.get(), mod); + if (!WasmEdge_ResultOK(res)) { + WasmEdge_ASTModuleDelete(mod); + return false; + } + ast_module_ = mod; + return true; +} + +void WasmEdge::initStore() { + if (store_ != nullptr) { + return; + } + loader_ = WasmEdge_LoaderCreate(nullptr); + validator_ = WasmEdge_ValidatorCreate(nullptr); + executor_ = WasmEdge_ExecutorCreate(nullptr, nullptr); + store_ = WasmEdge_StoreCreate(); +} + +bool WasmEdge::link(std::string_view /*debug_name*/) { + assert(ast_module_ != nullptr); + + // Create store and register imports. + initStore(); + if (store_ == nullptr) { + return false; + } + WasmEdge_Result res; + for (auto &&it : host_modules_) { + res = WasmEdge_ExecutorRegisterImport(executor_.get(), store_.get(), it.second->cxt_); + if (!WasmEdge_ResultOK(res)) { + fail(FailState::UnableToInitializeCode, + std::string("Failed to link Wasm module due to import: ") + it.first); + return false; + } + } + // Instantiate module. + WasmEdge_ModuleInstanceContext *mod = nullptr; + res = WasmEdge_ExecutorInstantiate(executor_.get(), &mod, store_.get(), ast_module_.get()); + if (!WasmEdge_ResultOK(res)) { + fail(FailState::UnableToInitializeCode, + std::string("Failed to link Wasm module: ") + std::string(WasmEdge_ResultGetMessage(res))); + return false; + } + // Get the function and memory exports. + uint32_t memory_num = WasmEdge_ModuleInstanceListMemoryLength(mod); + if (memory_num > 0) { + WasmEdge_String name; + WasmEdge_ModuleInstanceListMemory(mod, &name, 1); + memory_ = WasmEdge_ModuleInstanceFindMemory(mod, name); + if (memory_ == nullptr) { + WasmEdge_ModuleInstanceDelete(mod); + return false; + } + } + uint32_t func_num = WasmEdge_ModuleInstanceListFunctionLength(mod); + if (func_num > 0) { + std::vector names(func_num); + WasmEdge_ModuleInstanceListFunction(mod, &names[0], func_num); + for (auto i = 0; i < func_num; i++) { + module_functions_.insert(std::string(names[i].Buf, names[i].Length)); + } + } + module_ = mod; + return true; +} + +uint64_t WasmEdge::getMemorySize() { + if (memory_ != nullptr) { + return 65536ULL * WasmEdge_MemoryInstanceGetPageSize(memory_); + } + return 0; +} + +std::optional WasmEdge::getMemory(uint64_t pointer, uint64_t size) { + char *ptr = reinterpret_cast(WasmEdge_MemoryInstanceGetPointer(memory_, pointer, size)); + if (ptr == nullptr) { + return std::nullopt; + } + return std::string_view(ptr, size); +} + +bool WasmEdge::setMemory(uint64_t pointer, uint64_t size, const void *data) { + auto res = WasmEdge_MemoryInstanceSetData(memory_, reinterpret_cast(data), + pointer, size); + return WasmEdge_ResultOK(res); +} + +bool WasmEdge::getWord(uint64_t pointer, Word *word) { + constexpr auto size = sizeof(uint32_t); + uint32_t word32; + auto res = + WasmEdge_MemoryInstanceGetData(memory_, reinterpret_cast(&word32), pointer, size); + if (WasmEdge_ResultOK(res)) { + word->u64_ = word32; + return true; + } + return false; +} + +bool WasmEdge::setWord(uint64_t pointer, Word word) { + constexpr auto size = sizeof(uint32_t); + uint32_t word32 = word.u32(); + auto res = + WasmEdge_MemoryInstanceSetData(memory_, reinterpret_cast(&word32), pointer, size); + return WasmEdge_ResultOK(res); +} + +template +void WasmEdge::registerHostFunctionImpl(std::string_view module_name, + std::string_view function_name, void (*function)(Args...)) { + auto it = host_modules_.find(std::string(module_name)); + if (it == host_modules_.end()) { + host_modules_.emplace(module_name, std::make_unique(module_name)); + it = host_modules_.find(std::string(module_name)); + } + + auto data = std::make_unique(module_name, function_name); + auto *func_type = newWasmEdgeFuncType>(); + data->vm_ = this; + data->raw_func_ = reinterpret_cast(function); + data->callback_ = [](void *data, const WasmEdge_CallingFrameContext * /*CallFrameCxt*/, + const WasmEdge_Value *Params, + WasmEdge_Value * /*Returns*/) -> WasmEdge_Result { + auto *func_data = reinterpret_cast(data); + const bool log = func_data->vm_->cmpLogLevel(LogLevel::trace); + if (log) { + func_data->vm_->integration()->trace("[vm->host] " + func_data->modname_ + "." + + func_data->name_ + "(" + + printValues(Params, sizeof...(Args)) + ")"); + } + auto args = convValTypesToArgsTuple>(Params); + auto fn = reinterpret_cast(func_data->raw_func_); + std::apply(fn, args); + if (log) { + func_data->vm_->integration()->trace("[vm<-host] " + func_data->modname_ + "." + + func_data->name_ + " return: void"); + } + return WasmEdge_Result_Success; + }; + + auto *hostfunc_cxt = WasmEdge_FunctionInstanceCreate(func_type, data->callback_, data.get(), 0); + WasmEdge_FunctionTypeDelete(func_type); + if (hostfunc_cxt == nullptr) { + fail(FailState::MissingFunction, "Failed to allocate host function instance"); + return; + } + + WasmEdge_ModuleInstanceAddFunction( + it->second->cxt_, WasmEdge_StringWrap(function_name.data(), function_name.length()), + hostfunc_cxt); + host_functions_.insert_or_assign(std::string(module_name) + "." + std::string(function_name), + std::move(data)); +} + +template +void WasmEdge::registerHostFunctionImpl(std::string_view module_name, + std::string_view function_name, R (*function)(Args...)) { + auto it = host_modules_.find(std::string(module_name)); + if (it == host_modules_.end()) { + host_modules_.emplace(module_name, std::make_unique(module_name)); + it = host_modules_.find(std::string(module_name)); + } + + auto data = std::make_unique(module_name, function_name); + auto *func_type = newWasmEdgeFuncType>(); + data->vm_ = this; + data->raw_func_ = reinterpret_cast(function); + data->callback_ = [](void *data, const WasmEdge_CallingFrameContext * /*CallFrameCxt*/, + const WasmEdge_Value *Params, WasmEdge_Value *Returns) -> WasmEdge_Result { + auto *func_data = reinterpret_cast(data); + const bool log = func_data->vm_->cmpLogLevel(LogLevel::trace); + if (log) { + func_data->vm_->integration()->trace("[vm->host] " + func_data->modname_ + "." + + func_data->name_ + "(" + + printValues(Params, sizeof...(Args)) + ")"); + } + auto args = convValTypesToArgsTuple>(Params); + auto fn = reinterpret_cast(func_data->raw_func_); + R res = std::apply(fn, args); + Returns[0] = makeVal(res); + if (log) { + func_data->vm_->integration()->trace("[vm<-host] " + func_data->modname_ + "." + + func_data->name_ + " return: " + std::to_string(res)); + } + return WasmEdge_Result_Success; + }; + + auto *hostfunc_cxt = WasmEdge_FunctionInstanceCreate(func_type, data->callback_, data.get(), 0); + WasmEdge_FunctionTypeDelete(func_type); + if (hostfunc_cxt == nullptr) { + fail(FailState::MissingFunction, "Failed to allocate host function instance"); + return; + } + + WasmEdge_ModuleInstanceAddFunction( + it->second->cxt_, WasmEdge_StringWrap(function_name.data(), function_name.length()), + hostfunc_cxt); + host_functions_.insert_or_assign(std::string(module_name) + "." + std::string(function_name), + std::move(data)); +} + +template +void WasmEdge::getModuleFunctionImpl(std::string_view function_name, + std::function *function) { + auto *func_cxt = WasmEdge_ModuleInstanceFindFunction( + module_.get(), WasmEdge_StringWrap(function_name.data(), function_name.length())); + if (!func_cxt) { + *function = nullptr; + return; + } + + std::vector exp_args; + std::vector exp_returns; + convArgsTupleToValTypes>(exp_args); + convArgsTupleToValTypes>(exp_returns); + const auto *functype_cxt = WasmEdge_FunctionInstanceGetFunctionType(func_cxt); + std::vector act_args( + WasmEdge_FunctionTypeGetParametersLength(functype_cxt)); + std::vector act_returns( + WasmEdge_FunctionTypeGetReturnsLength(functype_cxt)); + WasmEdge_FunctionTypeGetParameters(functype_cxt, act_args.data(), act_args.size()); + WasmEdge_FunctionTypeGetReturns(functype_cxt, act_returns.data(), act_returns.size()); + + if (exp_args != act_args || exp_returns != act_returns) { + fail(FailState::UnableToInitializeCode, + "Bad function signature for: " + std::string(function_name) + + ", want: " + printValTypes(exp_args.data(), exp_args.size()) + " -> " + + printValTypes(exp_returns.data(), exp_returns.size()) + + ", but the module exports: " + printValTypes(act_args.data(), act_args.size()) + + " -> " + printValTypes(act_returns.data(), act_returns.size())); + return; + } + + *function = [function_name, func_cxt, this](ContextBase *context, Args... args) -> void { + WasmEdge_Value params[] = {makeVal(args)...}; + const bool log = cmpLogLevel(LogLevel::trace); + if (log) { + integration()->trace("[host->vm] " + std::string(function_name) + "(" + + printValues(params, sizeof...(Args)) + ")"); + } + SaveRestoreContext saved_context(context); + WasmEdge_Result res = + WasmEdge_ExecutorInvoke(executor_.get(), func_cxt, params, sizeof...(Args), nullptr, 0); + if (!WasmEdge_ResultOK(res)) { + fail(FailState::RuntimeError, "Function: " + std::string(function_name) + + " failed: " + WasmEdge_ResultGetMessage(res)); + return; + } + if (log) { + integration()->trace("[host<-vm] " + std::string(function_name) + " return: void"); + } + }; +} + +template +void WasmEdge::getModuleFunctionImpl(std::string_view function_name, + std::function *function) { + auto *func_cxt = WasmEdge_ModuleInstanceFindFunction( + module_.get(), WasmEdge_StringWrap(function_name.data(), function_name.length())); + if (!func_cxt) { + *function = nullptr; + return; + } + + std::vector exp_args; + std::vector exp_returns; + convArgsTupleToValTypes>(exp_args); + convArgsTupleToValTypes>(exp_returns); + const auto *functype_cxt = WasmEdge_FunctionInstanceGetFunctionType(func_cxt); + std::vector act_args( + WasmEdge_FunctionTypeGetParametersLength(functype_cxt)); + std::vector act_returns( + WasmEdge_FunctionTypeGetReturnsLength(functype_cxt)); + WasmEdge_FunctionTypeGetParameters(functype_cxt, act_args.data(), act_args.size()); + WasmEdge_FunctionTypeGetReturns(functype_cxt, act_returns.data(), act_returns.size()); + + if (exp_args != act_args || exp_returns != act_returns) { + fail(FailState::UnableToInitializeCode, + "Bad function signature for: " + std::string(function_name) + + ", want: " + printValTypes(exp_args.data(), exp_args.size()) + " -> " + + printValTypes(exp_returns.data(), exp_returns.size()) + + ", but the module exports: " + printValTypes(act_args.data(), act_args.size()) + + " -> " + printValTypes(act_returns.data(), act_returns.size())); + return; + } + + *function = [function_name, func_cxt, this](ContextBase *context, Args... args) -> R { + WasmEdge_Value params[] = {makeVal(args)...}; + WasmEdge_Value results[1]; + const bool log = cmpLogLevel(LogLevel::trace); + if (log) { + integration()->trace("[host->vm] " + std::string(function_name) + "(" + + printValues(params, sizeof...(Args)) + ")"); + } + SaveRestoreContext saved_context(context); + WasmEdge_Result res = + WasmEdge_ExecutorInvoke(executor_.get(), func_cxt, params, sizeof...(Args), results, 1); + if (!WasmEdge_ResultOK(res)) { + fail(FailState::RuntimeError, "Function: " + std::string(function_name) + + " failed: " + WasmEdge_ResultGetMessage(res)); + return R{}; + } + R ret = convValTypeToArg(results[0]); + if (log) { + integration()->trace("[host<-vm] " + std::string(function_name) + + " return: " + std::to_string(ret)); + } + return ret; + }; +} + +void WasmEdge::warm() { initStore(); } + +} // namespace WasmEdge + +std::unique_ptr createWasmEdgeVm() { return std::make_unique(); } + +} // namespace proxy_wasm diff --git a/src/wasmtime/types.h b/src/wasmtime/types.h new file mode 100644 index 000000000..14fe75053 --- /dev/null +++ b/src/wasmtime/types.h @@ -0,0 +1,43 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "src/common/types.h" +#include "crates/c-api/include/wasm.h" + +namespace proxy_wasm::wasmtime { + +using WasmEnginePtr = common::CSmartPtr; +using WasmFuncPtr = common::CSmartPtr; +using WasmStorePtr = common::CSmartPtr; +using WasmModulePtr = common::CSmartPtr; +using WasmSharedModulePtr = common::CSmartPtr; +using WasmMemoryPtr = common::CSmartPtr; +using WasmTablePtr = common::CSmartPtr; +using WasmInstancePtr = common::CSmartPtr; +using WasmFunctypePtr = common::CSmartPtr; +using WasmTrapPtr = common::CSmartPtr; +using WasmExternPtr = common::CSmartPtr; + +using WasmByteVec = + common::CSmartType; +using WasmImporttypeVec = common::CSmartType; +using WasmExportTypeVec = common::CSmartType; +using WasmExternVec = + common::CSmartType; +using WasmValtypeVec = + common::CSmartType; + +} // namespace proxy_wasm::wasmtime diff --git a/src/wasmtime/wasmtime.cc b/src/wasmtime/wasmtime.cc new file mode 100644 index 000000000..a72a0361d --- /dev/null +++ b/src/wasmtime/wasmtime.cc @@ -0,0 +1,715 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "include/proxy-wasm/wasmtime.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "src/wasmtime/types.h" + +#include "crates/c-api/include/wasm.h" + +namespace proxy_wasm { +namespace wasmtime { + +struct HostFuncData { + HostFuncData(std::string name) : name_(std::move(name)) {} + + std::string name_; + WasmFuncPtr callback_; + void *raw_func_{}; + WasmVm *vm_{}; +}; + +using HostFuncDataPtr = std::unique_ptr; + +wasm_engine_t *engine() { + static const auto engine = WasmEnginePtr(wasm_engine_new()); + return engine.get(); +} + +class Wasmtime : public WasmVm { +public: + Wasmtime() = default; + + std::string_view getEngineName() override { return "wasmtime"; } + Cloneable cloneable() override { return Cloneable::CompiledBytecode; } + std::string_view getPrecompiledSectionName() override { return ""; } + + bool load(std::string_view bytecode, std::string_view precompiled, + const std::unordered_map &function_names) override; + bool link(std::string_view debug_name) override; + std::unique_ptr clone() override; + uint64_t getMemorySize() override; + std::optional getMemory(uint64_t pointer, uint64_t size) override; + bool setMemory(uint64_t pointer, uint64_t size, const void *data) override; + bool getWord(uint64_t pointer, Word *word) override; + bool setWord(uint64_t pointer, Word word) override; + size_t getWordSize() override { return sizeof(uint32_t); }; + +#define _REGISTER_HOST_FUNCTION(T) \ + void registerCallback(std::string_view module_name, std::string_view function_name, T, \ + typename ConvertFunctionTypeWordToUint32::type f) override { \ + registerHostFunctionImpl(module_name, function_name, f); \ + }; + FOR_ALL_WASM_VM_IMPORTS(_REGISTER_HOST_FUNCTION) +#undef _REGISTER_HOST_FUNCTION + +#define _GET_MODULE_FUNCTION(T) \ + void getFunction(std::string_view function_name, T *f) override { \ + getModuleFunctionImpl(function_name, f); \ + }; + FOR_ALL_WASM_VM_EXPORTS(_GET_MODULE_FUNCTION) +#undef _GET_MODULE_FUNCTION + + void warm() override; + +private: + template + void registerHostFunctionImpl(std::string_view module_name, std::string_view function_name, + void (*function)(Args...)); + + template + void registerHostFunctionImpl(std::string_view module_name, std::string_view function_name, + R (*function)(Args...)); + + template + void getModuleFunctionImpl(std::string_view function_name, + std::function *function); + + template + void getModuleFunctionImpl(std::string_view function_name, + std::function *function); + + void terminate() override {} + bool usesWasmByteOrder() override { return true; } + + // Initialize the Wasmtime store if necessary. + void initStore(); + + WasmStorePtr store_; + WasmModulePtr module_; + WasmSharedModulePtr shared_module_; + WasmInstancePtr instance_; + WasmMemoryPtr memory_; + WasmTablePtr table_; + + std::unordered_map host_functions_; + std::unordered_map module_functions_; +}; + +void Wasmtime::initStore() { + if (store_ != nullptr) { + return; + } + store_ = wasm_store_new(engine()); +} + +bool Wasmtime::load(std::string_view bytecode, std::string_view /*precompiled*/, + const std::unordered_map & /*function_names*/) { + initStore(); + if (store_ == nullptr) { + return false; + } + + WasmByteVec vec; + wasm_byte_vec_new(vec.get(), bytecode.size(), bytecode.data()); + + module_ = wasm_module_new(store_.get(), vec.get()); + if (module_ == nullptr) { + return false; + } + + shared_module_ = wasm_module_share(module_.get()); + if (shared_module_ == nullptr) { + return false; + } + + return true; +} + +std::unique_ptr Wasmtime::clone() { + assert(shared_module_ != nullptr); + + auto clone = std::make_unique(); + if (clone == nullptr) { + return nullptr; + } + + clone->store_ = wasm_store_new(engine()); + if (clone->store_ == nullptr) { + return nullptr; + } + + clone->module_ = wasm_module_obtain(clone->store_.get(), shared_module_.get()); + if (clone->module_ == nullptr) { + return nullptr; + } + + auto *integration_clone = integration()->clone(); + if (integration_clone == nullptr) { + return nullptr; + } + clone->integration().reset(integration_clone); + + return clone; +} + +static bool equalValTypes(const wasm_valtype_vec_t *left, const wasm_valtype_vec_t *right) { + if (left->size != right->size) { + return false; + } + + for (size_t i = 0; i < left->size; i++) { + if (wasm_valtype_kind(left->data[i]) != wasm_valtype_kind(right->data[i])) { + return false; + } + } + + return true; +} + +static std::string printValue(const wasm_val_t &value) { + switch (value.kind) { + case WASM_I32: + return std::to_string(value.of.i32); + case WASM_I64: + return std::to_string(value.of.i64); + case WASM_F32: + return std::to_string(value.of.f32); + case WASM_F64: + return std::to_string(value.of.f64); + default: + return "unknown"; + } +} + +static std::string printValues(const wasm_val_vec_t *values) { + if (values->size == 0) { + return ""; + } + + std::string s; + for (size_t i = 0; i < values->size; i++) { + if (i != 0U) { + s.append(", "); + } + s.append(printValue(values->data[i])); + } + return s; +} + +static const char *printValKind(wasm_valkind_t kind) { + switch (kind) { + case WASM_I32: + return "i32"; + case WASM_I64: + return "i64"; + case WASM_F32: + return "f32"; + case WASM_F64: + return "f64"; + case WASM_EXTERNREF: + return "externref"; + case WASM_FUNCREF: + return "funcref"; + default: + return "unknown"; + } +} + +static std::string printValTypes(const wasm_valtype_vec_t *types) { + if (types->size == 0) { + return "void"; + } + + std::string s; + s.reserve(types->size * 8 /* max size + " " */ - 1); + for (size_t i = 0; i < types->size; i++) { + if (i != 0U) { + s.append(" "); + } + s.append(printValKind(wasm_valtype_kind(types->data[i]))); + } + return s; +} + +bool Wasmtime::link(std::string_view /*debug_name*/) { + assert(module_ != nullptr); + + WasmImporttypeVec import_types; + wasm_module_imports(module_.get(), import_types.get()); + + std::vector imports; + for (size_t i = 0; i < import_types.get()->size; i++) { + const wasm_name_t *module_name_ptr = wasm_importtype_module(import_types.get()->data[i]); + const wasm_name_t *name_ptr = wasm_importtype_name(import_types.get()->data[i]); + const wasm_externtype_t *extern_type = wasm_importtype_type(import_types.get()->data[i]); + + std::string_view module_name(module_name_ptr->data, module_name_ptr->size); + std::string_view name(name_ptr->data, name_ptr->size); + assert(name_ptr->size > 0); + switch (wasm_externtype_kind(extern_type)) { + case WASM_EXTERN_FUNC: { + auto it = host_functions_.find(std::string(module_name) + "." + std::string(name)); + if (it == host_functions_.end()) { + fail(FailState::UnableToInitializeCode, + std::string("Failed to load Wasm module due to a missing import: ") + + std::string(module_name) + "." + std::string(name)); + return false; + } + + auto *func = it->second->callback_.get(); + const wasm_functype_t *exp_type = wasm_externtype_as_functype_const(extern_type); + WasmFunctypePtr actual_type = wasm_func_type(it->second->callback_.get()); + if (!equalValTypes(wasm_functype_params(exp_type), wasm_functype_params(actual_type.get())) || + !equalValTypes(wasm_functype_results(exp_type), + wasm_functype_results(actual_type.get()))) { + fail( + FailState::UnableToInitializeCode, + std::string("Failed to load Wasm module due to an import type mismatch for function ") + + std::string(module_name) + "." + std::string(name) + + ", want: " + printValTypes(wasm_functype_params(exp_type)) + " -> " + + printValTypes(wasm_functype_results(exp_type)) + + ", but host exports: " + printValTypes(wasm_functype_params(actual_type.get())) + + " -> " + printValTypes(wasm_functype_results(actual_type.get()))); + return false; + } + imports.push_back(wasm_func_as_extern(func)); + } break; + case WASM_EXTERN_GLOBAL: { + // TODO(mathetake): add support when/if needed. + fail(FailState::UnableToInitializeCode, + "Failed to load Wasm module due to a missing import: " + std::string(module_name) + "." + + std::string(name)); + return false; + } break; + case WASM_EXTERN_MEMORY: { + assert(memory_ == nullptr); + const wasm_memorytype_t *memory_type = + wasm_externtype_as_memorytype_const(extern_type); // owned by `extern_type` + if (memory_type == nullptr) { + return false; + } + memory_ = wasm_memory_new(store_.get(), memory_type); + if (memory_ == nullptr) { + return false; + } + imports.push_back(wasm_memory_as_extern(memory_.get())); + } break; + case WASM_EXTERN_TABLE: { + assert(table_ == nullptr); + const wasm_tabletype_t *table_type = + wasm_externtype_as_tabletype_const(extern_type); // owned by `extern_type` + if (table_type == nullptr) { + return false; + } + table_ = wasm_table_new(store_.get(), table_type, nullptr); + if (table_ == nullptr) { + return false; + } + imports.push_back(wasm_table_as_extern(table_.get())); + } break; + } + } + + if (import_types.get()->size != imports.size()) { + return false; + } + + wasm_extern_vec_t imports_vec = {imports.size(), imports.data()}; + instance_ = wasm_instance_new(store_.get(), module_.get(), &imports_vec, nullptr); + if (instance_ == nullptr) { + fail(FailState::UnableToInitializeCode, "Failed to create new Wasm instance"); + return false; + } + + WasmExportTypeVec export_types; + wasm_module_exports(module_.get(), export_types.get()); + + WasmExternVec exports; + wasm_instance_exports(instance_.get(), exports.get()); + + for (size_t i = 0; i < export_types.get()->size; i++) { + const wasm_externtype_t *exp_extern_type = wasm_exporttype_type(export_types.get()->data[i]); + wasm_extern_t *actual_extern = exports.get()->data[i]; + + wasm_externkind_t kind = wasm_extern_kind(actual_extern); + assert(kind == wasm_externtype_kind(exp_extern_type)); + switch (kind) { + case WASM_EXTERN_FUNC: { + WasmFuncPtr func = wasm_func_copy(wasm_extern_as_func(actual_extern)); + const wasm_name_t *name_ptr = wasm_exporttype_name(export_types.get()->data[i]); + module_functions_.insert_or_assign(std::string(name_ptr->data, name_ptr->size), + std::move(func)); + } break; + case WASM_EXTERN_GLOBAL: { + // TODO(mathetake): add support when/if needed. + } break; + case WASM_EXTERN_MEMORY: { + assert(memory_ == nullptr); + memory_ = wasm_memory_copy(wasm_extern_as_memory(actual_extern)); + if (memory_ == nullptr) { + return false; + } + } break; + case WASM_EXTERN_TABLE: { + // TODO(mathetake): add support when/if needed. + } break; + } + } + return true; +} + +uint64_t Wasmtime::getMemorySize() { return wasm_memory_data_size(memory_.get()); } + +std::optional Wasmtime::getMemory(uint64_t pointer, uint64_t size) { + assert(memory_ != nullptr); + if (pointer + size > wasm_memory_data_size(memory_.get())) { + return std::nullopt; + } + return std::string_view(wasm_memory_data(memory_.get()) + pointer, size); +} + +bool Wasmtime::setMemory(uint64_t pointer, uint64_t size, const void *data) { + assert(memory_ != nullptr); + if (pointer + size > wasm_memory_data_size(memory_.get())) { + return false; + } + ::memcpy(wasm_memory_data(memory_.get()) + pointer, data, size); + return true; +} + +bool Wasmtime::getWord(uint64_t pointer, Word *word) { + assert(memory_ != nullptr); + constexpr auto size = sizeof(uint32_t); + if (pointer + size > wasm_memory_data_size(memory_.get())) { + return false; + } + + uint32_t word32; + ::memcpy(&word32, wasm_memory_data(memory_.get()) + pointer, size); + word->u64_ = wasmtoh(word32, true); + return true; +} + +bool Wasmtime::setWord(uint64_t pointer, Word word) { + constexpr auto size = sizeof(uint32_t); + if (pointer + size > wasm_memory_data_size(memory_.get())) { + return false; + } + uint32_t word32 = htowasm(word.u32(), true); + ::memcpy(wasm_memory_data(memory_.get()) + pointer, &word32, size); + return true; +} + +template void assignVal(T t, wasm_val_t &val); +template <> void assignVal(Word t, wasm_val_t &val) { + val.kind = WASM_I32; + val.of.i32 = static_cast(t.u64_); +} +template <> void assignVal(uint32_t t, wasm_val_t &val) { + val.kind = WASM_I32; + val.of.i32 = static_cast(t); +} +template <> void assignVal(uint64_t t, wasm_val_t &val) { + val.kind = WASM_I64; + val.of.i64 = static_cast(t); +} +template <> void assignVal(double t, wasm_val_t &val) { + val.kind = WASM_F64; + val.of.f64 = t; +} + +template wasm_val_t makeVal(T t) { + wasm_val_t val{}; + assignVal(t, val); + return val; +} + +template struct ConvertWordType { + using type = T; // NOLINT(readability-identifier-naming) +}; +template <> struct ConvertWordType { + using type = uint32_t; // NOLINT(readability-identifier-naming) +}; + +template auto convertArgToValTypePtr(); +template <> auto convertArgToValTypePtr() { return wasm_valtype_new_i32(); }; +template <> auto convertArgToValTypePtr() { return wasm_valtype_new_i32(); }; +template <> auto convertArgToValTypePtr() { return wasm_valtype_new_i64(); }; +template <> auto convertArgToValTypePtr() { return wasm_valtype_new_i64(); }; +template <> auto convertArgToValTypePtr() { return wasm_valtype_new_f64(); }; + +template T convertValueTypeToArg(wasm_val_t val); +template <> uint32_t convertValueTypeToArg(wasm_val_t val) { + return static_cast(val.of.i32); +} +template <> Word convertValueTypeToArg(wasm_val_t val) { return val.of.i32; } +template <> int64_t convertValueTypeToArg(wasm_val_t val) { return val.of.i64; } +template <> uint64_t convertValueTypeToArg(wasm_val_t val) { + return static_cast(val.of.i64); +} +template <> double convertValueTypeToArg(wasm_val_t val) { return val.of.f64; } + +template +constexpr T convertValTypesToArgsTuple(const U &vec, std::index_sequence /*comptime*/) { + return std::make_tuple( + convertValueTypeToArg>::type>( + vec->data[I])...); +} + +template +void convertArgsTupleToValTypesImpl(wasm_valtype_vec_t *types, + std::index_sequence /*comptime*/) { + auto size = std::tuple_size::value; + auto ps = std::array::value>{ + convertArgToValTypePtr::type>()...}; + wasm_valtype_vec_new(types, size, ps.data()); +} + +template ::value>> +void convertArgsTupleToValTypes(wasm_valtype_vec_t *types) { + convertArgsTupleToValTypesImpl(types, Is()); +} + +template WasmFunctypePtr newWasmNewFuncType() { + WasmValtypeVec params; + WasmValtypeVec results; + convertArgsTupleToValTypes(params.get()); + convertArgsTupleToValTypes>(results.get()); + return wasm_functype_new(params.get(), results.get()); +} + +template WasmFunctypePtr newWasmNewFuncType() { + WasmValtypeVec params; + WasmValtypeVec results; + convertArgsTupleToValTypes(params.get()); + convertArgsTupleToValTypes>(results.get()); + return wasm_functype_new(params.get(), results.get()); +} + +template +void Wasmtime::registerHostFunctionImpl(std::string_view module_name, + std::string_view function_name, void (*function)(Args...)) { + auto data = + std::make_unique(std::string(module_name) + "." + std::string(function_name)); + + WasmFunctypePtr type = newWasmNewFuncType>(); + WasmFuncPtr func = wasm_func_new_with_env( + store_.get(), type.get(), + [](void *data, const wasm_val_vec_t *params, wasm_val_vec_t * /*results*/) -> wasm_trap_t * { + auto *func_data = reinterpret_cast(data); + const bool log = func_data->vm_->cmpLogLevel(LogLevel::trace); + if (log) { + func_data->vm_->integration()->trace("[vm->host] " + func_data->name_ + "(" + + printValues(params) + ")"); + } + auto args = convertValTypesToArgsTuple>( + params, std::make_index_sequence{}); + auto fn = reinterpret_cast(func_data->raw_func_); + std::apply(fn, args); + if (log) { + func_data->vm_->integration()->trace("[vm<-host] " + func_data->name_ + " return: void"); + } + return nullptr; + }, + data.get(), nullptr); + + data->vm_ = this; + data->callback_ = std::move(func); + data->raw_func_ = reinterpret_cast(function); + host_functions_.insert_or_assign(std::string(module_name) + "." + std::string(function_name), + std::move(data)); +}; + +template +void Wasmtime::registerHostFunctionImpl(std::string_view module_name, + std::string_view function_name, R (*function)(Args...)) { + auto data = + std::make_unique(std::string(module_name) + "." + std::string(function_name)); + WasmFunctypePtr type = newWasmNewFuncType>(); + WasmFuncPtr func = wasm_func_new_with_env( + store_.get(), type.get(), + [](void *data, const wasm_val_vec_t *params, wasm_val_vec_t *results) -> wasm_trap_t * { + auto *func_data = reinterpret_cast(data); + const bool log = func_data->vm_->cmpLogLevel(LogLevel::trace); + if (log) { + func_data->vm_->integration()->trace("[vm->host] " + func_data->name_ + "(" + + printValues(params) + ")"); + } + auto args = convertValTypesToArgsTuple>( + params, std::make_index_sequence{}); + auto fn = reinterpret_cast(func_data->raw_func_); + R res = std::apply(fn, args); + assignVal(res, results->data[0]); + if (log) { + func_data->vm_->integration()->trace("[vm<-host] " + func_data->name_ + + " return: " + std::to_string(res)); + } + return nullptr; + }, + data.get(), nullptr); + + data->vm_ = this; + data->callback_ = std::move(func); + data->raw_func_ = reinterpret_cast(function); + host_functions_.insert_or_assign(std::string(module_name) + "." + std::string(function_name), + std::move(data)); +}; + +template +void Wasmtime::getModuleFunctionImpl(std::string_view function_name, + std::function *function) { + + auto it = module_functions_.find(std::string(function_name)); + if (it == module_functions_.end()) { + *function = nullptr; + return; + } + + WasmValtypeVec exp_args; + WasmValtypeVec exp_returns; + convertArgsTupleToValTypes>(exp_args.get()); + convertArgsTupleToValTypes>(exp_returns.get()); + wasm_func_t *func = it->second.get(); + WasmFunctypePtr func_type = wasm_func_type(func); + + if (!equalValTypes(wasm_functype_params(func_type.get()), exp_args.get()) || + !equalValTypes(wasm_functype_results(func_type.get()), exp_returns.get())) { + fail(FailState::UnableToInitializeCode, + "Bad function signature for: " + std::string(function_name) + ", want: " + + printValTypes(exp_args.get()) + " -> " + printValTypes(exp_returns.get()) + + ", but the module exports: " + printValTypes(wasm_functype_params(func_type.get())) + + " -> " + printValTypes(wasm_functype_results(func_type.get()))); + return; + } + + *function = [func, function_name, this](ContextBase *context, Args... args) -> void { + const bool log = cmpLogLevel(LogLevel::trace); + SaveRestoreContext saved_context(context); + wasm_val_vec_t results = WASM_EMPTY_VEC; + WasmTrapPtr trap; + + // Workaround for MSVC++ not supporting zero-sized arrays. + if constexpr (sizeof...(args) > 0) { + wasm_val_t params_arr[] = {makeVal(args)...}; + wasm_val_vec_t params = WASM_ARRAY_VEC(params_arr); + if (log) { + integration()->trace("[host->vm] " + std::string(function_name) + "(" + + printValues(¶ms) + ")"); + } + trap.reset(wasm_func_call(func, ¶ms, &results)); + } else { + wasm_val_vec_t params = WASM_EMPTY_VEC; + if (log) { + integration()->trace("[host->vm] " + std::string(function_name) + "()"); + } + trap.reset(wasm_func_call(func, ¶ms, &results)); + } + + if (trap) { + WasmByteVec error_message; + wasm_trap_message(trap.get(), error_message.get()); + std::string message(error_message.get()->data); // NULL-terminated + fail(FailState::RuntimeError, + "Function: " + std::string(function_name) + " failed: " + message); + return; + } + if (log) { + integration()->trace("[host<-vm] " + std::string(function_name) + " return: void"); + } + }; +}; + +template +void Wasmtime::getModuleFunctionImpl(std::string_view function_name, + std::function *function) { + auto it = module_functions_.find(std::string(function_name)); + if (it == module_functions_.end()) { + *function = nullptr; + return; + } + WasmValtypeVec exp_args; + WasmValtypeVec exp_returns; + convertArgsTupleToValTypes>(exp_args.get()); + convertArgsTupleToValTypes>(exp_returns.get()); + wasm_func_t *func = it->second.get(); + WasmFunctypePtr func_type = wasm_func_type(func); + if (!equalValTypes(wasm_functype_params(func_type.get()), exp_args.get()) || + !equalValTypes(wasm_functype_results(func_type.get()), exp_returns.get())) { + fail(FailState::UnableToInitializeCode, + "Bad function signature for: " + std::string(function_name) + ", want: " + + printValTypes(exp_args.get()) + " -> " + printValTypes(exp_returns.get()) + + ", but the module exports: " + printValTypes(wasm_functype_params(func_type.get())) + + " -> " + printValTypes(wasm_functype_results(func_type.get()))); + return; + } + + *function = [func, function_name, this](ContextBase *context, Args... args) -> R { + const bool log = cmpLogLevel(LogLevel::trace); + SaveRestoreContext saved_context(context); + wasm_val_t results_arr[1]; + wasm_val_vec_t results = WASM_ARRAY_VEC(results_arr); + WasmTrapPtr trap; + + // Workaround for MSVC++ not supporting zero-sized arrays. + if constexpr (sizeof...(args) > 0) { + wasm_val_t params_arr[] = {makeVal(args)...}; + wasm_val_vec_t params = WASM_ARRAY_VEC(params_arr); + if (log) { + integration()->trace("[host->vm] " + std::string(function_name) + "(" + + printValues(¶ms) + ")"); + } + trap.reset(wasm_func_call(func, ¶ms, &results)); + } else { + wasm_val_vec_t params = WASM_EMPTY_VEC; + if (log) { + integration()->trace("[host->vm] " + std::string(function_name) + "()"); + } + trap.reset(wasm_func_call(func, ¶ms, &results)); + } + + if (trap) { + WasmByteVec error_message; + wasm_trap_message(trap.get(), error_message.get()); + std::string message(error_message.get()->data); // NULL-terminated + fail(FailState::RuntimeError, + "Function: " + std::string(function_name) + " failed: " + message); + return R{}; + } + R ret = convertValueTypeToArg(results.data[0]); + if (log) { + integration()->trace("[host<-vm] " + std::string(function_name) + + " return: " + std::to_string(ret)); + } + return ret; + }; +}; + +void Wasmtime::warm() { initStore(); } + +} // namespace wasmtime + +std::unique_ptr createWasmtimeVm() { return std::make_unique(); } + +} // namespace proxy_wasm diff --git a/src/wavm/wavm.cc b/src/wavm/wavm.cc deleted file mode 100644 index d6b6b67a1..000000000 --- a/src/wavm/wavm.cc +++ /dev/null @@ -1,646 +0,0 @@ -// Copyright 2016-2019 Envoy Project Authors -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "include/proxy-wasm/wavm.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "include/proxy-wasm/wasm_vm.h" - -#include "WAVM/IR/Module.h" -#include "WAVM/IR/Operators.h" -#include "WAVM/IR/Types.h" -#include "WAVM/IR/Validate.h" -#include "WAVM/IR/Value.h" -#include "WAVM/Inline/Assert.h" -#include "WAVM/Inline/BasicTypes.h" -#include "WAVM/Inline/Errors.h" -#include "WAVM/Inline/Hash.h" -#include "WAVM/Inline/HashMap.h" -#include "WAVM/Inline/IndexMap.h" -#include "WAVM/Inline/IntrusiveSharedPtr.h" -#include "WAVM/Platform/Mutex.h" -#include "WAVM/Platform/Thread.h" -#include "WAVM/Runtime/Intrinsics.h" -#include "WAVM/Runtime/Linker.h" -#include "WAVM/Runtime/Runtime.h" -#include "WAVM/WASM/WASM.h" -#include "WAVM/WASTParse/WASTParse.h" - -#ifdef NDEBUG -#define ASSERT(_x) _x -#else -#define ASSERT(_x) \ - do { \ - if (!_x) \ - ::exit(1); \ - } while (0) -#endif - -using namespace WAVM; -using namespace WAVM::IR; - -namespace WAVM { -namespace IR { -template <> constexpr ValueType inferValueType() { return ValueType::i32; } -} // namespace IR -} // namespace WAVM - -namespace proxy_wasm { - -// Forward declarations. -template -void getFunctionWavm(WasmVm *vm, std::string_view function_name, - std::function *function); -template -void registerCallbackWavm(WasmVm *vm, std::string_view module_name, std::string_view function_name, - R (*)(Args...)); -template -void registerCallbackWavm(WasmVm *vm, std::string_view module_name, std::string_view function_name, - F, R (*)(Args...)); - -namespace Wavm { - -struct Wavm; - -namespace { - -#define CALL_WITH_CONTEXT(_x, _context, _wavm) \ - do { \ - try { \ - SaveRestoreContext _saved_context(static_cast(_context)); \ - WAVM::Runtime::catchRuntimeExceptions( \ - [&] { _x; }, \ - [&](WAVM::Runtime::Exception *exception) { \ - auto description = describeException(exception); \ - _wavm->fail(FailState::RuntimeError, \ - "Function: " + std::string(function_name) + " failed: " + description); \ - destroyException(exception); \ - throw std::exception(); \ - }); \ - } catch (...) { \ - } \ - } while (0) - -struct WasmUntaggedValue : public WAVM::IR::UntaggedValue { - WasmUntaggedValue() = default; - WasmUntaggedValue(I32 inI32) { i32 = inI32; } - WasmUntaggedValue(I64 inI64) { i64 = inI64; } - WasmUntaggedValue(U32 inU32) { u32 = inU32; } - WasmUntaggedValue(Word w) { u32 = static_cast(w.u64_); } - WasmUntaggedValue(U64 inU64) { u64 = inU64; } - WasmUntaggedValue(F32 inF32) { f32 = inF32; } - WasmUntaggedValue(F64 inF64) { f64 = inF64; } -}; - -class RootResolver : public WAVM::Runtime::Resolver { -public: - RootResolver(WAVM::Runtime::Compartment *, WasmVm *vm) : vm_(vm) {} - - virtual ~RootResolver() { module_name_to_instance_map_.clear(); } - - bool resolve(const std::string &module_name, const std::string &export_name, ExternType type, - WAVM::Runtime::Object *&out_object) override { - auto named_instance = module_name_to_instance_map_.get(module_name); - if (named_instance) { - out_object = getInstanceExport(*named_instance, export_name); - if (out_object) { - if (isA(out_object, type)) { - return true; - } else { - vm_->fail(FailState::UnableToInitializeCode, - "Failed to load WASM module due to a type mismatch in an import: " + - std::string(module_name) + "." + export_name + " " + - asString(WAVM::Runtime::getExternType(out_object)) + - " but was expecting type: " + asString(type)); - return false; - } - } - } - for (auto r : resolvers_) { - if (r->resolve(module_name, export_name, type, out_object)) { - return true; - } - } - vm_->fail(FailState::MissingFunction, - "Failed to load Wasm module due to a missing import: " + std::string(module_name) + - "." + std::string(export_name) + " " + asString(type)); - return false; - } - - HashMap &moduleNameToInstanceMap() { - return module_name_to_instance_map_; - } - - void addResolver(WAVM::Runtime::Resolver *r) { resolvers_.push_back(r); } - -private: - WasmVm *vm_; - HashMap module_name_to_instance_map_; - std::vector resolvers_; -}; - -const uint64_t WasmPageSize = 1 << 16; - -bool loadModule(const std::string &code, IR::Module &out_module) { - // If the code starts with the WASM binary magic number, load it as a binary IR::Module. - static const uint8_t WasmMagicNumber[4] = {0x00, 0x61, 0x73, 0x6d}; - if (code.size() >= 4 && !memcmp(code.data(), WasmMagicNumber, 4)) { - return WASM::loadBinaryModule(reinterpret_cast(code.data()), code.size(), - out_module); - } else { - // Load it as a text IR::Module. - std::vector parseErrors; - if (!WAST::parseModule(code.c_str(), code.size() + 1, out_module, parseErrors)) { - return false; - } - return true; - } -} - -} // namespace - -template struct NativeWord { using type = T; }; -template <> struct NativeWord { using type = uint32_t; }; - -template typename NativeWord::type ToNative(const T &t) { return t; } -template <> typename NativeWord::type ToNative(const Word &t) { return t.u32(); } - -struct PairHash { - template std::size_t operator()(const std::pair &x) const { - return std::hash()(x.first) + std::hash()(x.second); - } -}; - -struct Wavm : public WasmVm { - Wavm() : WasmVm() {} - ~Wavm() override; - - // WasmVm - std::string_view runtime() override { return "wavm"; } - Cloneable cloneable() override { return Cloneable::InstantiatedModule; }; - std::unique_ptr clone() override; - bool load(const std::string &code, bool allow_precompiled) override; - bool link(std::string_view debug_name) override; - uint64_t getMemorySize() override; - std::optional getMemory(uint64_t pointer, uint64_t size) override; - bool setMemory(uint64_t pointer, uint64_t size, const void *data) override; - bool getWord(uint64_t pointer, Word *data) override; - bool setWord(uint64_t pointer, Word data) override; - std::string_view getCustomSection(std::string_view name) override; - std::string_view getPrecompiledSectionName() override; - AbiVersion getAbiVersion() override; - -#define _GET_FUNCTION(_T) \ - void getFunction(std::string_view function_name, _T *f) override { \ - getFunctionWavm(this, function_name, f); \ - }; - FOR_ALL_WASM_VM_EXPORTS(_GET_FUNCTION) -#undef _GET_FUNCTION - -#define _REGISTER_CALLBACK(_T) \ - void registerCallback(std::string_view module_name, std::string_view function_name, _T, \ - typename ConvertFunctionTypeWordToUint32<_T>::type f) override { \ - registerCallbackWavm(this, module_name, function_name, f); \ - }; - FOR_ALL_WASM_VM_IMPORTS(_REGISTER_CALLBACK) -#undef _REGISTER_CALLBACK - - bool has_instantiated_module_ = false; - IR::Module ir_module_; - WAVM::Runtime::ModuleRef module_ = nullptr; - WAVM::Runtime::GCPointer module_instance_; - WAVM::Runtime::Memory *memory_; - WAVM::Runtime::GCPointer compartment_; - WAVM::Runtime::GCPointer context_; - std::map intrinsic_modules_; - std::map> - intrinsic_module_instances_; - std::vector> envoyFunctions_; - uint8_t *memory_base_ = nullptr; - AbiVersion abi_version_ = AbiVersion::Unknown; -}; - -Wavm::~Wavm() { - module_instance_ = nullptr; - context_ = nullptr; - intrinsic_module_instances_.clear(); - intrinsic_modules_.clear(); - envoyFunctions_.clear(); - if (compartment_) { - ASSERT(tryCollectCompartment(std::move(compartment_))); - } -} - -std::unique_ptr Wavm::clone() { - auto wavm = std::make_unique(); - wavm->compartment_ = WAVM::Runtime::cloneCompartment(compartment_); - wavm->memory_ = WAVM::Runtime::remapToClonedCompartment(memory_, wavm->compartment_); - wavm->memory_base_ = WAVM::Runtime::getMemoryBaseAddress(wavm->memory_); - wavm->context_ = WAVM::Runtime::createContext(wavm->compartment_); - wavm->abi_version_ = abi_version_; - for (auto &p : intrinsic_module_instances_) { - wavm->intrinsic_module_instances_.emplace( - p.first, WAVM::Runtime::remapToClonedCompartment(p.second, wavm->compartment_)); - } - wavm->module_instance_ = - WAVM::Runtime::remapToClonedCompartment(module_instance_, wavm->compartment_); - return wavm; -} - -bool Wavm::load(const std::string &code, bool allow_precompiled) { - ASSERT(!has_instantiated_module_); - has_instantiated_module_ = true; - compartment_ = WAVM::Runtime::createCompartment(); - context_ = WAVM::Runtime::createContext(compartment_); - if (!loadModule(code, ir_module_)) { - return false; - } - getAbiVersion(); // Cache ABI version. - const CustomSection *precompiled_object_section = nullptr; - if (allow_precompiled) { - for (const CustomSection &customSection : ir_module_.customSections) { - if (customSection.name == getPrecompiledSectionName()) { - precompiled_object_section = &customSection; - break; - } - } - } - if (!precompiled_object_section) { - module_ = WAVM::Runtime::compileModule(ir_module_); - } else { - module_ = WAVM::Runtime::loadPrecompiledModule(ir_module_, precompiled_object_section->data); - } - return true; -} - -AbiVersion Wavm::getAbiVersion() { - if (abi_version_ != AbiVersion::Unknown) { - return abi_version_; - } - for (auto &e : ir_module_.exports) { - if (e.name == "proxy_abi_version_0_1_0") { - abi_version_ = AbiVersion::ProxyWasm_0_1_0; - return abi_version_; - } - if (e.name == "proxy_abi_version_0_2_0") { - abi_version_ = AbiVersion::ProxyWasm_0_2_0; - return abi_version_; - } - if (e.name == "proxy_abi_version_0_2_1") { - abi_version_ = AbiVersion::ProxyWasm_0_2_1; - return abi_version_; - } - } - return AbiVersion::Unknown; -} - -bool Wavm::link(std::string_view debug_name) { - RootResolver rootResolver(compartment_, this); - for (auto &p : intrinsic_modules_) { - auto instance = Intrinsics::instantiateModule(compartment_, {&intrinsic_modules_[p.first]}, - std::string(p.first)); - intrinsic_module_instances_.emplace(p.first, instance); - rootResolver.moduleNameToInstanceMap().set(p.first, instance); - } - WAVM::Runtime::LinkResult link_result = linkModule(ir_module_, rootResolver); - if (!link_result.missingImports.empty()) { - for (auto &i : link_result.missingImports) { - error("Missing Wasm import " + i.moduleName + " " + i.exportName); - } - fail(FailState::MissingFunction, "Failed to load Wasm module due to a missing import(s)"); - return false; - } - module_instance_ = instantiateModule( - compartment_, module_, std::move(link_result.resolvedImports), std::string(debug_name)); - memory_ = getDefaultMemory(module_instance_); - memory_base_ = WAVM::Runtime::getMemoryBaseAddress(memory_); - return true; -} - -uint64_t Wavm::getMemorySize() { return WAVM::Runtime::getMemoryNumPages(memory_) * WasmPageSize; } - -std::optional Wavm::getMemory(uint64_t pointer, uint64_t size) { - auto memory_num_bytes = WAVM::Runtime::getMemoryNumPages(memory_) * WasmPageSize; - if (pointer + size > memory_num_bytes) { - return std::nullopt; - } - return std::string_view(reinterpret_cast(memory_base_ + pointer), size); -} - -bool Wavm::setMemory(uint64_t pointer, uint64_t size, const void *data) { - auto memory_num_bytes = WAVM::Runtime::getMemoryNumPages(memory_) * WasmPageSize; - if (pointer + size > memory_num_bytes) { - return false; - } - auto p = reinterpret_cast(memory_base_ + pointer); - memcpy(p, data, size); - return true; -} - -bool Wavm::getWord(uint64_t pointer, Word *data) { - auto memory_num_bytes = WAVM::Runtime::getMemoryNumPages(memory_) * WasmPageSize; - if (pointer + sizeof(uint32_t) > memory_num_bytes) { - return false; - } - auto p = reinterpret_cast(memory_base_ + pointer); - uint32_t data32; - memcpy(&data32, p, sizeof(uint32_t)); - data->u64_ = data32; - return true; -} - -bool Wavm::setWord(uint64_t pointer, Word data) { - uint32_t data32 = data.u32(); - return setMemory(pointer, sizeof(uint32_t), &data32); -} - -std::string_view Wavm::getCustomSection(std::string_view name) { - for (auto §ion : ir_module_.customSections) { - if (section.name == name) { - return {reinterpret_cast(section.data.data()), section.data.size()}; - } - } - return {}; -} - -std::string_view Wavm::getPrecompiledSectionName() { return "wavm.precompiled_object"; } - -} // namespace Wavm - -std::unique_ptr createWavmVm() { return std::make_unique(); } - -template -IR::FunctionType inferEnvoyFunctionType(R (*)(void *, Args...)) { - return IR::FunctionType(IR::inferResultType(), IR::TypeTuple({IR::inferValueType()...}), - IR::CallingConvention::intrinsic); -} - -using namespace Wavm; - -template -void registerCallbackWavm(WasmVm *vm, std::string_view module_name, std::string_view function_name, - R (*f)(Args...)) { - auto wavm = static_cast(vm); - wavm->envoyFunctions_.emplace_back(new Intrinsics::Function( - &wavm->intrinsic_modules_[std::string(module_name)], function_name.data(), - reinterpret_cast(f), inferEnvoyFunctionType(f))); -} - -template void registerCallbackWavm(WasmVm *vm, std::string_view module_name, - std::string_view function_name, void (*f)(void *)); -template void registerCallbackWavm(WasmVm *vm, std::string_view module_name, - std::string_view function_name, - void (*f)(void *, U32)); -template void registerCallbackWavm(WasmVm *vm, std::string_view module_name, - std::string_view function_name, - void (*f)(void *, U32, U32)); -template void registerCallbackWavm(WasmVm *vm, - std::string_view module_name, - std::string_view function_name, - void (*f)(void *, U32, U32, U32)); -template void -registerCallbackWavm(WasmVm *vm, std::string_view module_name, - std::string_view function_name, - void (*f)(void *, U32, U32, U32, U32)); -template void registerCallbackWavm( - WasmVm *vm, std::string_view module_name, std::string_view function_name, - void (*f)(void *, U32, U32, U32, U32, U32)); -template void registerCallbackWavm( - WasmVm *vm, std::string_view module_name, std::string_view function_name, - void (*f)(void *, U32, U32, U32, U32, U32, U32)); -template void registerCallbackWavm( - WasmVm *vm, std::string_view module_name, std::string_view function_name, - void (*f)(void *, U32, U32, U32, U32, U32, U32, U32)); -template void registerCallbackWavm( - WasmVm *vm, std::string_view module_name, std::string_view function_name, - void (*f)(void *, U32, U32, U32, U32, U32, U32, U32, U32)); -template void registerCallbackWavm( - WasmVm *vm, std::string_view module_name, std::string_view function_name, - void (*f)(void *, U32, U32, U32, U32, U32, U32, U32, U32, U32)); -template void registerCallbackWavm( - WasmVm *vm, std::string_view module_name, std::string_view function_name, - void (*f)(void *, U32, U32, U32, U32, U32, U32, U32, U32, U32, U32)); - -template void registerCallbackWavm(WasmVm *vm, std::string_view module_name, - std::string_view function_name, U32 (*f)(void *)); -template void registerCallbackWavm(WasmVm *vm, std::string_view module_name, - std::string_view function_name, - U32 (*f)(void *, U32)); -template void registerCallbackWavm(WasmVm *vm, std::string_view module_name, - std::string_view function_name, - U32 (*f)(void *, U32, U32)); -template void registerCallbackWavm(WasmVm *vm, - std::string_view module_name, - std::string_view function_name, - U32 (*f)(void *, U32, U32, U32)); -template void -registerCallbackWavm(WasmVm *vm, std::string_view module_name, - std::string_view function_name, - U32 (*f)(void *, U32, U32, U32, U32)); -template void registerCallbackWavm( - WasmVm *vm, std::string_view module_name, std::string_view function_name, - U32 (*f)(void *, U32, U32, U32, U32, U32)); -template void registerCallbackWavm( - WasmVm *vm, std::string_view module_name, std::string_view function_name, - U32 (*f)(void *, U32, U32, U32, U32, U32, U32)); -template void registerCallbackWavm( - WasmVm *vm, std::string_view module_name, std::string_view function_name, - U32 (*f)(void *, U32, U32, U32, U32, U32, U32, U32)); -template void registerCallbackWavm( - WasmVm *vm, std::string_view module_name, std::string_view function_name, - U32 (*f)(void *, U32, U32, U32, U32, U32, U32, U32, U32)); -template void registerCallbackWavm( - WasmVm *vm, std::string_view module_name, std::string_view function_name, - U32 (*f)(void *, U32, U32, U32, U32, U32, U32, U32, U32, U32)); -template void registerCallbackWavm( - WasmVm *vm, std::string_view module_name, std::string_view function_name, - U32 (*f)(void *, U32, U32, U32, U32, U32, U32, U32, U32, U32, U32)); - -template void registerCallbackWavm(WasmVm *vm, std::string_view module_name, - std::string_view function_name, - U64 (*f)(void *, U32)); -template void registerCallbackWavm(WasmVm *vm, std::string_view module_name, - std::string_view function_name, - void (*f)(void *, U32, I64)); -template void registerCallbackWavm(WasmVm *vm, std::string_view module_name, - std::string_view function_name, - void (*f)(void *, U32, U64)); - -template -IR::FunctionType inferStdFunctionType(std::function *) { - return IR::FunctionType(IR::inferResultType(), IR::TypeTuple({IR::inferValueType()...})); -} - -static bool checkFunctionType(WAVM::Runtime::Function *f, IR::FunctionType t) { - return getFunctionType(f) == t; -} - -template -void getFunctionWavmReturn(WasmVm *vm, std::string_view function_name, - std::function *function, uint32_t) { - auto wavm = static_cast(vm); - auto f = - asFunctionNullable(getInstanceExport(wavm->module_instance_, std::string(function_name))); - if (!f) - f = asFunctionNullable(getInstanceExport(wavm->module_instance_, std::string(function_name))); - if (!f) { - *function = nullptr; - return; - } - if (!checkFunctionType(f, inferStdFunctionType(function))) { - wavm->fail(FailState::UnableToInitializeCode, - "Bad function signature for: " + std::string(function_name)); - } - *function = [wavm, f, function_name](ContextBase *context, Args... args) -> R { - WasmUntaggedValue values[] = {args...}; - WasmUntaggedValue return_value; - CALL_WITH_CONTEXT( - invokeFunction(wavm->context_, f, getFunctionType(f), &values[0], &return_value), context, - wavm); - if (!wavm->isFailed()) { - return static_cast(return_value.i32); - } else { - return 0; - } - }; -} - -struct Void {}; - -template -void getFunctionWavmReturn(WasmVm *vm, std::string_view function_name, - std::function *function, Void) { - auto wavm = static_cast(vm); - auto f = - asFunctionNullable(getInstanceExport(wavm->module_instance_, std::string(function_name))); - if (!f) - f = asFunctionNullable(getInstanceExport(wavm->module_instance_, std::string(function_name))); - if (!f) { - *function = nullptr; - return; - } - if (!checkFunctionType(f, inferStdFunctionType(function))) { - wavm->fail(FailState::UnableToInitializeCode, - "Bad function signature for: " + std::string(function_name)); - } - *function = [wavm, f, function_name](ContextBase *context, Args... args) -> R { - WasmUntaggedValue values[] = {args...}; - CALL_WITH_CONTEXT(invokeFunction(wavm->context_, f, getFunctionType(f), &values[0]), context, - wavm); - }; -} - -// NB: Unfortunately 'void' is not treated like every other function type in C++. In -// particular it is not possible to specialize a template based on 'void'. Instead -// we use 'Void' for template matching. Note that the template implementation above -// which matchers on 'bool' does not use 'Void' in the implemenation. -template -void getFunctionWavm(WasmVm *vm, std::string_view function_name, - std::function *function) { - typename std::conditional::value, Void, uint32_t>::type x{}; - getFunctionWavmReturn(vm, function_name, function, x); -} - -template void getFunctionWavm(WasmVm *, std::string_view, - std::function *); -template void getFunctionWavm(WasmVm *, std::string_view, - std::function *); -template void -getFunctionWavm(WasmVm *, std::string_view, - std::function *); -template void getFunctionWavm( - WasmVm *, std::string_view, std::function *); -template void getFunctionWavm( - WasmVm *, std::string_view, - std::function *); -template void getFunctionWavm( - WasmVm *, std::string_view, - std::function *); -template void getFunctionWavm( - WasmVm *, std::string_view, - std::function - *); -template void getFunctionWavm( - WasmVm *, std::string_view, - std::function *); -template void getFunctionWavm( - WasmVm *, std::string_view, - std::function *); -template void getFunctionWavm( - WasmVm *, std::string_view, - std::function *); -template void getFunctionWavm( - WasmVm *, std::string_view, - std::function *); - -template void getFunctionWavm(WasmVm *, std::string_view, - std::function *); -template void -getFunctionWavm(WasmVm *, std::string_view, - std::function *); -template void getFunctionWavm( - WasmVm *, std::string_view, std::function *); -template void getFunctionWavm( - WasmVm *, std::string_view, - std::function *); -template void getFunctionWavm( - WasmVm *, std::string_view, - std::function *); -template void getFunctionWavm( - WasmVm *, std::string_view, - std::function *); -template void getFunctionWavm( - WasmVm *, std::string_view, - std::function *); -template void getFunctionWavm( - WasmVm *, std::string_view, - std::function *); -template void getFunctionWavm( - WasmVm *, std::string_view, - std::function *); -template void getFunctionWavm( - WasmVm *, std::string_view, - std::function *); -template void getFunctionWavm( - WasmVm *, std::string_view, - std::function *); - -template T getValue(IR::Value) {} -template <> Word getValue(IR::Value v) { return v.u32; } -template <> int32_t getValue(IR::Value v) { return v.i32; } -template <> uint32_t getValue(IR::Value v) { return v.u32; } -template <> int64_t getValue(IR::Value v) { return v.i64; } -template <> uint64_t getValue(IR::Value v) { return v.u64; } -template <> float getValue(IR::Value v) { return v.f32; } -template <> double getValue(IR::Value v) { return v.f64; } - -} // namespace proxy_wasm diff --git a/test/BUILD b/test/BUILD new file mode 100644 index 000000000..97e70558a --- /dev/null +++ b/test/BUILD @@ -0,0 +1,238 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +load("@proxy_wasm_cpp_host//bazel:select.bzl", "proxy_wasm_select_engine_null") +load("@rules_cc//cc:defs.bzl", "cc_library") +load("//bazel:cc_defs.bzl", "cc_test") + +licenses(["notice"]) # Apache 2 + +package(default_visibility = ["//visibility:public"]) + +cc_test( + name = "null_vm_test", + srcs = proxy_wasm_select_engine_null(["null_vm_test.cc"]), + linkstatic = 1, + deps = [ + "//:lib", + "@com_google_googletest//:gtest", + "@com_google_googletest//:gtest_main", + ], +) + +cc_test( + name = "bytecode_util_test", + srcs = ["bytecode_util_test.cc"], + data = [ + "//test/test_data:abi_export.wasm", + ], + linkstatic = 1, + deps = [ + ":utility_lib", + "//:lib", + "@com_google_googletest//:gtest", + "@com_google_googletest//:gtest_main", + ], +) + +cc_test( + name = "signature_util_test", + srcs = ["signature_util_test.cc"], + data = [ + "//test/test_data:abi_export.signed.with.key1.wasm", + "//test/test_data:abi_export.signed.with.key2.wasm", + "//test/test_data:abi_export.wasm", + ], + linkstatic = 1, + # Test only when compiled to verify plugins. + tags = ["manual"], + deps = [ + ":utility_lib", + "//:lib", + "@com_google_googletest//:gtest", + "@com_google_googletest//:gtest_main", + ], +) + +cc_test( + name = "runtime_test", + timeout = "long", + srcs = ["runtime_test.cc"], + data = [ + "//test/test_data:callback.wasm", + "//test/test_data:clock.wasm", + "//test/test_data:resource_limits.wasm", + "//test/test_data:trap.wasm", + ], + linkstatic = 1, + deps = [ + ":utility_lib", + "//:lib", + "@com_google_googletest//:gtest", + "@com_google_googletest//:gtest_main", + ], +) + +cc_test( + name = "exports_test", + srcs = ["exports_test.cc"], + data = [ + "//test/test_data:clock.wasm", + "//test/test_data:env.wasm", + "//test/test_data:random.wasm", + ], + linkstatic = 1, + shard_count = 8, + deps = [ + ":utility_lib", + "//:lib", + "@com_google_googletest//:gtest", + "@com_google_googletest//:gtest_main", + ], +) + +cc_test( + name = "wasm_test", + srcs = ["wasm_test.cc"], + data = [ + "//test/test_data:abi_export.wasm", + "//test/test_data:canary_check.wasm", + ], + linkstatic = 1, + deps = [ + ":utility_lib", + "//:lib", + "@com_google_googletest//:gtest", + "@com_google_googletest//:gtest_main", + ], +) + +cc_test( + name = "logging_test", + srcs = ["logging_test.cc"], + data = [ + "//test/test_data:http_logging.wasm", + ], + linkstatic = 1, + deps = [ + ":utility_lib", + "//:lib", + "@com_google_googletest//:gtest", + "@com_google_googletest//:gtest_main", + ], +) + +cc_test( + name = "stop_iteration_test", + srcs = ["stop_iteration_test.cc"], + data = [ + "//test/test_data:stop_iteration.wasm", + ], + linkstatic = 1, + deps = [ + ":utility_lib", + "//:lib", + "@com_google_googletest//:gtest", + "@com_google_googletest//:gtest_main", + ], +) + +cc_test( + name = "security_test", + srcs = ["security_test.cc"], + data = [ + "//test/test_data:bad_malloc.wasm", + ], + linkstatic = 1, + deps = [ + ":utility_lib", + "//:lib", + "@com_google_googletest//:gtest", + "@com_google_googletest//:gtest_main", + ], +) + +cc_test( + name = "shared_data", + srcs = ["shared_data_test.cc"], + linkstatic = 1, + deps = [ + "//:lib", + "@com_google_googletest//:gtest", + "@com_google_googletest//:gtest_main", + ], +) + +cc_test( + name = "shared_queue", + srcs = ["shared_queue_test.cc"], + linkstatic = 1, + deps = [ + "//:lib", + "@com_google_googletest//:gtest", + "@com_google_googletest//:gtest_main", + ], +) + +cc_test( + name = "vm_id_handle", + srcs = ["vm_id_handle_test.cc"], + linkstatic = 1, + deps = [ + "//:lib", + "@com_google_googletest//:gtest", + "@com_google_googletest//:gtest_main", + ], +) + +cc_test( + name = "wasm_vm_test", + timeout = "long", + srcs = ["wasm_vm_test.cc"], + data = [ + "//test/test_data:abi_export.wasm", + ], + linkstatic = 1, + deps = [ + ":utility_lib", + "//:lib", + "@com_google_googletest//:gtest", + "@com_google_googletest//:gtest_main", + ], +) + +cc_test( + name = "pairs_util_test", + srcs = ["pairs_util_test.cc"], + linkstatic = 1, + deps = [ + "//:lib", + "@com_google_googletest//:gtest", + "@com_google_googletest//:gtest_main", + ], +) + +cc_library( + name = "utility_lib", + testonly = True, + srcs = [ + "utility.cc", + "utility.h", + ], + hdrs = ["utility.h"], + deps = [ + "//:lib", + "@com_google_googletest//:gtest", + ], +) diff --git a/test/bytecode_util_test.cc b/test/bytecode_util_test.cc new file mode 100644 index 000000000..2e1a813cb --- /dev/null +++ b/test/bytecode_util_test.cc @@ -0,0 +1,126 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "include/proxy-wasm/bytecode_util.h" + +#include +#include +#include + +#include "test/utility.h" + +#include "gtest/gtest.h" + +namespace proxy_wasm { + +TEST(TestBytecodeUtil, getCustomSection) { + std::string custom_section = { + 0x00, 0x61, 0x73, 0x6d, // Wasm magic + 0x01, 0x00, 0x00, 0x00, // Wasm version + 0x00, // custom section id + 0x0a, // section length + 0x04, 0x68, 0x65, 0x79, 0x21, // section name: "hey!" + 0x68, 0x65, 0x6c, 0x6c, 0x6f, // content: "hello" + }; + std::string_view section = {}; + + // OK. + EXPECT_TRUE(BytecodeUtil::getCustomSection(custom_section, "hey!", section)); + EXPECT_EQ(std::string(section), "hello"); + section = {}; + + // Non exist. + EXPECT_TRUE(BytecodeUtil::getCustomSection(custom_section, "non-exist", section)); + EXPECT_EQ(section, ""); + + // Fail due to the corrupted bytecode. + // TODO(@mathetake): here we haven't covered all the parsing failure branches. Add more cases. + std::string corrupted = {custom_section.data(), + custom_section.data() + custom_section.size() - 3}; + EXPECT_FALSE(BytecodeUtil::getCustomSection(corrupted, "hey", section)); + corrupted = {custom_section.data() + 1, custom_section.data() + custom_section.size()}; + EXPECT_FALSE(BytecodeUtil::getCustomSection(corrupted, "hey", section)); +} + +TEST(TestBytecodeUtil, getFunctionNameIndex) { + const auto source = readTestWasmFile("abi_export.wasm"); + std::unordered_map actual; + // OK. + EXPECT_TRUE(BytecodeUtil::getFunctionNameIndex(source, actual)); + EXPECT_FALSE(actual.empty()); + bool abi_version_found = false; + for (const auto &it : actual) { + if (it.second == "proxy_abi_version_0_2_0") { + abi_version_found = true; + break; + } + } + EXPECT_TRUE(abi_version_found); + + // Fail due to the corrupted bytecode. + // TODO(@mathetake): here we haven't covered all the parsing failure branches. Add more cases. + actual = {}; + std::string_view name_section = {}; + EXPECT_TRUE(BytecodeUtil::getCustomSection(source, "name", name_section)); + // Passing module with malformed custom section. + std::string corrupted = {source.data(), name_section.data() + 1}; + EXPECT_FALSE(BytecodeUtil::getFunctionNameIndex(corrupted, actual)); + EXPECT_TRUE(actual.empty()); +} + +TEST(TestBytecodeUtil, getStrippedSource) { + // Unmodified case. + auto source = readTestWasmFile("abi_export.wasm"); + std::string actual; + EXPECT_TRUE(BytecodeUtil::getStrippedSource(source, actual)); + // If no `precompiled_` is found in the custom sections, + // then the copy of the original should be returned. + EXPECT_FALSE(actual.empty()); + EXPECT_TRUE(actual.data() != source.data()); + EXPECT_EQ(actual, source); + + // Append "precompiled_test" custom section + std::vector custom_section = {// custom section id + 0x00, + // section length + 0x13, + // name length + 0x10, + // name = precompiled_test + 0x70, 0x72, 0x65, 0x63, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, + 0x64, 0x5f, 0x74, 0x65, 0x73, 0x74, + // content + 0x01, 0x01}; + + source.append(custom_section.data(), custom_section.size()); + std::string_view section = {}; + EXPECT_TRUE(BytecodeUtil::getCustomSection(source, "precompiled_test", section)); + EXPECT_FALSE(section.empty()); + + // Chcek if the custom section is stripped. + actual = {}; + EXPECT_TRUE(BytecodeUtil::getStrippedSource(source, actual)); + // No `precompiled_` is found in the custom sections. + EXPECT_FALSE(actual.empty()); + EXPECT_EQ(actual.size(), source.size() - custom_section.size()); +} + +TEST(TestBytecodeUtil, getAbiVersion) { + const auto source = readTestWasmFile("abi_export.wasm"); + proxy_wasm::AbiVersion actual; + EXPECT_TRUE(BytecodeUtil::getAbiVersion(source, actual)); + EXPECT_EQ(actual, proxy_wasm::AbiVersion::ProxyWasm_0_2_0); +} + +} // namespace proxy_wasm diff --git a/test/exports_test.cc b/test/exports_test.cc new file mode 100644 index 000000000..026019c03 --- /dev/null +++ b/test/exports_test.cc @@ -0,0 +1,161 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "gtest/gtest.h" + +#include +#include +#include +#include +#include +#include + +#include "include/proxy-wasm/context.h" +#include "include/proxy-wasm/exports.h" +#include "include/proxy-wasm/wasm.h" + +#include "test/utility.h" + +namespace proxy_wasm { +namespace { + +INSTANTIATE_TEST_SUITE_P(WasmEngines, TestVm, testing::ValuesIn(getWasmEngines()), + [](const testing::TestParamInfo &info) { + return info.param; + }); + +TEST_P(TestVm, Environment) { + std::unordered_map envs = {{"KEY1", "VALUE1"}, {"KEY2", "VALUE2"}}; + auto source = readTestWasmFile("env.wasm"); + ASSERT_FALSE(source.empty()); + auto wasm = TestWasm(std::move(vm_), envs); + ASSERT_TRUE(wasm.load(source, false)); + ASSERT_TRUE(wasm.initialize()); + + WasmCallVoid<0> run; + wasm.wasm_vm()->getFunction("run", &run); + ASSERT_TRUE(run != nullptr); + run(wasm.vm_context()); + + // Check application logs. + auto *context = dynamic_cast(wasm.vm_context()); + EXPECT_TRUE(context->isLogged("KEY1: VALUE1\n")); + EXPECT_TRUE(context->isLogged("KEY2: VALUE2\n")); +} + +TEST_P(TestVm, WithoutEnvironment) { + auto source = readTestWasmFile("env.wasm"); + ASSERT_FALSE(source.empty()); + auto wasm = TestWasm(std::move(vm_), {}); + ASSERT_TRUE(wasm.load(source, false)); + ASSERT_TRUE(wasm.initialize()); + + WasmCallVoid<0> run; + wasm.wasm_vm()->getFunction("run", &run); + ASSERT_TRUE(run != nullptr); + run(wasm.vm_context()); + + // Check application logs. + auto *context = dynamic_cast(wasm.vm_context()); + EXPECT_TRUE(context->isLogEmpty()); +} + +TEST_P(TestVm, Clock) { + auto source = readTestWasmFile("clock.wasm"); + ASSERT_FALSE(source.empty()); + auto wasm = TestWasm(std::move(vm_)); + ASSERT_TRUE(wasm.load(source, false)); + ASSERT_TRUE(wasm.initialize()); + + WasmCallVoid<0> run; + wasm.wasm_vm()->getFunction("run", &run); + ASSERT_TRUE(run != nullptr); + run(wasm.vm_context()); + + // Check application logs. + auto *context = dynamic_cast(wasm.vm_context()); + EXPECT_TRUE(context->isLogged("monotonic: ")); + EXPECT_TRUE(context->isLogged("realtime: ")); +} + +TEST_P(TestVm, RandomZero) { + auto source = readTestWasmFile("random.wasm"); + ASSERT_FALSE(source.empty()); + auto wasm = TestWasm(std::move(vm_)); + ASSERT_TRUE(wasm.load(source, false)); + ASSERT_TRUE(wasm.initialize()); + + WasmCallVoid<1> run; + wasm.wasm_vm()->getFunction("run", &run); + ASSERT_TRUE(run != nullptr); + run(wasm.vm_context(), Word{0}); + + // Check application logs. + auto *context = dynamic_cast(wasm.vm_context()); + EXPECT_TRUE(context->isLogged("random_get(0) succeeded.")); +} + +TEST_P(TestVm, RandomSmall) { + auto source = readTestWasmFile("random.wasm"); + ASSERT_FALSE(source.empty()); + auto wasm = TestWasm(std::move(vm_)); + ASSERT_TRUE(wasm.load(source, false)); + ASSERT_TRUE(wasm.initialize()); + + WasmCallVoid<1> run; + wasm.wasm_vm()->getFunction("run", &run); + ASSERT_TRUE(run != nullptr); + run(wasm.vm_context(), Word{32}); + + // Check application logs. + auto *context = dynamic_cast(wasm.vm_context()); + EXPECT_TRUE(context->isLogged("random_get(32) succeeded.")); +} + +TEST_P(TestVm, RandomLarge) { + auto source = readTestWasmFile("random.wasm"); + ASSERT_FALSE(source.empty()); + auto wasm = TestWasm(std::move(vm_)); + ASSERT_TRUE(wasm.load(source, false)); + ASSERT_TRUE(wasm.initialize()); + + WasmCallVoid<1> run; + wasm.wasm_vm()->getFunction("run", &run); + ASSERT_TRUE(run != nullptr); + run(wasm.vm_context(), Word{64 * 1024}); + + // Check application logs. + auto *context = dynamic_cast(wasm.vm_context()); + EXPECT_TRUE(context->isLogged("random_get(65536) succeeded.")); +} + +TEST_P(TestVm, RandomTooLarge) { + auto source = readTestWasmFile("random.wasm"); + ASSERT_FALSE(source.empty()); + auto wasm = TestWasm(std::move(vm_)); + ASSERT_TRUE(wasm.load(source, false)); + ASSERT_TRUE(wasm.initialize()); + + WasmCallVoid<1> run; + wasm.wasm_vm()->getFunction("run", &run); + ASSERT_TRUE(run != nullptr); + run(wasm.vm_context(), Word{65 * 1024}); + + // Check application logs. + auto *context = dynamic_cast(wasm.vm_context()); + EXPECT_TRUE(context->isLogged("random_get(66560) failed.")); +} + +} // namespace +} // namespace proxy_wasm diff --git a/test/fuzz/BUILD b/test/fuzz/BUILD new file mode 100644 index 000000000..2221f6367 --- /dev/null +++ b/test/fuzz/BUILD @@ -0,0 +1,47 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +load("//bazel:cc_defs.bzl", "cc_fuzz_test") + +licenses(["notice"]) # Apache 2 + +package(default_visibility = ["//visibility:public"]) + +filegroup( + name = "corpus_bytecode", + srcs = glob(["corpus_bytecode/**"]), +) + +cc_fuzz_test( + name = "bytecode_util_fuzzer", + srcs = ["bytecode_util_fuzzer.cc"], + corpus = [":corpus_bytecode"], + deps = [ + "//:lib", + ], +) + +filegroup( + name = "corpus_pairs", + srcs = glob(["corpus_pairs/**"]), +) + +cc_fuzz_test( + name = "pairs_util_fuzzer", + srcs = ["pairs_util_fuzzer.cc"], + corpus = [":corpus_pairs"], + deps = [ + "//:lib", + ], +) diff --git a/test/fuzz/bytecode_util_fuzzer.cc b/test/fuzz/bytecode_util_fuzzer.cc new file mode 100644 index 000000000..b77d9423b --- /dev/null +++ b/test/fuzz/bytecode_util_fuzzer.cc @@ -0,0 +1,41 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "include/proxy-wasm/bytecode_util.h" + +#include + +namespace proxy_wasm { +namespace { + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + auto bytecode = std::string_view(reinterpret_cast(data), size); + + AbiVersion version; + BytecodeUtil::getAbiVersion(bytecode, version); + + std::string_view custom_section; + BytecodeUtil::getCustomSection(bytecode, "precompiled", custom_section); + + std::string stripped_source; + BytecodeUtil::getStrippedSource(bytecode, stripped_source); + + std::unordered_map function_names; + BytecodeUtil::getFunctionNameIndex(bytecode, function_names); + + return 0; +} + +} // namespace +} // namespace proxy_wasm diff --git a/test/fuzz/corpus_bytecode/crash-10198e96614e9ff7ca6dae581f4f7f13143257d7 b/test/fuzz/corpus_bytecode/crash-10198e96614e9ff7ca6dae581f4f7f13143257d7 new file mode 100644 index 000000000..a8e688a41 Binary files /dev/null and b/test/fuzz/corpus_bytecode/crash-10198e96614e9ff7ca6dae581f4f7f13143257d7 differ diff --git a/test/fuzz/corpus_bytecode/crash-6d94d1b10bc8dabc467a8e4a9a7105f62c81ff4c b/test/fuzz/corpus_bytecode/crash-6d94d1b10bc8dabc467a8e4a9a7105f62c81ff4c new file mode 100644 index 000000000..81aa8f42e Binary files /dev/null and b/test/fuzz/corpus_bytecode/crash-6d94d1b10bc8dabc467a8e4a9a7105f62c81ff4c differ diff --git a/test/fuzz/corpus_bytecode/crash-8cff35e5a0f9722df891fd1f05ca6dc2bd3d42aa b/test/fuzz/corpus_bytecode/crash-8cff35e5a0f9722df891fd1f05ca6dc2bd3d42aa new file mode 100644 index 000000000..63b0377d5 Binary files /dev/null and b/test/fuzz/corpus_bytecode/crash-8cff35e5a0f9722df891fd1f05ca6dc2bd3d42aa differ diff --git a/test/fuzz/corpus_bytecode/crash-9718722528a7c015ef3852490a6c67649bda70c0 b/test/fuzz/corpus_bytecode/crash-9718722528a7c015ef3852490a6c67649bda70c0 new file mode 100644 index 000000000..c5eb9dd06 Binary files /dev/null and b/test/fuzz/corpus_bytecode/crash-9718722528a7c015ef3852490a6c67649bda70c0 differ diff --git a/test/fuzz/corpus_bytecode/crash-ed7193f661f04a66a13facee4d25709e6f479d3d b/test/fuzz/corpus_bytecode/crash-ed7193f661f04a66a13facee4d25709e6f479d3d new file mode 100644 index 000000000..30e3f1ae1 Binary files /dev/null and b/test/fuzz/corpus_bytecode/crash-ed7193f661f04a66a13facee4d25709e6f479d3d differ diff --git a/test/fuzz/corpus_pairs/crash-0bf4371e72f7ae83f9c5bf3e2485531cdcaaaa04 b/test/fuzz/corpus_pairs/crash-0bf4371e72f7ae83f9c5bf3e2485531cdcaaaa04 new file mode 100644 index 000000000..7be804a26 Binary files /dev/null and b/test/fuzz/corpus_pairs/crash-0bf4371e72f7ae83f9c5bf3e2485531cdcaaaa04 differ diff --git a/test/fuzz/pairs_util_fuzzer.cc b/test/fuzz/pairs_util_fuzzer.cc new file mode 100644 index 000000000..84e7ca0f1 --- /dev/null +++ b/test/fuzz/pairs_util_fuzzer.cc @@ -0,0 +1,47 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "include/proxy-wasm/pairs_util.h" + +#include +#include + +namespace proxy_wasm { +namespace { + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + auto input = std::string_view(reinterpret_cast(data), size); + + auto pairs = PairsUtil::toPairs(input); + + if (!pairs.empty()) { + // Verify that non-empty Pairs serializes back to the same bytes. + auto new_size = PairsUtil::pairsSize(pairs); + if (new_size != size) { + __builtin_trap(); + } + std::vector new_data(new_size); + if (!PairsUtil::marshalPairs(pairs, new_data.data(), new_data.size())) { + __builtin_trap(); + } + if (::memcmp(new_data.data(), data, size) != 0) { + __builtin_trap(); + } + } + + return 0; +} + +} // namespace +} // namespace proxy_wasm diff --git a/test/logging_test.cc b/test/logging_test.cc new file mode 100644 index 000000000..e4cbdcdca --- /dev/null +++ b/test/logging_test.cc @@ -0,0 +1,69 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "gtest/gtest.h" +#include "include/proxy-wasm/wasm.h" +#include "test/utility.h" + +namespace proxy_wasm { + +INSTANTIATE_TEST_SUITE_P(WasmEngines, TestVm, testing::ValuesIn(getWasmEngines()), + [](const testing::TestParamInfo &info) { + return info.param; + }); + +// TestVm is parameterized for each engine and creates a VM on construction. +TEST_P(TestVm, HttpLogging) { + // Read the wasm source. + auto source = readTestWasmFile("http_logging.wasm"); + ASSERT_FALSE(source.empty()); + + // Create a WasmBase and load the plugin. + auto wasm = std::make_shared(std::move(vm_)); + ASSERT_TRUE(wasm->load(source, /*allow_precompiled=*/false)); + ASSERT_TRUE(wasm->initialize()); + + // Create a plugin. + const auto plugin = std::make_shared( + /*name=*/"test", /*root_id=*/"", /*vm_id=*/"", + /*engine=*/wasm->wasm_vm()->getEngineName(), /*plugin_config=*/"", + /*fail_open=*/false, /*key=*/""); + + // Create root context, call onStart(). + ContextBase *root_context = wasm->start(plugin); + ASSERT_TRUE(root_context != nullptr); + + // On the root context, call onConfigure(). + ASSERT_TRUE(wasm->configure(root_context, plugin)); + + // Create a stream context. + { + auto wasm_handle = std::make_shared(wasm); + auto plugin_handle = std::make_shared(wasm_handle, plugin); + auto stream_context = TestContext(wasm.get(), root_context->id(), plugin_handle); + stream_context.onCreate(); + EXPECT_TRUE(stream_context.isLogged("onCreate called")); + stream_context.onRequestHeaders(/*headers=*/0, /*end_of_stream=*/false); + EXPECT_TRUE(stream_context.isLogged("onRequestHeaders called")); + stream_context.onResponseHeaders(/*headers=*/0, /*end_of_stream=*/false); + EXPECT_TRUE(stream_context.isLogged("onResponseHeaders called")); + stream_context.onDone(); + EXPECT_TRUE(stream_context.isLogged("onDone called")); + stream_context.onDelete(); + EXPECT_TRUE(stream_context.isLogged("onDelete called")); + } + EXPECT_FALSE(wasm->isFailed()); +} + +} // namespace proxy_wasm diff --git a/wasm_vm_test.cc b/test/null_vm_test.cc similarity index 85% rename from wasm_vm_test.cc rename to test/null_vm_test.cc index 26d45473d..5bb862f96 100644 --- a/wasm_vm_test.cc +++ b/test/null_vm_test.cc @@ -14,10 +14,11 @@ #include "include/proxy-wasm/wasm_vm.h" -#include "gtest/gtest.h" #include "include/proxy-wasm/null.h" #include "include/proxy-wasm/null_vm_plugin.h" +#include "gtest/gtest.h" + namespace proxy_wasm { class TestNullVmPlugin : public NullVmPlugin { @@ -58,19 +59,24 @@ TEST(WasmVm, Word) { class BaseVmTest : public testing::Test { public: - BaseVmTest() {} + BaseVmTest() = default; }; TEST_F(BaseVmTest, NullVmStartup) { auto wasm_vm = createNullVm(); EXPECT_TRUE(wasm_vm != nullptr); - EXPECT_TRUE(wasm_vm->runtime() == "null"); + EXPECT_TRUE(wasm_vm->getEngineName() == "null"); EXPECT_TRUE(wasm_vm->cloneable() == Cloneable::InstantiatedModule); auto wasm_vm_clone = wasm_vm->clone(); EXPECT_TRUE(wasm_vm_clone != nullptr); - EXPECT_TRUE(wasm_vm->getCustomSection("user").empty()); - EXPECT_TRUE(wasm_vm->load("test_null_vm_plugin", true)); + EXPECT_TRUE(wasm_vm->load("test_null_vm_plugin", {}, {})); EXPECT_NE(test_null_vm_plugin, nullptr); } +TEST_F(BaseVmTest, ByteOrder) { + auto wasm_vm = createNullVm(); + EXPECT_TRUE(wasm_vm->load("test_null_vm_plugin", {}, {})); + EXPECT_FALSE(wasm_vm->usesWasmByteOrder()); +} + } // namespace proxy_wasm diff --git a/test/pairs_util_test.cc b/test/pairs_util_test.cc new file mode 100644 index 000000000..3f9fcd965 --- /dev/null +++ b/test/pairs_util_test.cc @@ -0,0 +1,33 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "include/proxy-wasm/pairs_util.h" +#include "gtest/gtest.h" + +namespace proxy_wasm { + +TEST(PairsUtilTest, EncodeDecode) { + proxy_wasm::Pairs pairs1; + std::string data1("some_data"); + auto size_str = std::to_string(data1.size()); + pairs1.push_back({data1, size_str}); + std::vector buffer(PairsUtil::pairsSize(pairs1)); + EXPECT_TRUE(PairsUtil::marshalPairs(pairs1, buffer.data(), buffer.size())); + auto pairs2 = PairsUtil::toPairs(std::string_view(buffer.data(), buffer.size())); + EXPECT_EQ(pairs2.size(), pairs1.size()); + EXPECT_EQ(pairs2[0].first, pairs1[0].first); + EXPECT_EQ(pairs2[0].second, pairs1[0].second); +} + +} // namespace proxy_wasm diff --git a/test/runtime_test.cc b/test/runtime_test.cc new file mode 100644 index 000000000..2e9080978 --- /dev/null +++ b/test/runtime_test.cc @@ -0,0 +1,248 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "gtest/gtest.h" + +#include +#include +#include + +#include "include/proxy-wasm/context.h" +#include "include/proxy-wasm/limits.h" +#include "include/proxy-wasm/wasm.h" + +#include "test/utility.h" + +namespace proxy_wasm { +namespace { + +INSTANTIATE_TEST_SUITE_P(WasmEngines, TestVm, testing::ValuesIn(getWasmEngines()), + [](const testing::TestParamInfo &info) { + return info.param; + }); + +TEST_P(TestVm, BadSignature) { + auto source = readTestWasmFile("clock.wasm"); + ASSERT_FALSE(source.empty()); + auto wasm = TestWasm(std::move(vm_)); + ASSERT_TRUE(wasm.load(source, false)); + ASSERT_TRUE(wasm.initialize()); + + WasmCallVoid<0> non_existent; + wasm.wasm_vm()->getFunction("non_existent", &non_existent); + EXPECT_TRUE(non_existent == nullptr); + + WasmCallWord<2> bad_signature_run; + wasm.wasm_vm()->getFunction("run", &bad_signature_run); + EXPECT_TRUE(bad_signature_run == nullptr); + + WasmCallVoid<0> run; + wasm.wasm_vm()->getFunction("run", &run); + ASSERT_TRUE(run != nullptr); +} + +TEST_P(TestVm, StraceLogLevel) { + auto source = readTestWasmFile("clock.wasm"); + ASSERT_FALSE(source.empty()); + auto wasm = TestWasm(std::move(vm_)); + ASSERT_TRUE(wasm.load(source, false)); + ASSERT_TRUE(wasm.initialize()); + + WasmCallVoid<0> run; + wasm.wasm_vm()->getFunction("run", &run); + ASSERT_TRUE(run != nullptr); + + auto *host = dynamic_cast(wasm.wasm_vm()->integration().get()); + host->setLogLevel(LogLevel::info); + run(wasm.vm_context()); + EXPECT_TRUE(host->isTraceLogEmpty()); + + host->setLogLevel(LogLevel::trace); + run(wasm.vm_context()); + EXPECT_TRUE(host->isTraceLogged("[host->vm] run()")); + EXPECT_TRUE(host->isTraceLogged("[vm->host] wasi_snapshot_preview1.clock_time_get(1, 1, ")); + EXPECT_TRUE(host->isTraceLogged("[vm<-host] wasi_snapshot_preview1.clock_time_get return: 0")); + EXPECT_TRUE(host->isTraceLogged("[host<-vm] run return: void")); +} + +TEST_P(TestVm, TerminateExecution) { + // TODO(chaoqin-li1123): implement execution termination for other runtime. + if (engine_ != "v8") { + return; + } + auto source = readTestWasmFile("resource_limits.wasm"); + ASSERT_FALSE(source.empty()); + auto wasm = TestWasm(std::move(vm_)); + ASSERT_TRUE(wasm.load(source, false)); + ASSERT_TRUE(wasm.initialize()); + + std::thread terminate([&]() { + std::this_thread::sleep_for(std::chrono::seconds(1)); + wasm.wasm_vm()->terminate(); + }); + + WasmCallVoid<0> infinite_loop; + wasm.wasm_vm()->getFunction("infinite_loop", &infinite_loop); + ASSERT_TRUE(infinite_loop != nullptr); + infinite_loop(wasm.vm_context()); + + terminate.join(); + + // Check integration logs. + auto *host = dynamic_cast(wasm.wasm_vm()->integration().get()); + EXPECT_TRUE(host->isErrorLogged("Function: infinite_loop failed")); + EXPECT_TRUE(host->isErrorLogged("TerminationException")); +} + +TEST_P(TestVm, WasmMemoryLimit) { + // TODO(PiotrSikora): enforce memory limits in other engines. + if (engine_ != "v8") { + return; + } + auto source = readTestWasmFile("resource_limits.wasm"); + ASSERT_FALSE(source.empty()); + auto wasm = TestWasm(std::move(vm_)); + ASSERT_TRUE(wasm.load(source, false)); + ASSERT_TRUE(wasm.initialize()); + + WasmCallVoid<0> infinite_memory; + wasm.wasm_vm()->getFunction("infinite_memory", &infinite_memory); + ASSERT_TRUE(infinite_memory != nullptr); + infinite_memory(wasm.vm_context()); + + EXPECT_GE(wasm.wasm_vm()->getMemorySize(), PROXY_WASM_HOST_MAX_WASM_MEMORY_SIZE_BYTES * 0.95); + EXPECT_LE(wasm.wasm_vm()->getMemorySize(), PROXY_WASM_HOST_MAX_WASM_MEMORY_SIZE_BYTES); + + // Check integration logs. + auto *host = dynamic_cast(wasm.wasm_vm()->integration().get()); + EXPECT_TRUE(host->isErrorLogged("Function: infinite_memory failed")); + // Trap message + EXPECT_TRUE(host->isErrorLogged("unreachable")); + // Backtrace + if (engine_ == "v8") { + EXPECT_TRUE(host->isErrorLogged("Proxy-Wasm plugin in-VM backtrace:")); + EXPECT_TRUE(host->isErrorLogged("rg_oom")); + EXPECT_TRUE(host->isErrorLogged(" - alloc::alloc::handle_alloc_error")); + } +} + +TEST_P(TestVm, Trap) { + auto source = readTestWasmFile("trap.wasm"); + ASSERT_FALSE(source.empty()); + auto wasm = TestWasm(std::move(vm_)); + ASSERT_TRUE(wasm.load(source, false)); + ASSERT_TRUE(wasm.initialize()); + + WasmCallVoid<0> trigger; + wasm.wasm_vm()->getFunction("trigger", &trigger); + ASSERT_TRUE(trigger != nullptr); + trigger(wasm.vm_context()); + + // Check integration logs. + auto *host = dynamic_cast(wasm.wasm_vm()->integration().get()); + EXPECT_TRUE(host->isErrorLogged("Function: trigger failed")); + // Trap message + EXPECT_TRUE(host->isErrorLogged("unreachable")); + // Backtrace + if (engine_ == "v8") { + EXPECT_TRUE(host->isErrorLogged("Proxy-Wasm plugin in-VM backtrace:")); + EXPECT_TRUE(host->isErrorLogged(" - std::panicking::begin_panic")); + EXPECT_TRUE(host->isErrorLogged(" - trigger")); + } +} + +TEST_P(TestVm, Trap2) { + auto source = readTestWasmFile("trap.wasm"); + ASSERT_FALSE(source.empty()); + auto wasm = TestWasm(std::move(vm_)); + ASSERT_TRUE(wasm.load(source, false)); + ASSERT_TRUE(wasm.initialize()); + + WasmCallWord<1> trigger2; + wasm.wasm_vm()->getFunction("trigger2", &trigger2); + ASSERT_TRUE(trigger2 != nullptr); + trigger2(wasm.vm_context(), 0); + + // Check integration logs. + auto *host = dynamic_cast(wasm.wasm_vm()->integration().get()); + EXPECT_TRUE(host->isErrorLogged("Function: trigger2 failed")); + // Trap message + EXPECT_TRUE(host->isErrorLogged("unreachable")); + // Backtrace + if (engine_ == "v8") { + EXPECT_TRUE(host->isErrorLogged("Proxy-Wasm plugin in-VM backtrace:")); + EXPECT_TRUE(host->isErrorLogged(" - std::panicking::begin_panic")); + EXPECT_TRUE(host->isErrorLogged(" - trigger2")); + } +} + +class TestCounterContext : public TestContext { +public: + TestCounterContext(WasmBase *wasm) : TestContext(wasm) {} + + void increment() { counter++; } + size_t getCount() { return counter; } + +private: + size_t counter = 0; +}; + +class TestCounterWasm : public TestWasm { +public: + TestCounterWasm(std::unique_ptr wasm_vm) : TestWasm(std::move(wasm_vm)) {} + + ContextBase *createVmContext() override { return new TestCounterContext(this); }; +}; + +void callback() { + auto *context = dynamic_cast(contextOrEffectiveContext()); + context->increment(); +} + +Word callback2(Word val) { return val + 100; } + +TEST_P(TestVm, Callback) { + auto source = readTestWasmFile("callback.wasm"); + ASSERT_FALSE(source.empty()); + auto wasm = TestCounterWasm(std::move(vm_)); + ASSERT_TRUE(wasm.load(source, false)); + + wasm.wasm_vm()->registerCallback( + "env", "callback", &callback, + &ConvertFunctionWordToUint32::convertFunctionWordToUint32); + + wasm.wasm_vm()->registerCallback( + "env", "callback2", &callback2, + &ConvertFunctionWordToUint32::convertFunctionWordToUint32); + + ASSERT_TRUE(wasm.initialize()); + + WasmCallVoid<0> run; + wasm.wasm_vm()->getFunction("run", &run); + ASSERT_TRUE(run != nullptr); + for (auto i = 0; i < 5; i++) { + run(wasm.vm_context()); + } + auto *context = dynamic_cast(wasm.vm_context()); + EXPECT_EQ(context->getCount(), 5); + + WasmCallWord<1> run2; + wasm.wasm_vm()->getFunction("run2", &run2); + ASSERT_TRUE(run2 != nullptr); + Word res = run2(wasm.vm_context(), Word{0}); + EXPECT_EQ(res.u32(), 100100); // 10000 (global) + 100 (in callback) +} + +} // namespace +} // namespace proxy_wasm diff --git a/test/security_test.cc b/test/security_test.cc new file mode 100644 index 000000000..a077e4ae6 --- /dev/null +++ b/test/security_test.cc @@ -0,0 +1,106 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "gtest/gtest.h" + +#include +#include + +#include "include/proxy-wasm/context.h" +#include "include/proxy-wasm/wasm.h" + +#include "test/utility.h" + +namespace proxy_wasm { + +INSTANTIATE_TEST_SUITE_P(WasmEngines, TestVm, testing::ValuesIn(getWasmEngines()), + [](const testing::TestParamInfo &info) { + return info.param; + }); + +TEST_P(TestVm, MallocNoHostcalls) { + if (engine_ != "v8") { + return; + } + auto source = readTestWasmFile("bad_malloc.wasm"); + ASSERT_FALSE(source.empty()); + auto wasm = TestWasm(std::move(vm_)); + ASSERT_TRUE(wasm.load(source, false)); + ASSERT_TRUE(wasm.initialize()); + + uint64_t ptr = 0; + void *result = wasm.allocMemory(0x1000, &ptr); + EXPECT_NE(result, nullptr); + EXPECT_FALSE(wasm.isFailed()); + + // Check application logs. + auto *context = dynamic_cast(wasm.vm_context()); + EXPECT_TRUE(context->isLogEmpty()); + // Check integration logs. + auto *integration = dynamic_cast(wasm.wasm_vm()->integration().get()); + EXPECT_FALSE(integration->isErrorLogged("Function: proxy_on_memory_allocate failed")); + EXPECT_FALSE(integration->isErrorLogged("restricted_callback")); +} + +TEST_P(TestVm, MallocWithLog) { + if (engine_ != "v8") { + return; + } + auto source = readTestWasmFile("bad_malloc.wasm"); + ASSERT_FALSE(source.empty()); + auto wasm = TestWasm(std::move(vm_)); + ASSERT_TRUE(wasm.load(source, false)); + ASSERT_TRUE(wasm.initialize()); + + uint64_t ptr = 0; + // 0xAAAA => hostcall to proxy_log (allowed). + void *result = wasm.allocMemory(0xAAAA, &ptr); + EXPECT_NE(result, nullptr); + EXPECT_FALSE(wasm.isFailed()); + + // Check application logs. + auto *context = dynamic_cast(wasm.vm_context()); + EXPECT_TRUE(context->isLogged("this is fine")); + // Check integration logs. + auto *integration = dynamic_cast(wasm.wasm_vm()->integration().get()); + EXPECT_FALSE(integration->isErrorLogged("Function: proxy_on_memory_allocate failed")); + EXPECT_FALSE(integration->isErrorLogged("restricted_callback")); +} + +TEST_P(TestVm, MallocWithHostcall) { + if (engine_ != "v8") { + return; + } + auto source = readTestWasmFile("bad_malloc.wasm"); + ASSERT_FALSE(source.empty()); + auto wasm = TestWasm(std::move(vm_)); + ASSERT_TRUE(wasm.load(source, false)); + ASSERT_TRUE(wasm.initialize()); + + uint64_t ptr = 0; + // 0xBBBB => hostcall to proxy_done (not allowed). + void *result = wasm.allocMemory(0xBBBB, &ptr); + EXPECT_EQ(result, nullptr); + EXPECT_TRUE(wasm.isFailed()); + + // Check application logs. + auto *context = dynamic_cast(wasm.vm_context()); + EXPECT_TRUE(context->isLogEmpty()); + // Check integration logs. + auto *integration = dynamic_cast(wasm.wasm_vm()->integration().get()); + EXPECT_TRUE(integration->isErrorLogged("Function: proxy_on_memory_allocate failed")); + EXPECT_TRUE(integration->isErrorLogged("restricted_callback")); +} + +} // namespace proxy_wasm diff --git a/test/shared_data_test.cc b/test/shared_data_test.cc new file mode 100644 index 000000000..89a964c33 --- /dev/null +++ b/test/shared_data_test.cc @@ -0,0 +1,148 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "src/shared_data.h" + +#include + +#include "gtest/gtest.h" + +#include "include/proxy-wasm/vm_id_handle.h" + +namespace proxy_wasm { + +TEST(SharedData, SingleThread) { + SharedData shared_data(false); + std::string_view vm_id = "id"; + + // Validate we get an 'Ok' response when fetching keys before anything + // is initialized. + std::vector keys; + EXPECT_EQ(WasmResult::Ok, shared_data.keys(vm_id, &keys)); + EXPECT_EQ(0, keys.size()); + + // Validate that we clear the result set + std::vector nonEmptyKeys(2); + nonEmptyKeys[0] = "valueA"; + nonEmptyKeys[1] = "valueB"; + EXPECT_EQ(WasmResult::Ok, shared_data.keys(vm_id, &nonEmptyKeys)); + EXPECT_EQ(0, nonEmptyKeys.size()); + + std::pair result; + EXPECT_EQ(WasmResult::NotFound, shared_data.get("non-exist", "non-exists", &result)); + + std::string_view key = "key"; + std::string_view value = "1"; + EXPECT_EQ(WasmResult::Ok, shared_data.set(vm_id, key, value, 0)); + // ok for cas == 0 + EXPECT_EQ(WasmResult::Ok, shared_data.set(vm_id, key, value, 0)); + EXPECT_EQ(WasmResult::CasMismatch, shared_data.set(vm_id, key, value, 100)); + + EXPECT_EQ(WasmResult::Ok, shared_data.get(vm_id, key, &result)); + EXPECT_EQ(value, result.first); + value = "2"; + EXPECT_EQ(result.second, 2); + + EXPECT_EQ(WasmResult::Ok, shared_data.set(vm_id, key, value, result.second)); + EXPECT_EQ(WasmResult::Ok, shared_data.get(vm_id, key, &result)); + EXPECT_EQ(value, result.first); + EXPECT_EQ(result.second, 3); + + EXPECT_EQ(WasmResult::Ok, shared_data.keys(vm_id, &keys)); + EXPECT_EQ(1, keys.size()); + EXPECT_EQ(key, keys[0]); + + keys.clear(); + EXPECT_EQ(WasmResult::CasMismatch, shared_data.remove(vm_id, key, 911, nullptr)); + EXPECT_EQ(WasmResult::Ok, shared_data.keys(vm_id, &keys)); + EXPECT_EQ(1, keys.size()); + + EXPECT_EQ(WasmResult::Ok, shared_data.remove(vm_id, key, 0, nullptr)); + EXPECT_EQ(WasmResult::NotFound, shared_data.get(vm_id, key, &result)); + + EXPECT_EQ(WasmResult::NotFound, shared_data.remove(vm_id, "non-existent_key", 0, nullptr)); + + EXPECT_EQ(WasmResult::Ok, shared_data.set(vm_id, key, value, 0)); + EXPECT_EQ(WasmResult::Ok, shared_data.set(vm_id, key, value, 0)); + EXPECT_EQ(WasmResult::Ok, shared_data.get(vm_id, key, &result)); + + uint32_t expectedCasValue = result.second; + + std::pair removeResult; + EXPECT_EQ(WasmResult::Ok, shared_data.remove(vm_id, key, 0, &removeResult)); + EXPECT_EQ(value, removeResult.first); + EXPECT_EQ(removeResult.second, expectedCasValue); +} + +void incrementData(SharedData *shared_data, std::string_view vm_id, std::string_view key) { + std::pair result; + for (auto i = 0; i < 10; i++) { + while (true) { + if (WasmResult::Ok != shared_data->get(vm_id, key, &result)) { + continue; + } + if (WasmResult::Ok != shared_data->set(vm_id, key, result.first + "a", result.second)) { + continue; + }; + break; + } + } +} + +TEST(SharedData, Concurrent) { + SharedData shared_data(false); + std::pair result; + + std::string_view vm_id = "id"; + std::string_view key = "key"; + std::string_view value; + EXPECT_EQ(WasmResult::Ok, shared_data.set(vm_id, key, value, 0)); + std::thread first(incrementData, &shared_data, vm_id, key); + std::thread second(incrementData, &shared_data, vm_id, key); + first.join(); + second.join(); + + EXPECT_EQ(WasmResult::Ok, shared_data.get(vm_id, key, &result)); + EXPECT_EQ(result.first, "aaaaaaaaaaaaaaaaaaaa"); +} + +TEST(SharedData, DeleteByVmId) { + SharedData shared_data(false); + std::string_view vm_id = "id"; + std::string_view key = "key"; + std::string_view value; + EXPECT_EQ(WasmResult::Ok, shared_data.set(vm_id, key, value, 0)); + + shared_data.deleteByVmId(vm_id); + std::pair result; + EXPECT_EQ(WasmResult::NotFound, shared_data.get(vm_id, key, &result)); +} + +TEST(SharedData, VmIdHandleCleanup) { + SharedData shared_data; + std::string_view vm_id = "proxy_wasm_shared_data_test"; + auto handle = getVmIdHandle(vm_id); + std::string_view key = "key"; + std::string_view value = "this is value"; + EXPECT_EQ(WasmResult::Ok, shared_data.set(vm_id, key, value, 0)); + + std::pair result; + EXPECT_EQ(WasmResult::Ok, shared_data.get(vm_id, key, &result)); + EXPECT_EQ(value, result.first); + + handle.reset(); + EXPECT_EQ(WasmResult::NotFound, shared_data.get(vm_id, key, &result)); +} + +} // namespace proxy_wasm diff --git a/test/shared_queue_test.cc b/test/shared_queue_test.cc new file mode 100644 index 000000000..6d08316a4 --- /dev/null +++ b/test/shared_queue_test.cc @@ -0,0 +1,160 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "src/shared_queue.h" + +#include + +#include "gtest/gtest.h" + +#include "include/proxy-wasm/vm_id_handle.h" + +namespace proxy_wasm { + +TEST(SharedQueue, NextQueueToken) { + SharedQueue shared_queue(false); + for (auto i = 1; i < 5; i++) { + EXPECT_EQ(i, shared_queue.nextQueueToken()); + } + EXPECT_EQ(5, shared_queue.registerQueue("a", "b", 1, nullptr, "c")); +} + +TEST(SharedQueue, SingleThread) { + SharedQueue shared_queue(false); + std::string_view vm_id = "id"; + std::string_view vm_key = "vm_key"; + std::string_view queue_name = "name"; + uint32_t context_id = 1; + + for (auto i = 0; i < 3; i++) { + // same token + EXPECT_EQ(1, shared_queue.registerQueue(vm_id, queue_name, context_id, nullptr, vm_key)); + } + EXPECT_EQ(1, shared_queue.resolveQueue(vm_id, queue_name)); + EXPECT_EQ(0, shared_queue.resolveQueue(vm_id, "non-exist")); + EXPECT_EQ(0, shared_queue.resolveQueue("non-exist", queue_name)); + + bool called = false; + std::function)> call_on_thread = + [&called](const std::function &f) { + called = true; + f(); // TODO(mathetake): test whether onQueueReady is called with mock WasmHandle + }; + queue_name = "name2"; + auto token = shared_queue.registerQueue(vm_id, queue_name, context_id, call_on_thread, vm_key); + EXPECT_EQ(2, token); + + std::string data; + EXPECT_EQ(WasmResult::NotFound, shared_queue.dequeue(0, &data)); + EXPECT_EQ(WasmResult::Empty, shared_queue.dequeue(token, &data)); + + std::string value = "value"; + EXPECT_EQ(WasmResult::NotFound, shared_queue.enqueue(0, value)); + EXPECT_EQ(WasmResult::Ok, shared_queue.enqueue(token, value)); + EXPECT_TRUE(called); + + EXPECT_EQ(WasmResult::Ok, shared_queue.dequeue(token, &data)); + EXPECT_EQ(data, "value"); +} + +void enqueueData(SharedQueue *shared_queue, uint32_t token, size_t num) { + for (size_t i = 0; i < num; i++) { + shared_queue->enqueue(token, "a"); + } +} + +void dequeueData(SharedQueue *shared_queue, uint32_t token, size_t *dequeued_count) { + std::string data; + while (WasmResult::Ok == shared_queue->dequeue(token, &data)) { + (*dequeued_count)++; + } +} + +TEST(SharedQueue, Concurrent) { + SharedQueue shared_queue(false); + std::string_view vm_id = "id"; + std::string_view vm_key = "vm_key"; + std::string_view queue_name = "name"; + uint32_t context_id = 1; + + auto queued_count = 0; + std::mutex mutex; + std::function)> call_on_thread = + [&mutex, &queued_count](const std::function &f) { + std::lock_guard lock(mutex); + queued_count++; + f(); // TODO(mathetake): test whether onQueueReady is called with mock WasmHandle + }; + auto token = shared_queue.registerQueue(vm_id, queue_name, context_id, call_on_thread, vm_key); + EXPECT_EQ(1, token); + + std::thread enqueue_first(enqueueData, &shared_queue, token, 100); + std::thread enqueue_second(enqueueData, &shared_queue, token, 100); + enqueue_first.join(); + enqueue_second.join(); + EXPECT_EQ(queued_count, 200); + + size_t first_cnt = 0; + size_t second_cnt = 0; + std::thread dequeue_first(dequeueData, &shared_queue, token, &first_cnt); + std::thread dequeue_second(dequeueData, &shared_queue, token, &second_cnt); + dequeue_first.join(); + dequeue_second.join(); + EXPECT_EQ(first_cnt + second_cnt, 200); +} + +TEST(SharedQueue, DeleteByVmId) { + SharedQueue shared_queue(false); + const auto *vm_id_1 = "id_1"; + const auto *vm_id_2 = "id_2"; + std::string_view vm_key = "vm_key"; + uint32_t context_id = 1; + auto queue_num_per_vm = 3; + + for (auto i = 1; i < queue_num_per_vm; i++) { + EXPECT_EQ(i, + shared_queue.registerQueue(vm_id_1, std::to_string(i), context_id, nullptr, vm_key)); + EXPECT_EQ(i, shared_queue.resolveQueue(vm_id_1, std::to_string(i))); + } + + for (auto i = queue_num_per_vm; i < 2 * queue_num_per_vm; i++) { + EXPECT_EQ(i, + shared_queue.registerQueue(vm_id_2, std::to_string(i), context_id, nullptr, vm_key)); + EXPECT_EQ(i, shared_queue.resolveQueue(vm_id_2, std::to_string(i))); + } + + shared_queue.deleteByVmId(vm_id_1); + for (auto i = 1; i < queue_num_per_vm; i++) { + EXPECT_EQ(0, shared_queue.resolveQueue(vm_id_1, std::to_string(i))); + } + + for (auto i = queue_num_per_vm; i < 2 * queue_num_per_vm; i++) { + EXPECT_EQ(i, shared_queue.resolveQueue(vm_id_2, std::to_string(i))); + } +} + +TEST(SharedQueue, VmIdHandleCleanup) { + SharedQueue shared_queue; + std::string_view vm_id = "proxy_wasm_shared_queue_test"; + std::string_view queue_name = "name"; + + auto handle = getVmIdHandle(vm_id); + EXPECT_EQ(1, shared_queue.registerQueue(vm_id, queue_name, 1, nullptr, "vm_key")); + EXPECT_EQ(1, shared_queue.resolveQueue(vm_id, queue_name)); + + handle.reset(); + EXPECT_EQ(0, shared_queue.resolveQueue(vm_id, queue_name)); +} + +} // namespace proxy_wasm diff --git a/test/signature_util_test.cc b/test/signature_util_test.cc new file mode 100644 index 000000000..f4b2ae24e --- /dev/null +++ b/test/signature_util_test.cc @@ -0,0 +1,60 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "include/proxy-wasm/signature_util.h" + +#include +#include +#include + +#include "test/utility.h" + +#include "gtest/gtest.h" + +namespace proxy_wasm { + +TEST(TestSignatureUtil, GoodSignature) { +#ifndef PROXY_WASM_VERIFY_WITH_ED25519_PUBKEY + FAIL() << "Built without a key for verifying signed Wasm modules."; +#endif + + const auto bytecode = readTestWasmFile("abi_export.signed.with.key1.wasm"); + std::string message; + EXPECT_TRUE(SignatureUtil::verifySignature(bytecode, message)); + EXPECT_EQ(message, "Wasm signature OK (Ed25519)"); +} + +TEST(TestSignatureUtil, BadSignature) { +#ifndef PROXY_WASM_VERIFY_WITH_ED25519_PUBKEY + FAIL() << "Built without a key for verifying signed Wasm modules."; +#endif + + const auto bytecode = readTestWasmFile("abi_export.signed.with.key2.wasm"); + std::string message; + EXPECT_FALSE(SignatureUtil::verifySignature(bytecode, message)); + EXPECT_EQ(message, "Signature mismatch"); +} + +TEST(TestSignatureUtil, NoSignature) { +#ifndef PROXY_WASM_VERIFY_WITH_ED25519_PUBKEY + FAIL() << "Built without a key for verifying signed Wasm modules."; +#endif + + const auto bytecode = readTestWasmFile("abi_export.wasm"); + std::string message; + EXPECT_FALSE(SignatureUtil::verifySignature(bytecode, message)); + EXPECT_EQ(message, "Custom Section \"signature_wasmsign\" not found"); +} + +} // namespace proxy_wasm diff --git a/test/stop_iteration_test.cc b/test/stop_iteration_test.cc new file mode 100644 index 000000000..9ff443f24 --- /dev/null +++ b/test/stop_iteration_test.cc @@ -0,0 +1,81 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "gtest/gtest.h" +#include "include/proxy-wasm/wasm.h" +#include "test/utility.h" + +namespace proxy_wasm { + +INSTANTIATE_TEST_SUITE_P(WasmEngines, TestVm, testing::ValuesIn(getWasmEngines()), + [](const testing::TestParamInfo &info) { + return info.param; + }); + +// TestVm is parameterized for each engine and creates a VM on construction. +TEST_P(TestVm, AllowOnHeadersStopIteration) { + // Read the wasm source. + auto source = readTestWasmFile("stop_iteration.wasm"); + ASSERT_FALSE(source.empty()); + + // Create a WasmBase and load the plugin. + auto wasm = std::make_shared(std::move(vm_)); + ASSERT_TRUE(wasm->load(source, /*allow_precompiled=*/false)); + ASSERT_TRUE(wasm->initialize()); + + // Create a plugin. + const auto plugin = std::make_shared( + /*name=*/"test", /*root_id=*/"", /*vm_id=*/"", + /*engine=*/wasm->wasm_vm()->getEngineName(), /*plugin_config=*/"", + /*fail_open=*/false, /*key=*/""); + + // Create root context, call onStart() and onConfigure() + ContextBase *root_context = wasm->start(plugin); + ASSERT_TRUE(root_context != nullptr); + ASSERT_TRUE(wasm->configure(root_context, plugin)); + + auto wasm_handle = std::make_shared(wasm); + auto plugin_handle = std::make_shared(wasm_handle, plugin); + + // By default, stream context onRequestHeaders and onResponseHeaders + // translates FilterHeadersStatus::StopIteration to + // FilterHeadersStatus::StopAllIterationAndWatermark. + { + auto stream_context = TestContext(wasm.get(), root_context->id(), plugin_handle); + stream_context.onCreate(); + EXPECT_EQ(stream_context.onRequestHeaders(/*headers=*/0, /*end_of_stream=*/false), + FilterHeadersStatus::StopAllIterationAndWatermark); + EXPECT_EQ(stream_context.onResponseHeaders(/*headers=*/0, /*end_of_stream=*/false), + FilterHeadersStatus::StopAllIterationAndWatermark); + stream_context.onDone(); + stream_context.onDelete(); + } + ASSERT_FALSE(wasm->isFailed()); + + // Create a stream context that propagates FilterHeadersStatus::StopIteration. + { + auto stream_context = TestContext(wasm.get(), root_context->id(), plugin_handle); + stream_context.set_allow_on_headers_stop_iteration(true); + stream_context.onCreate(); + EXPECT_EQ(stream_context.onRequestHeaders(/*headers=*/0, /*end_of_stream=*/false), + FilterHeadersStatus::StopIteration); + EXPECT_EQ(stream_context.onResponseHeaders(/*headers=*/0, /*end_of_stream=*/false), + FilterHeadersStatus::StopIteration); + stream_context.onDone(); + stream_context.onDelete(); + } + ASSERT_FALSE(wasm->isFailed()); +} + +} // namespace proxy_wasm diff --git a/test/test_data/BUILD b/test/test_data/BUILD new file mode 100644 index 000000000..e5ecd439e --- /dev/null +++ b/test/test_data/BUILD @@ -0,0 +1,96 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +load("@proxy_wasm_cpp_host//bazel:wasm.bzl", "wasm_rust_binary") +load("@proxy_wasm_cpp_sdk//bazel:defs.bzl", "proxy_wasm_cc_binary") + +licenses(["notice"]) # Apache 2 + +package(default_visibility = ["//visibility:public"]) + +wasm_rust_binary( + name = "abi_export.wasm", + srcs = ["abi_export.rs"], +) + +wasm_rust_binary( + name = "abi_export.signed.with.key1.wasm", + srcs = ["abi_export.rs"], + signing_key = [ + "signature_key1.key", + "signature_key1.pub", + ], +) + +wasm_rust_binary( + name = "abi_export.signed.with.key2.wasm", + srcs = ["abi_export.rs"], + signing_key = [ + "signature_key2.key", + "signature_key2.pub", + ], +) + +wasm_rust_binary( + name = "bad_malloc.wasm", + srcs = ["bad_malloc.rs"], +) + +wasm_rust_binary( + name = "callback.wasm", + srcs = ["callback.rs"], +) + +wasm_rust_binary( + name = "trap.wasm", + srcs = ["trap.rs"], +) + +wasm_rust_binary( + name = "resource_limits.wasm", + srcs = ["resource_limits.rs"], +) + +wasm_rust_binary( + name = "env.wasm", + srcs = ["env.rs"], + wasi = True, +) + +wasm_rust_binary( + name = "clock.wasm", + srcs = ["clock.rs"], + wasi = True, +) + +wasm_rust_binary( + name = "random.wasm", + srcs = ["random.rs"], + wasi = True, +) + +proxy_wasm_cc_binary( + name = "canary_check.wasm", + srcs = ["canary_check.cc"], +) + +proxy_wasm_cc_binary( + name = "http_logging.wasm", + srcs = ["http_logging.cc"], +) + +proxy_wasm_cc_binary( + name = "stop_iteration.wasm", + srcs = ["stop_iteration.cc"], +) diff --git a/test/test_data/abi_export.rs b/test/test_data/abi_export.rs new file mode 100644 index 000000000..64e47de65 --- /dev/null +++ b/test/test_data/abi_export.rs @@ -0,0 +1,34 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#[no_mangle] +pub extern "C" fn proxy_abi_version_0_2_0() {} + +#[no_mangle] +pub extern "C" fn proxy_on_vm_start(_: u32, _: usize) -> bool { + true +} + +#[no_mangle] +pub extern "C" fn proxy_on_context_create(_: u32, _: u32) {} + +#[no_mangle] +pub extern "C" fn proxy_on_memory_allocate(size: usize) -> *mut u8 { + let mut vec: Vec = Vec::with_capacity(size); + unsafe { + vec.set_len(size); + } + let slice = vec.into_boxed_slice(); + Box::into_raw(slice) as *mut u8 +} diff --git a/test/test_data/bad_malloc.rs b/test/test_data/bad_malloc.rs new file mode 100644 index 000000000..43c60da02 --- /dev/null +++ b/test/test_data/bad_malloc.rs @@ -0,0 +1,47 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use std::mem::MaybeUninit; + +extern "C" { + fn proxy_log(level: u32, message_data: *const u8, message_size: usize) -> u32; + fn proxy_done() -> u32; +} + +#[no_mangle] +pub extern "C" fn proxy_abi_version_0_2_0() {} + +#[no_mangle] +pub extern "C" fn proxy_on_memory_allocate(size: usize) -> *mut u8 { + let mut vec: Vec> = Vec::with_capacity(size); + unsafe { + vec.set_len(size); + } + match size { + 0xAAAA => { + let message = "this is fine"; + unsafe { + proxy_log(0, message.as_ptr(), message.len()); + } + } + 0xBBBB => { + unsafe { + proxy_done(); + } + } + _ => {} + } + let slice = vec.into_boxed_slice(); + Box::into_raw(slice) as *mut u8 +} diff --git a/test/test_data/callback.rs b/test/test_data/callback.rs new file mode 100644 index 000000000..cab0141c4 --- /dev/null +++ b/test/test_data/callback.rs @@ -0,0 +1,42 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#[no_mangle] +pub extern "C" fn proxy_abi_version_0_2_0() {} + +#[no_mangle] +pub extern "C" fn proxy_on_memory_allocate(_: usize) -> *mut u8 { + std::ptr::null_mut() +} + +#[no_mangle] +pub extern "C" fn run() { + unsafe { + callback(); + } +} + +static A : i32 = 100000; + +#[no_mangle] +pub extern "C" fn run2(val: i32) -> i32 { + unsafe { + callback2(val) + A + } +} + +extern "C" { + fn callback(); + fn callback2(val: i32) -> i32; +} diff --git a/test/test_data/canary_check.cc b/test/test_data/canary_check.cc new file mode 100644 index 000000000..38cf8b410 --- /dev/null +++ b/test/test_data/canary_check.cc @@ -0,0 +1,52 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include +#include + +#include "proxy_wasm_intrinsics.h" + +class CanaryCheckRootContext1 : public RootContext { +public: + explicit CanaryCheckRootContext1(uint32_t id, std::string_view root_id) + : RootContext(id, root_id) {} + bool onConfigure(size_t s) override { + LOG_TRACE("onConfigure: root_id_1"); + return s != 0; + } +}; + +class CanaryCheckContext : public Context { +public: + explicit CanaryCheckContext(uint32_t id, RootContext *root) : Context(id, root) {} +}; + +class CanaryCheckRootContext2 : public RootContext { +public: + explicit CanaryCheckRootContext2(uint32_t id, std::string_view root_id) + : RootContext(id, root_id) {} + bool onConfigure(size_t s) override { + LOG_TRACE("onConfigure: root_id_2"); + return s != 0; + } +}; + +static RegisterContextFactory register_CanaryCheckContext1(CONTEXT_FACTORY(CanaryCheckContext), + ROOT_FACTORY(CanaryCheckRootContext1), + "root_id_1"); + +static RegisterContextFactory register_CanaryCheckContext2(CONTEXT_FACTORY(CanaryCheckContext), + ROOT_FACTORY(CanaryCheckRootContext2), + "root_id_2"); diff --git a/test/test_data/clock.rs b/test/test_data/clock.rs new file mode 100644 index 000000000..e2697a949 --- /dev/null +++ b/test/test_data/clock.rs @@ -0,0 +1,29 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use std::time::{Instant, SystemTime}; + +#[no_mangle] +pub extern "C" fn proxy_abi_version_0_2_0() {} + +#[no_mangle] +pub extern "C" fn proxy_on_memory_allocate(_: usize) -> *mut u8 { + std::ptr::null_mut() +} + +#[no_mangle] +pub extern "C" fn run() { + println!("monotonic: {:?}", Instant::now()); + println!("realtime: {:?}", SystemTime::now()); +} diff --git a/test/test_data/env.rs b/test/test_data/env.rs new file mode 100644 index 000000000..63d345ee1 --- /dev/null +++ b/test/test_data/env.rs @@ -0,0 +1,39 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +extern "C" { + fn __wasm_call_ctors(); +} + +#[no_mangle] +pub extern "C" fn _initialize() { + unsafe { + __wasm_call_ctors(); + } +} + +#[no_mangle] +pub extern "C" fn proxy_abi_version_0_2_0() {} + +#[no_mangle] +pub extern "C" fn proxy_on_memory_allocate(_: usize) -> *mut u8 { + std::ptr::null_mut() +} + +#[no_mangle] +pub extern "C" fn run() { + for (key, value) in std::env::vars() { + println!("{}: {}\n", key, value); + } +} diff --git a/test/test_data/http_logging.cc b/test/test_data/http_logging.cc new file mode 100644 index 000000000..e25b410c2 --- /dev/null +++ b/test/test_data/http_logging.cc @@ -0,0 +1,37 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "proxy_wasm_intrinsics.h" + +class LoggingContext : public Context { +public: + explicit LoggingContext(uint32_t id, RootContext *root) : Context(id, root) {} + + void onCreate() override { LOG_INFO("onCreate called"); } + void onDelete() override { LOG_INFO("onDelete called"); } + void onDone() override { LOG_INFO("onDone called"); } + + FilterHeadersStatus onRequestHeaders(uint32_t headers, bool end_of_stream) override { + LOG_INFO("onRequestHeaders called"); + return FilterHeadersStatus::Continue; + } + + FilterHeadersStatus onResponseHeaders(uint32_t headers, bool end_of_stream) override { + LOG_INFO("onResponseHeaders called"); + return FilterHeadersStatus::Continue; + } +}; + +static RegisterContextFactory register_StaticContext(CONTEXT_FACTORY(LoggingContext), + ROOT_FACTORY(RootContext)); diff --git a/test/test_data/random.rs b/test/test_data/random.rs new file mode 100644 index 000000000..271434bb7 --- /dev/null +++ b/test/test_data/random.rs @@ -0,0 +1,38 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#[no_mangle] +pub extern "C" fn proxy_abi_version_0_2_0() {} + +#[no_mangle] +pub extern "C" fn proxy_on_memory_allocate(_: usize) -> *mut u8 { + std::ptr::null_mut() +} + +// TODO(PiotrSikora): switch to "getrandom" crate. +pub mod wasi_snapshot_preview1 { + #[link(wasm_import_module = "wasi_snapshot_preview1")] + extern "C" { + pub fn random_get(buf: *mut u8, buf_len: usize) -> u16; + } +} + +#[no_mangle] +pub extern "C" fn run(size: usize) { + let mut buf: Vec = Vec::with_capacity(size); + match unsafe { wasi_snapshot_preview1::random_get(buf.as_mut_ptr(), size) } { + 0 => println!("random_get({}) succeeded.", size), + _ => println!("random_get({}) failed.", size), + } +} diff --git a/test/test_data/resource_limits.rs b/test/test_data/resource_limits.rs new file mode 100644 index 000000000..4b1d2789e --- /dev/null +++ b/test/test_data/resource_limits.rs @@ -0,0 +1,37 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#[no_mangle] +pub extern "C" fn proxy_abi_version_0_2_0() {} + +#[no_mangle] +pub extern "C" fn proxy_on_memory_allocate(_: usize) -> *mut u8 { + std::ptr::null_mut() +} + +#[no_mangle] +pub extern "C" fn infinite_loop() { + let mut _count: u64 = 0; + loop { + _count += 1; + } +} + +#[no_mangle] +pub extern "C" fn infinite_memory() { + let mut vec = Vec::new(); + loop { + vec.push(Vec::::with_capacity(16384)); + } +} diff --git a/test/test_data/signature_key1.key b/test/test_data/signature_key1.key new file mode 100644 index 000000000..c1a292b6a Binary files /dev/null and b/test/test_data/signature_key1.key differ diff --git a/test/test_data/signature_key1.pub b/test/test_data/signature_key1.pub new file mode 100644 index 000000000..034a0de34 Binary files /dev/null and b/test/test_data/signature_key1.pub differ diff --git a/test/test_data/signature_key2.key b/test/test_data/signature_key2.key new file mode 100644 index 000000000..8ba90fb90 Binary files /dev/null and b/test/test_data/signature_key2.key differ diff --git a/test/test_data/signature_key2.pub b/test/test_data/signature_key2.pub new file mode 100644 index 000000000..07b614ff3 Binary files /dev/null and b/test/test_data/signature_key2.pub differ diff --git a/test/test_data/stop_iteration.cc b/test/test_data/stop_iteration.cc new file mode 100644 index 000000000..55594285f --- /dev/null +++ b/test/test_data/stop_iteration.cc @@ -0,0 +1,31 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "proxy_wasm_intrinsics.h" + +class StopIterationContext : public Context { +public: + explicit StopIterationContext(uint32_t id, RootContext *root) : Context(id, root) {} + + FilterHeadersStatus onRequestHeaders(uint32_t headers, bool end_of_stream) override { + return FilterHeadersStatus::StopIteration; + } + + FilterHeadersStatus onResponseHeaders(uint32_t headers, bool end_of_stream) override { + return FilterHeadersStatus::StopIteration; + } +}; + +static RegisterContextFactory register_StaticContext(CONTEXT_FACTORY(StopIterationContext), + ROOT_FACTORY(RootContext)); diff --git a/test/test_data/trap.rs b/test/test_data/trap.rs new file mode 100644 index 000000000..467397206 --- /dev/null +++ b/test/test_data/trap.rs @@ -0,0 +1,44 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#[no_mangle] +pub extern "C" fn proxy_abi_version_0_2_0() {} + +#[no_mangle] +pub extern "C" fn proxy_on_memory_allocate(_: usize) -> *mut u8 { + std::ptr::null_mut() +} + +#[no_mangle] +pub extern "C" fn trigger() { + one(); +} + +#[no_mangle] +pub extern "C" fn trigger2(_val: i32) -> i32 { + three(); + 0 +} + +fn one() { + two(); +} + +fn two() { + three(); +} + +fn three(){ + panic!("trap!"); +} diff --git a/test/utility.cc b/test/utility.cc new file mode 100644 index 000000000..7bdf9d2ad --- /dev/null +++ b/test/utility.cc @@ -0,0 +1,48 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "test/utility.h" + +namespace proxy_wasm { + +std::string TestContext::global_log_; + +std::vector getWasmEngines() { + std::vector engines = { +#if defined(PROXY_WASM_HOST_ENGINE_V8) + "v8", +#endif +#if defined(PROXY_WASM_HOST_ENGINE_WAMR) + "wamr", +#endif +#if defined(PROXY_WASM_HOST_ENGINE_WASMEDGE) + "wasmedge", +#endif +#if defined(PROXY_WASM_HOST_ENGINE_WASMTIME) + "wasmtime", +#endif + ""}; + engines.pop_back(); + return engines; +} + +std::string readTestWasmFile(const std::string &filename) { + auto path = "test/test_data/" + filename; + std::ifstream file(path, std::ios::binary); + EXPECT_FALSE(file.fail()) << "failed to open: " << path; + std::stringstream file_string_stream; + file_string_stream << file.rdbuf(); + return file_string_stream.str(); +} +} // namespace proxy_wasm diff --git a/test/utility.h b/test/utility.h new file mode 100644 index 000000000..0eb743037 --- /dev/null +++ b/test/utility.h @@ -0,0 +1,198 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#include "gtest/gtest.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "include/proxy-wasm/context.h" +#include "include/proxy-wasm/wasm.h" + +#if defined(PROXY_WASM_HOST_ENGINE_V8) +#include "include/proxy-wasm/v8.h" +#endif +#if defined(PROXY_WASM_HOST_ENGINE_WASMTIME) +#include "include/proxy-wasm/wasmtime.h" +#endif +#if defined(PROXY_WASM_HOST_ENGINE_WASMEDGE) +#include "include/proxy-wasm/wasmedge.h" +#endif +#if defined(PROXY_WASM_HOST_ENGINE_WAMR) +#include "include/proxy-wasm/wamr.h" +#endif + +namespace proxy_wasm { + +std::vector getWasmEngines(); +std::string readTestWasmFile(const std::string &filename); + +class TestIntegration : public WasmVmIntegration { +public: + ~TestIntegration() override = default; + WasmVmIntegration *clone() override { return new TestIntegration{}; } + + void setLogLevel(LogLevel level) { log_level_ = level; } + + LogLevel getLogLevel() override { return log_level_; } + + void error(std::string_view message) override { + std::cout << "ERROR from integration: " << message << std::endl; + error_log_ += std::string(message) + "\n"; + } + + bool isErrorLogEmpty() { return error_log_.empty(); } + + bool isErrorLogged(std::string_view message) { + return error_log_.find(message) != std::string::npos; + } + + void trace(std::string_view message) override { + std::cout << "TRACE from integration: " << message << std::endl; + trace_log_ += std::string(message) + "\n"; + } + + bool isTraceLogEmpty() { return trace_log_.empty(); } + + bool isTraceLogged(std::string_view message) { + return trace_log_.find(message) != std::string::npos; + } + + bool getNullVmFunction(std::string_view /*function_name*/, bool /*returns_word*/, + int /*number_of_arguments*/, NullPlugin * /*plugin*/, + void * /*ptr_to_function_return*/) override { + return false; + }; + +private: + std::string error_log_; + std::string trace_log_; + LogLevel log_level_ = LogLevel::trace; +}; + +class TestContext : public ContextBase { +public: + TestContext(WasmBase *wasm) : ContextBase(wasm) {} + TestContext(WasmBase *wasm, const std::shared_ptr &plugin) + : ContextBase(wasm, plugin) {} + TestContext(WasmBase *wasm, uint32_t parent_context_id, + std::shared_ptr &plugin_handle) + : ContextBase(wasm, parent_context_id, plugin_handle) {} + + WasmResult log(uint32_t /*log_level*/, std::string_view message) override { + auto new_log = std::string(message) + "\n"; + log_ += new_log; + global_log_ += new_log; + return WasmResult::Ok; + } + + WasmResult getProperty(std::string_view path, std::string *result) override { + if (path == "plugin_root_id") { + *result = root_id_; + return WasmResult::Ok; + } + return unimplemented(); + } + + bool isLogEmpty() { return log_.empty(); } + + bool isLogged(std::string_view message) { return log_.find(message) != std::string::npos; } + + static bool isGlobalLogged(std::string_view message) { + return global_log_.find(message) != std::string::npos; + } + + static void resetGlobalLog() { global_log_ = ""; } + + uint64_t getCurrentTimeNanoseconds() override { + return std::chrono::duration_cast( + std::chrono::system_clock::now().time_since_epoch()) + .count(); + } + uint64_t getMonotonicTimeNanoseconds() override { + return std::chrono::duration_cast( + std::chrono::steady_clock::now().time_since_epoch()) + .count(); + } + + void set_allow_on_headers_stop_iteration(bool allow) { allow_on_headers_stop_iteration_ = allow; } + +private: + std::string log_; + static std::string global_log_; +}; + +class TestWasm : public WasmBase { +public: + TestWasm(std::unique_ptr wasm_vm, std::unordered_map envs = {}, + std::string_view vm_id = "", std::string_view vm_configuration = "", + std::string_view vm_key = "") + : WasmBase(std::move(wasm_vm), vm_id, vm_configuration, vm_key, std::move(envs), {}) {} + + TestWasm(const std::shared_ptr &base_wasm_handle, const WasmVmFactory &factory) + : WasmBase(base_wasm_handle, factory) {} + + ContextBase *createVmContext() override { return new TestContext(this); }; + + ContextBase *createRootContext(const std::shared_ptr &plugin) override { + return new TestContext(this, plugin); + } +}; + +class TestVm : public testing::TestWithParam { +public: + TestVm() { + engine_ = GetParam(); + vm_ = makeVm(engine_); + } + + static std::unique_ptr makeVm(const std::string &engine) { + std::unique_ptr vm; + if (engine.empty()) { + ADD_FAILURE() << "engine must not be empty"; +#if defined(PROXY_WASM_HOST_ENGINE_V8) + } else if (engine == "v8") { + vm = proxy_wasm::createV8Vm(); +#endif +#if defined(PROXY_WASM_HOST_ENGINE_WASMTIME) + } else if (engine == "wasmtime") { + vm = proxy_wasm::createWasmtimeVm(); +#endif +#if defined(PROXY_WASM_HOST_ENGINE_WASMEDGE) + } else if (engine == "wasmedge") { + vm = proxy_wasm::createWasmEdgeVm(); +#endif +#if defined(PROXY_WASM_HOST_ENGINE_WAMR) + } else if (engine == "wamr") { + vm = proxy_wasm::createWamrVm(); +#endif + } else { + ADD_FAILURE() << "compiled without support for the requested \"" << engine << "\" engine"; + } + vm->integration() = std::make_unique(); + return vm; + } + + std::unique_ptr vm_; + std::string engine_; +}; + +// TODO: remove when #412 is fixed. +GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TestVm); + +} // namespace proxy_wasm diff --git a/test/vm_id_handle_test.cc b/test/vm_id_handle_test.cc new file mode 100644 index 000000000..3eee9af03 --- /dev/null +++ b/test/vm_id_handle_test.cc @@ -0,0 +1,41 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "include/proxy-wasm/vm_id_handle.h" + +#include "gtest/gtest.h" + +namespace proxy_wasm { + +TEST(VmIdHandle, Basic) { + const auto *vm_id = "vm_id"; + auto handle = getVmIdHandle(vm_id); + EXPECT_TRUE(handle); + + bool called = false; + registerVmIdHandleCallback([&called](std::string_view /*vm_id*/) { called = true; }); + + handle.reset(); + EXPECT_TRUE(called); + + handle = getVmIdHandle(vm_id); + auto handle2 = getVmIdHandle(vm_id); + called = false; + handle.reset(); + EXPECT_FALSE(called); + handle2.reset(); + EXPECT_TRUE(called); +} + +} // namespace proxy_wasm diff --git a/test/wasm_test.cc b/test/wasm_test.cc new file mode 100644 index 000000000..2a3e60cc4 --- /dev/null +++ b/test/wasm_test.cc @@ -0,0 +1,327 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "include/proxy-wasm/wasm.h" + +#include + +#include "gtest/gtest.h" + +#include "test/utility.h" + +#include "src/wasm.h" + +namespace proxy_wasm { + +INSTANTIATE_TEST_SUITE_P(WasmEngines, TestVm, testing::ValuesIn(getWasmEngines()), + [](const testing::TestParamInfo &info) { + return info.param; + }); + +// Fail callbacks only used for WasmVMs - not available for NullVM. +TEST_P(TestVm, GetOrCreateThreadLocalWasmFailCallbacks) { + const auto *const plugin_name = "plugin_name"; + const auto *const root_id = "root_id"; + const auto *const vm_id = "vm_id"; + const auto *const vm_config = "vm_config"; + const auto *const plugin_config = "plugin_config"; + const auto fail_open = false; + + // Create a plugin. + const auto plugin = std::make_shared(plugin_name, root_id, vm_id, engine_, + plugin_config, fail_open, "plugin_key"); + + // Define callbacks. + WasmHandleFactory wasm_handle_factory = + [this, vm_id, vm_config](std::string_view vm_key) -> std::shared_ptr { + auto base_wasm = std::make_shared(makeVm(engine_), vm_id, vm_config, vm_key, + std::unordered_map{}, + AllowedCapabilitiesMap{}); + return std::make_shared(base_wasm); + }; + + WasmHandleCloneFactory wasm_handle_clone_factory = + [this](const std::shared_ptr &base_wasm_handle) + -> std::shared_ptr { + auto wasm = std::make_shared( + base_wasm_handle, [this]() -> std::unique_ptr { return makeVm(engine_); }); + return std::make_shared(wasm); + }; + + PluginHandleFactory plugin_handle_factory = + [](const std::shared_ptr &base_wasm, + const std::shared_ptr &plugin) -> std::shared_ptr { + return std::make_shared(base_wasm, plugin); + }; + + // Read the minimal loadable binary. + auto source = readTestWasmFile("abi_export.wasm"); + + // Create base Wasm via createWasm. + auto base_wasm_handle = + createWasm("vm_key", source, plugin, wasm_handle_factory, wasm_handle_clone_factory, false); + ASSERT_TRUE(base_wasm_handle && base_wasm_handle->wasm()); + + // Create a thread local plugin. + auto thread_local_plugin = getOrCreateThreadLocalPlugin( + base_wasm_handle, plugin, wasm_handle_clone_factory, plugin_handle_factory); + ASSERT_TRUE(thread_local_plugin && thread_local_plugin->plugin()); + // If the VM is not failed, same WasmBase should be used for the same configuration. + ASSERT_EQ(getOrCreateThreadLocalPlugin(base_wasm_handle, plugin, wasm_handle_clone_factory, + plugin_handle_factory) + ->wasm(), + thread_local_plugin->wasm()); + + // Cause runtime crash. + thread_local_plugin->wasm()->wasm_vm()->fail(FailState::RuntimeError, "runtime error msg"); + ASSERT_TRUE(thread_local_plugin->wasm()->isFailed()); + // the Base Wasm should not be affected by cloned ones. + ASSERT_FALSE(base_wasm_handle->wasm()->isFailed()); + + // Create another thread local plugin with the same configuration. + // This one should not end up using the failed VM. + auto thread_local_plugin2 = getOrCreateThreadLocalPlugin( + base_wasm_handle, plugin, wasm_handle_clone_factory, plugin_handle_factory); + ASSERT_TRUE(thread_local_plugin2 && thread_local_plugin2->plugin()); + ASSERT_FALSE(thread_local_plugin2->wasm()->isFailed()); + // Verify the pointer to WasmBase is different from the failed one. + ASSERT_NE(thread_local_plugin2->wasm(), thread_local_plugin->wasm()); + + // Cause runtime crash again. + thread_local_plugin2->wasm()->wasm_vm()->fail(FailState::RuntimeError, "runtime error msg"); + ASSERT_TRUE(thread_local_plugin2->wasm()->isFailed()); + // the Base Wasm should not be affected by cloned ones. + ASSERT_FALSE(base_wasm_handle->wasm()->isFailed()); + + // This time, create another thread local plugin with *different* plugin key for the same vm_key. + // This one also should not end up using the failed VM. + const auto plugin2 = std::make_shared(plugin_name, root_id, vm_id, engine_, + plugin_config, fail_open, "another_plugin_key"); + auto thread_local_plugin3 = getOrCreateThreadLocalPlugin( + base_wasm_handle, plugin2, wasm_handle_clone_factory, plugin_handle_factory); + ASSERT_TRUE(thread_local_plugin3 && thread_local_plugin3->plugin()); + ASSERT_FALSE(thread_local_plugin3->wasm()->isFailed()); + // Verify the pointer to WasmBase is different from the failed one. + ASSERT_NE(thread_local_plugin3->wasm(), thread_local_plugin->wasm()); + ASSERT_NE(thread_local_plugin3->wasm(), thread_local_plugin2->wasm()); +} + +// Tests the canary is always applied when making a call `createWasm` +TEST_P(TestVm, AlwaysApplyCanary) { + // Use different root_id, but the others are the same + const auto *const plugin_name = "plugin_name"; + + const std::string root_ids[2] = {"root_id_1", "root_id_2"}; + const std::string vm_ids[2] = {"vm_id_1", "vm_id_2"}; + const std::string vm_configs[2] = {"vm_config_1", "vm_config_2"}; + const std::string plugin_configs[3] = {"plugin_config_1", "plugin_config_2", + /* raising the error */ ""}; + const std::string plugin_keys[2] = {"plugin_key_1", "plugin_key_2"}; + const auto fail_open = false; + + // Define common callbacks + auto canary_count = 0; + WasmHandleCloneFactory wasm_handle_clone_factory_for_canary = + [&canary_count, this](const std::shared_ptr &base_wasm_handle) + -> std::shared_ptr { + auto wasm = std::make_shared( + base_wasm_handle, [this]() -> std::unique_ptr { return makeVm(engine_); }); + canary_count++; + return std::make_shared(wasm); + }; + + PluginHandleFactory plugin_handle_factory = + [](const std::shared_ptr &base_wasm, + const std::shared_ptr &plugin) -> std::shared_ptr { + return std::make_shared(base_wasm, plugin); + }; + + // Read the minimal loadable binary. + auto source = readTestWasmFile("canary_check.wasm"); + + WasmHandleFactory wasm_handle_factory_baseline = + [this, vm_ids, vm_configs](std::string_view vm_key) -> std::shared_ptr { + auto base_wasm = + std::make_shared(makeVm(engine_), std::unordered_map(), + vm_ids[0], vm_configs[0], vm_key); + return std::make_shared(base_wasm); + }; + + // Create a baseline plugin. + const auto plugin_baseline = std::make_shared( + plugin_name, root_ids[0], vm_ids[0], engine_, plugin_configs[0], fail_open, plugin_keys[0]); + + const auto vm_key_baseline = makeVmKey(vm_ids[0], vm_configs[0], "common_code"); + // Create a base Wasm by createWasm. + auto wasm_handle_baseline = + createWasm(vm_key_baseline, source, plugin_baseline, wasm_handle_factory_baseline, + wasm_handle_clone_factory_for_canary, false); + ASSERT_TRUE(wasm_handle_baseline && wasm_handle_baseline->wasm()); + + // Check if it ran for baseline root context + EXPECT_TRUE(TestContext::isGlobalLogged("onConfigure: " + root_ids[0])); + // For each create Wasm, canary should be done. + EXPECT_EQ(canary_count, 1); + + bool first = true; + std::unordered_set> reference_holder; + + for (const auto &root_id : root_ids) { + for (const auto &vm_id : vm_ids) { + for (const auto &vm_config : vm_configs) { + for (const auto &plugin_key : plugin_keys) { + for (const auto &plugin_config : plugin_configs) { + canary_count = 0; + TestContext::resetGlobalLog(); + WasmHandleFactory wasm_handle_factory_comp = + [this, vm_id, + vm_config](std::string_view vm_key) -> std::shared_ptr { + auto base_wasm = std::make_shared( + makeVm(engine_), std::unordered_map(), vm_id, vm_config, + vm_key); + return std::make_shared(base_wasm); + }; + const auto plugin_comp = std::make_shared( + plugin_name, root_id, vm_id, engine_, plugin_config, fail_open, plugin_key); + const auto vm_key = makeVmKey(vm_id, vm_config, "common_code"); + // Create a base Wasm by createWasm. + auto wasm_handle_comp = + createWasm(vm_key, source, plugin_comp, wasm_handle_factory_comp, + wasm_handle_clone_factory_for_canary, false); + // Validate that canarying is cached for the first baseline plugin variant. + if (first) { + first = false; + EXPECT_EQ(canary_count, 0); + } else { + // For each create Wasm, canary should be done. + EXPECT_EQ(canary_count, 1); + EXPECT_TRUE(TestContext::isGlobalLogged("onConfigure: " + root_id)); + } + + if (plugin_config.empty()) { + // canary_check.wasm should raise the error at `onConfigure` in canary when the + // `plugin_config` is empty string. + EXPECT_EQ(wasm_handle_comp, nullptr); + continue; + } + + ASSERT_TRUE(wasm_handle_comp && wasm_handle_comp->wasm()); + // Keep the reference of wasm_handle_comp in order to utilize the WasmHandleBase + // cache of createWasm. If we don't keep the reference, WasmHandleBase and VM will be + // destroyed for each iteration. + reference_holder.insert(wasm_handle_comp); + + // Wasm VM is unique for vm_key. + if (vm_key == vm_key_baseline) { + EXPECT_EQ(wasm_handle_baseline->wasm(), wasm_handle_comp->wasm()); + } else { + EXPECT_NE(wasm_handle_baseline->wasm(), wasm_handle_comp->wasm()); + } + + // plugin->key() is unique for root_id + plugin_config + plugin_key. + // plugin->key() is used as an identifier of local-specific plugins as well. + if (root_id == root_ids[0] && plugin_config == plugin_configs[0] && + plugin_key == plugin_keys[0]) { + EXPECT_EQ(plugin_baseline->key(), plugin_comp->key()); + } else { + EXPECT_NE(plugin_baseline->key(), plugin_comp->key()); + } + } + } + } + } + } +} + +// Check that there are no stale thread-local cache keys (eventually) +TEST_P(TestVm, CleanupThreadLocalCacheKeys) { + const auto *const plugin_name = "plugin_name"; + const auto *const root_id = "root_id"; + const auto *const vm_id = "vm_id"; + const auto *const vm_config = "vm_config"; + const auto *const plugin_config = "plugin_config"; + const auto fail_open = false; + + WasmHandleFactory wasm_handle_factory = + [this, vm_id, vm_config](std::string_view vm_key) -> std::shared_ptr { + auto base_wasm = std::make_shared(makeVm(engine_), vm_id, vm_config, vm_key, + std::unordered_map{}, + AllowedCapabilitiesMap{}); + return std::make_shared(base_wasm); + }; + + WasmHandleCloneFactory wasm_handle_clone_factory = + [this](const std::shared_ptr &base_wasm_handle) + -> std::shared_ptr { + auto wasm = std::make_shared( + base_wasm_handle, [this]() -> std::unique_ptr { return makeVm(engine_); }); + return std::make_shared(wasm); + }; + + PluginHandleFactory plugin_handle_factory = + [](const std::shared_ptr &base_wasm, + const std::shared_ptr &plugin) -> std::shared_ptr { + return std::make_shared(base_wasm, plugin); + }; + + // Read the minimal loadable binary. + auto source = readTestWasmFile("abi_export.wasm"); + + // Simulate a plugin lifetime. + const auto plugin1 = std::make_shared(plugin_name, root_id, vm_id, engine_, + plugin_config, fail_open, "plugin_1"); + auto base_wasm_handle1 = + createWasm("vm_1", source, plugin1, wasm_handle_factory, wasm_handle_clone_factory, false); + ASSERT_TRUE(base_wasm_handle1 && base_wasm_handle1->wasm()); + + auto local_plugin1 = getOrCreateThreadLocalPlugin( + base_wasm_handle1, plugin1, wasm_handle_clone_factory, plugin_handle_factory); + ASSERT_TRUE(local_plugin1 && local_plugin1->plugin()); + local_plugin1.reset(); + + auto stale_plugins_keys = staleLocalPluginsKeysForTesting(); + EXPECT_EQ(1, stale_plugins_keys.size()); + + // Now we create another plugin with a slightly different key and expect that there are no stale + // thread-local cache entries. + const auto plugin2 = std::make_shared(plugin_name, root_id, vm_id, engine_, + plugin_config, fail_open, "plugin_2"); + auto local_plugin2 = getOrCreateThreadLocalPlugin( + base_wasm_handle1, plugin2, wasm_handle_clone_factory, plugin_handle_factory); + ASSERT_TRUE(local_plugin2 && local_plugin2->plugin()); + + stale_plugins_keys = staleLocalPluginsKeysForTesting(); + EXPECT_TRUE(stale_plugins_keys.empty()); + + // Trigger deletion of the thread-local WasmVM cloned from base_wasm_handle1 by freeing objects + // referencing it. + local_plugin2.reset(); + + auto stale_wasms_keys = staleLocalWasmsKeysForTesting(); + EXPECT_EQ(1, stale_wasms_keys.size()); + + // Create another base WASM handle and invoke WASM thread-local cache key cleanup. + auto base_wasm_handle2 = + createWasm("vm_2", source, plugin2, wasm_handle_factory, wasm_handle_clone_factory, false); + ASSERT_TRUE(base_wasm_handle2 && base_wasm_handle2->wasm()); + + auto local_plugin3 = getOrCreateThreadLocalPlugin( + base_wasm_handle2, plugin2, wasm_handle_clone_factory, plugin_handle_factory); + ASSERT_TRUE(local_plugin3 && local_plugin3->plugin()); + + stale_wasms_keys = staleLocalWasmsKeysForTesting(); + EXPECT_TRUE(stale_wasms_keys.empty()); +} + +} // namespace proxy_wasm diff --git a/test/wasm_vm_test.cc b/test/wasm_vm_test.cc new file mode 100644 index 000000000..346fe2a07 --- /dev/null +++ b/test/wasm_vm_test.cc @@ -0,0 +1,168 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "gtest/gtest.h" + +#include +#include +#include + +#include "include/proxy-wasm/wasm_vm.h" + +#include "test/utility.h" + +namespace proxy_wasm { +namespace { + +INSTANTIATE_TEST_SUITE_P(WasmEngines, TestVm, testing::ValuesIn(getWasmEngines()), + [](const testing::TestParamInfo &info) { + return info.param; + }); + +TEST_P(TestVm, Init) { + auto time1 = std::chrono::steady_clock::now(); + vm_->warm(); + auto time2 = std::chrono::steady_clock::now(); + vm_->warm(); + auto time3 = std::chrono::steady_clock::now(); + + auto cold = std::chrono::duration_cast(time2 - time1).count(); + auto warm = std::chrono::duration_cast(time3 - time2).count(); + + std::cout << "[" << engine_ << "] \"cold\" engine time: " << cold << "ns" << std::endl; + std::cout << "[" << engine_ << "] \"warm\" engine time: " << warm << "ns" << std::endl; + + // Default warm time in nanoseconds. + int warm_time_ns_limit = 10000; + +#if defined(__linux__) && defined(__s390x__) + // Linux 390x is significantly slower, so we use a more lenient limit. + warm_time_ns_limit = 75000; +#endif + + // Verify that getting a "warm" engine takes less than 10us. + EXPECT_LE(warm, warm_time_ns_limit); + + // Verify that getting a "warm" engine takes at least 50x less time than getting a "cold" one. + // We skip NullVM because warm() is a noop. + if (engine_ == "null") { + std::cout << "Skipping warm() performance assertions for NullVM." << std::endl; + return; + } + EXPECT_LE(warm * 50, cold); +} + +TEST_P(TestVm, Basic) { + if (engine_ == "wasmedge") { + EXPECT_EQ(vm_->cloneable(), proxy_wasm::Cloneable::NotCloneable); + } else if (engine_ == "wasmtime" || engine_ == "v8" || engine_ == "wamr") { + EXPECT_EQ(vm_->cloneable(), proxy_wasm::Cloneable::CompiledBytecode); + } else { + FAIL(); + } + EXPECT_EQ(vm_->getEngineName(), engine_); +} + +TEST_P(TestVm, Memory) { + auto source = readTestWasmFile("abi_export.wasm"); + ASSERT_TRUE(vm_->load(source, {}, {})); + ASSERT_TRUE(vm_->link("")); + + Word word; + ASSERT_TRUE(vm_->setWord(0x2000, Word(100))); + ASSERT_TRUE(vm_->getWord(0x2000, &word)); + ASSERT_EQ(100, word.u64_); + + uint32_t data[2] = {htowasm(static_cast(-1), vm_->usesWasmByteOrder()), + htowasm(200, vm_->usesWasmByteOrder())}; + ASSERT_TRUE(vm_->setMemory(0x200, sizeof(int32_t) * 2, static_cast(data))); + ASSERT_TRUE(vm_->getWord(0x200, &word)); + ASSERT_EQ(-1, static_cast(word.u64_)); + ASSERT_TRUE(vm_->getWord(0x204, &word)); + ASSERT_EQ(200, static_cast(word.u64_)); +} + +TEST_P(TestVm, Clone) { + if (vm_->cloneable() == proxy_wasm::Cloneable::NotCloneable) { + return; + } + auto source = readTestWasmFile("abi_export.wasm"); + ASSERT_TRUE(vm_->load(source, {}, {})); + ASSERT_TRUE(vm_->link("")); + const auto address = 0x2000; + Word word; + { + auto clone = vm_->clone(); + ASSERT_TRUE(clone != nullptr); + ASSERT_NE(vm_, clone); + if (clone->cloneable() != proxy_wasm::Cloneable::InstantiatedModule) { + ASSERT_TRUE(clone->link("")); + } + + ASSERT_TRUE(clone->setWord(address, Word(100))); + ASSERT_TRUE(clone->getWord(address, &word)); + ASSERT_EQ(100, word.u64_); + } + + // check memory arrays are not overrapped + ASSERT_TRUE(vm_->getWord(address, &word)); + ASSERT_NE(100, word.u64_); +} + +#if defined(__linux__) && defined(__x86_64__) + +TEST_P(TestVm, DISABLED_CloneUntilOutOfMemory) { + if (vm_->cloneable() == proxy_wasm::Cloneable::NotCloneable) { + return; + } + + auto source = readTestWasmFile("abi_export.wasm"); + ASSERT_TRUE(vm_->load(source, {}, {})); + ASSERT_TRUE(vm_->link("")); + + size_t max_clones = 100000; +#if defined(__has_feature) +#if __has_feature(address_sanitizer) + max_clones = 1000; +#endif +#endif + + std::vector> clones; + for (size_t i = 0; i < max_clones; i++) { + auto clone = vm_->clone(); + if (clone == nullptr) { + break; + } + if (clone->cloneable() != proxy_wasm::Cloneable::InstantiatedModule) { + if (!clone->link("")) { + break; + } + } + // Prevent clone from droping out of scope and freeing memory. + clones.push_back(std::move(clone)); + } + + size_t min_clones = 1000; +#if defined(__has_feature) +#if __has_feature(thread_sanitizer) + min_clones = 100; +#endif +#endif + EXPECT_GE(clones.size(), min_clones); +} + +#endif + +} // namespace +} // namespace proxy_wasm diff --git a/tools/gen_compilation_database.py b/tools/gen_compilation_database.py new file mode 100755 index 000000000..bff3d82d5 --- /dev/null +++ b/tools/gen_compilation_database.py @@ -0,0 +1,79 @@ +#!/usr/bin/env python3 + +# Copyright 2016-2019 Envoy Project Authors +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import argparse +import json +import os +import shlex +import subprocess +from pathlib import Path + +# This is copied from https://github.com/envoyproxy/envoy and remove unnecessary code. + +# This method is equivalent to https://github.com/grailbio/bazel-compilation-database/blob/master/generate.py +def generate_compilation_database(args): + # We need to download all remote outputs for generated source code. This option lives here to override those + # specified in bazelrc. + bazel_startup_options = shlex.split(os.environ.get("BAZEL_STARTUP_OPTION_LIST", "")) + bazel_options = shlex.split(os.environ.get("BAZEL_BUILD_OPTION_LIST", "")) + [ + "--remote_download_outputs=all", + ] + + source_dir_targets = args.bazel_targets + + subprocess.check_call(["bazel", *bazel_startup_options, "build"] + bazel_options + [ + "--aspects=@bazel_compdb//:aspects.bzl%compilation_database_aspect", + "--output_groups=compdb_files,header_files" + ] + source_dir_targets) + + execroot = subprocess.check_output( + ["bazel", *bazel_startup_options, "info", *bazel_options, + "execution_root"]).decode().strip() + + db_entries = [] + for db in Path(execroot).glob('**/*.compile_commands.json'): + db_entries.extend(json.loads(db.read_text())) + + def replace_execroot_marker(db_entry): + if 'directory' in db_entry and db_entry['directory'] == '__EXEC_ROOT__': + db_entry['directory'] = execroot + if 'command' in db_entry: + db_entry['command'] = ( + db_entry['command'].replace('-isysroot __BAZEL_XCODE_SDKROOT__', '')) + return db_entry + + return list(map(replace_execroot_marker, db_entries)) + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Generate JSON compilation database') + parser.add_argument('--include_external', action='https://github.com/store_true') + parser.add_argument('--include_genfiles', action='https://github.com/store_true') + parser.add_argument('--include_headers', action='https://github.com/store_true') + parser.add_argument('--include_all', action='https://github.com/store_true') + parser.add_argument( + '--system-clang', + action='https://github.com/store_true', + help= + 'Use `clang++` instead of the bazel wrapper for commands. This may help if `clangd` cannot find/run the tools.' + ) + parser.add_argument('bazel_targets', nargs='*', default=[]) + + args = parser.parse_args() + db = generate_compilation_database(args) + + with open("compile_commands.json", "w") as db_file: + json.dump(db, db_file, indent=2)