qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Stefan Weil <sw@weilnetz.de>,
	Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Cc: QEMU Developers <qemu-devel@nongnu.org>,
	Peter Maydell <peter.maydell@linaro.org>,
	 Richard Henderson <richard.henderson@linaro.org>
Subject: Re: [PATCH v2 63/93] tcg/tci: Use ffi for calls
Date: Tue, 2 Dec 2025 19:38:12 +0100	[thread overview]
Message-ID: <CAPMQPEKqX2+EOen0fRL1sO=pBOL-rs3-zwz9tJh+e2857kCFWA@mail.gmail.com> (raw)

On 7/2/21 22:33, Stefan Weil wrote:
> On 07.02.21 21:12, Richard Henderson wrote:
>> On 2/7/21 11:52 AM, Peter Maydell wrote:
>>> On Sun, 7 Feb 2021 at 17:41, Richard Henderson
>>> <richard.henderson@linaro.org> wrote:
>>>>
>>>> On 2/7/21 8:25 AM, Stefan Weil wrote:
>>>>>> +#include "qemu-common.h"
>>>>>> +#include "tcg/tcg.h"           /* MAX_OPC_PARAM_IARGS */
>>>>>> +#include "exec/cpu_ldst.h"
>>>>>> +#include "tcg/tcg-op.h"
>>>>>> +#include "qemu/compiler.h"
>>>>>> +#include <ffi.h>
>>>>>> +
>>>>>
>>>>>
>>>>> ffi.h is not found on macOS with Homebrew.
>>>>>
>>>>> This can be fixed by using pkg-config to find the right compiler (and maybe
>>>>> also linker) flags:
>>>>>
>>>>> % pkg-config --cflags libffi
>>>>> -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/ffi
>>>>> % pkg-config --libs libffi
>>>>> -lffi
>>>>
>>>>
>>>> Which is exactly what I do in the previous patch:
>>>>
>>>>
>>>>> +++ b/meson.build
>>>>> @@ -1901,7 +1901,14 @@ specific_ss.add(when: 'CONFIG_TCG', if_true: files(
>>>>>     'tcg/tcg-op.c',
>>>>>     'tcg/tcg.c',
>>>>>   ))
>>>>> -specific_ss.add(when: 'CONFIG_TCG_INTERPRETER', if_true: files('tcg/tci.c'))
>>>>> +
>>>>> +if get_option('tcg_interpreter')
>>>>> +  libffi = dependency('libffi', version: '>=3.0',
>>>>> +                      static: enable_static, method: 'pkg-config',
>>>>> +                      required: true)
>>>>> +  specific_ss.add(libffi)
>>>>> +  specific_ss.add(files('tcg/tci.c'))
>>>>> +endif
>>>>
>>>> Did you need a PKG_CONFIG_LIBDIR set for homebrew?
>>>
>>> Is this the "meson doesn't actually add the cflags everywhere it should"
>>> bug again ?
>>
>> I guess so.  I realized after sending this reply that PKG_CONFIG_LIBDIR can't
>> be the answer, since the original configure should have failed if pkg-config
>> didn't find ffi.
>>
>> Was there a resolution to said meson bug?
>
> Meanwhile I noticed an additional detail:
>
> There exist two different pkg-config configurations for libffi on Homebrew:
>
> % pkg-config --cflags libffi
> -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/ffi
> % export PKG_CONFIG_PATH="/opt/homebrew/opt/libffi/lib/pkgconfig"
> % pkg-config --cflags libffi
> -I/opt/homebrew/Cellar/libffi/3.3_2/include
>
> By default it points to a system directory which does not exist at all
> on my Mac, so that will never work.
>
> With the right PKG_CONFIG_PATH a correct include directory is set, and
> the latest rebased tci-next branch now works for me with a compiler warning:
>
> /opt/homebrew/Cellar/libffi/3.3_2/include/ffi.h:441:5: warning:
> 'FFI_GO_CLOSURES' is not defined, evaluates to 0 [-Wundef]

This got introduced in
https://github.com/libffi/libffi/commit/e951d64c0852; should we report there?

Cc'ing Jeremy who sent patches around FFI_GO_CLOSURES:
https://github.com/libffi/libffi/pull/586/commits/8c25da7d2cdf8

Meanwhile, about 5 years have passed, I'll post a patch...


             reply	other threads:[~2025-12-02 18:38 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-02 18:38 Philippe Mathieu-Daudé [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-02-04  1:43 [PATCH v2 00/93] TCI fixes and cleanups Richard Henderson
2021-02-04  1:44 ` [PATCH v2 63/93] tcg/tci: Use ffi for calls Richard Henderson
2021-02-07 16:25   ` Stefan Weil
2021-02-07 17:39     ` Richard Henderson
2021-02-07 19:52       ` Peter Maydell
2021-02-07 20:12         ` Richard Henderson
2021-02-07 21:33           ` Stefan Weil
2021-02-08  9:20           ` Peter Maydell
2021-02-08  9:35             ` Paolo Bonzini
2021-02-08 13:07               ` Stefan Weil
2021-02-08 17:39                 ` Richard Henderson
2021-02-08 19:04                   ` Stefan Weil
2021-02-08 22:55                     ` Richard Henderson
2021-02-09 20:46                       ` Richard Henderson
2021-02-09 21:15                         ` Stefan Weil
2021-02-09 21:54                           ` Stefan Weil

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='CAPMQPEKqX2+EOen0fRL1sO=pBOL-rs3-zwz9tJh+e2857kCFWA@mail.gmail.com' \
    --to=philmd@linaro.org \
    --cc=jeremyhu@apple.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=sw@weilnetz.de \
    /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 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).