-
Notifications
You must be signed in to change notification settings - Fork 16
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
workarounds for clang-cl #87
base: master
Are you sure you want to change the base?
Conversation
✅ Build pvDataCPP 1.0.31 completed (commit 949f930bb9 by @xiaoqiangwang) |
This is indeed an ugly change. I'm not sure it is standards defined behavior. It is certainly not common practice. Although "common practice" would likely be a set of explicit specializations, which would be even more verbose. |
I've encountered a linker error while trying to build this change locally. This is on Linux with GCC 10.2.1. For my locally builds I set
There is a possibility that doing something like explicitly instantiating the destructor while have the effect of making the typeinfo visible, but this is a guess on my part. Overall, I expect that some alternate solution/workaround will need to be found. |
From my reading of the clang issue, the trigger is Line 386 in c16f19c
and the associated explicit specializations. pvDataCPP/src/factory/PVDataCreateFactory.cpp Lines 34 to 35 in c16f19c
An alternative pattern/trick to include constant values in a template instance, which might work better, would be to replace the pvDataCPP/src/pv/pvIntrospect.h Lines 1434 to 1439 in c16f19c
This is a bit uglier as it requires casting the "dummy" enum back into the actual type. eg. pvDataCPP/src/misc/pv/sharedVector.h Line 703 in c16f19c
However, an |
When updating, please |
Also as a note, I'm still not certain that I understand why this change can work at all. My thinking is that the presence of the explicit specializations of pvDataCPP/src/factory/PVDataCreateFactory.cpp Lines 34 to 35 in c16f19c
Reading https://en.cppreference.com/w/cpp/language/class_template I find this paragraph under "Explicit instantiation".
Which almost describes the situation, except for the |
clang-cl has a problem with static memeber variable llvm/llvm-project#54814. But it has no problem with constexpr member variable.
As searching for a better workaround, I found clang-cl works if typeCode has the constexpr specifier. The following change makes use of constexpr if C++11 is detected. xiaoqiangwang@c09f6d8 The change assumes that user code will not specialize |
Which would then be required when Will you be updating your PR? (I'd suggest retaining your current set of changes as a local branch) Also, how can eg. if we want an explicit error if this limitation is encountered, instead of failing with an obscure linker error. Would something like the following work? #if defined(_MSC_VER) && defined(__clang__) && __cplusplus < 201103L
# error clang-ci requires >= c++11
#endif |
Do I understand that to keep this PR, I would need to reset this branch (after backing up) and then apply the constexpr fixes.
I have the same question in the epics-base/epics-base#391 (comment).
I checked that "llvm-rc.exe"(needed for libcom module) is not created until LLVM 7, which defaults to C++14. So the minimum requirement could be probably simply imposed on the whole support of windows clang. Update: llvm-rc.exe cannot compile the Com.rc file until LLVM |
c6d285a
to
c87dcde
Compare
✅ Build pvDataCPP 1.0.34 completed (commit 71cbcf24a7 by @xiaoqiangwang) |
This is related to epics-base/epics-base#391 to add clang-cl compiler support to EPICS base.
I put this draft here and wish to hear whether clang-cl support is worth the rather ugly workaround.