Skip to content
Snippets Groups Projects
  • Philippe Mathieu-Daudé's avatar
    2fed21d2
    disas/libvixl: Protect C system header for C++ compiler · 2fed21d2
    Philippe Mathieu-Daudé authored
    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)
            |                   ^
    
    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
    
    Partially cherry-pick vixl commit 78973f258039f6e96 [*]:
    
      Refactor VIXL to use `extern` block when including C header
      that do not have a C++ counterpart.
    
    which is similar to commit 875df03b ('osdep: protect qemu/osdep.h
    with extern "C"').
    
    [*] https://git.linaro.org/arm/vixl.git/commit/?id=78973f258039f6e96
    
    Buglink: https://bugs.launchpad.net/qemu/+bug/1914870
    
    
    Suggested-by: default avatarThomas Huth <thuth@redhat.com>
    Signed-off-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
    Reviewed-by: default avatarThomas Huth <thuth@redhat.com>
    Message-id: 20210516171023.510778-1-f4bug@amsat.org
    Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
    2fed21d2
    History
    disas/libvixl: Protect C system header for C++ compiler
    Philippe Mathieu-Daudé authored
    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)
            |                   ^
    
    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
    
    Partially cherry-pick vixl commit 78973f258039f6e96 [*]:
    
      Refactor VIXL to use `extern` block when including C header
      that do not have a C++ counterpart.
    
    which is similar to commit 875df03b ('osdep: protect qemu/osdep.h
    with extern "C"').
    
    [*] https://git.linaro.org/arm/vixl.git/commit/?id=78973f258039f6e96
    
    Buglink: https://bugs.launchpad.net/qemu/+bug/1914870
    
    
    Suggested-by: default avatarThomas Huth <thuth@redhat.com>
    Signed-off-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
    Reviewed-by: default avatarThomas Huth <thuth@redhat.com>
    Message-id: 20210516171023.510778-1-f4bug@amsat.org
    Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>