diff --git a/api/wasm/cpp/Makefile.base b/api/wasm/cpp/Makefile.base index f56e84a19c..24071e672e 100644 --- a/api/wasm/cpp/Makefile.base +++ b/api/wasm/cpp/Makefile.base @@ -11,7 +11,7 @@ else endif %.wasm %.wat: %.cc ${CPP_API}/proxy_wasm_intrinsics.h ${CPP_API}/proxy_wasm_enums.h ${CPP_API}/proxy_wasm_externs.h ${CPP_API}/proxy_wasm_api.h ${CPP_API}/proxy_wasm_intrinsics.js ${CPP_CONTEXT_LIB} - em++ -s STANDALONE_WASM=1 -s EMIT_EMSCRIPTEN_METADATA=1 -s EXPORTED_FUNCTIONS=['_malloc','_free'] --std=c++17 -O3 -flto -s WASM_OBJECT_FILES=0 --llvm-lto 1 -I${CPP_API} -I/usr/local/include --js-library ${CPP_API}/proxy_wasm_intrinsics.js $*.cc ${CPP_API}/proxy_wasm_intrinsics.pb.cc ${CPP_CONTEXT_LIB} ${CPP_API}/libprotobuf.a -o $*.wasm + em++ -s STANDALONE_WASM=1 -s EMIT_EMSCRIPTEN_METADATA=1 -s EXPORTED_FUNCTIONS=['_malloc'] --std=c++17 -O3 -flto -s WASM_OBJECT_FILES=0 --llvm-lto 1 -I${CPP_API} -I/usr/local/include --js-library ${CPP_API}/proxy_wasm_intrinsics.js $*.cc ${CPP_API}/proxy_wasm_intrinsics.pb.cc ${CPP_CONTEXT_LIB} ${CPP_API}/libprotobuf.a -o $*.wasm clean: rm *.wasm diff --git a/api/wasm/cpp/Makefile.base_lite b/api/wasm/cpp/Makefile.base_lite index 7c187be111..0373b1898c 100644 --- a/api/wasm/cpp/Makefile.base_lite +++ b/api/wasm/cpp/Makefile.base_lite @@ -11,7 +11,7 @@ else endif %.wasm %.wat: %.cc ${CPP_API}/proxy_wasm_intrinsics.h ${CPP_API}/proxy_wasm_enums.h ${CPP_API}/proxy_wasm_externs.h ${CPP_API}/proxy_wasm_api.h ${CPP_API}/proxy_wasm_intrinsics.js ${CPP_CONTEXT_LIB} - em++ -s STANDALONE_WASM=1 -s EMIT_EMSCRIPTEN_METADATA=1 -s EXPORTED_FUNCTIONS=['_malloc','_free'] --std=c++17 -O3 -flto -s WASM_OBJECT_FILES=0 --llvm-lto 1 -DPROXY_WASM_PROTOBUF_LITE=1 -I${CPP_API} -I/usr/local/include --js-library ${CPP_API}/proxy_wasm_intrinsics.js $*.cc ${CPP_API}/proxy_wasm_intrinsics_lite.pb.cc ${CPP_API}/struct_lite.pb.cc ${CPP_CONTEXT_LIB} ${CPP_API}/libprotobuf-lite.a -o $*.wasm + em++ -s STANDALONE_WASM=1 -s EMIT_EMSCRIPTEN_METADATA=1 -s EXPORTED_FUNCTIONS=['_malloc'] --std=c++17 -O3 -flto -s WASM_OBJECT_FILES=0 --llvm-lto 1 -DPROXY_WASM_PROTOBUF_LITE=1 -I${CPP_API} -I/usr/local/include --js-library ${CPP_API}/proxy_wasm_intrinsics.js $*.cc ${CPP_API}/proxy_wasm_intrinsics_lite.pb.cc ${CPP_API}/struct_lite.pb.cc ${CPP_CONTEXT_LIB} ${CPP_API}/libprotobuf-lite.a -o $*.wasm clean: rm *.wasm diff --git a/api/wasm/cpp/README.md b/api/wasm/cpp/README.md index 83b25c3d04..2e9ead57ac 100644 --- a/api/wasm/cpp/README.md +++ b/api/wasm/cpp/README.md @@ -105,7 +105,7 @@ all: plugin.wasm %.wasm %.wat: %.cc ${CPP_API}/proxy_wasm_intrinsics.h ${CPP_API}/proxy_wasm_enums.h ${CPP_API}/proxy_wasm_externs.h ${CPP_API}/proxy_wasm_api.h ${CPP_API}/proxy_wasm_intrinsics.js ${CPP_CONTEXT_LIB} ls /root - em++ -s STANDALONE_WASM=1 -s EMIT_EMSCRIPTEN_METADATA=1 -s EXPORTED_FUNCTIONS=['_malloc','_free'] --std=c++17 -O3 -flto -s WASM_OBJECT_FILES=0 --llvm-lto 1 -I${CPP_API} -I${CPP_API}/google/protobuf -I/usr/local/include -I${ABSL} --js-library ${CPP_API}/proxy_wasm_intrinsics.js ${ABSL_CPP} $*.cc ${CPP_API}/proxy_wasm_intrinsics.pb.cc ${CPP_CONTEXT_LIB} ${CPP_API}/libprotobuf.a -o $*.wasm + em++ -s STANDALONE_WASM=1 -s EMIT_EMSCRIPTEN_METADATA=1 -s EXPORTED_FUNCTIONS=['_malloc'] --std=c++17 -O3 -flto -s WASM_OBJECT_FILES=0 --llvm-lto 1 -I${CPP_API} -I${CPP_API}/google/protobuf -I/usr/local/include -I${ABSL} --js-library ${CPP_API}/proxy_wasm_intrinsics.js ${ABSL_CPP} $*.cc ${CPP_API}/proxy_wasm_intrinsics.pb.cc ${CPP_CONTEXT_LIB} ${CPP_API}/libprotobuf.a -o $*.wasm ``` Precompiled abseil libraries are also available, so the above can also be done as: @@ -121,7 +121,7 @@ all: plugin.wasm %.wasm %.wat: %.cc ${CPP_API}/proxy_wasm_intrinsics.h ${CPP_API}/proxy_wasm_enums.h ${CPP_API}/proxy_wasm_externs.h ${CPP_API}/proxy_wasm_api.h ${CPP_API}/proxy_wasm_intrinsics.js ${CPP_CONTEXT_LIB} ls /root - em++ -s STANDALONE_WASM=1 -s EMIT_EMSCRIPTEN_METADATA=1 -s EXPORTED_FUNCTIONS=['_malloc','_free'] --std=c++17 -O3 -flto -s WASM_OBJECT_FILES=0 --llvm-lto 1 -I${CPP_API} -I${CPP_API}/google/protobuf -I/usr/local/include -I${ABSL} --js-library ${CPP_API}/proxy_wasm_intrinsics.js $*.cc ${CPP_API}/proxy_wasm_intrinsics.pb.cc ${CPP_CONTEXT_LIB} ${CPP_API}/libprotobuf.a ${ABSL_LIBS} -o $*.wasm + em++ -s STANDALONE_WASM=1 -s EMIT_EMSCRIPTEN_METADATA=1 -s EXPORTED_FUNCTIONS=['_malloc'] --std=c++17 -O3 -flto -s WASM_OBJECT_FILES=0 --llvm-lto 1 -I${CPP_API} -I${CPP_API}/google/protobuf -I/usr/local/include -I${ABSL} --js-library ${CPP_API}/proxy_wasm_intrinsics.js $*.cc ${CPP_API}/proxy_wasm_intrinsics.pb.cc ${CPP_CONTEXT_LIB} ${CPP_API}/libprotobuf.a ${ABSL_LIBS} -o $*.wasm ``` ### Ownership of the resulting .wasm files diff --git a/examples/wasm/envoy_filter_http_wasm_example.wasm b/examples/wasm/envoy_filter_http_wasm_example.wasm index 95ee54f49e..588bc8fbd2 100644 Binary files a/examples/wasm/envoy_filter_http_wasm_example.wasm and b/examples/wasm/envoy_filter_http_wasm_example.wasm differ diff --git a/source/extensions/common/wasm/null/null_plugin.cc b/source/extensions/common/wasm/null/null_plugin.cc index b5f3aea61a..d8cfd1104d 100644 --- a/source/extensions/common/wasm/null/null_plugin.cc +++ b/source/extensions/common/wasm/null/null_plugin.cc @@ -41,9 +41,7 @@ void NullPlugin::getFunction(absl::string_view function_name, WasmCallVoid<0>* f void NullPlugin::getFunction(absl::string_view function_name, WasmCallVoid<1>* f) { auto plugin = this; - if (function_name == "free") { - *f = [](Common::Wasm::Context*, Word ptr) { return ::free(reinterpret_cast(ptr.u64_)); }; - } else if (function_name == "proxy_on_tick") { + if (function_name == "proxy_on_tick") { *f = [plugin](Common::Wasm::Context* context, Word context_id) { SaveRestoreContext saved_context(context); plugin->onTick(context_id.u64_); diff --git a/source/extensions/common/wasm/wasm.cc b/source/extensions/common/wasm/wasm.cc index e8eea749a8..3e8aa4d8f7 100644 --- a/source/extensions/common/wasm/wasm.cc +++ b/source/extensions/common/wasm/wasm.cc @@ -215,7 +215,6 @@ void Wasm::getFunctions() { _GET(__wasm_call_ctors); _GET(malloc); - _GET(free); #undef _GET #define _GET_PROXY(_fn) wasm_vm_->getFunction("proxy_" #_fn, &_fn##_); @@ -252,8 +251,8 @@ void Wasm::getFunctions() { _GET_PROXY(on_delete); #undef _GET_PROXY - if (!malloc_ || !free_) { - throw WasmException("WASM missing malloc/free"); + if (!malloc_) { + throw WasmException("WASM missing malloc"); } } diff --git a/source/extensions/common/wasm/wasm.h b/source/extensions/common/wasm/wasm.h index 020408b20e..a894fe4675 100644 --- a/source/extensions/common/wasm/wasm.h +++ b/source/extensions/common/wasm/wasm.h @@ -198,7 +198,6 @@ class Wasm : public Logger::Loggable, public std::enable_share WasmCallVoid<0> __wasm_call_ctors_; WasmCallWord<1> malloc_; - WasmCallVoid<1> free_; // Calls into the VM. WasmCallWord<2> validate_configuration_; diff --git a/test/extensions/access_loggers/wasm/test_data/logging.wasm b/test/extensions/access_loggers/wasm/test_data/logging.wasm index acd36abf26..9b23d9c4ec 100644 Binary files a/test/extensions/access_loggers/wasm/test_data/logging.wasm and b/test/extensions/access_loggers/wasm/test_data/logging.wasm differ diff --git a/test/extensions/common/wasm/test_data/bad_signature_cpp.wasm b/test/extensions/common/wasm/test_data/bad_signature_cpp.wasm index 044050f907..ecb7868071 100644 Binary files a/test/extensions/common/wasm/test_data/bad_signature_cpp.wasm and b/test/extensions/common/wasm/test_data/bad_signature_cpp.wasm differ diff --git a/test/extensions/common/wasm/test_data/test_cpp.wasm b/test/extensions/common/wasm/test_data/test_cpp.wasm index 0416d1f367..6ee170aec4 100644 Binary files a/test/extensions/common/wasm/test_data/test_cpp.wasm and b/test/extensions/common/wasm/test_data/test_cpp.wasm differ diff --git a/test/extensions/common/wasm/test_data/test_rust.wasm b/test/extensions/common/wasm/test_data/test_rust.wasm index 00438a858b..41c3044ab3 100755 Binary files a/test/extensions/common/wasm/test_data/test_rust.wasm and b/test/extensions/common/wasm/test_data/test_rust.wasm differ diff --git a/test/extensions/filters/http/wasm/test_data/async_call_cpp.wasm b/test/extensions/filters/http/wasm/test_data/async_call_cpp.wasm index 734333a52d..13315693b9 100644 Binary files a/test/extensions/filters/http/wasm/test_data/async_call_cpp.wasm and b/test/extensions/filters/http/wasm/test_data/async_call_cpp.wasm differ diff --git a/test/extensions/filters/http/wasm/test_data/grpc_call_cpp.wasm b/test/extensions/filters/http/wasm/test_data/grpc_call_cpp.wasm index 79095e6930..9accf17bd7 100644 Binary files a/test/extensions/filters/http/wasm/test_data/grpc_call_cpp.wasm and b/test/extensions/filters/http/wasm/test_data/grpc_call_cpp.wasm differ diff --git a/test/extensions/filters/http/wasm/test_data/grpc_callout_cpp.wasm b/test/extensions/filters/http/wasm/test_data/grpc_callout_cpp.wasm index 618773d410..2e2da2f65f 100644 Binary files a/test/extensions/filters/http/wasm/test_data/grpc_callout_cpp.wasm and b/test/extensions/filters/http/wasm/test_data/grpc_callout_cpp.wasm differ diff --git a/test/extensions/filters/http/wasm/test_data/headers_cpp.wasm b/test/extensions/filters/http/wasm/test_data/headers_cpp.wasm index acd36abf26..9b23d9c4ec 100644 Binary files a/test/extensions/filters/http/wasm/test_data/headers_cpp.wasm and b/test/extensions/filters/http/wasm/test_data/headers_cpp.wasm differ diff --git a/test/extensions/filters/http/wasm/test_data/http_callout_cpp.wasm b/test/extensions/filters/http/wasm/test_data/http_callout_cpp.wasm index 7f72f90305..3b5fc78e17 100644 Binary files a/test/extensions/filters/http/wasm/test_data/http_callout_cpp.wasm and b/test/extensions/filters/http/wasm/test_data/http_callout_cpp.wasm differ diff --git a/test/extensions/filters/http/wasm/test_data/metadata_cpp.wasm b/test/extensions/filters/http/wasm/test_data/metadata_cpp.wasm index caea59c343..53f5167ae2 100644 Binary files a/test/extensions/filters/http/wasm/test_data/metadata_cpp.wasm and b/test/extensions/filters/http/wasm/test_data/metadata_cpp.wasm differ diff --git a/test/extensions/filters/http/wasm/test_data/queue_cpp.wasm b/test/extensions/filters/http/wasm/test_data/queue_cpp.wasm index df5b293dac..b443e37ae3 100644 Binary files a/test/extensions/filters/http/wasm/test_data/queue_cpp.wasm and b/test/extensions/filters/http/wasm/test_data/queue_cpp.wasm differ diff --git a/test/extensions/filters/http/wasm/test_data/root_id_cpp.wasm b/test/extensions/filters/http/wasm/test_data/root_id_cpp.wasm index 55c43c77f2..0e2aa4b8d4 100644 Binary files a/test/extensions/filters/http/wasm/test_data/root_id_cpp.wasm and b/test/extensions/filters/http/wasm/test_data/root_id_cpp.wasm differ diff --git a/test/extensions/filters/http/wasm/test_data/shared_cpp.wasm b/test/extensions/filters/http/wasm/test_data/shared_cpp.wasm index 9372b293f0..1e7e4f5a8a 100644 Binary files a/test/extensions/filters/http/wasm/test_data/shared_cpp.wasm and b/test/extensions/filters/http/wasm/test_data/shared_cpp.wasm differ diff --git a/test/extensions/filters/network/wasm/test_data/logging_cpp.wasm b/test/extensions/filters/network/wasm/test_data/logging_cpp.wasm index 09d1af2fa4..5d6650e2ac 100644 Binary files a/test/extensions/filters/network/wasm/test_data/logging_cpp.wasm and b/test/extensions/filters/network/wasm/test_data/logging_cpp.wasm differ diff --git a/test/extensions/wasm/test_data/Makefile b/test/extensions/wasm/test_data/Makefile index 91afef8f2e..0dc9dcef46 100644 --- a/test/extensions/wasm/test_data/Makefile +++ b/test/extensions/wasm/test_data/Makefile @@ -6,4 +6,4 @@ include ../../../../api/wasm/cpp/Makefile.base_lite include ../../../../api/wasm/rust/Makefile.base missing_cpp.wasm missing_cpp.wat: missing_cpp.cc ${CPP_API}/proxy_wasm_intrinsics.h ${CPP_API}/proxy_wasm_intrinsics.js - em++ -s STANDALONE_WASM=1 -s EMIT_EMSCRIPTEN_METADATA=1 -s EXPORTED_FUNCTIONS=['_malloc','_free'] -s ERROR_ON_UNDEFINED_SYMBOLS=0 --std=c++17 -O3 -DPROXY_WASM_PROTOBUF_LITE=1 -I${CPP_API} -I${CPP_API}/google/protobuf -I/usr/local/include --js-library ${CPP_API}/proxy_wasm_intrinsics.js missing_cpp.cc ${CPP_API}/proxy_wasm_intrinsics_lite.pb.cc ${CPP_API}/struct_lite.pb.cc ${CPP_CONTEXT_LIB} ${CPP_API}/libprotobuf-lite.a -o missing_cpp.wasm + em++ -s STANDALONE_WASM=1 -s EMIT_EMSCRIPTEN_METADATA=1 -s EXPORTED_FUNCTIONS=['_malloc'] -s ERROR_ON_UNDEFINED_SYMBOLS=0 --std=c++17 -O3 -DPROXY_WASM_PROTOBUF_LITE=1 -I${CPP_API} -I${CPP_API}/google/protobuf -I/usr/local/include --js-library ${CPP_API}/proxy_wasm_intrinsics.js missing_cpp.cc ${CPP_API}/proxy_wasm_intrinsics_lite.pb.cc ${CPP_API}/struct_lite.pb.cc ${CPP_CONTEXT_LIB} ${CPP_API}/libprotobuf-lite.a -o missing_cpp.wasm diff --git a/test/extensions/wasm/test_data/Makefile.docker_cpp_builder b/test/extensions/wasm/test_data/Makefile.docker_cpp_builder index 809c390305..23f06dd3fb 100644 --- a/test/extensions/wasm/test_data/Makefile.docker_cpp_builder +++ b/test/extensions/wasm/test_data/Makefile.docker_cpp_builder @@ -6,7 +6,7 @@ all: logging_cpp.wasm bad_signature_cpp.wasm segv_cpp.wasm emscripten_cpp.wasm a chown ${uid}.${gid} *.wasm missing_cpp.wasm: missing_cpp.cc ${DOCKER_SDK}/proxy_wasm_intrinsics.h ${DOCKER_SDK}/proxy_wasm_intrinsics.js - em++ -s STANDALONE_WASM=1 -s EMIT_EMSCRIPTEN_METADATA=1 -s EXPORTED_FUNCTIONS=['_malloc','_free'] -s ERROR_ON_UNDEFINED_SYMBOLS=0 --std=c++17 -O3 -DPROXY_WASM_PROTOBUF_LITE=1 -I${DOCKER_SDK} -I${DOCKER_SDK}/google/protobuf -I/usr/local/include --js-library ${DOCKER_SDK}/proxy_wasm_intrinsics.js missing_cpp.cc ${DOCKER_SDK}/proxy_wasm_intrinsics_lite.pb.cc ${DOCKER_SDK}/struct_lite.pb.cc ${DOCKER_SDK}/libprotobuf-lite.a -o missing_cpp.wasm + em++ -s STANDALONE_WASM=1 -s EMIT_EMSCRIPTEN_METADATA=1 -s EXPORTED_FUNCTIONS=['_malloc'] -s ERROR_ON_UNDEFINED_SYMBOLS=0 --std=c++17 -O3 -DPROXY_WASM_PROTOBUF_LITE=1 -I${DOCKER_SDK} -I${DOCKER_SDK}/google/protobuf -I/usr/local/include --js-library ${DOCKER_SDK}/proxy_wasm_intrinsics.js missing_cpp.cc ${DOCKER_SDK}/proxy_wasm_intrinsics_lite.pb.cc ${DOCKER_SDK}/struct_lite.pb.cc ${DOCKER_SDK}/libprotobuf-lite.a -o missing_cpp.wasm chown ${uid}.${gid} missing_cpp.wasm include ${DOCKER_SDK}/Makefile.base_lite diff --git a/test/extensions/wasm/test_data/asm2wasm_cpp.wasm b/test/extensions/wasm/test_data/asm2wasm_cpp.wasm index 123a875477..2091ab6fb4 100644 Binary files a/test/extensions/wasm/test_data/asm2wasm_cpp.wasm and b/test/extensions/wasm/test_data/asm2wasm_cpp.wasm differ diff --git a/test/extensions/wasm/test_data/bad_signature_cpp.wasm b/test/extensions/wasm/test_data/bad_signature_cpp.wasm index c101cf308b..ecb7868071 100644 Binary files a/test/extensions/wasm/test_data/bad_signature_cpp.wasm and b/test/extensions/wasm/test_data/bad_signature_cpp.wasm differ diff --git a/test/extensions/wasm/test_data/emscripten_cpp.wasm b/test/extensions/wasm/test_data/emscripten_cpp.wasm index 58ed570af0..89c75ca4e9 100644 Binary files a/test/extensions/wasm/test_data/emscripten_cpp.wasm and b/test/extensions/wasm/test_data/emscripten_cpp.wasm differ diff --git a/test/extensions/wasm/test_data/logging_cpp.wasm b/test/extensions/wasm/test_data/logging_cpp.wasm index 34777f8e41..e5f540fa55 100644 Binary files a/test/extensions/wasm/test_data/logging_cpp.wasm and b/test/extensions/wasm/test_data/logging_cpp.wasm differ diff --git a/test/extensions/wasm/test_data/logging_rust.wasm b/test/extensions/wasm/test_data/logging_rust.wasm index ec34d3ad36..0045b40738 100755 Binary files a/test/extensions/wasm/test_data/logging_rust.wasm and b/test/extensions/wasm/test_data/logging_rust.wasm differ diff --git a/test/extensions/wasm/test_data/missing_cpp.wasm b/test/extensions/wasm/test_data/missing_cpp.wasm index 3ced0a7a82..02be7ebe11 100644 Binary files a/test/extensions/wasm/test_data/missing_cpp.wasm and b/test/extensions/wasm/test_data/missing_cpp.wasm differ diff --git a/test/extensions/wasm/test_data/segv_cpp.wasm b/test/extensions/wasm/test_data/segv_cpp.wasm index 8c8d2ccfc2..7f3d89cf62 100644 Binary files a/test/extensions/wasm/test_data/segv_cpp.wasm and b/test/extensions/wasm/test_data/segv_cpp.wasm differ diff --git a/test/extensions/wasm/test_data/speed_cpp.wasm b/test/extensions/wasm/test_data/speed_cpp.wasm index b70ae81439..49d40f03e8 100644 Binary files a/test/extensions/wasm/test_data/speed_cpp.wasm and b/test/extensions/wasm/test_data/speed_cpp.wasm differ diff --git a/test/extensions/wasm/test_data/start_cpp.wasm b/test/extensions/wasm/test_data/start_cpp.wasm index fafde618d5..ddb965068c 100644 Binary files a/test/extensions/wasm/test_data/start_cpp.wasm and b/test/extensions/wasm/test_data/start_cpp.wasm differ diff --git a/test/extensions/wasm/test_data/stats_cpp.wasm b/test/extensions/wasm/test_data/stats_cpp.wasm index 9428974637..0805ac1261 100644 Binary files a/test/extensions/wasm/test_data/stats_cpp.wasm and b/test/extensions/wasm/test_data/stats_cpp.wasm differ