From 7ab52102815a3ceacc8c8a35317551c7df81e866 Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Thu, 24 Oct 2019 16:18:20 +0000 Subject: [PATCH] fix envoy build Signed-off-by: Lizan Zhou --- mocktracer/BUILD | 2 ++ src/dynamic_load_unix.cpp | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/mocktracer/BUILD b/mocktracer/BUILD index 3b22bab..d425e2e 100644 --- a/mocktracer/BUILD +++ b/mocktracer/BUILD @@ -7,11 +7,13 @@ cc_library( deps = [ "//:opentracing", ], + alwayslink = 1, ) cc_binary( name = "libmocktracer_plugin.so", linkshared = 1, + linkstatic = 1, visibility = ["//visibility:public"], deps = [ "//mocktracer:mocktracer" diff --git a/src/dynamic_load_unix.cpp b/src/dynamic_load_unix.cpp index 17e08fd..7e8ac02 100644 --- a/src/dynamic_load_unix.cpp +++ b/src/dynamic_load_unix.cpp @@ -35,7 +35,13 @@ DynamicallyLoadTracingLibrary(const char* shared_library, std::string& error_message) noexcept try { dlerror(); // Clear any existing error. - const auto handle = dlopen(shared_library, RTLD_NOW | RTLD_LOCAL); + const auto handle = dlopen(shared_library, RTLD_NOW | RTLD_LOCAL +#if defined(__has_feature) +#if __has_feature(address_sanitizer) + | RTLD_NODELETE +#endif +#endif + ); if (handle == nullptr) { error_message = dlerror(); return make_unexpected(dynamic_load_failure_error);