Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUILD] Clang-15 warning about __has_trivial_destructor #2502

Merged
merged 7 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,25 @@ jobs:
./ci/do_ci.sh cmake.test

cmake_gcc_maintainer_sync_test:
name: CMake gcc 12 (maintainer mode, sync)
name: CMake gcc 13 (maintainer mode, sync)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: setup
env:
CC: /usr/bin/gcc-12
CXX: /usr/bin/g++-12
CC: /usr/bin/gcc-13
CXX: /usr/bin/g++-13
PROTOBUF_VERSION: 21.12
run: |
sudo -E ./ci/setup_cmake.sh
sudo -E ./ci/setup_ci_environment.sh
sudo -E ./ci/install_protobuf.sh
- name: run cmake gcc (maintainer mode, sync)
env:
CC: /usr/bin/gcc-12
CXX: /usr/bin/g++-12
CC: /usr/bin/gcc-13
CXX: /usr/bin/g++-13
run: |
./ci/do_ci.sh cmake.maintainer.sync.test
- name: generate test cert
Expand All @@ -61,25 +61,25 @@ jobs:
(cd ./functional/otlp; ./run_test.sh)

cmake_gcc_maintainer_async_test:
name: CMake gcc 12 (maintainer mode, async)
name: CMake gcc 13 (maintainer mode, async)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: setup
env:
CC: /usr/bin/gcc-12
CXX: /usr/bin/g++-12
CC: /usr/bin/gcc-13
CXX: /usr/bin/g++-13
PROTOBUF_VERSION: 21.12
run: |
sudo -E ./ci/setup_cmake.sh
sudo -E ./ci/setup_ci_environment.sh
sudo -E ./ci/install_protobuf.sh
- name: run cmake gcc (maintainer mode, async)
env:
CC: /usr/bin/gcc-12
CXX: /usr/bin/g++-12
CC: /usr/bin/gcc-13
CXX: /usr/bin/g++-13
run: |
./ci/do_ci.sh cmake.maintainer.async.test
- name: generate test cert
Expand All @@ -93,25 +93,25 @@ jobs:
(cd ./functional/otlp; ./run_test.sh)

cmake_clang_maintainer_sync_test:
name: CMake clang 14 (maintainer mode, sync)
name: CMake clang 15 (maintainer mode, sync)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: setup
env:
CC: /usr/bin/clang-14
CXX: /usr/bin/clang++-14
CC: /usr/bin/clang-15
CXX: /usr/bin/clang++-15
PROTOBUF_VERSION: 21.12
run: |
sudo -E ./ci/setup_cmake.sh
sudo -E ./ci/setup_ci_environment.sh
sudo -E ./ci/install_protobuf.sh
- name: run cmake clang (maintainer mode, sync)
env:
CC: /usr/bin/clang-14
CXX: /usr/bin/clang++-14
CC: /usr/bin/clang-15
CXX: /usr/bin/clang++-15
run: |
./ci/do_ci.sh cmake.maintainer.sync.test
- name: generate test cert
Expand All @@ -125,25 +125,25 @@ jobs:
(cd ./functional/otlp; ./run_test.sh)

cmake_clang_maintainer_async_test:
name: CMake clang 14 (maintainer mode, async)
name: CMake clang 15 (maintainer mode, async)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: setup
env:
CC: /usr/bin/clang-14
CXX: /usr/bin/clang++-14
CC: /usr/bin/clang-15
CXX: /usr/bin/clang++-15
PROTOBUF_VERSION: 21.12
run: |
sudo -E ./ci/setup_cmake.sh
sudo -E ./ci/setup_ci_environment.sh
sudo -E ./ci/install_protobuf.sh
- name: run cmake clang (maintainer mode, async)
env:
CC: /usr/bin/clang-14
CXX: /usr/bin/clang++-14
CC: /usr/bin/clang-15
CXX: /usr/bin/clang++-15
run: |
./ci/do_ci.sh cmake.maintainer.async.test
- name: generate test cert
Expand All @@ -157,25 +157,25 @@ jobs:
(cd ./functional/otlp; ./run_test.sh)

cmake_clang_maintainer_abiv2_test:
name: CMake clang 14 (maintainer mode, abiv2)
name: CMake clang 15 (maintainer mode, abiv2)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: setup
env:
CC: /usr/bin/clang-14
CXX: /usr/bin/clang++-14
CC: /usr/bin/clang-15
CXX: /usr/bin/clang++-15
PROTOBUF_VERSION: 21.12
run: |
sudo -E ./ci/setup_cmake.sh
sudo -E ./ci/setup_ci_environment.sh
sudo -E ./ci/install_protobuf.sh
- name: run cmake clang (maintainer mode, abiv2)
env:
CC: /usr/bin/clang-14
CXX: /usr/bin/clang++-14
CC: /usr/bin/clang-15
CXX: /usr/bin/clang++-15
run: |
./ci/do_ci.sh cmake.maintainer.abiv2.test
- name: generate test cert
Expand Down
13 changes: 13 additions & 0 deletions api/include/opentelemetry/nostd/internal/absl/base/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ static_assert(OTABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' ||
#ifdef OTABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE
#error OTABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE cannot be directly set
#elif defined(_LIBCPP_VERSION) || \
(defined(__clang__) && __clang_major__ >= 15) || \
(!defined(__clang__) && defined(__GNUC__) && defined(__GLIBCXX__) && \
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))) || \
defined(_MSC_VER)
Expand All @@ -194,6 +195,7 @@ static_assert(OTABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' ||
#elif defined(OTABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE)
#error OTABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE cannot directly set
#elif (defined(__clang__) && defined(_LIBCPP_VERSION)) || \
(defined(__clang__) && __clang_major__ >= 15) || \
(!defined(__clang__) && defined(__GNUC__) && \
(__GNUC__ > 7 || (__GNUC__ == 7 && __GNUC_MINOR__ >= 4)) && \
(defined(_LIBCPP_VERSION) || defined(__GLIBCXX__))) || \
Expand All @@ -202,6 +204,17 @@ static_assert(OTABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' ||
#define OTABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE 1
#endif

// OTABSL_HAVE_STD_IS_TRIVIALLY_COPYABLE
//
// Checks whether `std::is_trivially_copyable<T>` is supported.
//
// Notes: Clang 15+ with libc++ supports these features, GCC hasn't been tested.
#if defined(OTABSL_HAVE_STD_IS_TRIVIALLY_COPYABLE)
#error OTABSL_HAVE_STD_IS_TRIVIALLY_COPYABLE cannot be directly set
#elif defined(__clang__) && (__clang_major__ >= 15)
#define OTABSL_HAVE_STD_IS_TRIVIALLY_COPYABLE 1
#endif

// OTABSL_HAVE_SOURCE_LOCATION_CURRENT
//
// Indicates whether `absl::SourceLocation::current()` will return useful
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,12 @@ struct is_function
// https://gcc.gnu.org/onlinedocs/gcc/Type-Traits.html#Type-Traits.
template <typename T>
struct is_trivially_destructible
#ifdef OTABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE
: std::is_trivially_destructible<T> {
#else
: std::integral_constant<bool, __has_trivial_destructor(T) &&
std::is_destructible<T>::value> {
#endif
#ifdef OTABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE
private:
static constexpr bool compliant = std::is_trivially_destructible<T>::value ==
Expand Down Expand Up @@ -345,9 +349,13 @@ struct is_trivially_destructible
// Nontrivially destructible types will cause the expression to be nontrivial.
template <typename T>
struct is_trivially_default_constructible
#if defined(OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE)
: std::is_trivially_default_constructible<T> {
#else
: std::integral_constant<bool, __has_trivial_constructor(T) &&
std::is_default_constructible<T>::value &&
is_trivially_destructible<T>::value> {
#endif
#if defined(OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE) && \
!defined( \
OTABSL_META_INTERNAL_STD_CONSTRUCTION_TRAITS_DONT_CHECK_DESTRUCTION)
Expand Down Expand Up @@ -379,10 +387,14 @@ struct is_trivially_default_constructible
// expression to be nontrivial.
template <typename T>
struct is_trivially_move_constructible
#if defined(OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE)
: std::is_trivially_move_constructible<T> {
#else
: std::conditional<
std::is_object<T>::value && !std::is_array<T>::value,
type_traits_internal::IsTriviallyMoveConstructibleObject<T>,
std::is_reference<T>>::type::type {
#endif
#if defined(OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE) && \
!defined( \
OTABSL_META_INTERNAL_STD_CONSTRUCTION_TRAITS_DONT_CHECK_DESTRUCTION)
Expand Down Expand Up @@ -488,9 +500,13 @@ struct is_trivially_move_assignable
// `is_trivially_assignable<T&, const T&>`.
template <typename T>
struct is_trivially_copy_assignable
#ifdef OTABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE
: std::is_trivially_copy_assignable<T> {
#else
: std::integral_constant<
bool, __has_trivial_assign(typename std::remove_reference<T>::type) &&
absl::is_copy_assignable<T>::value> {
#endif
#ifdef OTABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE
private:
static constexpr bool compliant =
Expand Down Expand Up @@ -521,6 +537,11 @@ namespace type_traits_internal {
// destructible. Arrays of trivially copyable types are trivially copyable.
//
// We expose this metafunction only for internal use within absl.

#if defined(OTABSL_HAVE_STD_IS_TRIVIALLY_COPYABLE)
template <typename T>
struct is_trivially_copyable : std::is_trivially_copyable<T> {};
#else
template <typename T>
class is_trivially_copyable_impl {
using ExtentsRemoved = typename std::remove_all_extents<T>::type;
Expand All @@ -546,6 +567,7 @@ template <typename T>
struct is_trivially_copyable
: std::integral_constant<
bool, type_traits_internal::is_trivially_copyable_impl<T>::kValue> {};
#endif
} // namespace type_traits_internal

// -----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion api/test/common/spinlock_benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ inline void SpinThrash(benchmark::State &s, SpinLockType &spinlock, LockF lock,
// Value we will increment, fighting over a spinlock.
// The contention is meant to be brief, as close to our expected
// use cases of "updating pointers" or "pushing an event onto a buffer".
std::int64_t value = 0;
std::int64_t value OPENTELEMETRY_MAYBE_UNUSED = 0;

std::vector<std::thread> threads;
threads.reserve(num_threads);
Expand Down