qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [RFC] configure script mistakenly detects static libraries
@ 2018-04-23 16:10 Murilo Opsfelder Araujo
  2018-04-23 16:16 ` Peter Maydell
  0 siblings, 1 reply; 4+ messages in thread
From: Murilo Opsfelder Araujo @ 2018-04-23 16:10 UTC (permalink / raw)
  To: qemu-devel; +Cc: muriloo

Hi, everyone!

I'm facing an issue on how configure script detects static libraries and
would like to hear from community to find a common ground on how to
possibly fix it.

Throughout configure, we use pkg-config command to verify if a library
is installed so qemu can be linked to it. This works fine when linking
qemu dynamically. However, configuring qemu with --static can mistakenly
detect a library that is actually not present on the system.

For example, on Ubuntu Xenial, libcacard-dev package provides only
libcacard.so (not libcacard.a) and pkg-config reports success in both
cases:

    $ pkg-config libcacard
    $ echo $?
    0

    $ pkg-config --static libcacard
    $ echo $?
    0

Since we use `pkg-config libcacard` to set smartcard=yes, this
mistakenly enables smartcard feature. This is acceptable with dynamic
linkage, but can be an issue with static linkage, where libcacard.a
doesn't exist on the system, resulting on a build error:

    $ ./configure --target-list=ppc64-softmmu --static && make -j$(nproc)
    [...]
    /usr/bin/ld: cannot find -lcacard

A workaround can be specifying --disable-<feature> for all missing
libraries.

One possible solution would be having a function, e.g. check_pkg_config,
that writes a C skeleton and tries to compile it using the desired
library, given as function parameter. Thus, compile_prog would return
success if library actually exists on the system. For example:

    check_pkg_config() {
        local_pkg_name=$1
        local_cflags=$($pkg_config --cflags $local_pkg_name)
        local_ldflags=$($pkg_config --libs $local_pkg_name)
        write_c_skeleton
        compile_prog "$local_cflags" "$local_ldflags"
    }

That would work for both dynamic and static linkages. Then we could just
replace `$pkg_config <package>` by `check_pkg_config <package>` in the
configure script.

My approach might not be the best and only one, so I'd like to hear from
you what would be a reasoanble solution to fix this situation.

Cheers
Murilo

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-04-23 16:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-23 16:10 [Qemu-devel] [RFC] configure script mistakenly detects static libraries Murilo Opsfelder Araujo
2018-04-23 16:16 ` Peter Maydell
2018-04-23 16:30   ` Daniel P. Berrangé
2018-04-23 16:40   ` Murilo Opsfelder Araujo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).