All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] tcg/i386: Fix build for systems without working cpuid.h (MacOSX, Win32)
@ 2014-02-20 17:50 Peter Maydell
  2014-02-20 17:53 ` Peter Maydell
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Peter Maydell @ 2014-02-20 17:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: Richard Henderson, patches

Win32 doesn't have a cpuid.h, and MacOSX may have one but without
the __cpuid() function we use, which means that commit 9d2eec20
broke the build for those platforms. Fix this by tightening up
our configure cpuid.h check to test that the functions we need
are present, and adding some missing #ifdef guerds in
tcg/i386/tcg-target.c.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
Tested with Linux x86/64 gcc build, Linux x86/64 clang build,
W32 cross-build and MacOSX 10.8 build. If somebody would like to
review this I'll apply it directly to unbreak things.
Apologies for not catching it before I pushed the tcg pullreq;
I had forgotten to add the 'build on w32' command to my script.

 configure             | 8 +++++++-
 tcg/i386/tcg-target.c | 4 +++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 4648117..a2af9db 100755
--- a/configure
+++ b/configure
@@ -3564,7 +3564,13 @@ cpuid_h=no
 cat > $TMPC << EOF
 #include <cpuid.h>
 int main(void) {
-  return 0;
+    unsigned a, b, c, d;
+    int max = __get_cpuid_max(0, 0);
+
+    if (max >= 1) {
+        __cpuid(1, a, b, c, d);
+    }
+    return 0;
 }
 EOF
 if compile_prog "" "" ; then
diff --git a/tcg/i386/tcg-target.c b/tcg/i386/tcg-target.c
index fef1717..f832282 100644
--- a/tcg/i386/tcg-target.c
+++ b/tcg/i386/tcg-target.c
@@ -115,7 +115,7 @@ static const int tcg_target_call_oarg_regs[] = {
    is available.  */
 #if TCG_TARGET_REG_BITS == 64
 # define have_cmov 1
-#elif defined(CONFIG_CPUID_H)
+#elif defined(CONFIG_CPUID_H) && defined(bit_CMOV)
 static bool have_cmov;
 #else
 # define have_cmov 0
@@ -2295,6 +2295,7 @@ static void tcg_target_qemu_prologue(TCGContext *s)
 
 static void tcg_target_init(TCGContext *s)
 {
+#ifdef CONFIG_CPUID_H
     unsigned a, b, c, d;
     int max = __get_cpuid_max(0, 0);
 
@@ -2323,6 +2324,7 @@ static void tcg_target_init(TCGContext *s)
         have_bmi2 = (b & bit_BMI2) != 0;
 #endif
     }
+#endif
 
     if (TCG_TARGET_REG_BITS == 64) {
         tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I32], 0, 0xffff);
-- 
1.8.5

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH] tcg/i386: Fix build for systems without working cpuid.h (MacOSX, Win32)
  2014-02-20 17:50 [Qemu-devel] [PATCH] tcg/i386: Fix build for systems without working cpuid.h (MacOSX, Win32) Peter Maydell
@ 2014-02-20 17:53 ` Peter Maydell
  2014-02-20 19:22 ` Richard Henderson
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: Peter Maydell @ 2014-02-20 17:53 UTC (permalink / raw)
  To: QEMU Developers; +Cc: Patch Tracking, Richard Henderson

On 20 February 2014 17:50, Peter Maydell <peter.maydell@linaro.org> wrote:
> Win32 doesn't have a cpuid.h, and MacOSX may have one but without
> the __cpuid() function we use, which means that commit 9d2eec20
> broke the build for those platforms. Fix this by tightening up
> our configure cpuid.h check to test that the functions we need
> are present, and adding some missing #ifdef guerds in

"guards"; will fix locally.

> tcg/i386/tcg-target.c.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH] tcg/i386: Fix build for systems without working cpuid.h (MacOSX, Win32)
  2014-02-20 17:50 [Qemu-devel] [PATCH] tcg/i386: Fix build for systems without working cpuid.h (MacOSX, Win32) Peter Maydell
  2014-02-20 17:53 ` Peter Maydell
@ 2014-02-20 19:22 ` Richard Henderson
  2014-02-20 21:18 ` Stefan Weil
  2014-02-20 23:55 ` Brad Smith
  3 siblings, 0 replies; 10+ messages in thread
From: Richard Henderson @ 2014-02-20 19:22 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: patches

On 02/20/2014 11:50 AM, Peter Maydell wrote:
> +    unsigned a, b, c, d;
> +    int max = __get_cpuid_max(0, 0);
> +
> +    if (max >= 1) {
> +        __cpuid(1, a, b, c, d);
> +    }
> +    return 0;
>  }

You might as well check for __cpuid_count too while you're at it:

  if (max >= 7)
    __cpuid_count(7, 0, a, b, c, d);

Otherwise it looks good to me.

r~

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH] tcg/i386: Fix build for systems without working cpuid.h (MacOSX, Win32)
  2014-02-20 17:50 [Qemu-devel] [PATCH] tcg/i386: Fix build for systems without working cpuid.h (MacOSX, Win32) Peter Maydell
  2014-02-20 17:53 ` Peter Maydell
  2014-02-20 19:22 ` Richard Henderson
@ 2014-02-20 21:18 ` Stefan Weil
  2014-02-20 22:18   ` Peter Maydell
  2014-02-20 23:55 ` Brad Smith
  3 siblings, 1 reply; 10+ messages in thread
From: Stefan Weil @ 2014-02-20 21:18 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: patches, Richard Henderson

Am 20.02.2014 18:50, schrieb Peter Maydell:
> Win32 doesn't have a cpuid.h, and MacOSX may have one but without
> the __cpuid() function we use, which means that commit 9d2eec20
> broke the build for those platforms. Fix this by tightening up
> our configure cpuid.h check to test that the functions we need
> are present, and adding some missing #ifdef guerds in
> tcg/i386/tcg-target.c.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> Tested with Linux x86/64 gcc build, Linux x86/64 clang build,
> W32 cross-build and MacOSX 10.8 build. If somebody would like to
> review this I'll apply it directly to unbreak things.
> Apologies for not catching it before I pushed the tcg pullreq;
> I had forgotten to add the 'build on w32' command to my script.
> 


MinGW-w64's gcc has cpuid.h, so my 32 and 64 bit cross builds work
without problems. We can use that code for MinGW, too, but we could also
stop supporting MinGW (which has several other deficits).

Regards
Stefan

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH] tcg/i386: Fix build for systems without working cpuid.h (MacOSX, Win32)
  2014-02-20 21:18 ` Stefan Weil
@ 2014-02-20 22:18   ` Peter Maydell
  2014-02-21  5:53     ` Stefan Weil
  0 siblings, 1 reply; 10+ messages in thread
From: Peter Maydell @ 2014-02-20 22:18 UTC (permalink / raw)
  To: Stefan Weil; +Cc: Patch Tracking, QEMU Developers, Richard Henderson

On 20 February 2014 21:18, Stefan Weil <sw@weilnetz.de> wrote:
> MinGW-w64's gcc has cpuid.h, so my 32 and 64 bit cross builds work
> without problems. We can use that code for MinGW, too, but we could also
> stop supporting MinGW (which has several other deficits).

We need the conditionals for MacOSX builds anyway, so we
don't need to drop MinGW for this. (I compile with the 32 bit
version rather than -w64 because I was able to get that to
install on my Ubuntu box, whereas the -w64 seemed to have
dependency issues/conflicts somehow. I figured the 32 bit
version was good enough for detecting the typical "long is
a funny size and we don't build" issues.)

thanks
-- PMM

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH] tcg/i386: Fix build for systems without working cpuid.h (MacOSX, Win32)
  2014-02-20 17:50 [Qemu-devel] [PATCH] tcg/i386: Fix build for systems without working cpuid.h (MacOSX, Win32) Peter Maydell
                   ` (2 preceding siblings ...)
  2014-02-20 21:18 ` Stefan Weil
@ 2014-02-20 23:55 ` Brad Smith
  2014-02-21  0:09   ` Peter Maydell
  3 siblings, 1 reply; 10+ messages in thread
From: Brad Smith @ 2014-02-20 23:55 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: patches, Richard Henderson

On 20/02/14 12:50 PM, Peter Maydell wrote:
> Win32 doesn't have a cpuid.h, and MacOSX may have one but without
> the __cpuid() function we use, which means that commit 9d2eec20
> broke the build for those platforms. Fix this by tightening up
> our configure cpuid.h check to test that the functions we need
> are present, and adding some missing #ifdef guerds in
> tcg/i386/tcg-target.c.

The build will also fail if not using fairly new GCC or LLVM/Clang 3.4
or newer.

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH] tcg/i386: Fix build for systems without working cpuid.h (MacOSX, Win32)
  2014-02-20 23:55 ` Brad Smith
@ 2014-02-21  0:09   ` Peter Maydell
  2014-02-21  0:48     ` Brad Smith
  0 siblings, 1 reply; 10+ messages in thread
From: Peter Maydell @ 2014-02-21  0:09 UTC (permalink / raw)
  To: Brad Smith; +Cc: Patch Tracking, QEMU Developers, Richard Henderson

On 20 February 2014 23:55, Brad Smith <brad@comstyle.com> wrote:
> On 20/02/14 12:50 PM, Peter Maydell wrote:
>>
>> Win32 doesn't have a cpuid.h, and MacOSX may have one but without
>> the __cpuid() function we use, which means that commit 9d2eec20
>> broke the build for those platforms. Fix this by tightening up
>> our configure cpuid.h check to test that the functions we need
>> are present, and adding some missing #ifdef guerds in
>> tcg/i386/tcg-target.c.
>
>
> The build will also fail if not using fairly new GCC

Do you happen to know how new 'fairly new' is? My stock compile
is with gcc 4.6.something, which isn't a spring chicken any more,
and that worked OK.

(We're going to fix this anyway, so it's just for my curiosity.)

thanks
-- PMM

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH] tcg/i386: Fix build for systems without working cpuid.h (MacOSX, Win32)
  2014-02-21  0:09   ` Peter Maydell
@ 2014-02-21  0:48     ` Brad Smith
  0 siblings, 0 replies; 10+ messages in thread
From: Brad Smith @ 2014-02-21  0:48 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Patch Tracking, QEMU Developers, Richard Henderson

On 20/02/14 7:09 PM, Peter Maydell wrote:
> On 20 February 2014 23:55, Brad Smith <brad@comstyle.com> wrote:
>> On 20/02/14 12:50 PM, Peter Maydell wrote:
>>>
>>> Win32 doesn't have a cpuid.h, and MacOSX may have one but without
>>> the __cpuid() function we use, which means that commit 9d2eec20
>>> broke the build for those platforms. Fix this by tightening up
>>> our configure cpuid.h check to test that the functions we need
>>> are present, and adding some missing #ifdef guerds in
>>> tcg/i386/tcg-target.c.
>>
>>
>> The build will also fail if not using fairly new GCC
>
> Do you happen to know how new 'fairly new' is? My stock compile
> is with gcc 4.6.something, which isn't a spring chicken any more,
> and that worked OK.
>
> (We're going to fix this anyway, so it's just for my curiosity.)

Ok, it wasn't as new as I had thought. Actually taking a look at the
various releases __cpuid was added with GCC 4.3. __cpuid_count was
added with GCC 4.4.


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH] tcg/i386: Fix build for systems without working cpuid.h (MacOSX, Win32)
  2014-02-20 22:18   ` Peter Maydell
@ 2014-02-21  5:53     ` Stefan Weil
  2014-02-21 16:32       ` Peter Maydell
  0 siblings, 1 reply; 10+ messages in thread
From: Stefan Weil @ 2014-02-21  5:53 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Patch Tracking, QEMU Developers, Richard Henderson

Am 20.02.2014 23:18, schrieb Peter Maydell:
> On 20 February 2014 21:18, Stefan Weil <sw@weilnetz.de> wrote:
>> MinGW-w64's gcc has cpuid.h, so my 32 and 64 bit cross builds work
>> without problems. We can use that code for MinGW, too, but we could also
>> stop supporting MinGW (which has several other deficits).
> 
> We need the conditionals for MacOSX builds anyway, so we
> don't need to drop MinGW for this. (I compile with the 32 bit
> version rather than -w64 because I was able to get that to
> install on my Ubuntu box, whereas the -w64 seemed to have
> dependency issues/conflicts somehow. I figured the 32 bit
> version was good enough for detecting the typical "long is
> a funny size and we don't build" issues.)

One of my hosts runs Ubuntu precise. mingw-w64 works fine here and
includes both 32 bit and 64 compilers and libraries (the -w64 in its
name might be misleading). Maybe you will also need mingw-w64-tools, and
you can also add g++-mingw-w64 (which also includes two compilers).

Run configure with --cross-prefix=i686-w64-mingw32- or
--cross-prefix=x86_64-w64-mingw32- to build 32 or 64 bit executables.

Stefan

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH] tcg/i386: Fix build for systems without working cpuid.h (MacOSX, Win32)
  2014-02-21  5:53     ` Stefan Weil
@ 2014-02-21 16:32       ` Peter Maydell
  0 siblings, 0 replies; 10+ messages in thread
From: Peter Maydell @ 2014-02-21 16:32 UTC (permalink / raw)
  To: Stefan Weil; +Cc: Patch Tracking, QEMU Developers, Richard Henderson

On 21 February 2014 05:53, Stefan Weil <sw@weilnetz.de> wrote:
> One of my hosts runs Ubuntu precise. mingw-w64 works fine here and
> includes both 32 bit and 64 compilers and libraries (the -w64 in its
> name might be misleading). Maybe you will also need mingw-w64-tools, and
> you can also add g++-mingw-w64 (which also includes two compilers).

Hmm, it looks like apt-get is just confused and produces
a useless error message if you try to install mingw-w64
at the same time as mingw32...

thanks
-- PMM

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-02-21 16:33 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-20 17:50 [Qemu-devel] [PATCH] tcg/i386: Fix build for systems without working cpuid.h (MacOSX, Win32) Peter Maydell
2014-02-20 17:53 ` Peter Maydell
2014-02-20 19:22 ` Richard Henderson
2014-02-20 21:18 ` Stefan Weil
2014-02-20 22:18   ` Peter Maydell
2014-02-21  5:53     ` Stefan Weil
2014-02-21 16:32       ` Peter Maydell
2014-02-20 23:55 ` Brad Smith
2014-02-21  0:09   ` Peter Maydell
2014-02-21  0:48     ` Brad Smith

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.