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 failed when without RTTI (dynamic_cast not permitted with -fno-rtti) #1027

Closed
owent opened this issue Oct 23, 2021 · 5 comments · Fixed by #1294
Closed

Build failed when without RTTI (dynamic_cast not permitted with -fno-rtti) #1027

owent opened this issue Oct 23, 2021 · 5 comments · Fixed by #1294
Labels
bug Something isn't working do-not-stale help wanted Good for taking. Extra help will be provided by maintainers metrics

Comments

@owent
Copy link
Member

owent commented Oct 23, 2021

Describe your environment

Can not build with ENABLE_METRICS_PREVIEW and without RTTI -fno-rtti .

Steps to reproduce

cmake [...] -DWITH_METRICS_PREVIEW=ON "-DCMAKE_CXX_FLAGS=-fno-rtti"

What is the actual behavior?

2021-10-23T10:53:26.5426468Z /home/runner/work/cmake-toolset/cmake-toolset/test/third_party/packages/opentelemetry-cpp-v1.0.1/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h:408:31:   required from here
2021-10-23T10:53:26.5428857Z /home/runner/work/cmake-toolset/cmake-toolset/test/third_party/packages/opentelemetry-cpp-v1.0.1/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h:419:22: error: ‘dynamic_cast’ not permitted with ‘-fno-rtti’
2021-10-23T10:53:26.5430685Z   419 |       auto agg_ptr = dynamic_cast<BoundValueRecorder<T> *>(x.second.get())->GetAggregator();
2021-10-23T10:53:26.5431433Z       |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2021-10-23T10:53:26.5502316Z /home/runner/work/cmake-toolset/cmake-toolset/test/third_party/packages/opentelemetry-cpp-v1.0.1/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h: In instantiation of ‘std::vector<opentelemetry::v1::sdk::metrics::Record> opentelemetry::v1::sdk::metrics::ValueRecorder<T>::GetRecords() [with T = float]’:
2021-10-23T10:53:26.5504767Z /home/runner/work/cmake-toolset/cmake-toolset/test/third_party/packages/opentelemetry-cpp-v1.0.1/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h:408:31:   required from here
2021-10-23T10:53:26.5507189Z /home/runner/work/cmake-toolset/cmake-toolset/test/third_party/packages/opentelemetry-cpp-v1.0.1/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h:419:22: error: ‘dynamic_cast’ not permitted with ‘-fno-rtti’
2021-10-23T10:53:26.5600746Z /home/runner/work/cmake-toolset/cmake-toolset/test/third_party/packages/opentelemetry-cpp-v1.0.1/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h: In instantiation of ‘std::vector<opentelemetry::v1::sdk::metrics::Record> opentelemetry::v1::sdk::metrics::ValueRecorder<T>::GetRecords() [with T = int]’:
2021-10-23T10:53:26.5603182Z /home/runner/work/cmake-toolset/cmake-toolset/test/third_party/packages/opentelemetry-cpp-v1.0.1/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h:408:31:   required from here
2021-10-23T10:53:26.5605249Z /home/runner/work/cmake-toolset/cmake-toolset/test/third_party/packages/opentelemetry-cpp-v1.0.1/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h:419:22: error: ‘dynamic_cast’ not permitted with ‘-fno-rtti’
2021-10-23T10:53:26.5683511Z /home/runner/work/cmake-toolset/cmake-toolset/test/third_party/packages/opentelemetry-cpp-v1.0.1/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h: In instantiation of ‘std::vector<opentelemetry::v1::sdk::metrics::Record> opentelemetry::v1::sdk::metrics::ValueRecorder<T>::GetRecords() [with T = short int]’:
2021-10-23T10:53:26.5685919Z /home/runner/work/cmake-toolset/cmake-toolset/test/third_party/packages/opentelemetry-cpp-v1.0.1/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h:408:31:   required from here
2021-10-23T10:53:26.5688332Z /home/runner/work/cmake-toolset/cmake-toolset/test/third_party/packages/opentelemetry-cpp-v1.0.1/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h:419:22: error: ‘dynamic_cast’ not permitted with ‘-fno-rtti’
2021-10-23T10:53:26.5715576Z /home/runner/work/cmake-toolset/cmake-toolset/test/third_party/packages/opentelemetry-cpp-v1.0.1/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h: In instantiation of ‘std::vector<opentelemetry::v1::sdk::metrics::Record> opentelemetry::v1::sdk::metrics::UpDownCounter<T>::GetRecords() [with T = double]’:
2021-10-23T10:53:26.5718040Z /home/runner/work/cmake-toolset/cmake-toolset/test/third_party/packages/opentelemetry-cpp-v1.0.1/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h:279:31:   required from here
2021-10-23T10:53:26.5720128Z /home/runner/work/cmake-toolset/cmake-toolset/test/third_party/packages/opentelemetry-cpp-v1.0.1/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h:290:22: error: ‘dynamic_cast’ not permitted with ‘-fno-rtti’
2021-10-23T10:53:26.5721716Z   290 |       auto agg_ptr = dynamic_cast<BoundUpDownCounter<T> *>(x.second.get())->GetAggregator();
2021-10-23T10:53:26.5722357Z       |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@owent owent added the bug Something isn't working label Oct 23, 2021
@lalitb lalitb added the metrics label Nov 2, 2021
@hcoona
Copy link
Contributor

hcoona commented Nov 16, 2021

Strongly suggest use static_cast in release profile while use dynamic_cast only in debug profile with an option WITH_RTTI.

@lalitb
Copy link
Member

lalitb commented Nov 16, 2021

It's a bug in old metrics implementation which is been deprecated. The new metrics implementation is written from scratch and won't use any RTTI mechanisms.

@github-actions
Copy link

This issue was marked as stale due to lack of activity. It will be closed in 7 days if no furthur activity occurs.

@github-actions github-actions bot added the Stale label Jan 16, 2022
@lalitb lalitb added do-not-stale and removed Stale labels Jan 16, 2022
@lalitb lalitb added the help wanted Good for taking. Extra help will be provided by maintainers label Jan 26, 2022
@github-actions
Copy link

This issue was marked as stale due to lack of activity. It will be closed in 7 days if no furthur activity occurs.

@github-actions
Copy link

github-actions bot commented Apr 4, 2022

Closed as inactive. Feel free to reopen if this is still an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working do-not-stale help wanted Good for taking. Extra help will be provided by maintainers metrics
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants