Bug 209722

Summary: multimedia/vlc multimedia/vlc-qt4: Problems building with libc++ 3.8.0
Product: Ports & Packages Reporter: Dimitry Andric <dim>
Component: Individual Port(s)Assignee: Thomas Zander <riggs>
Status: Closed FIXED    
Severity: Affects Some People CC: allanjude, riggs
Priority: --- Flags: riggs: maintainer-feedback+
Version: Latest   
Hardware: Any   
OS: Any   
Bug Depends on:    
Bug Blocks: 208158    
Attachments:
Description Flags
Work around atomic redeclarations in vlc none

Description Dimitry Andric freebsd_committer 2016-05-23 20:10:18 UTC
During the exp-run in bug 208158, it was found that multimedia/vlc [1] and multimedia/vlc-qt4 [2] give errors with libc++ 3.8.0:

In file included from meta_engine/taglib.cpp:53:
In file included from /usr/local/include/taglib/taglib.h:47:
In file included from /usr/include/c++/v1/string:439:
In file included from /usr/include/c++/v1/algorithm:628:
In file included from /usr/include/c++/v1/memory:616:
/usr/include/c++/v1/atomic:823:1: error: expected unqualified-id
kill_dependency(_Tp __y) _NOEXCEPT
^
../include/vlc_atomic.h:45:7: note: expanded from macro 'kill_dependency'
    ((void)0)
      ^

And many more such errors.  These are caused by include/vlc_atomic.h, which defines a whole bunch of atomic macros, conflicting with the ones in the C++ standard <atomic> header.  Unfortunately there seems to be no easy workaround, as vlc_atomic.h starts with:

    29  # if !defined (__cplusplus) && (__STDC_VERSION__ >= 201112L) \
    30    && !defined (__STDC_NO_ATOMICS__)
    31
    32  /*** Native C11 atomics ***/
    33  #  include <stdatomic.h>
    34
    35  # else

and in the following part the macros are defined.  I attempted to use <stdatomic.h> even for C++ mode, but it isn't compatible with C++.  Also, we cannot unconditionally include <atomic> for C++, since a few types are not defined in there, e.g.:

../include/vlc_atomic.h:407:9: error: unknown type name 'atomic_uint_least32_t'; did you mean 'std::atomic_uint_least32_t'?
typedef atomic_uint_least32_t vlc_atomic_float;
        ^~~~~~~~~~~~~~~~~~~~~
        std::atomic_uint_least32_t

Also, <atomic> is only available when using libc++, not when using the version of libstdc++ in base.

I don't have any ready-made solution for this issue yet, but if anybody has good suggestions, please post them here. :)

[1] http://package18.nyi.freebsd.org/data/headamd64PR208158-default/2016-05-01_10h29m48s/logs/errors/vlc-2.2.1_8,4.log
[2] http://package18.nyi.freebsd.org/data/headamd64PR208158-default/2016-05-01_10h29m48s/logs/errors/vlc-qt4-2.2.1_8,4.log
Comment 1 Dimitry Andric freebsd_committer 2016-05-23 23:15:24 UTC
Created attachment 170584 [details]
Work around atomic redeclarations in vlc

Here is a first proposed patch, which is not very elegant, but it works for me in the following scenarios:
- Using clang on head with the old libc++ (approximately 3.7.0)
- Using clang on head with the new libc++ 3.8.0
- Using ports gcc on head with its copy of libstdc++

patch-include_vlc__atomic.h defines a special case for when libc++ 3.8.0 is used: then it includes <atomic>, and specifies a few atomic_xxx types (there were just three needed to make everything compile successfully).

patch-include_vlc__playlist.h and patch-include_vlc__sout.h move including of system and vlc headers to _before_ any 'extern "C" {' statement.  Otherwise inclusion of C++ headers within those system or vlc headers will basically explode with zillions of errors.

patch-modules_gui_qt4_dialogs_messages.hpp fixes an inconsistency in the qt4 dialog messages class, where it tried to atomic_store an int into an unsigned int.
Comment 2 Allan Jude freebsd_committer 2016-05-31 15:00:59 UTC
Note that the failure to build VLC is causing there to be no KDE4 meta package.
Comment 3 commit-hook freebsd_committer 2016-06-01 06:17:58 UTC
A commit references this bug:

Author: riggs
Date: Wed Jun  1 06:17:52 UTC 2016
New revision: 416225
URL: https://svnweb.freebsd.org/changeset/ports/416225

Log:
  Fix build with libc++ 3.8.0

  VLC brings its own header for atomic operations which defines a whole
  bunch of atomic macros, conflicting with the ones in the C++ standard
  <atomic> header. This changeset works around those.

  PR:		209722
  Submitted by:	dim

Changes:
  head/multimedia/vlc/files/patch-include_vlc__atomic.h
  head/multimedia/vlc/files/patch-include_vlc__playlist.h
  head/multimedia/vlc/files/patch-include_vlc__sout.h
  head/multimedia/vlc/files/patch-modules_gui_qt4_dialogs_messages.hpp
Comment 4 commit-hook freebsd_committer 2016-06-11 16:22:09 UTC
A commit references this bug:

Author: riggs
Date: Sat Jun 11 16:22:02 UTC 2016
New revision: 416726
URL: https://svnweb.freebsd.org/changeset/ports/416726

Log:
  MFH: r415944 r416225 r416711

  Update to upstream version 2.2.3

  Differential Revision:	https://reviews.freebsd.org/D6373

  Fix build with libc++ 3.8.0

  VLC brings its own header for atomic operations which defines a whole
  bunch of atomic macros, conflicting with the ones in the C++ standard
  <atomic> header. This changeset works around those.

  PR:		209722
  Submitted by:	dim

  Update to upstream release 2.2.4, fix remote attack CVE-2016-5108

  Detailed changelog (BSD relevant excerpts):

  Decoder:
  * Fix crash in G.711 wav files
  * Fix mp3 crash in libmad
  * Fix out-of-bound write in adpcm QT IMA codec (CVE-2016-5108)

  Qt:
  * Fix resizing issues

  Translations:
  * Update of Bulgarian, Catalan, German, French, Italian, Marathi, Norwegian
    Bokm?l, Norwegian Nynorsk, Portuguese, Slovak, Spanish (Mexico), Swedish,
    Simplified Chinese, and Traditional Chinese translations

  Security:	CVE-2016-5108

  Approved by:	ports-secteam (junovitch)

Changes:
_U  branches/2016Q2/
  branches/2016Q2/multimedia/vlc/Makefile
  branches/2016Q2/multimedia/vlc/distinfo
  branches/2016Q2/multimedia/vlc/files/patch-configure
  branches/2016Q2/multimedia/vlc/files/patch-include_vlc__atomic.h
  branches/2016Q2/multimedia/vlc/files/patch-include_vlc__playlist.h
  branches/2016Q2/multimedia/vlc/files/patch-include_vlc__sout.h
  branches/2016Q2/multimedia/vlc/files/patch-modules_gui_qt4_dialogs_messages.hpp
  branches/2016Q2/multimedia/vlc/files/patch-share-lua-intf-cli.lua
  branches/2016Q2/multimedia/vlc/files/patch-vendor-00-ce91452
  branches/2016Q2/multimedia/vlc/pkg-descr
  branches/2016Q2/multimedia/vlc/pkg-plist