protocolbuffers / protobuf

Protocol Buffers - Google's data interchange format
http://protobuf.dev
Other
65.21k stars 15.44k forks source link

build of grpc with protobuf dependency ends up with error in upb_message_lib #17238

Open DmitriiGorelov opened 2 months ago

DmitriiGorelov commented 2 months ago

At first I reported the issue in https://github.com/grpc/grpc/issues/37043, but got an answer that the problem belongs to protobuf dependency and was forwarded to this bug report page. To be precise, message.c in upb_message_lib does not compille due to errors described below. Please suggest the solution.

What version of gRPC and what language are you using?

grpc tag v.1.64.X with C++20 
and grpc tag v.1.56.0 with C++17
C++ using msvc 2022 community

What operating system (Linux, Windows,...) and version?

Windows 10

What runtime / compiler are you using (e.g. python version or version of gcc)

VC143

What did you do?

I try to build grpc from sources with the following commands:

IF NOT EXIST grpc\ (    
    git clone -b v1.64.2 https://github.com/grpc/grpc   
)

cd grpc
if %errorlevel% neq 0 exit

git submodule update --init

md .install_release
md .install_debug

cd cmake
md build_release
cd build_release

cmake ../.. -G "Visual Studio 17 2022" -A x64 -DgRPC_INSTALL=ON -DCMAKE_INSTALL_PREFIX=c:\dev\grpc\.install_release 
-DCMAKE_BUILD_TYPE=Release 
-DBUILD_SHARED_LIBS=OFF 
-DgRPC_ABSL_PROVIDER=module 
-DgRPC_CARES_PROVIDER=none 
-DgRPC_PROTOBUF_PROVIDER=module 
-DgRPC_RE2_PROVIDER=module 
-DgRPC_SSL_PROVIDER=module 
-DgRPC_ZLIB_PROVIDER=module     
-DgRPC_GFLAGS_PROVIDER=none 
-DgRPC_BENCHMARK_PROVIDER=none 
-DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$<CONFIG:Release>:Release>" 
-DCMAKE_CXX_STANDARD=20
-DCMAKE_CXX_STANDARD_REQUIRED=ON 
-DCMAKE_CXX_EXTENSIONS=OFF 
-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded 
-DgRPC_STATIC_LINKING=ON 
-DgRPC_MSVC_STATIC_RUNTIME=ON 
-DgRPC_BUILD_CODEGEN=ON 
-DgRPC_BUILD_GRPC_CPP_PLUGIN=ON 
-DgRPC_BUILD_GRPC_CSHARP_PLUGIN=ON 
-DgRPC_BUILD_GRPC_NODE_PLUGIN=OFF 
-DgRPC_BUILD_GRPC_OBJECTIVE_C_PLUGIN=OFF 
-DgRPC_BUILD_GRPC_PHP_PLUGIN=OFF 
-DgRPC_BUILD_GRPC_PYTHON_PLUGIN=OFF 
-DgRPC_BUILD_GRPC_RUBY_PLUGIN=OFF

cmake --build . --config Release -- /m
cmake --install . --config Release

What did you expect to see?

I expect to see successfull build with the output folder given in DCMAKE_INSTALL_PREFIX flag filled with bin, lib, include, shared folders of grpc.

What did you see instead?

compilation of upb_message_lib crashes with errors in message.c,

E0221 floating-point valu8e does not fit in required floating-point type
C:\dev\grpc\third_party\upb\upb\message\internal\message.c  20      

E0059 function call is not allowed in a constant expression upb_message_lib C:\dev\grpc\third_party\upb\upb\message\internal\message.c 22

const float kUpb_FltInfinity = INFINITY;
const double kUpb_Infinity = INFINITY;
const double kUpb_NaN = NAN;

though grpc build continues. But installation ends with an error message:

...
-- Up-to-date: C:/dev/grpc/.install_release/include/grpc/support/workaround_list.h
-- Installing: C:/dev/grpc/.install_release/lib/grpc_unsecure.lib
-- Installing: C:/dev/grpc/.install_release/lib/upb_base_lib.lib
-- Installing: C:/dev/grpc/.install_release/lib/upb_json_lib.lib
-- Installing: C:/dev/grpc/.install_release/lib/upb_mem_lib.lib
CMake Error at cmake_install.cmake:943 (file):
  file INSTALL cannot find
  "C:/dev/grpc/cmake/build_release/Release/upb_message_lib.lib": No error.
zhangskz commented 2 months ago

@ericsalo Can you take a look at if this is a possible issue in upb itself?

E0221 floating-point valu8e does not fit in required floating-point type
C:\dev\grpc\third_party\upb\upb\message\internal\message.c  20      
E0059 function call is not allowed in a constant expression upb_message_lib C:\dev\grpc\third_party\upb\upb\message\internal\message.c  22      
zhangskz commented 2 months ago

@DmitriiGorelov Can you confirm what version of protobuf you are using?

DmitriiGorelov commented 2 months ago

@DmitriiGorelov Can you confirm what version of protobuf you are using?

@zhangskz grcp v.1.64.2 checks out: Submodule path 'third_party/protobuf': checked out '2434ef2adf0c74149b9d547ac5fb545a1ff8b6b5'

I found following line in /third_party/protobuf/CMakeLists.txt : set(protobuf_VERSION_STRING "5.26.1")

haberman commented 2 months ago

Does it work to replace NAN with 0.0 / 0.0?

kagancapar commented 2 months ago

Hello @DmitriiGorelov Is the problem solved?

kagancapar commented 2 months ago

I will try it and share the results. @haberman

Does it work to replace NAN with 0.0 / 0.0?

content:

const float kUpb_FltInfinity = (float)(1.0 / 0.0); const double kUpb_Infinity = 1.0 / 0.0; const double kUpb_NaN = 0.0 / 0.0;

DmitriiGorelov commented 2 months ago

I take grpc v.1.65.0 and use same scripts to build it. It still pulls the same submodule protobuf: Submodule path 'third_party/protobuf': checked out '2434ef2adf0c74149b9d547ac5fb545a1ff8b6b5' and still shows the same error when compiles upb message.c file.

Does the upb submodule commit number have to be updated in protobuf repository?