|
From: | Akihiko Odaki |
Subject: | Re: [PATCH v2 01/12] build: Only define OS_OBJECT_USE_OBJC with gcc |
Date: | Thu, 31 Aug 2023 17:53:28 +0900 |
User-agent: | Mozilla Thunderbird |
On 2023/08/31 17:12, Philippe Mathieu-Daudé wrote:
On 30/8/23 18:14, Alexander Graf wrote:Recent versions of macOS use clang instead of gcc. The OS_OBJECT_USE_OBJC define is only necessary when building with gcc. Let's not define it when building with clang. With this patch, I can successfully include GCD headers in QEMU when building with clang. Signed-off-by: Alexander Graf <graf@amazon.com> --- meson.build | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 98e68ef0b1..0d6a0015a1 100644 --- a/meson.build +++ b/meson.build @@ -224,7 +224,9 @@ qemu_ldflags = [] if targetos == 'darwin'# Disable attempts to use ObjectiveC features in os/object.h since they# won't work when we're compiling with gcc as a C compiler. - qemu_common_flags += '-DOS_OBJECT_USE_OBJC=0' + if compiler.get_id() == 'gcc' + qemu_common_flags += '-DOS_OBJECT_USE_OBJC=0' + endif elif targetos == 'solaris' # needed for CMSG_ macros in sys/socket.h qemu_common_flags += '-D_XOPEN_SOURCE=600'Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Defining OS_OBJECT_USE_OBJC does not look like a proper solution. Looking at os/object.h, it seems OS_OBJECT_USE_OBJC is defined as 0 when: !defined(OS_OBJECT_HAVE_OBJC_SUPPORT) && (!defined(__OBJC__) || defined(__OBJC_GC__))
This means OS_OBJECT_USE_OBJC is always 0 if Objective-C is disabled. I also confirmed os/object.h will not use Objective-C features when compiled as C code on clang with the following command:
clang -E -x -c - <<EOF #include <os/object.h> EOFIf compilation fails with GCC when not defining OS_OBJECT_USE_OBJC, it probably means GCC incorrectly treats C code as Objective-C and that is the problem we should solve. I cannot confirm this theory however since I have only an Apple Silicon Mac that is incompatible with GCC.
Regards, Akihiko Odaki
[Prev in Thread] | Current Thread | [Next in Thread] |