Message ID | 20241101214101.3376595-1-roqueh@google.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | sysemu/os-win32.h: Windows clang-cl compiler fixes | expand |
On Fri, Nov 01, 2024 at 09:41:01PM +0000, Roque Arcudia Hernandez wrote: > This contains a series of small compiler fixes to enable the compilation > of qemu using clang-cl. > > It mainly involves adding some missing header files and updating #ifdefs > to handle clang-cl specific things. > > Signed-off-by: Erwin Jansen <jansene@google.com> > Signed-off-by: Roque Arcudia Hernandez <roqueh@google.com> > --- > include/qemu/compiler.h | 3 ++- > include/sysemu/dma.h | 2 ++ > include/sysemu/os-win32.h | 2 +- > migration/savevm.c | 2 ++ > tests/qtest/libqtest.c | 2 +- > 5 files changed, 8 insertions(+), 3 deletions(-) > > diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h > index c06954ccb4..7f532fe660 100644 > --- a/include/qemu/compiler.h > +++ b/include/qemu/compiler.h > @@ -22,7 +22,8 @@ > #define QEMU_EXTERN_C extern > #endif > > -#if defined(_WIN32) && (defined(__x86_64__) || defined(__i386__)) > +#if defined(_WIN32) && (defined(__x86_64__) || defined(__i386__)) && \ > + !defined(__clang__) > # define QEMU_PACKED __attribute__((gcc_struct, packed)) > #else > # define QEMU_PACKED __attribute__((packed)) We must use the 'gcc_struct' format for packing on Windows to preserve the correct ABI. clang doesn't support this yet, which is why we don't permit use of clang on Windows platforms at this time. With regards, Daniel
Hi Roque, On 1/11/24 18:41, Roque Arcudia Hernandez wrote: > This contains a series of small compiler fixes to enable the compilation > of qemu using clang-cl. > > It mainly involves adding some missing header files and updating #ifdefs > to handle clang-cl specific things. > > Signed-off-by: Erwin Jansen <jansene@google.com> > Signed-off-by: Roque Arcudia Hernandez <roqueh@google.com> > --- > include/qemu/compiler.h | 3 ++- > include/sysemu/dma.h | 2 ++ > include/sysemu/os-win32.h | 2 +- > migration/savevm.c | 2 ++ > tests/qtest/libqtest.c | 2 +- > 5 files changed, 8 insertions(+), 3 deletions(-) > diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h > index 5a49a30628..f53b751fe2 100644 > --- a/include/sysemu/dma.h > +++ b/include/sysemu/dma.h > @@ -14,6 +14,8 @@ > #include "exec/address-spaces.h" > #include "block/block.h" > #include "block/accounting.h" > +#include "block/aio.h" > +#include "qemu/iov.h" This change, ... > > typedef enum { > DMA_DIRECTION_TO_DEVICE = 0, > diff --git a/migration/savevm.c b/migration/savevm.c > index 7e1e27182a..c082015e84 100644 > --- a/migration/savevm.c > +++ b/migration/savevm.c > @@ -54,6 +54,8 @@ > #include "qemu/job.h" > #include "qemu/main-loop.h" > #include "block/snapshot.h" > +#include "block/block-io.h" > +#include "block/block-global-state.h" ... and this one look sane. But please commit them separately (preferably justifying what declarations are missing), not hidden behind "sysemu/os-win32.h" subject. > #include "qemu/cutils.h" > #include "io/channel-buffer.h" > #include "io/channel-file.h" Could you post a series (including this patch) ending with a patch exercising clang-cl in a job on our CI? Thanks, Phil.
diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h index c06954ccb4..7f532fe660 100644 --- a/include/qemu/compiler.h +++ b/include/qemu/compiler.h @@ -22,7 +22,8 @@ #define QEMU_EXTERN_C extern #endif -#if defined(_WIN32) && (defined(__x86_64__) || defined(__i386__)) +#if defined(_WIN32) && (defined(__x86_64__) || defined(__i386__)) && \ + !defined(__clang__) # define QEMU_PACKED __attribute__((gcc_struct, packed)) #else # define QEMU_PACKED __attribute__((packed)) diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h index 5a49a30628..f53b751fe2 100644 --- a/include/sysemu/dma.h +++ b/include/sysemu/dma.h @@ -14,6 +14,8 @@ #include "exec/address-spaces.h" #include "block/block.h" #include "block/accounting.h" +#include "block/aio.h" +#include "qemu/iov.h" typedef enum { DMA_DIRECTION_TO_DEVICE = 0, diff --git a/include/sysemu/os-win32.h b/include/sysemu/os-win32.h index b82a5d3ad9..b5f1c61df4 100644 --- a/include/sysemu/os-win32.h +++ b/include/sysemu/os-win32.h @@ -70,7 +70,7 @@ int __mingw_setjmp(jmp_buf); void __attribute__((noreturn)) __mingw_longjmp(jmp_buf, int); #define setjmp(env) __mingw_setjmp(env) #define longjmp(env, val) __mingw_longjmp(env, val) -#elif defined(_WIN64) +#elif defined(_WIN64) && !defined(__clang__) /* * On windows-x64, setjmp is implemented by _setjmp which needs a second parameter. * If this parameter is NULL, longjump does no stack unwinding. diff --git a/migration/savevm.c b/migration/savevm.c index 7e1e27182a..c082015e84 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -54,6 +54,8 @@ #include "qemu/job.h" #include "qemu/main-loop.h" #include "block/snapshot.h" +#include "block/block-io.h" +#include "block/block-global-state.h" #include "qemu/cutils.h" #include "io/channel-buffer.h" #include "io/channel-file.h" diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 9d07de1fbd..1fcb749602 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -386,7 +386,7 @@ static pid_t qtest_create_process(char *cmd) abort(); } - return (pid_t)pi.hProcess; + return (pid_t)GetProcessId(pi.hProcess); } #endif /* _WIN32 */