-
Notifications
You must be signed in to change notification settings - Fork 440
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
[POC RFC] header only API for singletons #1525
Conversation
Fix header only API for singletons (open-telemetry#1520)
Fixed asan build
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #1525 +/- ##
==========================================
- Coverage 85.02% 84.94% -0.07%
==========================================
Files 156 156
Lines 4977 4959 -18
==========================================
- Hits 4231 4212 -19
- Misses 746 747 +1
|
Did a quick test with this PR on Linux, by creating an instrumented library with Need to check on Windows, but based on what @owent has already tested here, it may not work with PE ABI as |
I have add more examples here, and |
Resources: Paper from Ulrich Drepper, see section 2.2 export control, page 17: https://akkadia.org/drepper/dsohowto.pdf Gnu visibility doc |
I have a quick look at https://akkadia.org/drepper/dsohowto.pdf, I think it's for ELF ABI of Linux, not PE ABI of Windows. My question is: is there any way to make the singleton unique with GCC on Windows? |
@owent - We agreed this PR to be scoped for Linux and Mac. Let us know if you have any comment on that. |
Fine by me. I think we can document this if we do not support build shared library with gcc and clang on Windows, can we also force set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, Do we need set BUILD_SHARED_LIB
to OFF
with gcc on Windows to avoid misuse?
I added a singleton_test unit test, and makefiles for both CMake and Bazel. This test does not build properly on windows platforms, and I can not figure out why. "component_c" is compiled as a shared library / DDL (expected), On linux, the same makefile with cmake properly builds static libraries (component_a, component_b) and shared libraries (component_c, d, e and f) as expected. For bazel, I could not find a proper way to express in the BUILD file how to link a test binary singleton_test with a mix of static (component_a and b) and shared (component_c, d, e and f) libraries. Any help appreciated, the goal is to have first a unit test that builds everywhere. Regards, |
@@ -29,8 +44,8 @@ class Provider | |||
*/ | |||
static nostd::shared_ptr<MeterProvider> GetMeterProvider() noexcept | |||
{ | |||
std::lock_guard<common::SpinLockMutex> guard(lock); | |||
nostd::shared_ptr<MeterProvider> result(provider); | |||
std::lock_guard<common::SpinLockMutex> guard(s.lock); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should not use a short name here
Do we need declare To my knowledge, MSVC will create both |
Good point, fixing this. Thanks |
This PR contains proof of concept code, for a general fix. It is now closed, for the benefit of:
Work for windows should continue in PR #1595. |
Fix header only API for singletons (#1520)
Changes
DRAFT -- implement header only API singletons.
CHANGELOG.md
updated for non-trivial changes