All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Thomas Huth <thuth@redhat.com>,
	Peter Maydell <peter.maydell@linaro.org>,
	 QEMU Developers <qemu-devel@nongnu.org>
Cc: "Alex Bennée" <alex.bennee@linaro.org>
Subject: Re: [PULL 00/13] Testing, build system and misc patches
Date: Mon, 6 Sep 2021 17:08:09 +0200	[thread overview]
Message-ID: <4c6dde86-b6d1-c61e-0a5a-824deff79521@redhat.com> (raw)
In-Reply-To: <2afbb10f-b813-e1b6-8b61-5c7874994813@redhat.com>

On 06/09/21 11:51, Thomas Huth wrote:
> On 03/09/2021 18.49, Peter Maydell wrote:
>> On Fri, 3 Sept 2021 at 17:37, Alex Bennée <alex.bennee@linaro.org> wrote:
>>> Thomas Huth <thuth@redhat.com> writes:
>>>> On 03/09/2021 15.22, Peter Maydell wrote:
>>>>> This provokes a new warning from meson on a linux-static build:
>>>>> Run-time dependency appleframeworks found: NO (tried framework)
>>>>> Library rt found: YES
>>>>> Found pkg-config: /usr/bin/pkg-config (0.29.1)
>>>>> WARNING: Static library 'gbm' not found for dependency 'gbm', may not
>>>>> be statically linked
>>>>> Run-time dependency gbm found: YES 20.0.8
>>>>> Dependency libpng found: YES 1.6.34 (cached)
>>>>> Dependency libjpeg found: YES unknown (cached)
>>>>> If we're building statically and we can't find a static
>>>>> library then (a) we shouldn't print a WARNING and
>>>>> (b) we shouldn't then conclude that we've found gdm.
>>>>
>>>> Hmmm, no clue what's wrong here, since I basically did declare it like
>>>> all other libraries are declared, too (so this problem should have
>>>> shown up somewhere else already?)... Paolo, do you have any ideas
>>>> what's going on here?
>>>
>>> In attempting to replicate I found all the dynamic libs blow up:
>>
>>>    WARNING: Static library 'xkbcommon' not found for dependency 
>>> 'xkbcommon', may not be statically l
>>>    Run-time dependency xkbcommon found: YES 1.0.3
>>
>> I do vaguely recall complaining about new meson warnings for
>> static library detection in the past as well:
>> https://lore.kernel.org/qemu-devel/CAFEAcA8chPqS0keyGv0vBgNgacnMo95gA3LZDU2QfmteQ=4UZg@mail.gmail.com/ 
>>
>> https://lore.kernel.org/qemu-devel/CAFEAcA_-cNmt-sY3nqnGkpUqET86M6-82rf-Uv3QkwCR14kYsw@mail.gmail.com/ 
>>
>> https://lore.kernel.org/qemu-devel/CAFEAcA8xHxCGhh2hibsdCxZrYRRU+xcwVsa85O7KL9BsmW7ohw@mail.gmail.com/ 
>>
>>
>>> So is this a general problem with static libs. BTW I didn't catch this
>>> because I only build user with --static as I thought system --static was
>>> flakey anyway.
>>
>> I'm not doing a system build in this case... Looking at some of
>> those older threads, it looks like part of the answer is that
>> for dependencies that we don't need for linux-user mode we should
>> guard the test with some suitable if condition so we don't create
>> the dependency unless we're going to use it, eg the brlapi check
>> uses "if not get_option('brlapi').auto() or have_system", rbd
>> has a similar thing involving have_block, etc.
> 
> Ok, thanks, that seems to work, I'll change the patch accordingly.
> 
>> But I think there is an underlying meson bug here which that kind of
>> use of an if is merely working around: if we ask for a static library
>> it should not give us a dynamic library.
> 
> Agreed. Actually, when I run configure with "--static --disable-system" 
> on my laptop, I'm also getting some warnings:
> 
> WARNING: Static library 'z' not found for dependency 'zlib', may not be 
> statically linked
> Run-time dependency zlib found: YES 1.2.11
> Run-time dependency appleframeworks found: NO (tried framework)
> Library rt found: YES
> WARNING: Static library 'png16' not found for dependency 'libpng', may 
> not be statically linked
> WARNING: Static library 'z' not found for dependency 'libpng', may not 
> be statically linked
> 
> ... and linking then later fails while running "make".
> 
> Paolo, could the behavior of meson be changed to fail already the 
> configuration step in this case instead of only printing a warning?

The reason why this is just a warning is explained only in the code, and
it's this:

     # Library wasn't found, maybe we're looking in the wrong
     # places or the library will be provided with LDFLAGS or
     # LIBRARY_PATH from the environment (on macOS), and many
     # other edge cases that we can't account for.
     #
     # Add all -L paths and use it as -lfoo

In other words, Meson doesn't really know the library will be used for a
statically-linked binary (as opposed to just not wanting a shared
library for whatever reason).  So it looks for a .a file, and forces use
of the a static library by passing a path to that file.  If it cannot
find one, it warns.

Note that pre-Meson we didn't warn for --disable-system (correct) but we
did the wrong thing silently for --enable-system (just like now, except
without a warning).  So Meson's warning forces us to be a bit more verbose
to do only strictly necesary tests, as in:

   pam = not_found
   if not get_option('auth_pam').auto() or have_system
     pam = cc.find_library('pam', has_headers: ['security/pam_appl.h'],
                           required: get_option('auth_pam'),
                           kwargs: static_kwargs)
   endif

but it also catches incorrect setups on the user side and makes the "configure"
step a little faster with --disable-system.

FWIW, in the latest Meson version there's a shortcut for the above pattern,
since it is very common in QEMU; it can be rewritten as follows to avoid the
if/endif:

   pam = cc.find_library('pam', has_headers: ['security/pam_appl.h'],
                         required: get_option('auth_pam').disable_auto_if(not have_system)
                         kwargs: static_kwargs)

Paolo



  reply	other threads:[~2021-09-06 15:09 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-02 12:48 [PULL 00/13] Testing, build system and misc patches Thomas Huth
2021-09-02 12:48 ` [PULL 01/13] docs: add definitions of terms for CI/testing Thomas Huth
2021-09-02 12:49 ` [PULL 02/13] libqtest: check for g_setenv() failure Thomas Huth
2021-09-02 12:49 ` [PULL 03/13] gitlab-ci: Merge "build-disabled" with "build-without-default-features" Thomas Huth
2021-09-02 12:49 ` [PULL 04/13] gitlab-ci: Remove superfluous "dnf install" statement Thomas Huth
2021-09-02 12:49 ` [PULL 05/13] gitlab-ci: Fix ..._RUNNER_AVAILABLE variables and document them Thomas Huth
2021-09-02 12:49 ` [PULL 06/13] gitlab-ci: Don't try to use the system libfdt in the debian job Thomas Huth
2021-09-02 12:49 ` [PULL 07/13] meson.build: Fix the check for a usable libfdt Thomas Huth
2021-09-02 12:49 ` [PULL 08/13] meson.build: Don't use internal libfdt if the user requested the system libfdt Thomas Huth
2021-09-02 12:49 ` [PULL 09/13] configure / meson: Move the GBM handling to meson.build Thomas Huth
2021-09-02 12:49 ` [PULL 10/13] scripts: Remove the "show-fixed-bugs.sh" file Thomas Huth
2021-09-02 12:49 ` [PULL 11/13] softmmu/vl: Add a "grab-mod" parameter to the -display sdl option Thomas Huth
2021-09-02 12:49 ` [PULL 12/13] softmmu/vl: Deprecate the old grab options Thomas Huth
2021-09-02 12:49 ` [PULL 13/13] softmmu/vl: Deprecate the -sdl and -curses option Thomas Huth
2021-09-03 13:22 ` [PULL 00/13] Testing, build system and misc patches Peter Maydell
2021-09-03 14:19   ` Thomas Huth
2021-09-03 16:35     ` Alex Bennée
2021-09-03 16:49       ` Peter Maydell
2021-09-06  9:51         ` Thomas Huth
2021-09-06 15:08           ` Paolo Bonzini [this message]
2021-09-06 15:14             ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4c6dde86-b6d1-c61e-0a5a-824deff79521@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.