Skip to content

Fix regression in Requires.private for library(), and difference wrt shared_library()#15691

Open
bonzini wants to merge 5 commits intomesonbuild:masterfrom
bonzini:fix-shared-library-pkgconfig-difference
Open

Fix regression in Requires.private for library(), and difference wrt shared_library()#15691
bonzini wants to merge 5 commits intomesonbuild:masterfrom
bonzini:fix-shared-library-pkgconfig-difference

Conversation

@bonzini
Copy link
Copy Markdown
Contributor

@bonzini bonzini commented Apr 7, 2026

Ensure that when a .pc file is created for a shared library, its
Requires.private line now always includes the dependencies of the
shared library. Until Meson 1.11-rc2, the line was included for
shared libraries created with library, because those were created
with shared_library_only=False; commit 6519dd4 ("interpreter:
set shared_library_only within build_target", 2026-04-02) made
shared_library and library behave the same way.

Unfortunately the behavior corresponding to shared_library_only=True
was the wrong one. For the shared_library_only case, link_with and link_whole libraries are irrelevant but external dependencies are relevant indeed.

Overall this is a bugfix because the Requires.private lines was absent for shared_library.

Fixes: #15690

@bonzini bonzini added this to the 1.11 milestone Apr 7, 2026
@bonzini bonzini force-pushed the fix-shared-library-pkgconfig-difference branch 2 times, most recently from 992a26d to fcf6a2c Compare April 7, 2026 14:53
@bonzini bonzini force-pushed the fix-shared-library-pkgconfig-difference branch 2 times, most recently from d1f51f3 to 4d592d8 Compare April 7, 2026 15:17
@bonzini bonzini marked this pull request as ready for review April 7, 2026 16:15
when `pkg-config` or `pkgconf` are invoked with `--cflags`. Previously,
the line was included for shared libraries created with `library` (even
if the `default_library` option was set to `shared`), whereas now
`library` and `shared_library` behave in the same way.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this note needs to make it clearer that this is a bugfix only for shared_library(). The wording right now makes it seem like Meson was always generating incorrect pc files for shared libraries, but (IIUC) that was not the case for library() with default_library=shared?

@nirbheek
Copy link
Copy Markdown
Member

nirbheek commented Apr 7, 2026

FWIW, this was the original PR that added the shared_library() behaviour: #3251

It seems that back then there was vigorous debate about whether this should be done or not. I think we should split out the "difference wrt shared_library()" part of this PR out, it has the potential to break stuff.

@bonzini bonzini modified the milestones: 1.11, 1.12 Apr 8, 2026
@bonzini bonzini removed the regression label Apr 8, 2026
bonzini added 5 commits April 13, 2026 18:39
This reverts commit be99ec0, so that
a proper solution can be included in 1.12.
…vate

test_usage_pkgconfig_prefixes works only because one of the
shared_libraries is not specifying a Requires.private for its dependent.
Fix it so that it keeps working after the Requires.private (which is
already present for library()) is added.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
…ared library

Ensure that when a `.pc` file is created for a shared library, its
`Requires.private` line now always includes the dependencies of the
shared library.  Until Meson 1.11-rc2, the line was included for
shared libraries created with `library`, because those were created
with shared_library_only=False; commit 6519dd4 ("interpreter:
set shared_library_only within build_target", 2026-04-02) made
`shared_library` and `library` behave the same way.

Unfortunately the behavior corresponding to `shared_library_only=True`
was the wrong one.  For the shared_library_only case link_with and
link_whole libraries are irrelevant but external dependencies are
relevant.

Fixes: 6519dd4 ("interpreter: set shared_library_only within build_target", 2026-04-02)
Fixes: mesonbuild#15690
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
…uires.private

When generating .pc files for shared libraries, Meson automatically
adds Requires.private entries for the library's dependencies (so that
pkg-config --cflags works correctly). However, this can pull in
unnecessary build dependencies when the library's public headers do not
actually expose its dependency's headers.

Add a new requires_shared keyword argument that, when specified,
replaces the automatic Requires.private entries for shared libraries
with a user-provided list. Passing an empty list suppresses the
automatic entries entirely.
@bonzini bonzini force-pushed the fix-shared-library-pkgconfig-difference branch from 4d592d8 to 040219b Compare April 13, 2026 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[regression] 1.11.0rc3 Fails to build > 20 packages from the openSUSE/GNOME stack

2 participants