qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] build-sys: fix win32 compilation with --target-list=''


From: Marc-André Lureau
Subject: Re: [PATCH] build-sys: fix win32 compilation with --target-list=''
Date: Thu, 17 Dec 2020 15:41:50 +0400

Hi

On Thu, Dec 17, 2020 at 3:33 PM Claudio Fontana <cfontana@suse.de> wrote:
On 12/17/20 11:44 AM, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> Fixes linking:
> x86_64-w64-mingw32-gcc  -o tests/test-qapi-util.exe version.rc_version.o tests/test-qapi-util.exe.p/test-qapi-util.c.obj -Wl,--allow-shlib-undefined -Wl,--nxcompat -Wl,--no-seh -Wl,--dynamicbase -Wl,--warn-common -m64 -fstack-protector-strong -Wl,--start-group libqemuutil.a -pthread -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib -lgnutls -lwinmm -lm -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib -lgthread-2.0 -lglib-2.0 -lintl -lws2_32 -mconsole -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -Wl,--end-group
> /usr/lib/gcc/x86_64-w64-mingw32/10.2.1/../../../../x86_64-w64-mingw32/bin/ld: libqemuutil.a(util_oslib-win32.c.obj): in function `qemu_try_set_nonblock':
> /home/elmarco/src/qemu/buildw/../util/oslib-win32.c:224: undefined reference to `qemu_fd_register'
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  util/main-loop-stub.c | 26 ++++++++++++++++++++++++++
>  util/meson.build      |  2 ++
>  2 files changed, 28 insertions(+)
>  create mode 100644 util/main-loop-stub.c
>
> diff --git a/util/main-loop-stub.c b/util/main-loop-stub.c
> new file mode 100644
> index 0000000000..b3e175ade5
> --- /dev/null
> +++ b/util/main-loop-stub.c
> @@ -0,0 +1,26 @@
> +/*
> + * QEMU main loop stub impl
> + *
> + * Copyright (c) 2020 Red Hat, Inc.
> + *
> + * This library is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * This library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this library; if not, see <http://www.gnu.org/licenses/>.
> + *
> + */
> +
> +#include "qemu/osdep.h"
> +#include "qemu/main-loop.h"
> +
> +void qemu_fd_register(int fd)
> +{
> +}
> diff --git a/util/meson.build b/util/meson.build
> index f359af0d46..462b79a61a 100644
> --- a/util/meson.build
> +++ b/util/meson.build
> @@ -79,4 +79,6 @@ if have_block
>    util_ss.add(when: 'CONFIG_INOTIFY1', if_true: files('filemonitor-inotify.c'),
>                                          if_false: files('filemonitor-stub.c'))
>    util_ss.add(when: 'CONFIG_LINUX', if_true: files('vfio-helpers.c'))
> +else
> +  util_ss.add(files('main-loop-stub.c'))
>  endif
>

Is the root cause elsewhere though?

I don't like stubs very much, because often they are introduced as the easy way out of a problem instead of doing the necessary refactoring,
and they end up confusing the hell out of someone trying to understand what is actually used where, never mind trying to debug the linker errors.

There is already an bunch of #ifndef _WIN32, #else , ... in util/main-loop.c (quite a bunch of them really),
is that what actually needs reworking, and putting the pieces together in the build system in a way that makes sense?


I am not sure we can improve it so much.

qemu_fd_register() is called from qemu_set_nonblock() and net/slirp.c.

It is necessary for win32 util/main-loop.c.

Eventually, we could move qemu_fd_register() in its own unit, but then we will probably need more stubs or configure knobs for the main-loop symbols. I don't think it's worth, but maybe I am missing something and I should try it.
 

reply via email to

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