proxy-wasm-rust-sdk
proxy-wasm-rust-sdk copied to clipboard
MacOS giving Undefined symbols for architecture x86_64
When using set_http_request_header on a MacOS, I get linker errors
= note: Undefined symbols for architecture x86_64:
"_proxy_remove_header_map_value", referenced from:
proxy_wasm::hostcalls::set_map_value::hc96c1a7a99f6f34a in libproxy_wasm-e355260dbc0dec8a.rlib(proxy_wasm-e355260dbc0dec8a.proxy_wasm.9pm5zsy4-cgu.1.rcgu.o)
"_proxy_get_shared_data", referenced from:
proxy_wasm::hostcalls::get_shared_data::hd8811788dfd1f02b in libproxy_wasm-e355260dbc0dec8a.rlib(proxy_wasm-e355260dbc0dec8a.proxy_wasm.9pm5zsy4-cgu.1.rcgu.o)
"_proxy_replace_header_map_value", referenced from:
proxy_wasm::hostcalls::set_map_value::hc96c1a7a99f6f34a in libproxy_wasm-e355260dbc0dec8a.rlib(proxy_wasm-e355260dbc0dec8a.proxy_wasm.9pm5zsy4-cgu.1.rcgu.o)
"_proxy_get_header_map_value", referenced from:
proxy_wasm::hostcalls::get_map_value::h5a56287dd21a2019 in libproxy_wasm-e355260dbc0dec8a.rlib(proxy_wasm-e355260dbc0dec8a.proxy_wasm.9pm5zsy4-cgu.1.rcgu.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Here's a testbed I was using to play around with
use proxy_wasm::traits::*;
use proxy_wasm::types::*;
struct MyFilter {
}
pub trait MyTrait {
fn set_http_request_header(&self, name: &str, value: Option<&str>) {
}
fn on_http_request_headers(&mut self, _: usize) -> Action {
Action::Continue
}
}
impl MyFilter {
fn add_token_to_headers(&mut self, token: Option<&str>) {
proxy_wasm::traits::HttpContext::set_http_request_header(self, "header_name", Some("token"));
//try proxy_wasm::traits::HttpContext:: or MyTrait::
}
}
impl MyTrait for MyFilter {
fn on_http_request_headers(&mut self, _: usize) -> Action {
self.add_token_to_headers(Some("token"));
//self.set_http_request_header("header_name", Some("token"));
Action::Continue
}
}
impl Context for MyFilter { }
impl HttpContext for MyFilter {
fn on_http_request_headers(&mut self, _: usize) -> Action {
self.add_token_to_headers(Some("token"));
//self.set_http_request_header("header_name", Some("token"));
Action::Continue
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_linkage() {
let mut filter = MyFilter {
};
//filter.add_token_to_headers(Some("token"));
proxy_wasm::traits::HttpContext::on_http_request_headers(&mut filter, usize::from_str_radix("A", 16).ok().unwrap());
//try proxy_wasm::traits::HttpContext:: or MyTrait::
}
}
MacBook Pro (15-inch, 2019) 2.6 GHz 6-Core Intel Core i7
Have you find a solution for this?
You need to be building for wasm32-wasip1 (or wasm32-unknown-unknown) target, i.e.
cargo build --target wasm32-wasip1 --release
(as described in README in all of the examples)