From 1060f882be902922843e1455b3a21cbb7e242464 Mon Sep 17 00:00:00 2001 From: WenTao Ou Date: Wed, 9 Jun 2021 11:42:44 +0800 Subject: [PATCH] Fix issue #834 (#835) --- .bazelrc | 3 ++ CMakeLists.txt | 4 +-- api/CMakeLists.txt | 4 +++ api/include/opentelemetry/nostd/variant.h | 2 +- .../sdk/trace/multi_span_processor.h | 2 +- sdk/src/common/core.cc | 28 ------------------- 6 files changed, 11 insertions(+), 32 deletions(-) diff --git a/.bazelrc b/.bazelrc index a10ad12060..7a1fead515 100644 --- a/.bazelrc +++ b/.bazelrc @@ -19,3 +19,6 @@ common:tsan --copt -fsanitize=thread common:tsan --copt -DTHREAD_SANITIZER common:tsan --linkopt -fsanitize=thread common:tsan --cc_output_directory_tag=tsan +# This is needed to address false positive problem with abseil.The same setting as gRPC +# https://github.com/google/sanitizers/issues/953 +common:tsan --test_env=TSAN_OPTIONS=report_atomic_races=0 diff --git a/CMakeLists.txt b/CMakeLists.txt index c8bce5be1f..c9fd35d8aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,10 +50,10 @@ option(WITH_STL "Whether to use Standard Library for C++latest features" OFF) option(WITH_ABSEIL "Whether to use Abseil for C++latest features" OFF) if(WITH_ABSEIL) - add_definitions(-DHAVE_ABSEIL) find_package(absl CONFIG REQUIRED) - set(CORE_RUNTIME_LIBS absl::any absl::base absl::bits absl::city) + set(CORE_RUNTIME_LIBS absl::bad_variant_access absl::any absl::base + absl::bits absl::city) # target_link_libraries(main PRIVATE absl::any absl::base absl::bits # absl::city) diff --git a/api/CMakeLists.txt b/api/CMakeLists.txt index 20d786e0cb..89839b48be 100644 --- a/api/CMakeLists.txt +++ b/api/CMakeLists.txt @@ -41,6 +41,10 @@ if(BUILD_TESTING) add_subdirectory(test) endif() +if(WITH_ABSEIL) + target_compile_definitions(opentelemetry_api INTERFACE HAVE_ABSEIL) +endif() + if(WITH_STL) message("Building with standard library types...") target_compile_definitions(opentelemetry_api INTERFACE HAVE_CPP_STDLIB diff --git a/api/include/opentelemetry/nostd/variant.h b/api/include/opentelemetry/nostd/variant.h index cab15547fe..c2c04ad41b 100644 --- a/api/include/opentelemetry/nostd/variant.h +++ b/api/include/opentelemetry/nostd/variant.h @@ -47,7 +47,7 @@ OPENTELEMETRY_END_NAMESPACE # endif # ifdef HAVE_ABSEIL -# include "absl/types/variant.h" +# include # else # include "./absl/types/variant.h" # endif diff --git a/sdk/include/opentelemetry/sdk/trace/multi_span_processor.h b/sdk/include/opentelemetry/sdk/trace/multi_span_processor.h index a273710bd7..8463ad5209 100644 --- a/sdk/include/opentelemetry/sdk/trace/multi_span_processor.h +++ b/sdk/include/opentelemetry/sdk/trace/multi_span_processor.h @@ -148,7 +148,7 @@ class MultiSpanProcessor : public SpanProcessor ProcessorNode(std::unique_ptr &&value, ProcessorNode *prev = nullptr, ProcessorNode *next = nullptr) - : value_(std::move(value)), prev_(prev), next_(next) + : value_(std::move(value)), next_(next), prev_(prev) {} }; diff --git a/sdk/src/common/core.cc b/sdk/src/common/core.cc index 2bc6da52a9..16012e765c 100644 --- a/sdk/src/common/core.cc +++ b/sdk/src/common/core.cc @@ -6,31 +6,3 @@ #include "opentelemetry/version.h" #include "opentelemetry/nostd/variant.h" // clang-format on - -#if defined(HAVE_ABSEIL) -/* The option of building and linking with Abseil library implies that Abseil - * may already provide the ThrowBadVariantAccess implementation if its own. - * Reconsider the implementation below: we are potentially introducing - * a function that is already implemented in the Abseil. Most likely the code - * below needs to be removed entirely. - */ -# if defined(__GNUC__) || defined(__GNUG__) -# ifndef __cdecl -// see https://gcc.gnu.org/onlinedocs/gcc/x86-Function-Attributes.html -// Intel x86 architecture specific calling conventions -# ifdef _M_IX86 -# define __cdecl __attribute__((__cdecl__)) -# else -# define __cdecl -# endif -# endif -# endif - -namespace absl -{ -namespace variant_internal -{ -void __cdecl ThrowBadVariantAccess(){/* TODO: std::terminate or re-throw? */}; -} -} // namespace absl -#endif