Skip to content

build: omit certain deps from libcurl.pc unless found via pkg-config - #15573

Closed
vszakats wants to merge 11 commits into
curl:masterfrom
vszakats:limit-problematic-pc
Closed

vszakats wants to merge 11 commits into
curl:masterfrom
vszakats:limit-problematic-pc

Conversation

@vszakats

@vszakats vszakats commented Nov 13, 2024 •

Copy link
Copy Markdown
Member

The idea of linking dependencies found to libcurl.pc turns out not
to work in practice in some cases.

Specifically: gss, ldap, mbedtls, libmsh3, rustls

A .pc may not work or be missing for a couple of reasons:

The effect of such issues shall be subtle in theory, because
libcurl.pc normally lists these dependencies in the Requires.private
section meant for static linking. But, e.g. pkg-config --exists
requires these to be present, and builds sometimes use this check
regardless of build type. This bug is not present in pkgconf; it only
checks for them when --static is also passed.

Fix these by adding affected .pc references to libcurl.pc only when
we detected the dependency via pkg-config.

There are a few side-effects of this solution:

  • references are never added for dependencies where curl doesn't
    implement pkg-config detection. These are:
  • generated libcurl.pc depends on the build-time environment.
  • generated libcurl.pc depends on curl build tool (cmake, autotools).
  • generated libcurl.pc depends on curl build implementation details.

Make an exception for GNU GSS, where I blindly guess that gss.pc is
always available, as no issues were reported.

Other, not mentioned, dependencies continue to be added regardless
of the detection method.

Reported-by: Harmen Stoppels, Thomas, Daniel Engberg, Andy Fiddaman
Fixes #15469
Fixes #15507
Fixes #15535
Fixes #15163 (comment)


@github-actions github-actions Bot added the build label Nov 13, 2024
@vszakats vszakats changed the title build: omit gss/ldap/mbedtls/libmsh3/rustls from libcurl.pc unless found via pkg-config build: omit certain deps from libcurl.pc unless found via pkg-config Nov 13, 2024
@vszakats

Copy link
Copy Markdown
Member Author

@haampie, @Thom1b, @diizzyy, @citrus-it: Can you give this a test and report if it improves your build case?

@Thom1b

Thom1b commented Nov 14, 2024 •

Copy link
Copy Markdown

Hi,

I just applied these both patches to curl-8.11.0.tar.xz tarball:
b69ebe36a45222ee845239bbe908bb90415f483a
fb6f0185197e695156029afadfaf7922429be9f1

Then I built and installed curl (using ./configure, not cmake). I understand the patch avoid adding ldap in Requires.private but it's still there:

# grep Requires.private /usr/lib64/pkgconfig/libcurl.pc
Requires.private: libidn2,ldap,zlib,libbrotlidec,libzstd,mit-krb5-gssapi,openssl,libpsl,libssh2,libnghttp2,libnghttp3,libcares

So php still can't build with openldap2.4 which has no .pc file.

@vszakats

vszakats commented Nov 14, 2024 •

Copy link
Copy Markdown
Member Author

Hi,

I just applied these both patches to curl-8.11.0.tar.xz tarball: b69ebe3 fb6f018

Then I built and installed curl (using ./configure, not cmake). I understand the patch avoid adding ldap in Requires.private but it's still there:

# grep Requires.private /usr/lib64/pkgconfig/libcurl.pc
Requires.private: libidn2,ldap,zlib,libbrotlidec,libzstd,mit-krb5-gssapi,openssl,libpsl,libssh2,libnghttp2,libnghttp3,libcares

So php still can't build with openldap2.4 which has no .pc file.

Thanks for testing!

It's odd because this patch unconditionally disables adding ldap via both cmake and autotools. (it's due to be re-added later for cmake, on the condition that LDAP was detected via pkg-config.)

Did you run autoreconf -fi after applying this patch?

@Thom1b

Thom1b commented Nov 14, 2024

Copy link
Copy Markdown

Did you run autoreconf -fi after applying this patch?

I forgot of course. ;)
I just retried, it works fine. ldap is not in Requires.private so I can build php now. It solved the issue. Thanks!

@citrus-it

citrus-it commented Nov 14, 2024 •

Copy link
Copy Markdown

I tested this PR on OmniOS and it works - the libcurl.pc files are back to exactly the same content as curl 8.10.x

bloody:omnios:curl-ldap% sed '1,/^$/d' tmp/pkg/usr/lib/amd64/pkgconfig/libcurl.pc
prefix=/usr
exec_prefix=${prefix}
libdir=/usr/lib/amd64
includedir=/usr/include
supported_protocols="DICT FILE FTP FTPS GOPHER GOPHERS HTTP HTTPS IMAP IMAPS IPFS IPNS LDAP LDAPS MQTT POP3 POP3S RTSP SMB SMBS SMTP SMTPS TELNET TFTP WS WSS"
supported_features="alt-svc AsynchDNS brotli HSTS HTTP2 HTTPS-proxy IPv6 Largefile libz NTLM PSL SSL threadsafe TLS-SRP UnixSockets zstd"

Name: libcurl
URL: https://curl.se/
Description: Library to transfer files with HTTP, FTP, etc.
Version: 8.11.0
Requires:
Requires.private: zlib,libbrotlidec,libzstd,openssl,libpsl,libnghttp2
Libs: -L${libdir} -lcurl
Libs.private: -m64 -L/usr/lib/amd64 -L/usr -L/usr/lib/amd64 -L/usr/lib/amd64 -lnghttp2 -lpsl -lssl -lcrypto -lssl -lcrypto -lldap -lzstd -lbrotlidec -lz -lsocket -lnsl
Cflags: -I${includedir}
Cflags.private: -DCURL_STATICLIB

Thanks @vszakats !

@diizzyy

diizzyy commented Nov 14, 2024

Copy link
Copy Markdown
Contributor

@vszakats
Appears to work as expected on my end, thanks!

vszakats added a commit that referenced this pull request Dec 26, 2024
Make the Find modules set and return their respective `pkg-config`
module name(s) to the CMake build process, which then adds those
to the `Requires:` list.

Before this patch, `pkg-config` module names were maintainted in two
separate places. After this patch, they are maintained in the Find
modules for dependencies that have one (most do).

Re-align existing modules with this change: msh3, mbedtls, rustls.
These modules return their `pkg-config` module name only when
detected via `pkg-config`.

Follow-up to d511ec8 #15573
Closes #15800
pps83 pushed a commit to pps83/curl that referenced this pull request Apr 26, 2025
The idea of linking dependencies found to `libcurl.pc` turns out not
to work in practice in some cases.

Specifically: gss, ldap, mbedtls, libmsh3, rustls

A `.pc` may not work or be missing for a couple of reasons:
- not all build methods generate it: mbedTLS, Rustls
- generated file is broken: msh3
  Ref: nibanks/msh3#225
- installed package flavour isn't shipping with one:
  FreeBSD GSS, OmniOS LDAP, macOS LDAP

The effect of such issues shall be subtle in theory, because
`libcurl.pc` normally lists these dependencies in the `Requires.private`
section meant for static linking. But, e.g. `pkg-config --exists`
requires these to be present, and builds sometimes use this check
regardless of build type. This bug is not present in `pkgconf`; it only
checks for them when `--static` is also passed.

Fix these by adding affected `.pc` references to `libcurl.pc` only when
we detected the dependency via `pkg-config`.

There are a few side-effects of this solution:
- references are never added for dependencies where curl doesn't
  implement `pkg-config` detection. These are:
  - autotools: ldap, mbedtls, msh3
  - cmake: ldap (pending curl#15273)
- generated `libcurl.pc` depends on the build-time environment.
- generated `libcurl.pc` depends on curl build tool (cmake, autotools).
- generated `libcurl.pc` depends on curl build implementation details.

Make an exception for GNU GSS, where I blindly guess that `gss.pc` is
always available, as no issues were reported.

Other, not mentioned, dependencies continue to be added regardless
of the detection method.

Reported-by: Harmen Stoppels, Thomas, Daniel Engberg, Andy Fiddaman
Fixes curl#15469
Fixes curl#15507
Fixes curl#15535
Fixes curl#15163 (comment)
Closes curl#15573
pps83 pushed a commit to pps83/curl that referenced this pull request Apr 26, 2025
pps83 pushed a commit to pps83/curl that referenced this pull request Apr 26, 2025
Make the Find modules set and return their respective `pkg-config`
module name(s) to the CMake build process, which then adds those
to the `Requires:` list.

Before this patch, `pkg-config` module names were maintainted in two
separate places. After this patch, they are maintained in the Find
modules for dependencies that have one (most do).

Re-align existing modules with this change: msh3, mbedtls, rustls.
These modules return their `pkg-config` module name only when
detected via `pkg-config`.

Follow-up to d511ec8 curl#15573
Closes curl#15800
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

8.11.0: Requires.private ldap issue libcurl's package config file unconditionally references mbedtls in Requires.private but it does not exist

4 participants