All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Weil via <qemu-devel@nongnu.org>
To: Bin Meng <bmeng.cn@gmail.com>
Cc: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>,
	"qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>,
	Bin Meng <bin.meng@windriver.com>, Cleber Rosa <crosa@redhat.com>,
	John Snow <jsnow@redhat.com>
Subject: Re: [PATCH 3/7] scripts/nsis.py: Automatically package required DLLs of QEMU executables
Date: Mon, 26 Feb 2024 07:30:54 +0100	[thread overview]
Message-ID: <3b6e065d-c50f-4503-bcd1-f6f08e734d97@weilnetz.de> (raw)
In-Reply-To: <CAEUhbmUdvtbAZSOh_hQRLFmQtr8zeUadm6XBo+Ayg=CvidCOag@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 4230 bytes --]

Am 26.02.24 um 05:35 schrieb Bin Meng:

> On Mon, Feb 26, 2024 at 1:37 AM Stefan Weil<sw@weilnetz.de>  wrote:
>> Am 10.09.22 um 02:37 schrieb Bin Meng:
>>> On Sat, Sep 10, 2022 at 12:49 AM Mark Cave-Ayland
>>> <mark.cave-ayland@ilande.co.uk>  wrote:
>>>> On 08/09/2022 14:28, Bin Meng wrote:
>>>>
>>>>> From: Bin Meng<bin.meng@windriver.com>
>>>>>
>>>>> At present packaging the required DLLs of QEMU executables is a
>>>>> manual process, and error prone.
>>>>>
>>>>> Actually build/config-host.mak contains a GLIB_BINDIR variable
>>>>> which is the directory where glib and other DLLs reside. This
>>>>> works for both Windows native build and cross-build on Linux.
>>>>> We can use it as the search directory for DLLs and automate
>>>>> the whole DLL packaging process.
>>>>>
>>>>> Signed-off-by: Bin Meng<bin.meng@windriver.com>
>>>>> ---
>>>>>
>>>>>     meson.build     |  1 +
>>>>>     scripts/nsis.py | 46 ++++++++++++++++++++++++++++++++++++++++++----
>>>>>     2 files changed, 43 insertions(+), 4 deletions(-)
>>>>>
>> [...]>>> diff --git a/scripts/nsis.py b/scripts/nsis.py
>>>>> index baa6ef9594..03ed7608a2 100644
>>>>> --- a/scripts/nsis.py
>>>>> +++ b/scripts/nsis.py
>>>>> @@ -18,12 +18,36 @@ def signcode(path):
>>>>>             return
>>>>>         subprocess.run([cmd, path])
>>>>>
>>>>> +def find_deps(exe_or_dll, search_path, analyzed_deps):
>>>>> +    deps = [exe_or_dll]
>>>>> +    output = subprocess.check_output(["objdump", "-p", exe_or_dll], text=True)
>> This fails on non x86 hosts where objdump does not know how to handle a
>> Windows x86_64 exe file.
> Does this command work in the MSYS2 environment on Windows Arm?


I don't know and cannot test that, because I don't run Windows on ARM.

>>>>> +    output = output.split("\n")
>>>>> +    for line in output:
>>>>> +        if not line.startswith("\tDLL Name: "):
>>>>> +            continue
>>>>> +
>>>>> +        dep = line.split("DLL Name: ")[1].strip()
>>>>> +        if dep in analyzed_deps:
>>>>> +            continue
>>>>> +
>>>>> +        dll = os.path.join(search_path, dep)
>>>>> +        if not os.path.exists(dll):
>>>>> +            # assume it's a Windows provided dll, skip it
>>>>> +            continue
>>>>> +
>>>>> +        analyzed_deps.add(dep)
>>>>> +        # locate the dll dependencies recursively
>>>>> +        rdeps = find_deps(dll, search_path, analyzed_deps)
>>>>> +        deps.extend(rdeps)
>>>>> +
>>>>> +    return deps
>> [...]
>>>> FWIW I wrote a similar script a while back to help package a custom Windows build for
>>>> a client, however I used ldd instead of objdump since it provided the full paths for
>>>> DLLs installed in the msys2/mingw-w64 environment via pacman which were outside the
>>>> QEMU build tree.
>>>>
>>> Yep, ldd also works, but only on Windows native build. objdump can
>>> work on both Windows native and Linux cross builds.
>>
>> objdump fails on Linux cross builds on any non x86 host, because objdump
>> typically only supports the native host architecture.
>>
>> Therefore I get an error on an ARM64 host (podman on Mac M1):
>>
>>           objdump: /tmp/tmpvae5u0qm/qemu/qemu-system-aarch64.exe: file
>> format not recognized
>>
>> I could use x86_64-w64-mingw32-objdump to fix the cross builds, but then
>> native builds might fail because they don't have x86_64-w64-mingw32-objdump.
>>
>> Is there a simple way how we can get the information here whether
>> objdump requires a cross build prefix?
> For QEMU Windows, I believe the only supported architecture is x86_64,
> correct? Do we want to support (cross) building QEMU for Windows Arm?


Yes, I think we only support QEMU on Windows x86_64. I also don't know 
anyone who has tried building for Windows ARM. And up to now I also was 
never asked for that, so obviously there is still no need for it.


> Based on your observation, objdump on Linux cross builds on any x86
> host works, but not on non x86 host.
> Maybe it's a hint to ask for binutils guys to include the PE format
> support for objdump Arm by default.


I am afraid that we'll have to find a solution on the QEMU side, not 
wait until all binutils support the PE format for x86_64 (which would 
make the binaries or the library much larger).

Stefan


[-- Attachment #2: Type: text/html, Size: 6541 bytes --]

  reply	other threads:[~2024-02-26  6:31 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-08 13:28 [PATCH 0/7] nsis: gitlab-ci: Improve QEMU Windows installer packaging Bin Meng
2022-09-08 13:28 ` [PATCH 1/7] scripts/nsis.py: Drop the unnecessary path separator Bin Meng
2022-09-17 21:18   ` Philippe Mathieu-Daudé via
2022-10-29  7:44   ` Stefan Weil via
2022-09-08 13:28 ` [PATCH 2/7] scripts/nsis.py: Fix destination directory name when invoked on Windows Bin Meng
2022-09-08 13:46   ` Marc-André Lureau
2022-09-17 21:20   ` Philippe Mathieu-Daudé via
2022-10-29  7:58   ` Stefan Weil via
2022-09-08 13:28 ` [PATCH 3/7] scripts/nsis.py: Automatically package required DLLs of QEMU executables Bin Meng
2022-09-08 13:56   ` Marc-André Lureau
2022-09-09 16:49   ` Mark Cave-Ayland
2022-09-10  0:37     ` Bin Meng
2024-02-25 17:37       ` Stefan Weil via
2024-02-26  4:35         ` Bin Meng
2024-02-26  6:30           ` Stefan Weil via [this message]
2024-03-10  8:02             ` Mark Cave-Ayland
2022-10-29  9:04   ` Stefan Weil via
2022-09-08 13:28 ` [PATCH 4/7] .gitlab-ci.d/windows.yml: Drop the sed processing in the 64-bit build Bin Meng
2022-09-08 14:04   ` Marc-André Lureau
2022-09-09 16:30     ` Thomas Huth
2022-09-17 21:22   ` Philippe Mathieu-Daudé via
2022-09-08 13:28 ` [PATCH 5/7] block/nfs: Fix 32-bit Windows build Bin Meng
2022-09-17 21:32   ` Philippe Mathieu-Daudé via
2022-09-21 12:10     ` Meng, Bin
2022-09-24  1:19       ` Bin Meng
2022-10-27  2:45         ` Bin Meng
2022-10-27  7:54           ` Kevin Wolf
2022-10-27  8:16             ` Bin Meng
2022-10-29 15:57   ` Stefan Weil via
2022-09-08 13:28 ` [PATCH 6/7] .gitlab-ci.d/windows.yml: Unify the prerequisite packages Bin Meng
2022-09-09 16:32   ` Thomas Huth
2022-09-10  0:32     ` Bin Meng
2022-09-10  5:09       ` 罗勇刚(Yonggang Luo)
2022-09-24  9:20       ` Bin Meng
2022-10-29 13:06         ` Bin Meng
2022-10-29 16:19           ` Stefan Weil via
2022-10-31  6:43           ` Thomas Huth
2022-09-08 13:28 ` [PATCH 7/7] .gitlab-ci.d/windows.yml: Test 'make installer' in the CI Bin Meng
2022-09-17 21:31   ` Philippe Mathieu-Daudé via
2022-10-29 16:39   ` Stefan Weil via
2022-10-30  3:21     ` Bin Meng
2022-10-31  7:01       ` Thomas Huth
2022-09-16  0:35 ` [PATCH 0/7] nsis: gitlab-ci: Improve QEMU Windows installer packaging Bin Meng
2022-09-21 12:18 ` Bin Meng
2022-09-21 12:24   ` Thomas Huth
2022-09-23  2:28     ` Bin Meng
2022-10-29 13:45     ` Bin Meng
2022-10-31  6:52       ` Thomas Huth
2022-10-31  9:26         ` Stefan Weil via
2022-10-31  9:29           ` Marc-André Lureau

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=3b6e065d-c50f-4503-bcd1-f6f08e734d97@weilnetz.de \
    --to=qemu-devel@nongnu.org \
    --cc=bin.meng@windriver.com \
    --cc=bmeng.cn@gmail.com \
    --cc=crosa@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=mark.cave-ayland@ilande.co.uk \
    --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 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.