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); # commit 3a6f049c123a1906c7381e824292c18fd8698293 # Author: Christian Neumüller # Date: Wed Feb 27 01:48:17 2019 +0100 # # Fix MSVC compiler flags. (#104) # # * All debug specific flags would be replaced by release specific on MSVC. # * The OPENTRACING_STATIC flag would be missing from OpenTracingConfig.cmake when linking against OpenTracing::opentracing-static # diff --git a/CMakeLists.txt b/CMakeLists.txt index 1721fb3..3873b3a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,7 +52,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_RELEASE} -D_SCL_SECURE_NO_WARNINGS") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_SCL_SECURE_NO_WARNINGS") endif() # ==============================================================================