[Bug]: generated pkg configs have excessive dependencies
- 主要语言
- C++
- 星标
- 18.1k
- 派生
- 3.2k
- 平均合并
- 20 小时 36 分钟
- 30 天内合并 PR
- 1
描述
### 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.
```console
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.
```console
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++
```
- here is a tests I made along with diffs in package confings https://salsa.debian.org/fboranek/abseil/-/tree/fb-release-20240702/debian/pkg_performace_issue?ref_type=heads
- here is a patch to absl (I remove a lot 732 depenendencies - anything what script tell me is already dependency) https://salsa.debian.org/fboranek/abseil/-/blob/fb-release-20240702/debian/patches/reduce-dependencies.diff?ref_type=heads
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.
```CMake
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.
贡献指南
评估
这个 Issue 还没有评估数据。