Skip to content

1.20 no longer builds due to deprecated stuff being activated (solution suggestion included) #3354

@killerbot242

Description

@killerbot242

The problem is as follows (compiler output from clang, but similar for gcc), building with -std=c++23. And otel configured to use this standard.

[ 23%] Building CXX object _deps/opentelemetry-cpp-build/sdk/src/trace/CMakeFiles/opentelemetry_trace.dir/tracer_context.cc.o
In file included from /home/ldco/Projects/supernative/build/ClangRelease/_deps/opentelemetry-cpp-src/sdk/src/trace/tracer_context.cc:9:
In file included from /home/ldco/Projects/supernative/build/ClangRelease/_deps/opentelemetry-cpp-src/sdk/include/opentelemetry/sdk/instrumentationscope/scope_configurator.h:7:
In file included from /home/ldco/Projects/supernative/build/ClangRelease/_deps/opentelemetry-cpp-src/sdk/include/opentelemetry/sdk/instrumentationscope/instrumentation_scope.h:9:
In file included from /home/ldco/Projects/supernative/build/ClangRelease/_deps/opentelemetry-cpp-src/api/include/opentelemetry/common/key_value_iterable_view.h:18:
/home/ldco/Projects/supernative/build/ClangRelease/_deps/opentelemetry-cpp-src/api/include/opentelemetry/nostd/type_traits.h:145:73: error: builtin __has_trivial_copy is deprecated; use __is_trivially_copyable instead [-Werror,-Wdeprecated-builtins]
145 | static constexpr bool value = std::is_copy_constructible::value && __has_trivial_copy(T);
| ^
/home/ldco/Projects/supernative/build/ClangRelease/_deps/opentelemetry-cpp-src/api/include/opentelemetry/nostd/type_traits.h:157:70: error: builtin __has_trivial_assign is deprecated; use __is_trivially_assignable instead [-Werror,-Wdeprecated-builtins]
157 | static constexpr bool value = std::is_copy_assignable::value && __has_trivial_assign(T);
| ^

The root cause of this is that the file "api/include/opentelemetry/nostd/type_traits.h" has changed. In the previous versions, most of the file content was not active, due to the #if !defined(OPENTELEMETRY_HAVE_STD_TYPE_TRAITS) at the top, which only ended at the bottom of the file.
In 1.20 this is ending 5 lines further from where it starts. So much more code in this file is now active, till we reach the following section:

#ifdef OPENTELEMETRY_TRIVIALITY_TYPE_TRAITS
using std::is_trivially_copy_assignable;
using std::is_trivially_copy_constructible;
using std::is_trivially_move_assignable;
using std::is_trivially_move_constructible;
#else
template
struct is_trivially_copy_constructible
{
static constexpr bool value = std::is_copy_constructible::value && __has_trivial_copy(T);
};

template
struct is_trivially_move_constructible
{
static constexpr bool value = __is_trivial(T);
};

template
struct is_trivially_copy_assignable
{
static constexpr bool value = std::is_copy_assignable::value && __has_trivial_assign(T);
};

template
struct is_trivially_move_assignable
{
static constexpr bool value = __is_trivial(T);
};
#endif

In this file, now and also in previous versions "OPENTELEMETRY_TRIVIALITY_TYPE_TRAITS" is NOT defined. But in previous versions this did not matter for this file, since top ifdef disabled all the rest of the file.

Now who defines this, this is still the same as in the previous versions: api/include/opentelemetry/config.h
#if !defined(GLIBCXX) || OPENTELEMETRY_HAS_INCLUDE() // >= libstdc++-5

define OPENTELEMETRY_TRIVIALITY_TYPE_TRAITS

#endif

The define is active, I have checked, HOWEVER this file is not being included in type_trait.h.
If for example add the include, near the top:#include "opentelemetry/config.h"

=====> the builds is fine again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions