userver build failed
hi: When I try to build userver, got errors below, It seems something error with libabsl?
operating system: Arch linux cc: g++ (GCC) 12.1.1 20220730
cmake command: cmake -DUSERVER_FEATURE_PATCH_LIBPQ=0 -DCMAKE_BUILD_TYPE=Release ..
make output(errors):
/usr/bin/ld: libuserver-samples-grpc_service_proto.a(greeter.grpc.pb.cc.o): undefined reference to symbol '_ZN4absl12lts_202206235MutexD1Ev'
/usr/bin/ld: /usr/lib/libabsl_synchronization.so.2206.0.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [samples/grpc_service/CMakeFiles/userver-samples-grpc_service.dir/build.make:129: samples/grpc_service/userver-samples-grpc_service] Error 1
Yeah sorry, this is most likely due to https://github.com/userver-framework/userver/pull/81
This may need to be unmerged as it's introducing too many issues (beyond those exercises by the CI and myself (fedora 36)). By the looks of things @Anton3 is also seeing these side effect as has commented against the pr post merge.
Looks like it might be fixed now https://github.com/userver-framework/userver/commit/8ba9f453ee26d376b15f257fd06b32bbdcb26f1e (not sure when 'REQUIRED' made it on the libabsl find tho which was probably the root)
Yeah sorry, this is most likely due to #81
This may need to be unmerged as it's introducing too many issues (beyond those exercises by the CI and myself (fedora 36)). By the looks of things @Anton3 is also seeing these side effect as has commented against the pr post merge.
Looks like it might be fixed now 8ba9f45 (not sure when 'REQUIRED' made it on the libabsl find tho which was probably the root)
Thanks for you reply I've tried sync my local git repo, but the same error occurred again, maybe any other problems with this issue.
It could be solved with setting -DUSERVER_FEATURE_GRPC=0. But after running tests i got this results
Total Test time (real) = 55.86 sec
The following tests FAILED:
1 - userver-core_unittest (Failed)
5 - userver-mongo_mongotest (Failed)
8 - userver-postgresql_pgtest (Failed)
10 - userver-redis_redistest (Failed)
12 - userver-clickhouse_chtest (Failed)
13 - userver-rabbitmq_rmqtest (Failed)
22 - testsuite-userver-samples-mongo_service (Failed)
23 - testsuite-userver-samples-mongo-support (Failed)
28 - testsuite-userver-samples-redis_service (Failed)
29 - testsuite-userver-samples-clickhouse_service (Failed)
30 - testsuite-userver-samples-rabbitmq_service (Failed)
Errors while running CTest
Output from these tests are in: /home/n3zhov/userver/build_release/Testing/Temporary/LastTest.log
Use "--rerun-failed --output-on-failure" to re-run the failed cases verbosely.
Hi.
I had investigate a little bit of this issue on my Fedora 36 with fresh upstream/develop.
Looks like https://github.com/userver-framework/userver/commit/8ba9f453ee26d376b15f257fd06b32bbdcb26f1e does not fix completely. Got the same error (with missed symbols _ZN4absl12lts_202103245Mutex4LockEv).
TL;DR build is completes fine with the following patch:
diff --git a/cmake/GrpcTargets.cmake b/cmake/GrpcTargets.cmake
index fb6f209b..73600fcd 100644
--- a/cmake/GrpcTargets.cmake
+++ b/cmake/GrpcTargets.cmake
@@ -132,6 +132,10 @@ function(add_grpc_library NAME)
target_compile_options(${NAME} PUBLIC -Wno-unused-parameter)
target_include_directories(${NAME} SYSTEM PUBLIC ${include_paths})
target_link_libraries(${NAME} PUBLIC userver-grpc Protobuf)
+ if(NOT gRPC_VERSION)
+ find_package(gRPC REQUIRED)
+ endif()
+
if(gRPC_VERSION VERSION_GREATER_EQUAL "1.41")
target_link_libraries(${NAME} PUBLIC absl::base absl::synchronization)
endif()
diff --git a/grpc/CMakeLists.txt b/grpc/CMakeLists.txt
index e5ee2da0..7ec5aa75 100644
--- a/grpc/CMakeLists.txt
+++ b/grpc/CMakeLists.txt
@@ -10,8 +10,12 @@ else()
find_package(Protobuf REQUIRED)
endif()
+if(NOT gRPC_VERSION)
+ find_package(gRPC REQUIRED)
+endif()
+
if(gRPC_VERSION VERSION_GREATER_EQUAL "1.41")
- find_package(absl REQUIRED)
+ find_package(absl REQUIRED)
endif()
include(GrpcTargets)
I'm not sure is it good way to duplicate condition with find_package call, but gRPC_VERSION does not shared within GrpcTargets.cmake. Does someone have any ideas about it?
@yuqaf1989 Could you please check, does it fixing the issue on Arch?
userver-grpc-build.patch.txt
git apply userver-grpc-build.patch.txt
Investigation log details:
Same case - there is missing library /usr/lib64/libabsl_synchronization.so while linking userver-grpc_unittest and userver-samples-grpc_service.
The library which distribute this symbols could be found with command:
$ find /usr/lib64 build_release/ \( -iname "*.so" -o -iname "*.a" \) \
-exec bash -c 'grep -q "_ZN4absl12lts_202103245Mutex4LockEv" {} 2> /dev/null && echo {} && objdump -T {} | grep "_ZN4absl12lts_202103245Mutex4LockEv"' \;
... # skipped _DF *UND*_
/usr/lib64/libabsl_synchronization.so
000000000000a5d0 g DF .text 000000000000011a Base _ZN4absl12lts_202103245Mutex4LockEv
For complete build with *grpc* /usr/lib64/libabsl_synchronization.so were manually added before /usr/lib64/libgrpc.so into files:
build_release/userver/grpc/CMakeFiles/userver-grpc_unittest.dir/link.txtbuild_release/samples/grpc_service/CMakeFiles/userver-samples-grpc_service.dir/link.txt
And finnally, I've found that variable gRPC_VERSION does not set at all during cmake run...
The issue should have been fixed in af14c58122e2de0cbfb28b6100e566936cdd5fad
Please check that the fix works for you
Arch linux build working fine now
Many thanks for the report! Create new reports if something breaks