hangover icon indicating copy to clipboard operation
hangover copied to clipboard

Compiling fails due to atomic/stdatomic.h(?) errors when building QEMU [RPi4B/Ubuntu 20.04.1]?

Open pseudofunizer opened this issue 3 years ago • 4 comments

Hi,

I was inquiring previously about a clang issue that I had in building Hangover. I got way past that problem point by setting the clang flags as instructed - the issue was this one: https://github.com/AndreRH/hangover/issues/84 .

I solved it by changing the config/compile flags of HANGOVER_WINE_CC and HANGOVER_WINE_CXX as recommended, like this:

export HANGOVER_WINE_CC=clang export HANGOVER_WINE_CXX=clang

And thus everything worked just fine for quite the while up until it was time to compile the QEMU side of things within Hangover.

I've been able to build Hangover before on a 64-bit Ubuntu system on the RPi4B (even without changing the HANGOVER_WINE_CC or HANGOVER_WINE_CXX flags), but now, for some reason, on the same RPi4B/Ubuntu 20.04.1LTS, my QEMU build within Hangover fails.

I've tried going to the qemu/ subdirectory separately to try to (re)compile:

  CC      util/fdmon-io_uring.o
  CC      util/module.o
  CC      util/host-utils.o
  CC      util/bitmap.o
  CC      util/bitops.o
  CC      util/fifo8.o
/home/ubuntu/builds/hangover/qemu/util/fdmon-io_uring.c:106:17: error: address argument to atomic operation must be a pointer to _Atomic type ('unsigned int *' invalid)
    old_flags = atomic_fetch_or(&node->flags, FDMON_IO_URING_PENDING | flags);
                ^               ~~~~~~~~~~~~
/usr/lib/llvm-10/lib/clang/10.0.0/include/stdatomic.h:138:42: note: expanded from macro 'atomic_fetch_or'
#define atomic_fetch_or(object, operand) __c11_atomic_fetch_or(object, operand, __ATOMIC_SEQ_CST)
                                         ^                     ~~~~~~
/home/ubuntu/builds/hangover/qemu/util/fdmon-io_uring.c:130:14: error: address argument to atomic operation must be a pointer to _Atomic type ('unsigned int *' invalid)
    *flags = atomic_fetch_and(&node->flags, ~(FDMON_IO_URING_PENDING |
             ^                ~~~~~~~~~~~~
/usr/lib/llvm-10/lib/clang/10.0.0/include/stdatomic.h:144:43: note: expanded from macro 'atomic_fetch_and'
#define atomic_fetch_and(object, operand) __c11_atomic_fetch_and(object, operand, __ATOMIC_SEQ_CST)
                                          ^                      ~~~~~~
/home/ubuntu/builds/hangover/qemu/util/fdmon-io_uring.c:236:13: error: address argument to atomic operation must be a pointer to _Atomic type ('unsigned int *' invalid)
    flags = atomic_fetch_and(&node->flags, ~FDMON_IO_URING_REMOVE);
            ^                ~~~~~~~~~~~~
/usr/lib/llvm-10/lib/clang/10.0.0/include/stdatomic.h:144:43: note: expanded from macro 'atomic_fetch_and'
#define atomic_fetch_and(object, operand) __c11_atomic_fetch_and(object, operand, __ATOMIC_SEQ_CST)
                                          ^                      ~~~~~~
/home/ubuntu/builds/hangover/qemu/util/fdmon-io_uring.c:347:30: error: address argument to atomic operation must be a pointer to _Atomic type ('unsigned int *' invalid)
            unsigned flags = atomic_fetch_and(&node->flags,
                             ^                ~~~~~~~~~~~~
/usr/lib/llvm-10/lib/clang/10.0.0/include/stdatomic.h:144:43: note: expanded from macro 'atomic_fetch_and'
#define atomic_fetch_and(object, operand) __c11_atomic_fetch_and(object, operand, __ATOMIC_SEQ_CST)
                                          ^                      ~~~~~~
4 errors generated.
winegcc: /usr/bin/clang failed
make: *** [/home/ubuntu/builds/hangover/qemu/rules.mak:69: util/fdmon-io_uring.o] Error 2
make: *** Waiting for unfinished jobs....

All help kindly appreciated. Thanks.

pseudofunizer avatar Oct 20 '20 15:10 pseudofunizer

It turns out that https://github.com/AndreRH/hangover/issues/84#issuecomment-707114047 wasn't exactly right, winegcc will always default to gcc while you want to build qemu with clang. I solved it that hacky way in our cross Dockerfile: https://github.com/AndreRH/hangover/blob/6ebfa067c5607a10c57119c82ee6d122cc957710/Dockerfile.cross_arm64#L45

AndreRH avatar Oct 28 '20 17:10 AndreRH

Maybe we should make HANGOVER_WINE_CC/CXX default to clang unless specified otherwise? gcc will only do something useful on x86_64 Linux hosts and everything else either needs clang set manually or defaults to it (mac).

stefand avatar Oct 28 '20 18:10 stefand

@AndreRH & @stefand -- Thanks for the replies! However, my question still remains as for what would be the solution to this one?

As mentioned before, I'm building on an aarch64 host - more specifically, Raspberry Pi 4B running 64-bit Ubuntu -- if I don't set the HANGOVER_WINE_CC and HANGOVER_WINE_CXX flags to =clang before starting the compile altogether, for some reason the build fails right from the get-go as it can't find my up-to-date version of clang.

Should I try something else in the compiler flags, or what would be your suggestion here ...?

Thanks a lot in advance.

pseudofunizer avatar Oct 29 '20 11:10 pseudofunizer

follow this link to see how I solved it, it's hacky and you want to backup things before doing it, but it at least should work: https://github.com/AndreRH/hangover/blob/6ebfa067c5607a10c57119c82ee6d122cc957710/Dockerfile.cross_arm64#L45 (you need to hide the gcc installation)

AndreRH avatar Oct 29 '20 21:10 AndreRH

irrelevant with new Hangover approach

AndreRH avatar Feb 15 '23 20:02 AndreRH