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

protobuf.pc pkgconfig file generated by protobuf's cmake build doesn't declare absl and utf8_range dependencies. #12439

Closed
jtattermusch opened this issue Apr 11, 2023 · 6 comments · Fixed by #12583
Assignees

Comments

@jtattermusch
Copy link
Contributor

Starting from 22.x, protobuf now depends on absl and utf8_range, but the protobuf.pc pkgconfig file doesn't properly declare those dependencies.
As a result, the build is broken if someone installs protobuf and then wants to include it via pkgconfig (since they'd be missing absl and utf8_validity symbols when trying to link).

See https://github.com/protocolbuffers/protobuf/blob/f11079b01f075bc7c5b3286d85a8feca798c09e9/cmake/protobuf.pc.cmake

This issue breaks grpc's build-and-install "distribtest" that tries to build helloworld example with grpc and protobuf:
https://github.com/grpc/grpc/blob/24d83cda9bb1caaff9c03ace6f418e946e88c49d/examples/cpp/helloworld/Makefile#L28
(which runs pkgconfig to get a list of libraries to link against when building a project that depends on grpc++ and protobuf).

@jtattermusch jtattermusch added the untriaged auto added to all issues by default when created. label Apr 11, 2023
@jtattermusch
Copy link
Contributor Author

CC @deannagarcia @mkruskal-google I have a dirty workaround I can use in our distribtests so fixing this isn't a strict blocker for grpc's protobuf 22.x upgrade, but of course this is something that still needs to be fixed in order for building via pkgconfig to become clean again.

@mmjkelso
Copy link

mmjkelso commented Apr 13, 2023

I have run into this trying to build grpc . In the grpc cmake build I'm declaring gRPC_PROTOBUF_PROVIDER=package and pointing Protobuf_DIR to the part of the protobuf install with the protobuf-config.cmake file. When the grpc config gets up to the protobuf part it fails saying the protobuf is marked as not found due to missing utf8_range dependency.

What workarounds are there ? I'm trying various thing but no luck so far.

Edit: actually I don't know if this is the same pkgconfig problem, but it seems related.

@jtattermusch
Copy link
Contributor Author

I have run into this trying to build grpc . In the grpc cmake build I'm declaring gRPC_PROTOBUF_PROVIDER=package and pointing Protobuf_DIR to the part of the protobuf install with the protobuf-config.cmake file. When the grpc config gets up to the protobuf part it fails saying the protobuf is marked as not found due to missing utf8_range dependency.

What workarounds are there ? I'm trying various thing but no luck so far.

Edit: actually I don't know if this is the same pkgconfig problem, but it seems related.

You can use the gRPC's "distribtests" as a reference for what cmake flags/options you need to use to successfully build under different scenarios: https://github.com/grpc/grpc/tree/master/test/distrib/cpp (choose script that best matches your use case) Hope that helps.

copybara-service bot pushed a commit to protocolbuffers/utf8_range that referenced this issue Apr 20, 2023
See protocolbuffers/protobuf#12439 for more information

PiperOrigin-RevId: 525796488
copybara-service bot pushed a commit to protocolbuffers/utf8_range that referenced this issue Apr 20, 2023
See protocolbuffers/protobuf#12439 for more information

PiperOrigin-RevId: 525796488
copybara-service bot pushed a commit to protocolbuffers/utf8_range that referenced this issue Apr 20, 2023
See protocolbuffers/protobuf#12439 for more information

PiperOrigin-RevId: 525796488
@ejona86
Copy link
Contributor

ejona86 commented Apr 20, 2023

This is impacting grpc-java as well (for the protoc plugin). Absl has an incredible 83 libraries, each with their own separate .pc. Although this will only solve our build on Linux, I'm still uncertain how we'll handle this many libraries on Windows.

copybara-service bot pushed a commit to protocolbuffers/utf8_range that referenced this issue Apr 20, 2023
copybara-service bot pushed a commit to protocolbuffers/utf8_range that referenced this issue Apr 20, 2023
@ejona86
Copy link
Contributor

ejona86 commented Apr 26, 2023

@mkruskal-google, this still seems broken.

When building on 344f6de:

/usr/bin/ld: /tmp/protobuf-cache/main/Linux-x86_64/lib/libprotobuf.a(generated_message_tctable_lite.cc.o): in function `google::protobuf::internal::TcParser::FastSS1(google::protobuf::MessageLite*, char const*, google::protobuf::internal::ParseContext*, google::protobuf::internal::TcFieldData, google::protobuf::internal::TcParseTableBase const*, unsigned long)':
generated_message_tctable_lite.cc:(.text+0x123d0): undefined reference to `utf8_range::IsStructurallyValid(std::basic_string_view<char, std::char_traits<char> >)'
...

Manually adding -lutf8_validity fixes my build, and it is missing from protobuf:

$ pkg-config --libs-only-l protobuf
-lprotobuf -labsl_log_internal_check_op -labsl_leak_check -labsl_die_if_null -labsl_log_internal_conditions -labsl_log_internal_message -labsl_examine_stack -labsl_log_internal_format -labsl_log_internal_proto -labsl_log_internal_nullguard -labsl_log_internal_log_sink_set -labsl_log_sink -labsl_log_entry -labsl_flags -labsl_flags_internal -labsl_flags_marshalling -labsl_flags_reflection -labsl_flags_private_handle_accessor -labsl_flags_commandlineflag -labsl_flags_commandlineflag_internal -labsl_flags_config -labsl_flags_program_name -labsl_log_initialize -labsl_log_globals -labsl_log_internal_globals -labsl_hash -labsl_city -labsl_low_level_hash -labsl_raw_hash_set -labsl_hashtablez_sampler -labsl_statusor -labsl_status -labsl_cord -labsl_cordz_info -labsl_cord_internal -labsl_cordz_functions -labsl_exponential_biased -labsl_cordz_handle -labsl_crc_cord_state -labsl_crc32c -labsl_crc_internal -labsl_crc_cpu_detect -labsl_bad_optional_access -labsl_str_format_internal -labsl_strerror -labsl_synchronization -labsl_graphcycles_internal -labsl_stacktrace -labsl_symbolize -labsl_debugging_internal -labsl_demangle_internal -labsl_malloc_internal -labsl_time -labsl_civil_time -labsl_time_zone -labsl_bad_variant_access -lprotobuf-lite -labsl_strings -labsl_strings_internal -lrt -labsl_base -labsl_spinlock_wait -labsl_int128 -labsl_throw_delegate -labsl_raw_logging_internal -labsl_log_severity

Looks like the problem is utf8_range doesn't add its library:

$ pkg-config --libs-only-l utf8_range 
-lprotobuf-lite -labsl_strings -labsl_strings_internal -lrt -labsl_base -labsl_spinlock_wait -labsl_int128 -labsl_throw_delegate -labsl_raw_logging_internal -labsl_log_severity

@mkruskal-google
Copy link
Member

Whoops, that's what I get for copy pasting >.<! That -lprotobuf-lite was supposed to be -lutf8_range. I'll send out a fix ASAP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants