On 28/11/24 20:06, Phil Dennis-Jordan wrote:
On Thu, 28 Nov 2024 at 17:46, Philippe Mathieu-Daudé <philmd@xxxxxxxxxx
<mailto:philmd@xxxxxxxxxx>> wrote:
On 28/11/24 17:38, Phil Dennis-Jordan wrote:
> Paolo, could we please apply either Sairaj and Santosh's fix at
> https://patchew.org/QEMU/20241114114509.15350-1-sarunkod@xxxxxxx/
<https://patchew.org/QEMU/20241114114509.15350-1-sarunkod@xxxxxxx/>
>
<https://patchew.org/QEMU/20241114114509.15350-1-sarunkod@xxxxxxx/
<https://patchew.org/QEMU/20241114114509.15350-1-sarunkod@xxxxxxx/>>
> or mine to fix this link error? As neither patch has so far been
merged,
> 9.2.0-rc2 still fails to build on macOS, at least on my local
systems.
> I'm not sure why CI builds aren't jumping up and down about this,
but
> neither the Xcode 15.2 nor 16.1 toolchains are happy on macOS
14.7/arm64.
Just curious, is your build configured with --enable-hvf --enable-tcg?
It's my understanding that both HVF and TCG are enabled by default when
building on macOS - they both show up as "YES" in the ./configure
output, and the relevant -accel works; at any rate, specifying them
explicitly made no difference with regard to this link error. Your
question did however prompt me to dig a little deeper and check which of
my test configurations was affected.
It looks like the critical setting is --enable-debug. I think that
changes the exact optimisation level (not -O0 but less aggressive than
the default), so it's not unreasonable that this would change the
compiler pass(es) for eliminating constant conditional branches.
So yeah, when I build latest master/staging with --enable-debug on macOS
and my --target-list includes x86_64, QEMU fails to link with an
undefined symbol error for _kvm_enable_x2apic. This happens on both
arm64 and x86-64 hosts, and with various Xcode 15.x and 16.y toolchains.
Indeed:
C compiler for the host machine: clang (clang 16.0.0 "Apple clang
version 16.0.0 (clang-1600.0.26.4)")
C linker for the host machine: clang ld64 1115.7.3
Host machine cpu family: aarch64
Host machine cpu: aarch64
Compilation
host CPU : aarch64
host endianness : little
C compiler : clang
Host C compiler : clang
C++ compiler : NO
Objective-C compiler : clang
Rust support : NO
CFLAGS : -g -O0
User defined options
optimization : 0
Undefined symbols for architecture arm64:
"_kvm_enable_x2apic", referenced from:
_amdvi_sysbus_realize in hw_i386_amd_iommu.c.o
ld: symbol(s) not found for architecture arm64
I have to admit I'm personally not a big fan of relying on the optimiser
for removing references to these symbols, but restructuring the
conditional expression like in Sairaj and Santosh's patch seems to allow
even the optimisation level used for debug builds to do it, so I guess I
can't argue with the result. :-)
See related commit 9926cf34de5 ("target/i386: Allow elision of
kvm_enable_x2apic()").