Message ID | 20230907130004.500601-1-pbonzini@redhat.com |
---|---|
State | New |
Headers | show |
Applied, thanks. Please update the changelog at https://wiki.qemu.org/ChangeLog/8.2 for any user-visible changes.
Am 07.09.2023 um 17:44 hat Stefan Hajnoczi geschrieben: > Applied, thanks. > > Please update the changelog at https://wiki.qemu.org/ChangeLog/8.2 for any user-visible changes. Something in this has broken the build for me, it seems to be the linux-user binary that doesn't link any more: /usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o: in function `cpu_x86_cpuid': /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:6180: 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': /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7158: undefined reference to `kvm_arch_get_supported_cpuid' /usr/bin/ld: /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7159: undefined reference to `kvm_arch_get_supported_cpuid' /usr/bin/ld: /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7160: undefined reference to `kvm_arch_get_supported_cpuid' /usr/bin/ld: /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7161: undefined reference to `kvm_arch_get_supported_cpuid' /usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o:/home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7162: more undefined references to `kvm_arch_get_supported_cpuid' follow clang-15: error: linker command failed with exit code 1 (use -v to see invocation) In case it makes a difference, I'm using clang on F37. Kevin
I wonder how it passed CI? https://gitlab.com/qemu-project/qemu/-/pipelines/996175923/ Stefan On Fri, 8 Sept 2023 at 11:02, Kevin Wolf <kwolf@redhat.com> wrote: > > Am 07.09.2023 um 17:44 hat Stefan Hajnoczi geschrieben: > > Applied, thanks. > > > > Please update the changelog at https://wiki.qemu.org/ChangeLog/8.2 for any user-visible changes. > > Something in this has broken the build for me, it seems to be the > linux-user binary that doesn't link any more: > > /usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o: in function `cpu_x86_cpuid': > /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:6180: 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': > /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7158: undefined reference to `kvm_arch_get_supported_cpuid' > /usr/bin/ld: /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7159: undefined reference to `kvm_arch_get_supported_cpuid' > /usr/bin/ld: /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7160: undefined reference to `kvm_arch_get_supported_cpuid' > /usr/bin/ld: /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7161: undefined reference to `kvm_arch_get_supported_cpuid' > /usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o:/home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7162: more undefined references to `kvm_arch_get_supported_cpuid' follow > clang-15: error: linker command failed with exit code 1 (use -v to see invocation) > > In case it makes a difference, I'm using clang on F37. > > Kevin
Hi Kevin, On 8/9/23 17:01, Kevin Wolf wrote: > Am 07.09.2023 um 17:44 hat Stefan Hajnoczi geschrieben: >> Applied, thanks. >> >> Please update the changelog at https://wiki.qemu.org/ChangeLog/8.2 for any user-visible changes. > > Something in this has broken the build for me, it seems to be the > linux-user binary that doesn't link any more: > > /usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o: in function `cpu_x86_cpuid': > /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:6180: undefined reference to `kvm_arch_get_supported_cpuid' My patches. I can not reproduce so far, What are your ./configure command options? > /usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o: in function `x86_cpu_filter_features': > /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7158: undefined reference to `kvm_arch_get_supported_cpuid' > /usr/bin/ld: /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7159: undefined reference to `kvm_arch_get_supported_cpuid' > /usr/bin/ld: /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7160: undefined reference to `kvm_arch_get_supported_cpuid' > /usr/bin/ld: /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7161: undefined reference to `kvm_arch_get_supported_cpuid' > /usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o:/home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7162: more undefined references to `kvm_arch_get_supported_cpuid' follow > clang-15: error: linker command failed with exit code 1 (use -v to see invocation) > > In case it makes a difference, I'm using clang on F37. > > Kevin
Am 08.09.2023 um 18:11 hat Philippe Mathieu-Daudé geschrieben: > Hi Kevin, > > On 8/9/23 17:01, Kevin Wolf wrote: > > Am 07.09.2023 um 17:44 hat Stefan Hajnoczi geschrieben: > > > Applied, thanks. > > > > > > Please update the changelog at https://wiki.qemu.org/ChangeLog/8.2 for any user-visible changes. > > > > Something in this has broken the build for me, it seems to be the > > linux-user binary that doesn't link any more: > > > > /usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o: in function `cpu_x86_cpuid': > > /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:6180: undefined reference to `kvm_arch_get_supported_cpuid' > > My patches. I can not reproduce so far, Hm, ok. I can try to bisect it further then. > What are your ./configure command options? '/home/kwolf/source/qemu/configure' '--cc=clang' '--target-list=x86_64-linux-user,x86_64-softmmu,arm-softmmu,aarch64-softmmu' '--enable-debug' '--cxx=clang++' '--disable-blkio' Kevin > > /usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o: in function `x86_cpu_filter_features': > > /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7158: undefined reference to `kvm_arch_get_supported_cpuid' > > /usr/bin/ld: /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7159: undefined reference to `kvm_arch_get_supported_cpuid' > > /usr/bin/ld: /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7160: undefined reference to `kvm_arch_get_supported_cpuid' > > /usr/bin/ld: /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7161: undefined reference to `kvm_arch_get_supported_cpuid' > > /usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o:/home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7162: more undefined references to `kvm_arch_get_supported_cpuid' follow > > clang-15: error: linker command failed with exit code 1 (use -v to see invocation) > > > > In case it makes a difference, I'm using clang on F37. > > > > Kevin >
On Fri, Sep 08, 2023 at 07:16:16PM +0200, Kevin Wolf wrote: > Am 08.09.2023 um 18:11 hat Philippe Mathieu-Daudé geschrieben: > > Hi Kevin, > > > > On 8/9/23 17:01, Kevin Wolf wrote: > > > Am 07.09.2023 um 17:44 hat Stefan Hajnoczi geschrieben: > > > > Applied, thanks. > > > > > > > > Please update the changelog at https://wiki.qemu.org/ChangeLog/8.2 for any user-visible changes. > > > > > > Something in this has broken the build for me, it seems to be the > > > linux-user binary that doesn't link any more: > > > > > > /usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o: in function `cpu_x86_cpuid': > > > /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:6180: undefined reference to `kvm_arch_get_supported_cpuid' > > > > My patches. I can not reproduce so far, Given the missing function name, I'm assuming the problem is this commit: [quote] Subject: [PULL 42/51] target/i386: Remove unused KVM stubs From: Philippe Mathieu-Daudé <philmd@linaro.org> All these functions: - kvm_arch_get_supported_cpuid() - kvm_has_smm(() - kvm_hyperv_expand_features() - kvm_set_max_apic_id() are called after checking for kvm_enabled(), which is false when KVM is not built. Since the compiler elides these functions, their stubs are not used and can be removed. [/quote] > Hm, ok. I can try to bisect it further then. > > > What are your ./configure command options? > > '/home/kwolf/source/qemu/configure' '--cc=clang' '--target-list=x86_64-linux-user,x86_64-softmmu,arm-softmmu,aarch64-softmmu' '--enable-debug' '--cxx=clang++' '--disable-blkio' --enable-debug results in "-O0" being used for optimization. I bet this stops the compiler from eliding the functions as claimed by the commit above. IOW, we do in fact still need these stubs. With regards, Daniel
08.09.2023 20:16, Kevin Wolf: > Am 08.09.2023 um 18:11 hat Philippe Mathieu-Daudé geschrieben: >> Hi Kevin, >> >> On 8/9/23 17:01, Kevin Wolf wrote: >>> Am 07.09.2023 um 17:44 hat Stefan Hajnoczi geschrieben: >>>> Applied, thanks. >>>> >>>> Please update the changelog at https://wiki.qemu.org/ChangeLog/8.2 for any user-visible changes. >>> >>> Something in this has broken the build for me, it seems to be the >>> linux-user binary that doesn't link any more: >>> >>> /usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o: in function `cpu_x86_cpuid': >>> /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:6180: undefined reference to `kvm_arch_get_supported_cpuid' >> >> My patches. I can not reproduce so far, > > Hm, ok. I can try to bisect it further then. case 7: /* Structured Extended Feature Flags Enumeration Leaf */ if (count == 0) { ... if ((*ebx & CPUID_7_0_EBX_SGX) && (!kvm_enabled() || !(kvm_arch_get_supported_cpuid(cs->kvm_state, 0x7, 0, R_EBX) & CPUID_7_0_EBX_SGX))) { *ebx &= ~CPUID_7_0_EBX_SGX; } if ((*ecx & CPUID_7_0_ECX_SGX_LC) && (!(*ebx & CPUID_7_0_EBX_SGX) || !kvm_enabled() || !(kvm_arch_get_supported_cpuid(cs->kvm_state, 0x7, 0, R_ECX) & CPUID_7_0_ECX_SGX_LC))) { *ecx &= ~CPUID_7_0_ECX_SGX_LC; } It is most likely patch "target/i386: Remove unused KVM stubs" which removed kvm_arch_get_supported_cpuid(). Apparently clang isn't smart enough to eliminate call to this function? /mjt
Am 08.09.2023 um 19:16 hat Kevin Wolf geschrieben: > Am 08.09.2023 um 18:11 hat Philippe Mathieu-Daudé geschrieben: > > Hi Kevin, > > > > On 8/9/23 17:01, Kevin Wolf wrote: > > > Am 07.09.2023 um 17:44 hat Stefan Hajnoczi geschrieben: > > > > Applied, thanks. > > > > > > > > Please update the changelog at https://wiki.qemu.org/ChangeLog/8.2 for any user-visible changes. > > > > > > Something in this has broken the build for me, it seems to be the > > > linux-user binary that doesn't link any more: > > > > > > /usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o: in function `cpu_x86_cpuid': > > > /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:6180: undefined reference to `kvm_arch_get_supported_cpuid' > > > > My patches. I can not reproduce so far, > > Hm, ok. I can try to bisect it further then. Right, the commit message is obviously related, so you probably knew this already... :-) commit 3adce820cf9c454b49cabf52b829001ecb98500e Author: Philippe Mathieu-Daudé <philmd@linaro.org> Date: Mon Sep 4 14:43:17 2023 +0200 target/i386: Remove unused KVM stubs All these functions: - kvm_arch_get_supported_cpuid() - kvm_has_smm(() - kvm_hyperv_expand_features() - kvm_set_max_apic_id() are called after checking for kvm_enabled(), which is false when KVM is not built. Since the compiler elides these functions, their stubs are not used and can be removed. Inspired-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-ID: <20230904124325.79040-7-philmd@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> target/i386/kvm/kvm-stub.c | 26 -------------------------- 1 file changed, 26 deletions(-) Maybe the calls aren't eliminated because --enable-debug implies -O0? Kevin > > What are your ./configure command options? > > '/home/kwolf/source/qemu/configure' '--cc=clang' '--target-list=x86_64-linux-user,x86_64-softmmu,arm-softmmu,aarch64-softmmu' '--enable-debug' '--cxx=clang++' '--disable-blkio' > > Kevin > > > > /usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o: in function `x86_cpu_filter_features': > > > /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7158: undefined reference to `kvm_arch_get_supported_cpuid' > > > /usr/bin/ld: /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7159: undefined reference to `kvm_arch_get_supported_cpuid' > > > /usr/bin/ld: /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7160: undefined reference to `kvm_arch_get_supported_cpuid' > > > /usr/bin/ld: /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7161: undefined reference to `kvm_arch_get_supported_cpuid' > > > /usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o:/home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7162: more undefined references to `kvm_arch_get_supported_cpuid' follow > > > clang-15: error: linker command failed with exit code 1 (use -v to see invocation) > > > > > > In case it makes a difference, I'm using clang on F37. > > > > > > Kevin > >
On Fri, Sep 8, 2023 at 7:28 PM Kevin Wolf <kwolf@redhat.com> wrote: > Maybe the calls aren't eliminated because --enable-debug implies -O0? My experience is that it will still fold simple dead code like "0 && foo()" or even "if (0) { ... }", but maybe it's a GCC vs. clang difference. Philippe, I take it that you are looking at it? Paolo > Kevin > > > > What are your ./configure command options? > > > > '/home/kwolf/source/qemu/configure' '--cc=clang' '--target-list=x86_64-linux-user,x86_64-softmmu,arm-softmmu,aarch64-softmmu' '--enable-debug' '--cxx=clang++' '--disable-blkio' > > > > Kevin > > > > > > /usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o: in function `x86_cpu_filter_features': > > > > /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7158: undefined reference to `kvm_arch_get_supported_cpuid' > > > > /usr/bin/ld: /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7159: undefined reference to `kvm_arch_get_supported_cpuid' > > > > /usr/bin/ld: /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7160: undefined reference to `kvm_arch_get_supported_cpuid' > > > > /usr/bin/ld: /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7161: undefined reference to `kvm_arch_get_supported_cpuid' > > > > /usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o:/home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7162: more undefined references to `kvm_arch_get_supported_cpuid' follow > > > > clang-15: error: linker command failed with exit code 1 (use -v to see invocation) > > > > > > > > In case it makes a difference, I'm using clang on F37. > > > > > > > > Kevin > > > >
On 8/9/23 17:47, Stefan Hajnoczi wrote: > I wonder how it passed CI? > https://gitlab.com/qemu-project/qemu/-/pipelines/996175923/ The conditions are: - x86 host - both system / user emulation enabled - KVM disabled - debug enabled We have jobs with 3 of the 4, but none with all the 4. Is it worth test it? > > Stefan > > On Fri, 8 Sept 2023 at 11:02, Kevin Wolf <kwolf@redhat.com> wrote: >> >> Am 07.09.2023 um 17:44 hat Stefan Hajnoczi geschrieben: >>> Applied, thanks. >>> >>> Please update the changelog at https://wiki.qemu.org/ChangeLog/8.2 for any user-visible changes. >> >> Something in this has broken the build for me, it seems to be the >> linux-user binary that doesn't link any more: >> >> /usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o: in function `cpu_x86_cpuid': >> /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:6180: 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': >> /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7158: undefined reference to `kvm_arch_get_supported_cpuid' >> /usr/bin/ld: /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7159: undefined reference to `kvm_arch_get_supported_cpuid' >> /usr/bin/ld: /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7160: undefined reference to `kvm_arch_get_supported_cpuid' >> /usr/bin/ld: /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7161: undefined reference to `kvm_arch_get_supported_cpuid' >> /usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o:/home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7162: more undefined references to `kvm_arch_get_supported_cpuid' follow >> clang-15: error: linker command failed with exit code 1 (use -v to see invocation) >> >> In case it makes a difference, I'm using clang on F37. >> >> Kevin >
On 8/9/23 21:21, Paolo Bonzini wrote: > On Fri, Sep 8, 2023 at 7:28 PM Kevin Wolf <kwolf@redhat.com> wrote: >> Maybe the calls aren't eliminated because --enable-debug implies -O0? > > My experience is that it will still fold simple dead code like "0 && > foo()" or even "if (0) { ... }", but maybe it's a GCC vs. clang > difference. Philippe, I take it that you are looking at it? Yes, I'll send a patch soon. Sorry I didn't catch that case.
On 11/9/23 12:10, Philippe Mathieu-Daudé wrote: > On 8/9/23 17:47, Stefan Hajnoczi wrote: >> I wonder how it passed CI? >> https://gitlab.com/qemu-project/qemu/-/pipelines/996175923/ > > The conditions are: > - x86 host > - both system / user emulation enabled > - KVM disabled > - debug enabled Oh, I forgot: - clang compiler (because this isn't an issue with GCC). > We have jobs with 3 of the 4, but none with > all the 4. > > Is it worth test it?
08.09.2023 22:21, Paolo Bonzini wrote: > On Fri, Sep 8, 2023 at 7:28 PM Kevin Wolf <kwolf@redhat.com> wrote: >> Maybe the calls aren't eliminated because --enable-debug implies -O0? > > My experience is that it will still fold simple dead code like "0 && > foo()" or even "if (0) { ... }", but maybe it's a GCC vs. clang > difference. [..] In my view it's too fragile to rely on this. And yes, it's the clang builds which triggers this issue. We've a bugreport, https://gitlab.com/qemu-project/qemu/-/issues/1848 , where obviously-unreachable code hasn't been detected by gcc when optimizing for certain CPU type. This smells like a GCC bug but still it's something which we shouldn't rely on. What can be done though is, instead of making kvm_arch_get_supported_cpuid et all a stubs, to replace them in .h file with an empty macro when some condition(s) are met. In other words, fold kvm_enabled() "inside" of kvm_arch_get_supported_cpuid() and use some assert_not_reached() there. /mjt
11.09.2023 13:41, Michael Tokarev: > What can be done though is, instead of making kvm_arch_get_supported_cpuid > et all a stubs, to replace them in .h file with an empty macro when some > condition(s) are met. In other words, fold kvm_enabled() "inside" of > kvm_arch_get_supported_cpuid() and use some assert_not_reached() there. Which is exactly what Philippe did in "Re-introduce few KVM stubs for Clang debug builds". /mjt
On Mon, 11 Sept 2023 at 06:10, Philippe Mathieu-Daudé <philmd@linaro.org> wrote: > > On 8/9/23 17:47, Stefan Hajnoczi wrote: > > I wonder how it passed CI? > > https://gitlab.com/qemu-project/qemu/-/pipelines/996175923/ > > The conditions are: > - x86 host > - both system / user emulation enabled > - KVM disabled > - debug enabled > > We have jobs with 3 of the 4, but none with > all the 4. > > Is it worth test it? I think so. Kevin: Can you confirm your configuration matches what Philippe described? Stefan > > > > > Stefan > > > > On Fri, 8 Sept 2023 at 11:02, Kevin Wolf <kwolf@redhat.com> wrote: > >> > >> Am 07.09.2023 um 17:44 hat Stefan Hajnoczi geschrieben: > >>> Applied, thanks. > >>> > >>> Please update the changelog at https://wiki.qemu.org/ChangeLog/8.2 for any user-visible changes. > >> > >> Something in this has broken the build for me, it seems to be the > >> linux-user binary that doesn't link any more: > >> > >> /usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o: in function `cpu_x86_cpuid': > >> /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:6180: 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': > >> /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7158: undefined reference to `kvm_arch_get_supported_cpuid' > >> /usr/bin/ld: /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7159: undefined reference to `kvm_arch_get_supported_cpuid' > >> /usr/bin/ld: /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7160: undefined reference to `kvm_arch_get_supported_cpuid' > >> /usr/bin/ld: /home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7161: undefined reference to `kvm_arch_get_supported_cpuid' > >> /usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o:/home/kwolf/source/qemu/build-clang/../target/i386/cpu.c:7162: more undefined references to `kvm_arch_get_supported_cpuid' follow > >> clang-15: error: linker command failed with exit code 1 (use -v to see invocation) > >> > >> In case it makes a difference, I'm using clang on F37. > >> > >> Kevin > > >
Am 11.09.2023 um 12:22 hat Philippe Mathieu-Daudé geschrieben: > On 11/9/23 12:10, Philippe Mathieu-Daudé wrote: > > On 8/9/23 17:47, Stefan Hajnoczi wrote: > > > I wonder how it passed CI? > > > https://gitlab.com/qemu-project/qemu/-/pipelines/996175923/ > > > > The conditions are: > > - x86 host I didn't actually try other hosts, but why do you think it depends on the host? Is it not x86 target? > > - both system / user emulation enabled I did try this one while bisection because I didn't want to build the system emulator in each step. User emulation only is enough, you don't need to build the system emulator to get the build failure. > > - KVM disabled I didn't explicitly disable KVM, but I suppose it's automatically disabled for linux-user. > > - debug enabled > > Oh, I forgot: > > - clang compiler > > (because this isn't an issue with GCC). > > > We have jobs with 3 of the 4, but none with > > all the 4. > > > > Is it worth test it? So it's x86, user emulation is built, debug enabled, on clang. This doesn't feel very exotic, though of course --enable-debug will be more common for developers while it's not the primary test case for CI. I don't see any existing test to which it could be added without losing another important configuration. Not sure if it's worth an additional test when we're already hitting the CI limits too often. On the other hand, now that I'm looking at the CI configuration, is it correct that we have no build for clang + --enable-debug at all? Even if you ignore the other conditions? Maybe that's basic enough that we should have it. Kevin
On Mon, 2023-09-11 at 07:06 -0400, Stefan Hajnoczi wrote: > On Mon, 11 Sept 2023 at 06:10, Philippe Mathieu-Daudé > <philmd@linaro.org> wrote: > > > > On 8/9/23 17:47, Stefan Hajnoczi wrote: > > > I wonder how it passed CI? > > > https://gitlab.com/qemu-project/qemu/-/pipelines/996175923/ > > > > The conditions are: > > - x86 host > > - both system / user emulation enabled > > - KVM disabled > > - debug enabled > > > > We have jobs with 3 of the 4, but none with > > all the 4. > > > > Is it worth test it? > > I think so. Would it be feasible to modify one of the existing jobs instead of introducing more load to the CI by adding yet another new job? Thomas
On 11/9/23 12:11, Philippe Mathieu-Daudé wrote: > On 8/9/23 21:21, Paolo Bonzini wrote: >> On Fri, Sep 8, 2023 at 7:28 PM Kevin Wolf <kwolf@redhat.com> wrote: >>> Maybe the calls aren't eliminated because --enable-debug implies -O0? >> >> My experience is that it will still fold simple dead code like "0 && >> foo()" or even "if (0) { ... }", but maybe it's a GCC vs. clang >> difference. Philippe, I take it that you are looking at it? FTR preprocessed code is indeed: # 5682 "../../target/i386/cpu.c" uint64_t x86_cpu_get_supported_feature_word(FeatureWord w, _Bool migratable_only) { FeatureWordInfo *wi = &feature_word_info[w]; uint64_t r = 0; if ((0)) { switch (wi->type) { case CPUID_FEATURE_WORD: r = kvm_arch_get_supported_cpuid(kvm_state, wi->cpuid.eax, wi->cpuid.ecx, wi->cpuid.reg); break; case MSR_FEATURE_WORD: r = kvm_arch_get_supported_msr_feature(kvm_state, wi->msr.index); break; } } else if (0) { if (wi->type != CPUID_FEATURE_WORD) { return 0; } r = 0; } else if ((tcg_allowed)) { r = wi->tcg_features; } else { return ~0; } # 5725 "../../target/i386/cpu.c" if (migratable_only) { r &= x86_cpu_get_migratable_flags(w); } return r; } static void x86_cpu_get_supported_cpuid(uint32_t func, uint32_t index, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) { if ((0)) { *eax = kvm_arch_get_supported_cpuid(kvm_state, func, index, R_EAX); *ebx = kvm_arch_get_supported_cpuid(kvm_state, func, index, R_EBX); *ecx = kvm_arch_get_supported_cpuid(kvm_state, func, index, R_ECX); *edx = kvm_arch_get_supported_cpuid(kvm_state, func, index, R_EDX); } else if (0) { *eax = 0; *ebx = 0; *ecx = 0; *edx = 0; } else { *eax = 0; *ebx = 0; *ecx = 0; *edx = 0; } } Which made me wonder about this sysemu code use from useremu, in particular because the link failure comes from libqemu-x86_64-linux-user.fa.p. This pair of #ifdef'ry to restrict system-specific code seems sufficient to link: -- >8 -- diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 24ee67b42d..83914d5d1b 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6163,6 +6163,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, } *edx = env->features[FEAT_7_0_EDX]; /* Feature flags */ +#ifndef CONFIG_USER_ONLY /* * SGX cannot be emulated in software. If hardware does not * support enabling SGX and/or SGX flexible launch control, @@ -6181,6 +6182,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, CPUID_7_0_ECX_SGX_LC))) { *ecx &= ~CPUID_7_0_ECX_SGX_LC; } +#endif } else if (count == 1) { *eax = env->features[FEAT_7_1_EAX]; *edx = env->features[FEAT_7_1_EDX]; @@ -7152,6 +7154,7 @@ static void x86_cpu_filter_features(X86CPU *cpu, bool verbose) mark_unavailable_features(cpu, w, unavailable_features, prefix); } +#ifndef CONFIG_USER_ONLY if ((env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_INTEL_PT) && kvm_enabled()) { KVMState *s = CPU(cpu)->kvm_state; @@ -7179,6 +7182,7 @@ static void x86_cpu_filter_features(X86CPU *cpu, bool verbose) mark_unavailable_features(cpu, FEAT_7_0_EBX, CPUID_7_0_EBX_INTEL_PT, prefix); } } +#endif } --- So I'll send a v3.