Bug 208754 - games/assaultcube: Fix build with libc++ 3.8.0
Summary: games/assaultcube: 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: Jan Beich
URL:
Keywords:
Depends on:
Blocks: 208158
  Show dependency treegraph
 
Reported: 2016-04-12 18:54 UTC by Dimitry Andric
Modified: 2016-04-13 16:18 UTC (History)
1 user (show)

See Also:
lightside: maintainer-feedback+


Attachments
Remove hand-rolled round function from games/assaultcube (1.07 KB, patch)
2016-04-12 18:54 UTC, Dimitry Andric
no flags Details | Diff
Proposed patch (since 412346 revision) (12.82 KB, patch)
2016-04-13 00:40 UTC, lightside
lightside: maintainer-approval+
Details | Diff
The poudriere testport log (FreeBSD 10.2 amd64) (58.90 KB, text/plain)
2016-04-13 00:40 UTC, lightside
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dimitry Andric freebsd_committer 2016-04-12 18:54:27 UTC
Created attachment 169252 [details]
Remove hand-rolled round function from games/assaultcube

During the exp-run in bug 208158, it was found that games/assaultcube gives errors with libc++ 3.8.0 [1]:

In file included from crypto.cpp:1:
In file included from ./cube.h:8:
./tools.h:58:21: error: static declaration of 'round' follows non-static declaration
static inline float round(float x) { return floor(x + 0.5f); }
                    ^
/usr/include/c++/v1/math.h:1364:46: note: previous definition is here
inline _LIBCPP_INLINE_VISIBILITY float       round(float __lcpp_x) _NOEXCEPT       {return roundf(__lcpp_x);}
                                             ^

This is because the header attempts to redefine round(), which is a standard function from <math.h> (or <cmath>).  Remove the custom definition to make the program compile.

[1] http://package18.nyi.freebsd.org/data/headamd64PR208158-default/2016-03-22_18h30m05s/logs/errors/assaultcube-1.2.0.2_4.log
Comment 1 lightside 2016-04-13 00:38:44 UTC
Hello, Dimitry Andric.

Thanks for your patch.

I found, that "hand-rolled" round() function was removed by upstream for development version also:
https://github.com/assaultcube/AC/commit/752950989b4e286459ca9aee3d61a868d7b20fa4
-8<--
fix some errors and warnings for GCC 6

* do not use std::abs() because math.h includes one, that converts ints
  to double. Use own iabs(), which directly uses labs() instead.
* don't use the word "gamma" as name for variables
* don't use a homebrew round() function
-->8-

There are also some upstream fixes for Clang warnings, some of which already included:
https://github.com/assaultcube/AC/commit/6e4b23734f115888ce73907a85739ec833a333fd

Therefore, I propose to use mentioned upstream fixes (adapted for current 1.2.0.2 version), which includes your fix for round() function.

The proposed patch attached to the following message.
Comment 2 lightside 2016-04-13 00:40:11 UTC
Created attachment 169270 [details]
Proposed patch (since 412346 revision)

- Bump PORTREVISION
- Add adapted and merged upstream patches to fix some errors and warnings for (newer) GCC and Clang
- Remove merged files/patch-source_src_bot_bot_waypoint.cpp file
Comment 3 lightside 2016-04-13 00:40:40 UTC
Created attachment 169271 [details]
The poudriere testport log (FreeBSD 10.2 amd64)
Comment 4 commit-hook freebsd_committer 2016-04-13 16:18:03 UTC
A commit references this bug:

Author: jbeich
Date: Wed Apr 13 16:17:48 UTC 2016
New revision: 413214
URL: https://svnweb.freebsd.org/changeset/ports/413214

Log:
  games/assaultcube: unbreak build with newer C++ library

  - Add upstream fixes for clang/libc++ 3.8 and gcc/libstdc++ 6.0
  - Remove merged files/patch-source_src_bot_bot_waypoint.cpp file
  - Bump PORTREVISION

  In file included from crypto.cpp:1:
  In file included from ./cube.h:8:
  ./tools.h:58:21: error: static declaration of 'round' follows non-static
  declaration
  static inline float round(float x) { return floor(x + 0.5f); }
  			^
  /usr/include/c++/v1/math.h:1364:46: note: previous definition is here
  inline _LIBCPP_INLINE_VISIBILITY float       round(float __lcpp_x) _NOEXCEPT
     {return roundf(__lcpp_x);}
  						 ^
  In file included from cube.h:8:0,
  		     from crypto.cpp:1:
  tools.h: In function 'float round(float)':
  tools.h:58:34: error: 'float round(float)' conflicts with a previous declaration
   static inline float round(float x) { return floor(x + 0.5f); }
  				      ^
  In file included from /usr/local/lib/gcc6/include/c++/math.h:36:0,
  		     from platform.h:9,
  		     from cube.h:7,
  		     from crypto.cpp:1:
  /usr/local/lib/gcc6/include/c++/cmath:1708:3: note: previous declaration 'constexpr float std::round(float)'
     round(float __x)
     ^~~~~

  PR:		208754
  Reported by:	dim (libc++), lightside (libstdc++)
  Submitted by:	lightside <lightside@gmx.com> (maintainer)

Changes:
  head/games/assaultcube/Makefile
  head/games/assaultcube/files/patch-fixes-for-GCC-and-Clang.diff
  head/games/assaultcube/files/patch-source_src_bot_bot_waypoint.cpp
Comment 5 Jan Beich freebsd_committer 2016-04-13 16:18:29 UTC
Thanks. Committed.