Skip to content

[Bug]: generated pkg configs have excessive dependencies #1970

@fboranek

Description

@fboranek

Describe the issue

The pkg config contains all dependencies, but it should contain only direct dependencies, not indirect onces.
Pkgconfig recursively search for all dependencies and this causes resolving one dependency several times,
which slow down configuration.
In Cmake configure for pkg_check_modules(absl REQUIRED absl_flat_hash_set) tooks 1.30 secs.
After reducing unesesary dependency it tooks only 86.27 millis.

For full picture the configuration of gprc++ on Trixie, which using absl, and also his dependency re2 also use absl took about 40 seconds instead of 1-2 second on Bookworm.

11:59:40 O: -- Found Protobuf: /usr/lib/x86_64-linux-gnu/libprotobuf.so (found version "3.21.12")
11:59:40 O: -- Checking for modules 'grpc++'
11:59:40 O: --   Checking for module 're2'
11:59:46 O: --     Found re2, version 11.0.0
12:00:23 O: --   Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.3.1")
12:00:23 O: --   Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found version "3.5.1")
12:00:23 O: --   Found Threads: TRUE
12:00:23 O: --   Found grpc++

Steps to reproduce the problem

apt install libabsl-dev

pkg-config --variable=prefix          absl_flat_hash_set
pkg-config --static --libs-only-l     absl_flat_hash_set
pkg-config --libs                     absl_flat_hash_set
pkg-config --libs-only-other          absl_flat_hash_set
pkg-config --static --libs-only-other absl_flat_hash_set
pkg-config --cflags-only-I            absl_flat_hash_set

What version of Abseil are you using?

20240722.0

What operating system and version are you using?

Debian Trixie

What compiler and version are you using?

gcc version 14.2.0 (Debian 14.2.0-19)

What build system are you using?

cmake version 3.31.6

Additional context

I made a patch to the Debian package and repack package with a patch. After removing unnecessary dependencies it significantly faster. One second of my build with grpc++ library.

12:49:49 O: -- Checking for modules 'grpc++'
12:49:49 O: --   Checking for module 're2'
12:49:49 O: --     Found re2, version 11.0.0
12:49:50 O: --   Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.3.1")
12:49:50 O: --   Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found version "3.5.1")
12:49:50 O: --   Found Threads: TRUE
12:49:50 O: --   Found grpc++

I would make a MR with such change however I would like to know which direction take.

  • Reducing dependencies directly in Cmake is simple, reliable. If some depenency would be missing, linking of the tests would fails.
  • Reducing only in generate package config is difficult to do directly in CMake. It can be done by quering depending targets. But the target must by already defined. It is not on many placed. For instance log_flags have dependency absl::log_globals which is not defined yet and thus impossible query target absl::log_globals for its dependencies. It would require a lot of refactoring of order of definitions and houping there is not circle dependency.
absl_cc_library(
  NAME
    log_flags
  SRCS
    "flags.cc"
  HDRS
    "flags.h"
  COPTS
    ${ABSL_DEFAULT_COPTS}
  LINKOPTS
    ${ABSL_DEFAULT_LINKOPTS}
  DEPS
    absl::log_globals
    absl::log_internal_config
    absl::log_internal_flags
  PUBLIC
)

absl_cc_library(
  NAME
    log_globals
  SRCS
  • Any of previous will not be accepted since this is problem only for package config. I guess the Cmake config is not suffer by this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions