Re: V2 [PATCH] PKG_CHECK_MODULES: Check if $pkg_cv_[]$1[]_LIBS works

Simon Marchi
2020-07-28T13:54:39Z

On 2020-07-28 9:33 a.m., H.J. Lu wrote:
> On x86, the native GCC can support -m32 and -m64. "gcc -m32" or "gcc -m64"
> are not cross compiling.

And how does that make it not cross-compîling?

>> Anyway regardless of vocabulary, I don't think there was a problem to begin with (not that I blame
>> you, it's not made in an intuitive way). The problem is that you were using pkg-config as
>> configured to look up x86_64 packages. It looks up .pc files in (amongst others)
>> /usr/lib64/pkgconfig, which provides information about x86_64 packages, which are in turn obviously
>> not suitable not suitable to build a i686 program. Just like you cross-compile "for real" (say,
>> for an ARM host), you need to set PKG_CONFIG or the PKG_CONFIG_* variables to returns packages for
>> the --host architecture. That means searching in /usr/lib/pkgconfig instead of /usr/lib64/pkgconfig.
>>
>> You could for example set the PKG_CONFIG_LIBDIR variable to /usr/lib/pkgconfig:/usr/share/pkgconfig
>
> I didn't set PKG_CONFIG_LIBDIR and I don't want to set it.

Why are you fine adjusting CC="gcc -m32" but not PKG_CONFIG*?

>
>> This way, if you don't install the elfutils-debuginfod-client-devel.i686 package, your binutils won't
>> try to link with libdebuginfod (because pkg-config won't find it). If you install it, then your
>> binutils will be built against the i686 libdebuginfod.
>>
>> Ideally, distros would ship a i686-something-something-pkg-config that automatically searchs in paths
>> that make sense for that architecture (just like you have arm-linux-gnueabihf-pkg-config when cross
>> compiling for ARM), but that doesn't seem to exist. But this is just like you have to explicitly set
>> CC="gcc -m32" instead of using some i686-something-something-gcc.
>>
>> You can always make it yourself, create, say, a `i686-pc-linux-gnu-pkg-config` file somewhere in $PATH,
>> with:
>>
>> export PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig:/usr/share/pkgconfig
>> exec pkg-config $*
>
> I don't want to do it. PKG_CHECK_MODULES should check if the library
> really works.
> Otherwise we can use remove it and use the library directly without checking.

We could, but that would have its own disadvantages.

Simon