qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC] configure script mistakenly detects static libraries


From: Murilo Opsfelder Araujo
Subject: [Qemu-devel] [RFC] configure script mistakenly detects static libraries
Date: Mon, 23 Apr 2018 13:10:47 -0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]