Bug 209590 - emulators/qemu-sbruno emulators/qemu-user-static: Fix build with libc++ 3.8.0
Summary: emulators/qemu-sbruno emulators/qemu-user-static: Fix build with libc++ 3.8.0
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Sean Bruno
URL:
Keywords:
Depends on:
Blocks: 208158
  Show dependency treegraph
 
Reported: 2016-05-17 21:12 UTC by Dimitry Andric
Modified: 2016-06-29 13:26 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (sbruno)


Attachments
Don't define certain atomic macros for C++ (2.03 KB, patch)
2016-05-17 21:12 UTC, Dimitry Andric
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dimitry Andric freebsd_committer freebsd_triage 2016-05-17 21:12:10 UTC
Created attachment 170418 [details]
Don't define certain atomic macros for C++

During the exp-run in bug 208158, it was found that emulators/qemu-sbruno [1] and emulators/qemu-user-static [2] give errors with libc++ 3.8.0:

  CXX   disas/arm-a64.o
In file included from disas/arm-a64.cc:25:
In file included from /wrkdirs/usr/ports/emulators/qemu-sbruno/work/qemu-bsd-user-743fbff/disas/libvixl/vixl/a64/disasm-a64.h:33:
In file included from /wrkdirs/usr/ports/emulators/qemu-sbruno/work/qemu-bsd-user-743fbff/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /usr/include/c++/v1/list:173:
In file included from /usr/include/c++/v1/memory:616:
/usr/include/c++/v1/atomic:1316:1: error: expected parameter declarator
atomic_fetch_add(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
^
/wrkdirs/usr/ports/emulators/qemu-sbruno/work/qemu-bsd-user-743fbff/include/qemu/atomic.h:139:61: note: expanded from macro 'atomic_fetch_add'
#define atomic_fetch_add(ptr, n) __atomic_fetch_add(ptr, n, __ATOMIC_SEQ_CST)
                                                            ^
<built-in>:16:26: note: expanded from here
#define __ATOMIC_SEQ_CST 5
                         ^

This is because qemu's include/qemu/atomic.h defines several atomic macro names which conflict with standard C++ names, e.g. atomic_fetch_add, atomic_fetch_sub, etc.  Fix this (for both ports), by not defining the macros when __cplusplus is defined.  If any future qemu C++ code needs to use these atomic macros, it will have to be fixed separately.

It would be better if qemu didn't attempt to use the same identifiers as being used in the C++ standard, but renaming all the instances to e.g. qemu_atomic_xxx would cause a lot of code churn, so it is probably not worth it.

[1] http://package18.nyi.freebsd.org/data/headamd64PR208158-default/2016-05-01_10h29m48s/logs/errors/qemu-sbruno-2.5.93.g20160428.log
[2] http://package18.nyi.freebsd.org/data/headamd64PR208158-default/2016-05-01_10h29m48s/logs/errors/qemu-user-static-2.5.93.g20160428.log
Comment 1 Sean Bruno freebsd_committer freebsd_triage 2016-05-18 19:57:23 UTC
We will merge this upstream in the github repository and then update the port to pull this version.
Comment 2 commit-hook freebsd_committer freebsd_triage 2016-05-19 17:28:11 UTC
A commit references this bug:

Author: sbruno
Date: Thu May 19 17:27:35 UTC 2016
New revision: 415511
URL: https://svnweb.freebsd.org/changeset/ports/415511

Log:
  Update qemu-sbruno/qemu-static-user:
  Disable atomic macros which conflict with C++ QEMU's atomic header defines
  a few macros which conflict with standard C++ function names, namely
  atomic_fetch_{add,sub,and,or}.  Disable these macros when compiling for C++.

  PR:		209590
  Submitted by:	dim

Changes:
  head/emulators/qemu-sbruno/Makefile
  head/emulators/qemu-sbruno/distinfo
Comment 3 commit-hook freebsd_committer freebsd_triage 2016-06-02 18:38:22 UTC
A commit references this bug:

Author: sbruno
Date: Thu Jun  2 18:37:34 UTC 2016
New revision: 416287
URL: https://svnweb.freebsd.org/changeset/ports/416287

Log:
  Fixup for macros that conflict with standard C++ function names.

  PR:	209590
  Submitted by:	dim@

Changes:
  head/emulators/qemu-devel/Makefile
  head/emulators/qemu-devel/files/patch-include_qemu_atomic.h