Skip to contentSkip to conversation

target/i386: Re-introduce few KVM stubs for Clang debug builds

PATCH Superseded Philippe Mathieu-Daudé 5 participants 8 messages Sep 11, 2023 KVM

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/i386: Re-introduce few KVM stubs for Clang debug builds

Since commits 3adce820cf..ef1cf6890f, When building on a x86 host configured as:

  $ ./configure --cc=clang \
    --target-list=x86_64-linux-user,x86_64-softmmu \
    --enable-debug

we get:

[71/71] Linking target qemu-x86_64
FAILED: qemu-x86_64
/usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o: in function `cpu_x86_cpuid':
cpu.c:(.text+0x1374): undefined reference to `kvm_arch_get_supported_cpuid'
/usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o: in function `x86_cpu_filter_features':
cpu.c:(.text+0x81c2): undefined reference to `kvm_arch_get_supported_cpuid'
/usr/bin/ld: cpu.c:(.text+0x81da): undefined reference to `kvm_arch_get_supported_cpuid'
/usr/bin/ld: cpu.c:(.text+0x81f2): undefined reference to `kvm_arch_get_supported_cpuid'
/usr/bin/ld: cpu.c:(.text+0x820a): undefined reference to `kvm_arch_get_supported_cpuid'
/usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o:cpu.c:(.text+0x8225): more undefined references to `kvm_arch_get_supported_cpuid' follow
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

'--enable-debug' disables optimizations (CFLAGS=-O0).

While at this (un)optimization level GCC eliminate the following dead code:

  if (0 && foo()) {
      ...
  }

Clang does not. Therefore restore a pair of stubs for unoptimized Clang builds.

Fixes 3adce820cf ("target/i386: Remove unused KVM stubs")
Fixes ef1cf6890f ("target/i386: Allow elision of kvm_hv_vpindex_settable()")
---
 target/i386/kvm/kvm_i386.h | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
target/i386/kvm/kvm_i386.h +18 -3
index 55d4e68c34..0b62ac628f 100644
@@ -32,7 +32,6 @@
 
 bool kvm_has_smm(void);
 bool kvm_enable_x2apic(void);
-bool kvm_hv_vpindex_settable(void);
 bool kvm_has_pit_state2(void);
 
 bool kvm_enable_sgx_provisioning(KVMState *s);
@@ -41,8 +40,6 @@ bool kvm_hyperv_expand_features(X86CPU *cpu, Error **errp);
 void kvm_arch_reset_vcpu(X86CPU *cs);
 void kvm_arch_after_reset_vcpu(X86CPU *cpu);
 void kvm_arch_do_init_vcpu(X86CPU *cs);
-uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function,
-                                      uint32_t index, int reg);
 uint64_t kvm_arch_get_supported_msr_feature(KVMState *s, uint32_t index);
 
 void kvm_set_max_apic_id(uint32_t max_apic_id);
@@ -60,6 +57,10 @@ void kvm_put_apicbase(X86CPU *cpu, uint64_t value);
 
 bool kvm_has_x2apic_api(void);
 bool kvm_has_waitpkg(void);
+bool kvm_hv_vpindex_settable(void);
+
+uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function,
+                                      uint32_t index, int reg);
 
 uint64_t kvm_swizzle_msi_ext_dest_id(uint64_t address);
 void kvm_update_msi_routes_all(void *private, bool global,
@@ -76,6 +77,20 @@ typedef struct kvm_msr_handlers {
 bool kvm_filter_msr(KVMState *s, uint32_t msr, QEMURDMSRHandler *rdmsr,
                     QEMUWRMSRHandler *wrmsr);
 
+#elif defined(__clang__) && !defined(__OPTIMIZE__)
+
+static inline bool kvm_hv_vpindex_settable(void)
+{
+    g_assert_not_reached();
+}
+
+static inline uint32_t kvm_arch_get_supported_cpuid(KVMState *env,
+                                                    uint32_t function,
+                                                    uint32_t index, int reg)
+{
+    g_assert_not_reached();
+}
+
 #endif /* CONFIG_KVM */
 
 void kvm_pc_setup_irq_routing(bool pci_enabled);
Signature · 1 line
2.41.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 76 lines · Philippe Mathieu-Daudé

Since commits 3adce820cf..ef1cf6890f, When building on a x86 host configured as:

  $ ./configure --cc=clang \
    --target-list=x86_64-linux-user,x86_64-softmmu \
    --enable-debug

we get:

[71/71] Linking target qemu-x86_64
FAILED: qemu-x86_64
/usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o: in function `cpu_x86_cpuid':
cpu.c:(.text+0x1374): undefined reference to `kvm_arch_get_supported_cpuid'
/usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o: in function `x86_cpu_filter_features':
cpu.c:(.text+0x81c2): undefined reference to `kvm_arch_get_supported_cpuid'
/usr/bin/ld: cpu.c:(.text+0x81da): undefined reference to `kvm_arch_get_supported_cpuid'
/usr/bin/ld: cpu.c:(.text+0x81f2): undefined reference to `kvm_arch_get_supported_cpuid'
/usr/bin/ld: cpu.c:(.text+0x820a): undefined reference to `kvm_arch_get_supported_cpuid'
/usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o:cpu.c:(.text+0x8225): more undefined references to `kvm_arch_get_supported_cpuid' follow
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

'--enable-debug' disables optimizations (CFLAGS=-O0).

While at this (un)optimization level GCC eliminate the following dead code:

  if (0 && foo()) {
      ...
  }

Clang does not. Therefore restore a pair of stubs for unoptimized Clang builds.

Fixes 3adce820cf ("target/i386: Remove unused KVM stubs")
Fixes ef1cf6890f ("target/i386: Allow elision of kvm_hv_vpindex_settable()")
---
 target/i386/kvm/kvm_i386.h | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
target/i386/kvm/kvm_i386.h +4 -3
index 55d4e68c34..0b62ac628f 100644
@@ -32,7 +32,6 @@
 
 bool kvm_has_smm(void);
 bool kvm_enable_x2apic(void);
-bool kvm_hv_vpindex_settable(void);
 bool kvm_has_pit_state2(void);
 
 bool kvm_enable_sgx_provisioning(KVMState *s);
@@ -41,8 +40,6 @@ bool kvm_hyperv_expand_features(X86CPU *cpu, Error **errp);
 void kvm_arch_reset_vcpu(X86CPU *cs);
 void kvm_arch_after_reset_vcpu(X86CPU *cpu);
 void kvm_arch_do_init_vcpu(X86CPU *cs);
-uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function,
-                                      uint32_t index, int reg);
 uint64_t kvm_arch_get_supported_msr_feature(KVMState *s, uint32_t index);
 
 void kvm_set_max_apic_id(uint32_t max_apic_id);
@@ -60,6 +57,10 @@ void kvm_put_apicbase(X86CPU *cpu, uint64_t value);
 
 bool kvm_has_x2apic_api(void);
 bool kvm_has_waitpkg(void);
+bool kvm_hv_vpindex_settable(void);
+
+uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function,
+                                      uint32_t index, int reg);
 
 uint64_t kvm_swizzle_msi_ext_dest_id(uint64_t address);
 void kvm_update_msi_routes_all(void *private, bool global,

target/i386/kvm/kvm_i386.h typedef struct kvm_msr_handlers { · line 80

Quoted 4 lines
target/i386/kvm/kvm_i386.h +1 -0
@@ -76,6 +77,20 @@ typedef struct kvm_msr_handlers {
 bool kvm_filter_msr(KVMState *s, uint32_t msr, QEMURDMSRHandler *rdmsr,
                     QEMUWRMSRHandler *wrmsr);
 
+#elif defined(__clang__) && !defined(__OPTIMIZE__)

Another approach is a static library with a .o file containing the stubs so the linker only includes it in the executable if the compiler emitted the symbols. That way there is no need for defined(__clang__) && !defined(__OPTIMIZE__) and it will work with other compilers/optimization levels. It's more work to set up though.

#2 lore raw

Or instead of using linker behavior, maybe just change the #ifdef so it only applies when KVM is disabled. I didn't look at the code to see if this is possible, but it would be nice to avoid the very specific #ifdef condition in this patch.

Stefan

Quoted 104 lines · On Mon, Sep 11, 2023, 07:15 Stefan Hajnoczi <[email protected]> wrote:
Quoted 8 lines · Philippe Mathieu-Daudé

Since commits 3adce820cf..ef1cf6890f, When building on a x86 host configured as:

  $ ./configure --cc=clang \
    --target-list=x86_64-linux-user,x86_64-softmmu \
    --enable-debug
Quoted 5 lines

we get:

[71/71] Linking target qemu-x86_64
FAILED: qemu-x86_64
/usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o: in

function `cpu_x86_cpuid':

Quoted 1 line

cpu.c:(.text+0x1374): undefined reference to

`kvm_arch_get_supported_cpuid'

Quoted 1 line

/usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o: in

function `x86_cpu_filter_features':

Quoted 1 line

cpu.c:(.text+0x81c2): undefined reference to

`kvm_arch_get_supported_cpuid'

Quoted 1 line

/usr/bin/ld: cpu.c:(.text+0x81da): undefined reference to

`kvm_arch_get_supported_cpuid'

Quoted 1 line

/usr/bin/ld: cpu.c:(.text+0x81f2): undefined reference to

`kvm_arch_get_supported_cpuid'

Quoted 1 line

/usr/bin/ld: cpu.c:(.text+0x820a): undefined reference to

`kvm_arch_get_supported_cpuid'

Quoted 1 line

/usr/bin/ld:

libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o:cpu.c:(.text+0x8225):
more undefined references to `kvm_arch_get_supported_cpuid' follow

Quoted 1 line

clang: error: linker command failed with exit code 1 (use -v to see

invocation)

Quoted 11 lines

ninja: build stopped: subcommand failed.

'--enable-debug' disables optimizations (CFLAGS=-O0).

While at this (un)optimization level GCC eliminate the following dead code:

  if (0 && foo()) {
      ...
  }
Quoted 6 lines

Clang does not. Therefore restore a pair of stubs for unoptimized Clang builds.

Fixes 3adce820cf ("target/i386: Remove unused KVM stubs")
Fixes ef1cf6890f ("target/i386: Allow elision of

kvm_hv_vpindex_settable()")

target/i386/kvm/kvm_i386.h bool kvm_hyperv_expand_features(X86CPU *cpu, Error

Quoted 18 lines
---
 target/i386/kvm/kvm_i386.h | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
target/i386/kvm/kvm_i386.h +0 -1
index 55d4e68c34..0b62ac628f 100644
@@ -32,7 +32,6 @@
 
 bool kvm_has_smm(void);
 bool kvm_enable_x2apic(void);
-bool kvm_hv_vpindex_settable(void);
 bool kvm_has_pit_state2(void);
 
 bool kvm_enable_sgx_provisioning(KVMState *s);
@@ -41,8 +40,6 @@ bool kvm_hyperv_expand_features(X86CPU *cpu, Error

**errp);

target/i386/kvm/kvm_i386.h bool kvm_hyperv_expand_features(X86CPU *cpu, Error **errp);

Quoted 6 lines
target/i386/kvm/kvm_i386.h +0 -2
 void kvm_arch_reset_vcpu(X86CPU *cs);
 void kvm_arch_after_reset_vcpu(X86CPU *cpu);
 void kvm_arch_do_init_vcpu(X86CPU *cs);
-uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function,
-                                      uint32_t index, int reg);
 uint64_t kvm_arch_get_supported_msr_feature(KVMState *s, uint32_t

index);

Quoted 14 lines
target/i386/kvm/kvm_i386.h +4 -0
 void kvm_set_max_apic_id(uint32_t max_apic_id);
@@ -60,6 +57,10 @@ void kvm_put_apicbase(X86CPU *cpu, uint64_t value);
 
 bool kvm_has_x2apic_api(void);
 bool kvm_has_waitpkg(void);
+bool kvm_hv_vpindex_settable(void);
+
+uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function,
+                                      uint32_t index, int reg);
 
 uint64_t kvm_swizzle_msi_ext_dest_id(uint64_t address);
 void kvm_update_msi_routes_all(void *private, bool global,

target/i386/kvm/kvm_i386.h typedef struct kvm_msr_handlers { · line 80

Quoted 4 lines
target/i386/kvm/kvm_i386.h +1 -0
@@ -76,6 +77,20 @@ typedef struct kvm_msr_handlers {
 bool kvm_filter_msr(KVMState *s, uint32_t msr, QEMURDMSRHandler *rdmsr,
                     QEMUWRMSRHandler *wrmsr);
 
+#elif defined(__clang__) && !defined(__OPTIMIZE__)

Another approach is a static library with a .o file containing the stubs so the linker only includes it in the executable if the compiler emitted the symbols. That way there is no need for defined(__clang__) && !defined(__OPTIMIZE__) and it will work with other compilers/optimization levels. It's more work to set up though.

#3 lore raw

11.09.2023 14:56, Stefan Hajnoczi:

Quoted 1 line

Or instead of using linker behavior, maybe just change the #ifdef so it only applies when KVM is disabled. I didn't look at the code to see if this is possible, but it would be nice to avoid the very specific #ifdef condition in this patch.

Yeah, this is definitely preferrable to define it based on !kvm instead of !optimize.

I mean the same thing when replied in the pullreq which broke things, - to base it on !kvm. But use something very similar to what Philippe did with the functions themselves (not with the condition).

/mjt

#4 lore raw
In reply to Stefan Hajnoczi

Am 11.09.2023 um 13:15 hat Stefan Hajnoczi geschrieben:

Quoted 80 lines · Philippe Mathieu-Daudé
Quoted 79 lines

Since commits 3adce820cf..ef1cf6890f, When building on a x86 host configured as:

  $ ./configure --cc=clang \
    --target-list=x86_64-linux-user,x86_64-softmmu \
    --enable-debug

we get:

[71/71] Linking target qemu-x86_64
FAILED: qemu-x86_64
/usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o: in function `cpu_x86_cpuid':
cpu.c:(.text+0x1374): undefined reference to `kvm_arch_get_supported_cpuid'
/usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o: in function `x86_cpu_filter_features':
cpu.c:(.text+0x81c2): undefined reference to `kvm_arch_get_supported_cpuid'
/usr/bin/ld: cpu.c:(.text+0x81da): undefined reference to `kvm_arch_get_supported_cpuid'
/usr/bin/ld: cpu.c:(.text+0x81f2): undefined reference to `kvm_arch_get_supported_cpuid'
/usr/bin/ld: cpu.c:(.text+0x820a): undefined reference to `kvm_arch_get_supported_cpuid'
/usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o:cpu.c:(.text+0x8225): more undefined references to `kvm_arch_get_supported_cpuid' follow
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

'--enable-debug' disables optimizations (CFLAGS=-O0).

While at this (un)optimization level GCC eliminate the following dead code:

  if (0 && foo()) {
      ...
  }

Clang does not. Therefore restore a pair of stubs for unoptimized Clang builds.

Fixes 3adce820cf ("target/i386: Remove unused KVM stubs")
Fixes ef1cf6890f ("target/i386: Allow elision of kvm_hv_vpindex_settable()")
---
 target/i386/kvm/kvm_i386.h | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
target/i386/kvm/kvm_i386.h +4 -3
index 55d4e68c34..0b62ac628f 100644
@@ -32,7 +32,6 @@
 
 bool kvm_has_smm(void);
 bool kvm_enable_x2apic(void);
-bool kvm_hv_vpindex_settable(void);
 bool kvm_has_pit_state2(void);
 
 bool kvm_enable_sgx_provisioning(KVMState *s);
@@ -41,8 +40,6 @@ bool kvm_hyperv_expand_features(X86CPU *cpu, Error **errp);
 void kvm_arch_reset_vcpu(X86CPU *cs);
 void kvm_arch_after_reset_vcpu(X86CPU *cpu);
 void kvm_arch_do_init_vcpu(X86CPU *cs);
-uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function,
-                                      uint32_t index, int reg);
 uint64_t kvm_arch_get_supported_msr_feature(KVMState *s, uint32_t index);
 
 void kvm_set_max_apic_id(uint32_t max_apic_id);
@@ -60,6 +57,10 @@ void kvm_put_apicbase(X86CPU *cpu, uint64_t value);
 
 bool kvm_has_x2apic_api(void);
 bool kvm_has_waitpkg(void);
+bool kvm_hv_vpindex_settable(void);
+
+uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function,
+                                      uint32_t index, int reg);
 
 uint64_t kvm_swizzle_msi_ext_dest_id(uint64_t address);
 void kvm_update_msi_routes_all(void *private, bool global,
@@ -76,6 +77,20 @@ typedef struct kvm_msr_handlers {
 bool kvm_filter_msr(KVMState *s, uint32_t msr, QEMURDMSRHandler *rdmsr,
                     QEMUWRMSRHandler *wrmsr);
 
Quoted 7 lines

target/i386/kvm/kvm_i386.h typedef struct kvm_msr_handlers { · line 80

Quoted 1 line
target/i386/kvm/kvm_i386.h +1 -0
+#elif defined(__clang__) && !defined(__OPTIMIZE__)

Another approach is a static library with a .o file containing the stubs so the linker only includes it in the executable if the compiler emitted the symbols. That way there is no need for defined(__clang__) && !defined(__OPTIMIZE__) and it will work with other compilers/optimization levels. It's more work to set up though.

Isn't that exactly how it was before the stubs were removed? It would be a simple revert of that commit.

The approach with static inline functions defined only for a very specific configuration looks a lot more fragile to me. In fact, I'm surprised that it works because I think it requires that the header isn't used in any files that are shared between user space and system emulation - and naively cpu.c sounded like something that could be shared. Looks like this patch only works because the linux-user target uses a separate build of the same CPU emulation source file.

So I think reverting the commit that removed the stubs would be much more obvious.

Kevin

#5 lore raw
Quoted 65 lines · Kevin Wolf

Am 11.09.2023 um 13:15 hat Stefan Hajnoczi geschrieben:

Quoted 45 lines · Philippe Mathieu-Daudé
Quoted 42 lines

Since commits 3adce820cf..ef1cf6890f, When building on a x86 host configured as:

   $ ./configure --cc=clang \
     --target-list=x86_64-linux-user,x86_64-softmmu \
     --enable-debug

we get:

   [71/71] Linking target qemu-x86_64
   FAILED: qemu-x86_64
   /usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o: in function `cpu_x86_cpuid':
   cpu.c:(.text+0x1374): undefined reference to `kvm_arch_get_supported_cpuid'
   /usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o: in function `x86_cpu_filter_features':
   cpu.c:(.text+0x81c2): undefined reference to `kvm_arch_get_supported_cpuid'
   /usr/bin/ld: cpu.c:(.text+0x81da): undefined reference to `kvm_arch_get_supported_cpuid'
   /usr/bin/ld: cpu.c:(.text+0x81f2): undefined reference to `kvm_arch_get_supported_cpuid'
   /usr/bin/ld: cpu.c:(.text+0x820a): undefined reference to `kvm_arch_get_supported_cpuid'
   /usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o:cpu.c:(.text+0x8225): more undefined references to `kvm_arch_get_supported_cpuid' follow
   clang: error: linker command failed with exit code 1 (use -v to see invocation)
   ninja: build stopped: subcommand failed.

'--enable-debug' disables optimizations (CFLAGS=-O0).

While at this (un)optimization level GCC eliminate the following dead code:

   if (0 && foo()) {
       ...
   }

Clang does not. Therefore restore a pair of stubs for unoptimized Clang builds.

Fixes 3adce820cf ("target/i386: Remove unused KVM stubs")
Fixes ef1cf6890f ("target/i386: Allow elision of kvm_hv_vpindex_settable()")
---
  target/i386/kvm/kvm_i386.h | 21 ++++++++++++++++++---
  1 file changed, 18 insertions(+), 3 deletions(-)
Quoted 7 lines
Quoted 1 line

+#elif defined(__clang__) && !defined(__OPTIMIZE__)

Another approach is a static library with a .o file containing the stubs so the linker only includes it in the executable if the compiler emitted the symbols. That way there is no need for defined(__clang__) && !defined(__OPTIMIZE__) and it will work with other compilers/optimization levels. It's more work to set up though.

Isn't that exactly how it was before the stubs were removed? It would be a simple revert of that commit.

The approach with static inline functions defined only for a very specific configuration looks a lot more fragile to me. In fact, I'm surprised that it works because I think it requires that the header isn't used in any files that are shared between user space and system emulation - and naively cpu.c sounded like something that could be shared. Looks like this patch only works because the linux-user target uses a separate build of the same CPU emulation source file.

Quoted 2 lines

So I think reverting the commit that removed the stubs would be much more obvious.

Yes, v2 reverts:
https://lore.kernel.org/qemu-devel/[email protected]/

#6 lore raw
In reply to Kevin Wolf

11.09.2023 15:32, Kevin Wolf wrote:
..

Quoted 8 lines

The approach with static inline functions defined only for a very specific configuration looks a lot more fragile to me. In fact, I'm surprised that it works because I think it requires that the header isn't used in any files that are shared between user space and system emulation - and naively cpu.c sounded like something that could be shared. Looks like this patch only works because the linux-user target uses a separate build of the same CPU emulation source file.

That's why both I and Stephan disliked the #ifdef condition, not the approach. If it were me, I'd change the condition to be !KVM and keep the inline functions (or #defines for that matter), instead of re- introducing stubs in a separate .c file.

/mjt

#7 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 31 lines · Philippe Mathieu-Daudé

Since commits 3adce820cf..ef1cf6890f, When building on a x86 host configured as:

  $ ./configure --cc=clang \
    --target-list=x86_64-linux-user,x86_64-softmmu \
    --enable-debug

we get:

[71/71] Linking target qemu-x86_64
FAILED: qemu-x86_64
/usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o: in function `cpu_x86_cpuid':
cpu.c:(.text+0x1374): undefined reference to `kvm_arch_get_supported_cpuid'
/usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o: in function `x86_cpu_filter_features':
cpu.c:(.text+0x81c2): undefined reference to `kvm_arch_get_supported_cpuid'
/usr/bin/ld: cpu.c:(.text+0x81da): undefined reference to `kvm_arch_get_supported_cpuid'
/usr/bin/ld: cpu.c:(.text+0x81f2): undefined reference to `kvm_arch_get_supported_cpuid'
/usr/bin/ld: cpu.c:(.text+0x820a): undefined reference to `kvm_arch_get_supported_cpuid'
/usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o:cpu.c:(.text+0x8225): more undefined references to `kvm_arch_get_supported_cpuid' follow
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

'--enable-debug' disables optimizations (CFLAGS=-O0).

While at this (un)optimization level GCC eliminate the following dead code:

  if (0 && foo()) {
      ...
  }
Quoted 6 lines

Clang does not. Therefore restore a pair of stubs for unoptimized Clang builds.

Fixes 3adce820cf ("target/i386: Remove unused KVM stubs")
Fixes ef1cf6890f ("target/i386: Allow elision of kvm_hv_vpindex_settable()")

Why not just revert those two commits, since we now learned the rationale for them was incorrect ?

Quoted 4 lines
---
 target/i386/kvm/kvm_i386.h | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|