diff --git a/src/runtime/hexagon/rpc/simulator/rpc_server.cc b/src/runtime/hexagon/rpc/simulator/rpc_server.cc index 29373be542f3..9b4ce3f11443 100644 --- a/src/runtime/hexagon/rpc/simulator/rpc_server.cc +++ b/src/runtime/hexagon/rpc/simulator/rpc_server.cc @@ -18,6 +18,7 @@ */ #include +#include #include #include @@ -288,7 +289,16 @@ int DISPATCH_FUNCTION_NAME(void* serverp) { return 0; } -int main() { +int main(int argc, char* argv[]) { + // Load C++RT and ourselves as "global" to make all the symbols defined + // there be visible to any subsequent libraries loaded via dlopen. + void* cxx_abi = dlopen("libc++abi.so", RTLD_GLOBAL); + ICHECK(cxx_abi != nullptr); + void* cxx = dlopen("libc++.so", RTLD_GLOBAL); + ICHECK(cxx != nullptr); + void* self = dlopen(argv[0], RTLD_GLOBAL); + ICHECK(self != nullptr); + const auto* api = tvm::runtime::Registry::Get("device_api.hexagon"); ICHECK(api != nullptr); tvm::runtime::Registry::Register("device_api.cpu", true).set_body(*api); @@ -308,6 +318,9 @@ int main() { // nothing } + dlclose(self); + dlclose(cxx); + dlclose(cxx_abi); return 0; }