Skip to content

dependencies/pkgconfig: Canonicalize libpaths #14426

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions mesonbuild/dependencies/pkgconfig.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2013-2021 The Meson development team
# Copyright 2013-2025 The Meson development team

from __future__ import annotations

Expand Down Expand Up @@ -411,11 +411,11 @@ def _search_libs(self, libs_in: ImmutableListProtocol[str], raw_libs_in: Immutab
if not os.path.isabs(path):
# Resolve the path as a compiler in the build directory would
path = os.path.join(self.env.get_build_dir(), path)
prefix_libpaths.add(path)
prefix_libpaths.add(Path(path).resolve().as_posix())
# Library paths are not always ordered in a meaningful way
#
# Instead of relying on pkg-config or pkgconf to provide -L flags in a
# specific order, we reorder library paths ourselves, according to th
# specific order, we reorder library paths ourselves, according to the
# order specified in PKG_CONFIG_PATH. See:
# https://github.com/mesonbuild/meson/issues/4271
#
Expand Down
2 changes: 1 addition & 1 deletion unittests/allplatformstests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2045,7 +2045,7 @@ def test_pkgconfig_gen_escaping(self):
kwargs = {'required': True, 'silent': True}
foo_dep = PkgConfigDependency('libanswer', env, kwargs)
# Ensure link_args are properly quoted
libdir = PurePath(prefix) / PurePath(libdir)
libdir = Path(prefix, libdir).resolve()
link_args = ['-L' + libdir.as_posix(), '-lanswer']
self.assertEqual(foo_dep.get_link_args(), link_args)
# Ensure include args are properly quoted
Expand Down
2 changes: 2 additions & 0 deletions unittests/internaltests.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,8 @@ def _call_pkgbin(self, args, env=None):
instance_method.return_value = FakeInstance(env, MachineChoice.HOST, silent=True)
kwargs = {'required': True, 'silent': True}
foo_dep = PkgConfigDependency('foo', env, kwargs)
p1 = p1.resolve()
p2 = p2.resolve()
self.assertEqual(foo_dep.get_link_args(),
[(p1 / 'libfoo.a').as_posix(), (p2 / 'libbar.a').as_posix()])
bar_dep = PkgConfigDependency('bar', env, kwargs)
Expand Down
4 changes: 2 additions & 2 deletions unittests/linuxliketests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2016-2022 The Meson development team
# Copyright 2016-2025 The Meson development team

import stat
import subprocess
Expand Down Expand Up @@ -1116,7 +1116,7 @@ def test_pkgconfig_relative_paths(self):
self.assertTrue(relative_path_dep.found())

# Ensure link_args are properly quoted
libpath = Path(self.builddir) / '../relativepath/lib'
libpath = Path(self.builddir).parent / 'relativepath/lib'
link_args = ['-L' + libpath.as_posix(), '-lrelativepath']
self.assertEqual(relative_path_dep.get_link_args(), link_args)

Expand Down
Loading