-
Notifications
You must be signed in to change notification settings - Fork 438
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 (Windows) #1595
Conversation
The first commit fails 18 checks, which is actually good. This commit only contains the unit test, which fails, showing that the unit test logic is working. |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #1595 +/- ##
==========================================
+ Coverage 85.24% 85.30% +0.07%
==========================================
Files 156 156
Lines 4978 4978
==========================================
+ Hits 4243 4246 +3
+ Misses 735 732 -3
|
@@ -99,7 +99,8 @@ | |||
#elif defined(__GNUC__) | |||
# define OPENTELEMETRY_API_SINGLETON __attribute__((visibility("default"))) | |||
#elif defined(_MSC_VER) | |||
# define OPENTELEMETRY_API_SINGLETON | |||
/* Tentative fix */ | |||
# define OPENTELEMETRY_API_SINGLETON __declspec(selectany) |
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.
Just wondering why __declspec(selectany)
is removed?Doesn't it work with MSVC on Windows?
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.
__declspec(selectany)
works when applied to a member.
This PR tested applying it to a method, which failed to compile.
See places where OPENTELEMETRY_API_SINGLETON
is used in this patch,
which are different compared to PR#1525
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.
Could we also add __declspec(selectany)
to variables, so we can also support dll on Windows with MSVC?
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.
@owent, see file macros.h in the latest push.
commit 74ec691 Author: WenTao Ou <[email protected]> Date: Thu Apr 7 14:06:59 2022 +0800 Move public definitions into `opentelemetry_api`. (open-telemetry#1314) Signed-off-by: owent <[email protected]> When using WITH_STL in cmake, HAVE_CPP_STDLIB must be defined for unit tests.
I think that the only way to make Windows dll work is to have the |
See Status as of Sept 7:
So, at this point, we can:
I don't have access to a windows machine, and can not debug, so help is most welcome. Testing is needed on windows to see if the fix can at least work with .LIB alone. Testing is also needed to see if gcc/clang on windows can work, and see if changes are needed in the macros.h header for that. If it turns out there is no solution for windows, then the only option will be to have a windows DLL for the api singletons, which is causing other issues. |
Could you please show the codes about the not working |
Agree to merge the visibility changes for unix like system first, and we can continue to find a better solution for Windows later. I can help to test it some times later, the problem may be the dll can not be found by exe. Unlike Linux, the executable on Windows do not have a |
I would really like to get a solution for non windows into a release so we can create packages based on an actual opentelemetry-cpp release rather than taking one and patching it. |
I'll try to find some time to test this with just static linking on Windows and to try to at least build this shared on Windows.
My expectation is that this is unfortunately going to be the option that will we will end up with for Windows DLLs. |
Sorry, but I found BTW: |
include(GoogleTest) | ||
|
||
add_library(component_a STATIC component_a.cc) | ||
|
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.
target_link_libraries(component_a opentelemetry_api)
is required here to import macros from opentelemetry_api
by target_compile_definitions(opentelemetry_api INTERFACE ...)
.
So do component_c
, component_d
, component_e
and component_f
.
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.
Thanks, will fix.
To clarify my understanding: Does the fix work with simply static libraries (.LIB), for component_a and component_b alone ? If so, at least we will have a solution for windows static libs only, which is better than none. Thanks. |
proper cmake dependency in opentelemetry-api
only test static libraries for windows.
Yes.
Static libraries (.LIB) do not has a standalone heap. I think it works well as before. |
Yes, static libraries should work fine for all the platforms in the existing setup. |
testing CI with windows static lib, no annotation
Status: This PR, 1595, is kept open to continue investigation for windows. The fix for gcc and clang, which is working, is to be merged in PR #1604. |
Added the help wanted tag. Not a windows expert, so anyone with more knowledge is welcome to investigate, |
Fix header only API for singletons (#1520)
Changes
Alternate solution, test annotation on methods instead of members
For significant contributions please make sure you have completed the following items:
CHANGELOG.md
updated for non-trivial changes