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

circular_buffer.h fails to compile on Win32 because of a conversion from uint64_t to size_t #842

Closed
BuildMan-Alpha opened this issue Jun 10, 2021 · 7 comments · Fixed by #847
Assignees
Labels
bug Something isn't working metrics release:after-ga To be resolved after GA release

Comments

@BuildMan-Alpha
Copy link

Describe your environment
Win32 Compile using Visual Studio 2019 (16.10.0)

Steps to reproduce
Run CMake with -G "Visual Studio 16 2019" -A "Win32" "-DBUILD_TESTING=OFF" "c:\dev\AA3rdPartyExt\opentelemetry-cpp" "-DCMAKE_TOOLCHAIN_FILE=C:\dev\vcpkg\scripts\buildsystems\vcpkg.cmake" "-DCMAKE_PREFIX_PATH=c:\dev\AA3rdPartyExt\Build\nlohmann_json\VS16\Win32;c:\dev\AA3rdPartyExt\Build\googletest\VS16\Win32" -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DWITH_PROMETHEUS=ON

What is the expected behavior?
Clean compile

What is the actual behavior?
C:\dev\AA3rdPartyExt\opentelemetry-cpp\sdk\include\opentelemetry/sdk/common/circular_buffer.h(146,17): warning C4244: 'return': conversion from 'uint64_t' to 'size_t', possible loss of data [C:\dev\AA3rdPartyExt\Build\opentelemetry-cpp\VS16\Win32\sdk\src\trace\opentelemetry_trace.vcxproj]
C:\dev\AA3rdPartyExt\opentelemetry-cpp\sdk\include\opentelemetry/sdk/common/circular_buffer.h(142): message : while compiling class template member function 'size_t opentelemetry::v0::sdk::common::CircularBufferopentelemetry::v0::sdk::trace::Recordable::size(void) noexcept const' [C:\dev\AA3rdPartyExt\Build\opentelemetry-cpp\VS16\Win32\sdk\src\trace\opentelemetry_trace.vcxproj]
C:\dev\AA3rdPartyExt\opentelemetry-cpp\sdk\src\trace\batch_span_processor.cc(51): message : see reference to function template instantiation 'size_t opentelemetry::v0::sdk::common::CircularBufferopentelemetry::v0::sdk::trace::Recordable::size(void) noexcept const' being compiled [C:\dev\AA3rdPartyExt\Build\opentelemetry-cpp\VS16\Win32\sdk\src\trace\opentelemetry_trace.vcxproj]
C:\dev\AA3rdPartyExt\opentelemetry-cpp\sdk\include\opentelemetry/sdk/trace/batch_span_processor.h(145): message : see reference to class template instantiation 'opentelemetry::v0::sdk::common::CircularBufferopentelemetry::v0::sdk::trace::Recordable' being compiled [C:\dev\AA3rdPartyExt\Build\opentelemetry-cpp\VS16\Win32\sdk\src\trace\opentelemetry_trace.vcxproj]
C:\dev\AA3rdPartyExt\opentelemetry-cpp\sdk\include\opentelemetry/sdk/common/circular_buffer.h(96,17): warning C4244: 'argument': conversion from 'uint64_t' to 'size_t', possible loss of data [C:\dev\AA3rdPartyExt\Build\opentelemetry-cpp\VS16\Win32\sdk\src\trace\opentelemetry_trace.vcxproj]
C:\dev\AA3rdPartyExt\opentelemetry-cpp\sdk\include\opentelemetry/sdk/common/circular_buffer.h(83): message : while compiling class template member function 'bool opentelemetry::v0::sdk::common::CircularBufferopentelemetry::v0::sdk::trace::Recordable::Add(std::unique_ptr<opentelemetry::v0::sdk::trace::Recordable,std::default_deleteopentelemetry::v0::sdk::trace::Recordable> &) noexcept' [C:\dev\AA3rdPartyExt\Build\opentelemetry-cpp\VS16\Win32\sdk\src\trace\opentelemetry_trace.vcxproj]
C:\dev\AA3rdPartyExt\opentelemetry-cpp\sdk\src\trace\batch_span_processor.cc(44): message : see reference to function template instantiation 'bool opentelemetry::v0::sdk::common::CircularBufferopentelemetry::v0::sdk::trace::Recordable::Add(std::unique_ptr<opentelemetry::v0::sdk::trace::Recordable,std::default_deleteopentelemetry::v0::sdk::trace::Recordable> &) noexcept' being compiled [C:\dev\AA3rdPartyExt\Build\opentelemetry-cpp\VS16\Win32\sdk\src\trace\opentelemetry_trace.vcxproj]
C:\dev\AA3rdPartyExt\opentelemetry-cpp\sdk\include\opentelemetry/sdk/common/circular_buffer.h(112,15): warning C4244: 'argument': conversion from 'uint64_t' to 'size_t', possible loss of data [C:\dev\AA3rdPartyExt\Build\opentelemetry-cpp\VS16\Win32\sdk\src\trace\opentelemetry_trace.vcxproj]
C:\dev\AA3rdPartyExt\opentelemetry-cpp\sdk\include\opentelemetry/sdk/common/circular_buffer.h(177,73): error C2398: Element '2': conversion from 'uint64_t' to 'size_t' requires a narrowing conversion [C:\dev\AA3rdPartyExt\Build\opentelemetry-cpp\VS16\Win32\sdk\src\trace\opentelemetry_trace.vcxproj]
C:\dev\AA3rdPartyExt\opentelemetry-cpp\sdk\include\opentelemetry/sdk/common/circular_buffer.h(166): message : while compiling class template member function 'opentelemetry::v0::sdk::common::CircularBufferRange<opentelemetry::v0::sdk::common::AtomicUniquePtr> opentelemetry::v0::sdk::common::CircularBuffer::PeekImpl(void) noexcept' [C:\dev\AA3rdPartyExt\Build\opentelemetry-cpp\VS16\Win32\sdk\src\trace\opentelemetry_trace.vcxproj]
with
[
T=opentelemetry::v0::sdk::trace::Recordable
]
C:\dev\AA3rdPartyExt\opentelemetry-cpp\sdk\include\opentelemetry/sdk/common/circular_buffer.h(55): message : see reference to function template instantiation 'opentelemetry::v0::sdk::common::CircularBufferRange<opentelemetry::v0::sdk::common::AtomicUniquePtr> opentelemetry::v0::sdk::common::CircularBuffer::PeekImpl(void) noexcept' being compiled [C:\dev\AA3rdPartyExt\Build\opentelemetry-cpp\VS16\Win32\sdk\src\trace\opentelemetry_trace.vcxproj]
with
[
T=opentelemetry::v0::sdk::trace::Recordable
]
C:\dev\AA3rdPartyExt\opentelemetry-cpp\sdk\include\opentelemetry/sdk/common/circular_buffer.h(177,73): warning C4244: 'argument': conversion from 'uint64_t' to 'size_t', possible loss of data [C:\dev\AA3rdPartyExt\Build\opentelemetry-cpp\VS16\Win32\sdk\src\trace\opentelemetry_trace.vcxproj]
C:\dev\AA3rdPartyExt\opentelemetry-cpp\sdk\include\opentelemetry/sdk/common/circular_buffer.h(179,74): error C2398: Element '2': conversion from 'uint64_t' to 'size_t' requires a narrowing conversion [C:\dev\AA3rdPartyExt\Build\opentelemetry-cpp\VS16\Win32\sdk\src\trace\opentelemetry_trace.vcxproj]
C:\dev\AA3rdPartyExt\opentelemetry-cpp\sdk\include\opentelemetry/sdk/common/circular_buffer.h(179,74): warning C4244: 'argument': conversion from 'uint64_t' to 'size_t', possible loss of data [C:\dev\AA3rdPartyExt\Build\opentelemetry-cpp\VS16\Win32\sdk\src\trace\opentelemetry_trace.vcxproj]
C:\dev\AA3rdPartyExt\opentelemetry-cpp\sdk\include\opentelemetry/sdk/common/circular_buffer.h(180,51): error C2398: Element '2': conversion from 'uint64_t' to 'size_t' requires a narrowing conversion [C:\dev\AA3rdPartyExt\Build\opentelemetry-cpp\VS16\Win32\sdk\src\trace\opentelemetry_trace.vcxproj]
C:\dev\AA3rdPartyExt\opentelemetry-cpp\sdk\include\opentelemetry/sdk/common/circular_buffer.h(180,51): warning C4244: 'argument': conversion from 'uint64_t' to 'size_t', possible loss of data [C:\dev\AA3rdPartyExt\Build\opentelemetry-cpp\VS16\Win32\sdk\src\trace\opentelemetry_trace.vcxproj]
Additional context

@BuildMan-Alpha BuildMan-Alpha added the bug Something isn't working label Jun 10, 2021
@maxgolov
Copy link
Contributor

OpenTelemetry C++ SDK v1.0 will not have support for Metrics. These features are experimental and were turned off by WITH_METRICS_PREVIEW=OFF, which in turn does not enable WITH_PROMETHEUS. Please compile without prometheus. We'd be able to tackle this after v1.0 GA.

@lalitb

@maxgolov maxgolov added metrics release:after-ga To be resolved after GA release labels Jun 10, 2021
@maxgolov
Copy link
Contributor

Re. Win32 vs x64 issue - please use x64 for now. We'd address the x86 on Windows promptly (without prometheus support though!).

@ThomsonTan
Copy link
Contributor

@maxgolov is prometheus 64-bit only?

@maxgolov
Copy link
Contributor

maxgolov commented Jun 10, 2021

@ThomsonTan - no, it appears like Visual Studio 2019 is rather strict with type conversion. There's common issue with Win32.

All of our CI so far has been x64 only (for Linux, Mac, Windows). And we never caught a few issues in common core code with Win32 / x86... Some of these are new warnings, that were quite lax in older version of the compiler.

I think there are two separate tasks here:

  • P1: clean-up x86 building without Prometheus, without Metrics, without Logs Preview. This has to happen for v1.0 GA, because we do not deliver Prometheus for v1.

  • P∞: clean-up x86 for the rest of optional code, including experimental + Prometheus. That is after v1.0 by the end of this year. I expect there would be more clean-up needed in additional things we are not intending to release for v1 ( for WITH_METRICS_PREVIEW , WITH_LOGS_PREVIEW , WITH_PROMETHEUS ).

I'll send out the fix for basic / common core components for Win32 / x86. Almost done. Again - cleaning up the core only for Win32, without metrics / prometheus pieces. It also needs a few patches to CMakeLists.txt to auto-install the missing deps via vcpkg. The scripts already support ARCH variable to install the proper parts, just need to pass the right variable (ARCH=x86) in function(install_windows_deps) , that'll satisfy the deps even if building Win32 configuration via Visual Studio 2019 IDE.

@BuildMan-Alpha
Copy link
Author

BuildMan-Alpha commented Jun 11, 2021 via email

@BuildMan-Alpha
Copy link
Author

BuildMan-Alpha commented Jun 11, 2021 via email

@maxgolov
Copy link
Contributor

@BuildMan-Alpha - we'll make the core work well with 32-bit before July 1st. All core tests work and pass with the fix I sent for review. #847 ... Once we get there, we'll set up the build loop for Win32 / x86, and incrementally add the other components, including Logs and Metrics. I hit some minor issue with Prometheus (Metrics) on Win32. Thus, I want to take staged approach. Fixing core first. Then fixing Metrics right after.

@maxgolov maxgolov self-assigned this Jun 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working metrics release:after-ga To be resolved after GA release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants