mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.65k stars 1.64k forks source link

Regression setting PKG_CONFIG_LIBDIR with msys2 pkg-config after 0.62.1 #11226

Open andrzejc opened 1 year ago

andrzejc commented 1 year ago

Describe the bug Commit 18bec0d3e31884dc493a03741b2ec9fef17047ee introduces a regression in my build setup with the way it sets PKG_CONFIG_LIBDIR. In this particular configuration I use msys2 pkg-config which expects Unix-style path separator (':') in env vars. It seems that aformentioned commit changes the path separator to windows-style (';') which is no longer recongized by pkg-config and dependency discovery fails. I'm not aware if there's any other pkg-config variant usable on Windows which uses ';' as a separator, msys seems lika a natural choice.

meson-log.txt before the commit:

env[PKG_CONFIG_LIBDIR]: c:\data2\moonlight-deps\windows-clang15\icu4c-71_1\x64\lib\pkgconfig:c:\data2\moonlight-deps\windows-clang15\cmph-2.0\x64\lib\pkgconfig:c:\data2\moonlight-deps\windows-clang15\openssl-1.1.1s\x64\lib\pkgconfig:c:\data2\moonlight-deps\windows-clang15\xxHash-0.8.1\x64\lib\pkgconfig:c:\data2\moonlight-deps\windows-clang15\zlib-1.2.13\x64\lib\pkgconfig:c:\data2\moonlight-deps\windows-clang15\zstd-1.5.2\x64\lib\pkgconfig:c:\data2\moonlight-deps\windows-clang15\flac-1.3.2\x64\lib\pkgconfig:c:\data2\moonlight-deps\windows-clang15\libogg-1.3.5\x64\lib\pkgconfig:c:\data2\moonlight-deps\windows-clang15\opus-1.3.1\x64\lib\pkgconfig:c:\data2\moonlight-deps\windows-clang15\opusfile-0.12\x64\lib\pkgconfig:c:\data2\moonlight-deps\windows-clang15\libsndfile-1.1.0\x64\lib\pkgconfig:c:\data2\moonlight-deps\windows-clang15\soxr-0.1.3\x64\lib\pkgconfig:c:\data2\moonlight-deps\windows-clang15\libvorbis-1.3.7\x64\lib\pkgconfig:c:\data2\moonlight-deps\windows-clang15\yaml-cpp-0.7.0\x64\share\pkgconfig

after the commit:

env[PKG_CONFIG_LIBDIR]: c:\data2\moonlight-deps\windows-clang15\icu4c-71_1\x64\lib\pkgconfig;c:\data2\moonlight-deps\windows-clang15\cmph-2.0\x64\lib\pkgconfig;c:\data2\moonlight-deps\windows-clang15\openssl-1.1.1s\x64\lib\pkgconfig;c:\data2\moonlight-deps\windows-clang15\xxHash-0.8.1\x64\lib\pkgconfig;c:\data2\moonlight-deps\windows-clang15\zlib-1.2.13\x64\lib\pkgconfig;c:\data2\moonlight-deps\windows-clang15\zstd-1.5.2\x64\lib\pkgconfig;c:\data2\moonlight-deps\windows-clang15\flac-1.3.2\x64\lib\pkgconfig;c:\data2\moonlight-deps\windows-clang15\libogg-1.3.5\x64\lib\pkgconfig;c:\data2\moonlight-deps\windows-clang15\opus-1.3.1\x64\lib\pkgconfig;c:\data2\moonlight-deps\windows-clang15\opusfile-0.12\x64\lib\pkgconfig;c:\data2\moonlight-deps\windows-clang15\libsndfile-1.1.0\x64\lib\pkgconfig;c:\data2\moonlight-deps\windows-clang15\soxr-0.1.3\x64\lib\pkgconfig;c:\data2\moonlight-deps\windows-clang15\libvorbis-1.3.7\x64\lib\pkgconfig;c:\data2\moonlight-deps\windows-clang15\yaml-cpp-0.7.0\x64\share\pkgconfig

This causes the discovery of libcrypto to fail:

moonlight-tools| Run-time dependency libcrypto found: NO (tried pkgconfig, system and cmake)

subprojects\moonlight-tools\src\meson.build:2:0: ERROR: Dependency "libcrypto" not found, tried pkgconfig, system and cmake

To Reproduce Please include your meson.build files, preferably as a minimal toy example showing the issue. You may need to create simple source code files (don't include private/proprietary code).

setup command:

 meson setup build -Dbuildtype=release -Dwrap_mode=forcefallback -Db_lto=false -Ddebug=True -Doptimization=3 -Db_ndebug=false -Denable_cuda=true --native-file tools/meson/windows.conf --native-file tools/meson/windows/x64.conf

windows.conf:

[constants]
deps_dir = 'c:\data2\moonlight-deps\windows-clang15'
boost_stem = 'boost_1_80_0'
cmph_stem = 'cmph-2.0'
icu4c_stem = 'icu4c-71_1'
openssl_stem = 'openssl-1.1.1s'
xxhash_stem = 'xxHash-0.8.1'
zlib_stem = 'zlib-1.2.13'
yaml_cpp_stem = 'yaml-cpp-0.7.0'
flac_stem = 'flac-1.3.2'
ogg_stem = 'libogg-1.3.5'
opus_stem = 'opus-1.3.1'
opusfile_stem = 'opusfile-0.12'
sndfile_stem = 'libsndfile-1.1.0'
soxr_stem = 'soxr-0.1.3'
vorbis_stem = 'libvorbis-1.3.7'
zstd_stem = 'zstd-1.5.2'
thinlto_cache_dir = 'c:\ThinLTO'

[properties]
clang_target = 'msvc'
platform = platform
deps_dir = deps_dir
boost_root = deps_dir / boost_stem
pkg_config_libdir = [
    deps_dir / icu4c_stem / platform / 'lib\pkgconfig',
    deps_dir / cmph_stem / platform / 'lib\pkgconfig',
    deps_dir / openssl_stem / platform / 'lib\pkgconfig',
    deps_dir / xxhash_stem / platform / 'lib\pkgconfig',
    deps_dir / zlib_stem / platform / 'lib\pkgconfig',
    deps_dir / zstd_stem / platform / 'lib\pkgconfig',
    deps_dir / flac_stem / platform / 'lib\pkgconfig',
    deps_dir / ogg_stem / platform / 'lib\pkgconfig',
    deps_dir / opus_stem / platform / 'lib\pkgconfig',
    deps_dir / opusfile_stem / platform / 'lib\pkgconfig',
    deps_dir / sndfile_stem / platform / 'lib\pkgconfig',
    deps_dir / soxr_stem / platform / 'lib\pkgconfig',
    deps_dir / vorbis_stem / platform / 'lib\pkgconfig',
    deps_dir / yaml_cpp_stem / platform / 'share\pkgconfig']
cuda_lib_dir = cuda_lib_dir
thinlto_cache_dir = thinlto_cache_dir

[built-in options]
c_link_args = ['-Wl,/lldltocache:' + thinlto_cache_dir]
cpp_link_args = c_link_args
cpp_args = [
    # XXX workaround: boost/type_traits/has_trivial_copy.hpp:34:4: error: builtin __has_trivial_copy is deprecated
    '-Wno-deprecated-builtins',
    # XXX workaround: https://github.com/llvm/llvm-project/issues/56300
    '-D_DISABLE_STRING_ANNOTATION',
    '-D_DISABLE_VECTOR_ANNOTATION']

[project options]
CUDA_dir = 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8'

[binaries]
pkgconfig = 'c:\msys64\usr\bin\pkg-config'
c = ['c:\msys64\mingw64\bin\ccache', 'clang', '--target=' + clang_target]
cpp = ['c:\msys64\mingw64\bin\ccache', 'clang++', '--target=' + clang_target]
c_ld = 'lld'
cpp_ld = 'lld'
strip = 'llvm-strip'
ar = 'llvm-ar'
nm = 'llvm-nm'
ranlib = 'llvm-ranlib'

x64.conf:

[constants]
platform = 'x64'
platform_bits = '64'
cuda_lib_dir = 'lib\x64'
clang_target = 'x86_64-pc-windows-msvc'

(minimized) meson.build:

project('foo', 'cpp',
  meson_version: '>= 0.56.0',
  default_options: [
    'cpp_std=c++20',
    'werror=true',
    'warning_level=2',
    'b_lto=true',
    'b_lto_mode=thin',
])

deps = [
  dependency('libcrypto', static: true, required: true, include_type: 'system'),
  dependency('libxxhash', static: true, required: true, include_type: 'system'),
]
...

Expected behavior I expect the build setup to succeed just like it did before commit 18bec0d3e31884dc493a03741b2ec9fef17047ee

system parameters

eli-schwartz commented 1 year ago

https://github.com/mesonbuild/meson/pull/10275#issuecomment-1102800077

Hmm...

andrzejc commented 1 year ago

After reading #10275 I did a very simple check with my current msys2 pkg-config 1.8.0:

with ':' as a separator:

> set "PKG_CONFIG_PATH=c:\data2\moonlight-deps\windows-clang15\icu4c-71_1\x64\lib\pkgconfig:c:\data2\moonlight-deps\windows-clang15\openssl-1.1.1s\x64\lib\pkgconfig"
> c:\msys64\usr\bin\pkg-config --modversion libcrypto
1.1.1s

with ';' separator:

> set "PKG_CONFIG_PATH=c:\data2\moonlight-deps\windows-clang15\icu4c-71_1\x64\lib\pkgconfig;c:\data2\moonlight-deps\windows-clang15\openssl-1.1.1s\x64\lib\pkgconfig"
> c:\msys64\usr\bin\pkg-config --modversion libcrypto
Package libcrypto was not found in the pkg-config search path.
Perhaps you should add the directory containing `libcrypto.pc'
to the PKG_CONFIG_PATH environment variable
Package 'libcrypto', required by 'virtual:world', not found

somehow it seems that the translation of path list separator isn't happening in this case. Behaves the same when called from cmd.exe and when using msys bash...