qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] disas/libvixl: Protect C system header for C++ compiler
@ 2021-05-15 18:35 Philippe Mathieu-Daudé
  2021-05-16 12:40 ` Philippe Mathieu-Daudé
  2021-05-16 12:46 ` Thomas Huth
  0 siblings, 2 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-15 18:35 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Thomas Huth, Daniel P . Berrangé,
	Richard Henderson, Philippe Mathieu-Daudé,
	qemu-arm, Paolo Bonzini

When selecting an ARM target on Debian unstable, we get:

  Compiling C++ object libcommon.fa.p/disas_libvixl_vixl_utils.cc.o
  FAILED: libcommon.fa.p/disas_libvixl_vixl_utils.cc.o
  c++ -Ilibcommon.fa.p -I. -I.. [...] -o libcommon.fa.p/disas_libvixl_vixl_utils.cc.o -c ../disas/libvixl/vixl/utils.cc
  In file included from /home/philmd/qemu/disas/libvixl/vixl/utils.h:30,
                   from ../disas/libvixl/vixl/utils.cc:27:
  /usr/include/string.h:36:43: error: missing binary operator before token "("
     36 | #if defined __cplusplus && (__GNUC_PREREQ (4, 4) \
        |                                           ^
  /usr/include/string.h:53:62: error: missing binary operator before token "("
     53 | #if defined __USE_MISC || defined __USE_XOPEN || __GLIBC_USE (ISOC2X)
        |                                                              ^
  /usr/include/string.h:165:21: error: missing binary operator before token "("
    165 |      || __GLIBC_USE (LIB_EXT2) || __GLIBC_USE (ISOC2X))
        |                     ^
  /usr/include/string.h:174:43: error: missing binary operator before token "("
    174 | #if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2) || __GLIBC_USE (ISOC2X)
        |                                           ^
  /usr/include/string.h:492:19: error: missing binary operator before token "("
    492 | #if __GNUC_PREREQ (3,4)
        |                   ^

Similarly to commit 875df03b221 ('osdep: protect qemu/osdep.h with
extern "C"'), guard the <string.h> system header with 'extern "C"'.

Relevant information from the host:

  $ lsb_release -d
  Description:    Debian GNU/Linux 11 (bullseye)
  $ gcc --version
  gcc (Debian 10.2.1-6) 10.2.1 20210110
  $ dpkg -S /usr/include/string.h
  libc6-dev: /usr/include/string.h
  $ apt-cache show libc6-dev
  Package: libc6-dev
  Version: 2.31-11

Buglink: https://bugs.launchpad.net/qemu/+bug/1914870
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
RFC because I've no idea about C++, but this fixes the build for me.

Quick reproducer:

  $ ../configure --disable-tools --target-list=aarch64-linux-user

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Daniel P. Berrangé <berrange@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: Eric Blake <eblake@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>
---
 disas/libvixl/vixl/utils.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/disas/libvixl/vixl/utils.h b/disas/libvixl/vixl/utils.h
index 5ab134e240a..fc28d7456c1 100644
--- a/disas/libvixl/vixl/utils.h
+++ b/disas/libvixl/vixl/utils.h
@@ -27,8 +27,10 @@
 #ifndef VIXL_UTILS_H
 #define VIXL_UTILS_H
 
-#include <string.h>
 #include <cmath>
+extern "C" {
+#include <string.h>
+}
 #include "vixl/globals.h"
 #include "vixl/compiler-intrinsics.h"
 
-- 
2.26.3



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

* Re: [PATCH] disas/libvixl: Protect C system header for C++ compiler
  2021-05-15 18:35 [PATCH] disas/libvixl: Protect C system header for C++ compiler Philippe Mathieu-Daudé
@ 2021-05-16 12:40 ` Philippe Mathieu-Daudé
  2021-05-16 12:46 ` Thomas Huth
  1 sibling, 0 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-16 12:40 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Thomas Huth, Daniel P . Berrangé,
	Michael Tokarev, Richard Henderson, qemu-arm, Paolo Bonzini

Forgot to tag as RFC.

Cc'ing mjt to have feedback from Debian packaging.

On 5/15/21 8:35 PM, Philippe Mathieu-Daudé wrote:
> When selecting an ARM target on Debian unstable, we get:
> 
>   Compiling C++ object libcommon.fa.p/disas_libvixl_vixl_utils.cc.o
>   FAILED: libcommon.fa.p/disas_libvixl_vixl_utils.cc.o
>   c++ -Ilibcommon.fa.p -I. -I.. [...] -o libcommon.fa.p/disas_libvixl_vixl_utils.cc.o -c ../disas/libvixl/vixl/utils.cc
>   In file included from /home/philmd/qemu/disas/libvixl/vixl/utils.h:30,
>                    from ../disas/libvixl/vixl/utils.cc:27:
>   /usr/include/string.h:36:43: error: missing binary operator before token "("
>      36 | #if defined __cplusplus && (__GNUC_PREREQ (4, 4) \
>         |                                           ^
>   /usr/include/string.h:53:62: error: missing binary operator before token "("
>      53 | #if defined __USE_MISC || defined __USE_XOPEN || __GLIBC_USE (ISOC2X)
>         |                                                              ^
>   /usr/include/string.h:165:21: error: missing binary operator before token "("
>     165 |      || __GLIBC_USE (LIB_EXT2) || __GLIBC_USE (ISOC2X))
>         |                     ^
>   /usr/include/string.h:174:43: error: missing binary operator before token "("
>     174 | #if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2) || __GLIBC_USE (ISOC2X)
>         |                                           ^
>   /usr/include/string.h:492:19: error: missing binary operator before token "("
>     492 | #if __GNUC_PREREQ (3,4)
>         |                   ^
> 
> Similarly to commit 875df03b221 ('osdep: protect qemu/osdep.h with
> extern "C"'), guard the <string.h> system header with 'extern "C"'.
> 
> Relevant information from the host:
> 
>   $ lsb_release -d
>   Description:    Debian GNU/Linux 11 (bullseye)
>   $ gcc --version
>   gcc (Debian 10.2.1-6) 10.2.1 20210110
>   $ dpkg -S /usr/include/string.h
>   libc6-dev: /usr/include/string.h
>   $ apt-cache show libc6-dev
>   Package: libc6-dev
>   Version: 2.31-11
> 
> Buglink: https://bugs.launchpad.net/qemu/+bug/1914870
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> RFC because I've no idea about C++, but this fixes the build for me.
> 
> Quick reproducer:
> 
>   $ ../configure --disable-tools --target-list=aarch64-linux-user
> 
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Daniel P. Berrangé <berrange@redhat.com>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Cc: Eric Blake <eblake@redhat.com>
> Cc: Thomas Huth <thuth@redhat.com>
> ---
>  disas/libvixl/vixl/utils.h | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/disas/libvixl/vixl/utils.h b/disas/libvixl/vixl/utils.h
> index 5ab134e240a..fc28d7456c1 100644
> --- a/disas/libvixl/vixl/utils.h
> +++ b/disas/libvixl/vixl/utils.h
> @@ -27,8 +27,10 @@
>  #ifndef VIXL_UTILS_H
>  #define VIXL_UTILS_H
>  
> -#include <string.h>
>  #include <cmath>
> +extern "C" {
> +#include <string.h>
> +}
>  #include "vixl/globals.h"
>  #include "vixl/compiler-intrinsics.h"
>  
> 


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

* Re: [PATCH] disas/libvixl: Protect C system header for C++ compiler
  2021-05-15 18:35 [PATCH] disas/libvixl: Protect C system header for C++ compiler Philippe Mathieu-Daudé
  2021-05-16 12:40 ` Philippe Mathieu-Daudé
@ 2021-05-16 12:46 ` Thomas Huth
  2021-05-16 17:05   ` Philippe Mathieu-Daudé
  1 sibling, 1 reply; 4+ messages in thread
From: Thomas Huth @ 2021-05-16 12:46 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Daniel P . Berrangé,
	Richard Henderson, qemu-arm, Paolo Bonzini

On 15/05/2021 20.35, Philippe Mathieu-Daudé wrote:
> When selecting an ARM target on Debian unstable, we get:
> 
>    Compiling C++ object libcommon.fa.p/disas_libvixl_vixl_utils.cc.o
>    FAILED: libcommon.fa.p/disas_libvixl_vixl_utils.cc.o
>    c++ -Ilibcommon.fa.p -I. -I.. [...] -o libcommon.fa.p/disas_libvixl_vixl_utils.cc.o -c ../disas/libvixl/vixl/utils.cc
>    In file included from /home/philmd/qemu/disas/libvixl/vixl/utils.h:30,
>                     from ../disas/libvixl/vixl/utils.cc:27:
>    /usr/include/string.h:36:43: error: missing binary operator before token "("
>       36 | #if defined __cplusplus && (__GNUC_PREREQ (4, 4) \
>          |                                           ^
>    /usr/include/string.h:53:62: error: missing binary operator before token "("
>       53 | #if defined __USE_MISC || defined __USE_XOPEN || __GLIBC_USE (ISOC2X)
>          |                                                              ^
>    /usr/include/string.h:165:21: error: missing binary operator before token "("
>      165 |      || __GLIBC_USE (LIB_EXT2) || __GLIBC_USE (ISOC2X))
>          |                     ^
>    /usr/include/string.h:174:43: error: missing binary operator before token "("
>      174 | #if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2) || __GLIBC_USE (ISOC2X)
>          |                                           ^
>    /usr/include/string.h:492:19: error: missing binary operator before token "("
>      492 | #if __GNUC_PREREQ (3,4)
>          |                   ^
> 
> Similarly to commit 875df03b221 ('osdep: protect qemu/osdep.h with
> extern "C"'), guard the <string.h> system header with 'extern "C"'.
> 
> Relevant information from the host:
> 
>    $ lsb_release -d
>    Description:    Debian GNU/Linux 11 (bullseye)
>    $ gcc --version
>    gcc (Debian 10.2.1-6) 10.2.1 20210110
>    $ dpkg -S /usr/include/string.h
>    libc6-dev: /usr/include/string.h
>    $ apt-cache show libc6-dev
>    Package: libc6-dev
>    Version: 2.31-11
> 
> Buglink: https://bugs.launchpad.net/qemu/+bug/1914870
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> RFC because I've no idea about C++, but this fixes the build for me.
> 
> Quick reproducer:
> 
>    $ ../configure --disable-tools --target-list=aarch64-linux-user
> 
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Daniel P. Berrangé <berrange@redhat.com>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Cc: Eric Blake <eblake@redhat.com>
> Cc: Thomas Huth <thuth@redhat.com>
> ---
>   disas/libvixl/vixl/utils.h | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/disas/libvixl/vixl/utils.h b/disas/libvixl/vixl/utils.h
> index 5ab134e240a..fc28d7456c1 100644
> --- a/disas/libvixl/vixl/utils.h
> +++ b/disas/libvixl/vixl/utils.h
> @@ -27,8 +27,10 @@
>   #ifndef VIXL_UTILS_H
>   #define VIXL_UTILS_H
>   
> -#include <string.h>
>   #include <cmath>
> +extern "C" {
> +#include <string.h>
> +}

Could you please try to backport the upstream patch instead:

https://git.linaro.org/arm/vixl.git/commit/?id=78973f258039f6e96

See the changes to utils-vixl.h:

diff --git a/src/utils-vixl.h b/src/utils-vixl.h
index 06c7551e..b27310db 100644
--- a/src/utils-vixl.h
+++ b/src/utils-vixl.h
@@ -27,9 +27,8 @@
  #ifndef VIXL_UTILS_H
  #define VIXL_UTILS_H

-#include <string.h>
-
  #include <cmath>
+#include <cstring>
  #include <vector>

  #include "compiler-intrinsics-vixl.h"

  Thomas



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

* Re: [PATCH] disas/libvixl: Protect C system header for C++ compiler
  2021-05-16 12:46 ` Thomas Huth
@ 2021-05-16 17:05   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-16 17:05 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel
  Cc: Peter Maydell, Richard Henderson, Daniel P . Berrangé,
	qemu-arm, Paolo Bonzini

On 5/16/21 2:46 PM, Thomas Huth wrote:
> On 15/05/2021 20.35, Philippe Mathieu-Daudé wrote:
>> When selecting an ARM target on Debian unstable, we get:
>>
>>    Compiling C++ object libcommon.fa.p/disas_libvixl_vixl_utils.cc.o
>>    FAILED: libcommon.fa.p/disas_libvixl_vixl_utils.cc.o
>>    c++ -Ilibcommon.fa.p -I. -I.. [...] -o
>> libcommon.fa.p/disas_libvixl_vixl_utils.cc.o -c
>> ../disas/libvixl/vixl/utils.cc
>>    In file included from /home/philmd/qemu/disas/libvixl/vixl/utils.h:30,
>>                     from ../disas/libvixl/vixl/utils.cc:27:
>>    /usr/include/string.h:36:43: error: missing binary operator before
>> token "("
>>       36 | #if defined __cplusplus && (__GNUC_PREREQ (4, 4) \
>>          |                                           ^
>>    /usr/include/string.h:53:62: error: missing binary operator before
>> token "("
>>       53 | #if defined __USE_MISC || defined __USE_XOPEN ||
>> __GLIBC_USE (ISOC2X)
>>          |                                                              ^
>>    /usr/include/string.h:165:21: error: missing binary operator before
>> token "("
>>      165 |      || __GLIBC_USE (LIB_EXT2) || __GLIBC_USE (ISOC2X))
>>          |                     ^
>>    /usr/include/string.h:174:43: error: missing binary operator before
>> token "("
>>      174 | #if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2) ||
>> __GLIBC_USE (ISOC2X)
>>          |                                           ^
>>    /usr/include/string.h:492:19: error: missing binary operator before
>> token "("
>>      492 | #if __GNUC_PREREQ (3,4)
>>          |                   ^
>>
>> Similarly to commit 875df03b221 ('osdep: protect qemu/osdep.h with
>> extern "C"'), guard the <string.h> system header with 'extern "C"'.
>>
>> Relevant information from the host:
>>
>>    $ lsb_release -d
>>    Description:    Debian GNU/Linux 11 (bullseye)
>>    $ gcc --version
>>    gcc (Debian 10.2.1-6) 10.2.1 20210110
>>    $ dpkg -S /usr/include/string.h
>>    libc6-dev: /usr/include/string.h
>>    $ apt-cache show libc6-dev
>>    Package: libc6-dev
>>    Version: 2.31-11
>>
>> Buglink: https://bugs.launchpad.net/qemu/+bug/1914870
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>> RFC because I've no idea about C++, but this fixes the build for me.
>>
>> Quick reproducer:
>>
>>    $ ../configure --disable-tools --target-list=aarch64-linux-user
>>
>> Cc: Paolo Bonzini <pbonzini@redhat.com>
>> Cc: Daniel P. Berrangé <berrange@redhat.com>
>> Cc: Peter Maydell <peter.maydell@linaro.org>
>> Cc: Richard Henderson <richard.henderson@linaro.org>
>> Cc: Eric Blake <eblake@redhat.com>
>> Cc: Thomas Huth <thuth@redhat.com>
>> ---
>>   disas/libvixl/vixl/utils.h | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/disas/libvixl/vixl/utils.h b/disas/libvixl/vixl/utils.h
>> index 5ab134e240a..fc28d7456c1 100644
>> --- a/disas/libvixl/vixl/utils.h
>> +++ b/disas/libvixl/vixl/utils.h
>> @@ -27,8 +27,10 @@
>>   #ifndef VIXL_UTILS_H
>>   #define VIXL_UTILS_H
>>   -#include <string.h>
>>   #include <cmath>
>> +extern "C" {
>> +#include <string.h>
>> +}
> 
> Could you please try to backport the upstream patch instead:
> 
> https://git.linaro.org/arm/vixl.git/commit/?id=78973f258039f6e96

Yes it works, thanks!


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

end of thread, other threads:[~2021-05-16 17:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-15 18:35 [PATCH] disas/libvixl: Protect C system header for C++ compiler Philippe Mathieu-Daudé
2021-05-16 12:40 ` Philippe Mathieu-Daudé
2021-05-16 12:46 ` Thomas Huth
2021-05-16 17:05   ` Philippe Mathieu-Daudé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).