qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] tcg/ppc: Fix building with Clang


From: Richard Henderson
Subject: Re: [PATCH] tcg/ppc: Fix building with Clang
Date: Wed, 21 Apr 2021 22:18:22 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1

On 4/21/21 2:03 AM, Peter Maydell wrote:
+/* Clang does not define _CALL_* */
+#if defined(__clang__) && defined(__ELF__) && !defined(_CALL_SYSV)
+#define _CALL_SYSV 1
+#endif

This is trying to identify the calling convention used by the OS.
That's not purely compiler specific (ie it is not the case that
all ELF output from clang is definitely using the calling convention
that _CALL_SYSV implies), so settign it purely based on "this is clang
producing ELF files" doesn't seem right.

We can get pretty close though. There are three ppc32 calling conventions: AIX, DARWIN, SYSV. The _CALL_ELF symbol is a 64-bit thing, and AIX itself doesn't use ELF.

I guess if clang doesn't reliably tell us the calling convention
maybe we should scrap the use of _CALL_SYSV and _CALL_ELF and
use the host OS defines to guess the calling convention ?

No, I'd rely on _CALL_* first, and only fall back to something else if they're not present.

I'm thinking something like

#if !defined(_CALL_SYSV) && \
    !defined(_CALL_DARWIN) && \
    !defined(_CALL_AIX) && \
    !defined(_CALL_ELF)
# if defined(__APPLE__)
#  define _CALL_DARWIN
# elif defined(__ELF__) && TCG_TARGET_REG_BITS == 32
#  define _CALL_SYSV
# else
#  error "Unknown ABI"
# endif
#endif


r~



reply via email to

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