2019-08-26 11:31 CEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0004729Spring engineGeneralpublic2018-02-13 01:27
ReporterUnitedMarsupials 
Assigned To 
PrioritynormalSeveritymajorReproducibilityhave not tried
StatusresolvedResolutionfixed 
Product Version98.0 
Target VersionFixed in Version 
Summary0004729: Compiling with clang on FreeBSD dies because of math-functions
DescriptionTrying to build on FreeBSD-10.1 using clang-3.4.1 dies:

...
In file included from /home/ports/games/spring/work/spring_98.0/rts/Rendering/Fonts/CFontTexture.h:5:
In file included from /usr/include/c++/v1/unordered_map:350:
In file included from /usr/include/c++/v1/__hash_table:19:
/usr/include/c++/v1/cmath:641:9: error: no member named 'isinf' in the global namespace
using ::isinf;
      ~~^
/usr/include/c++/v1/cmath:642:9: error: no member named 'isnan' in the global namespace; did you mean 'isnanf'?
using ::isnan;
      ~~^
/usr/include/math.h:329:5: note: 'isnanf' declared here
int isnanf(float) __pure2;
        ^
In file included from /home/ports/games/spring/work/spring_98.0/rts/aGui/Button.cpp:6:
In file included from /home/ports/games/spring/work/spring_98.0/rts/Rendering/Fonts/glFont.h:10:
In file included from /home/ports/games/spring/work/spring_98.0/rts/Rendering/Fonts/TextWrap.h:9:
In file included from /home/ports/games/spring/work/spring_98.0/rts/Rendering/Fonts/CFontTexture.h:5:
In file included from /usr/include/c++/v1/unordered_map:350:
In file included from /usr/include/c++/v1/__hash_table:19:
/usr/include/c++/v1/cmath:643:7: error: no member named 'isnormal' in the global namespace; did you mean 'math::isnormal'?
using ::isnormal;
/home/ports/games/spring/work/spring_98.0/rts/lib/streflop/SMath.h:291:13: note: 'math::isnormal' declared here
        inline int isnormal(Simple x) {return fpclassify(x) == STREFLOP_FP_NORMAL;}
... more errors listing other math-functions (isgreater, fpclassify ...) follow ...

It is unclear, whether the implementations bundled with SpringRTS or the OS-provided functions should be used, though the latter seems more likely.
Steps To ReproduceTry building the 0.98 release on FreeBSD-10 with clang (the default system compiler).
Additional InformationI'd be happy to offer access to my computer to a SpringRTS-developer to help resolve this issue.
TagsNo tags attached.
Checked infolog.txt for lua Errors
Attached Files
  • ? file icon patch-include-cmath (3,508 bytes) 2015-04-09 01:34 -
    +++ rts/aGui/GuiElement.h	2015-04-08 15:06:26.000000000 -0400
    @@ -4,4 +4,5 @@
     #define GUIELEMENT_H
     
    +#include <cmath>
     #include <list>
     #include <SDL_events.h>
    +++ rts/Sim/Weapons/LaserCannon.cpp	2015-04-07 20:49:52.000000000 -0400
    @@ -1,4 +1,6 @@
     /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
     
    +#include <cmath>
    +
     #include "LaserCannon.h"
     #include "WeaponDef.h"
    +++ rts/Sim/Weapons/FlameThrower.cpp	2015-04-07 20:50:46.000000000 -0400
    @@ -1,4 +1,6 @@
     /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
     
    +#include <cmath>
    +
     #include "FlameThrower.h"
     #include "WeaponDef.h"
    +++ rts/Sim/Weapons/MissileLauncher.cpp	2015-04-07 20:53:21.000000000 -0400
    @@ -1,4 +1,6 @@
     /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
     
    +#include <cmath>
    +
     #include "MissileLauncher.h"
     #include "WeaponDef.h"
    +++ rts/Sim/Weapons/EmgCannon.cpp	2015-04-07 20:57:50.000000000 -0400
    @@ -1,4 +1,6 @@
     /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
     
    +#include <cmath>
    +
     #include "EmgCannon.h"
     #include "WeaponDef.h"
    +++ rts/Sim/Units/Groups/GroupHandler.cpp	2015-04-08 16:24:53.000000000 -0400
    @@ -2,4 +2,6 @@
     
     #include <boost/cstdint.hpp>
    +
    +#include <cmath>
     #include <SDL_keycode.h>
     
    +++ rts/Sim/Weapons/TorpedoLauncher.cpp	2015-04-08 16:26:07.000000000 -0400
    @@ -1,4 +1,6 @@
     /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
     
    +#include <cmath>
    +
     #include "TorpedoLauncher.h"
     #include "WeaponDef.h"
    +++ rts/Game/Camera.cpp	2015-04-08 16:27:30.000000000 -0400
    @@ -1,4 +1,5 @@
     /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
     
    +#include <cmath>
     #include <string.h>
     
    +++ rts/Game/InMapDraw.cpp	2015-04-08 16:44:34.000000000 -0400
    @@ -1,6 +1,7 @@
     /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
     
    -#include "SDL_mouse.h"
    -#include "SDL_keyboard.h"
    +#include <cmath>
    +#include <SDL_mouse.h>
    +#include <SDL_keyboard.h>
     
     #include "InMapDraw.h"
    +++ rts/Game/PreGame.cpp	2015-04-08 16:45:50.000000000 -0400
    @@ -1,4 +1,5 @@
     /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
     
    +#include <cmath>
     #include <map>
     #include <SDL_keycode.h>
    +++ rts/Game/UI/MiniMap.cpp	2015-04-08 16:47:16.000000000 -0400
    @@ -1,4 +1,5 @@
     /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
     
    +#include <cmath>
     #include <SDL_keycode.h>
     #include <SDL_mouse.h>
    +++ rts/Rendering/GL/myGL.cpp	2015-04-08 16:51:02.000000000 -0400
    @@ -1,4 +1,5 @@
     /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
     
    +#include <cmath>
     #include <vector>
     #include <string>
    +++ rts/System/Input/Joystick.cpp	2015-04-08 16:54:28.000000000 -0400
    @@ -1,4 +1,6 @@
     /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
     
    +#include <cmath>
    +
     #include "InputHandler.h"
     #include "Joystick.h"
    +++ rts/System/SpringApp.cpp	2015-04-08 16:59:02.000000000 -0400
    @@ -1,4 +1,6 @@
     /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
     
    +#include <cmath>
    +
     #include "System/Input/InputHandler.h"
     
    +++ rts/Sim/Projectiles/WeaponProjectiles/LargeBeamLaserProjectile.cpp	2015-04-07 20:42:45.000000000 -0400
    @@ -10,4 +10,5 @@
     #include "System/myMath.h"
     #include <cstring> //memset
    +#include <cmath> // floor
     
     CR_BIND_DERIVED(CLargeBeamLaserProjectile, CWeaponProjectile, (ProjectileParams()))
    
    ? file icon patch-include-cmath (3,508 bytes) 2015-04-09 01:34 +
  • cpp file icon patch-rts-Sim-Path-IPathController.cpp (1,977 bytes) 2015-04-09 01:35
  • cpp file icon patch-rts-Sim-Projectiles-Unsynced-BitmapMuzzleFlame.cpp (533 bytes) 2015-04-09 01:35

-Relationships
related to 0004731closedabma headlessStubs/glstub.c out of sync with the lastest GL/glext.h 
+Relationships

-Notes

~0014279

abma (administrator)

> It is unclear, whether the implementations bundled with SpringRTS or the OS-provided functions should be used, though the latter seems more likely.

very likely the implementation of spring should be used because the lib streflop is used to maintain "sync" when playing over network.

idk if its possible to fix this error by avoding including cmath in __hash_table:19. maybe a #include "lib/streflop/streflop_cond.h" in CFontTexture.h:4 fixes this.

~0014281

abma (administrator)

reordering includes in Button.cpp could fix this, too

~0014282

UnitedMarsupials (reporter)

Last edited: 2015-04-08 20:16

View 2 revisions

> very likely the implementation of spring should be used
> because the lib streflop is used to maintain "sync" when
> playing over network.

I don't understand. Are you saying, streflop's implementation for isnan, fpclassify, signbit, and friends might return a result different from that of the OS' own?

> reordering includes in Button.cpp could fix this, too

Likely, other sources will need similar reshuffling...

~0014284

abma (administrator)

> I don't understand. Are you saying, streflop's implementation for isnan, fpclassify, signbit, and friends might return a result different from that of the OS' own?

maybe not these specific functions, but the functions which are implemented in streflop return different values across different computers.

~0014287

UnitedMarsupials (reporter)

> maybe not these specific functions, but the functions which
> are implemented in streflop return different values across
> different computers.

Understood. Still, for "noncontroversial" things like isnan, wouldn't you rather have the OS-provided (and, presumably, optimized) implementation over your own cross-platform one?

~0014288

abma (administrator)

Last edited: 2015-04-08 20:37

View 2 revisions

the internal is prefered:

https://github.com/spring/spring/blob/develop/rts/lib/streflop/SMath.h#L284

sorry, i don't know many details about streflop, so i have to investigate code, too.

~0014289

UnitedMarsupials (reporter)

Now I am confused. The following two statements seem to conflict with each other:

> very likely the implementation of spring should be used

vs.

> on other OS/compilers it uses the OS-provided ones... so it is prefered

If the native implementation is preferred, then why try to use spring's? Is FreeBSD/clang combination considered especially suspect?

~0014290

abma (administrator)

> on other OS/compilers it uses the OS-provided ones... so it is prefered

thats wrong, sorry.

~0014294

UnitedMarsupials (reporter)

Ok, yes, moving the

#include "Rendering/Fonts/glFont.h"

to the very top of Button.cpp helps compile that file. Now the same problem strikes in rts/aGui/LineEdit.cpp...

~0014296

abma (administrator)

welcome in the "compile-hell" of spring :-)

~0014297

UnitedMarsupials (reporter)

The following patch seems to fix the problem -- <cmath> needs to be included before SDL-anything. Because SDL headers are C-only and include <math.h>. Why does this matter, I don't know. Maybe, a libcpp thing:

+++ rts/aGui/GuiElement.h 2015-04-08 15:06:26.000000000 -0400
@@ -4,4 +4,5 @@
 #define GUIELEMENT_H

+#include <cmath>
 #include <list>
 #include <SDL_events.h>

~0014320

abma (administrator)

Last edited: 2015-04-09 11:40

View 2 revisions

replacing math::fabs with fabs very likely breaks sync, these fixes are imo invalid :-|

but this needs testing...

~0014323

abma (administrator)

Last edited: 2015-04-09 12:07

View 2 revisions

had some talk in chat with jK:

real problem here: it's just that unordered_map must not include cmath and so polute our math functions space

can this be workarrounded by some #define ?

if not, unordered_map / __hash_table should to be fixed!

~0014324

abma (administrator)

related? https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=182657

~0014325

UnitedMarsupials (reporter)

Last edited: 2015-04-09 15:32

View 2 revisions

> replacing math::fabs with fabs very likely breaks sync,
> these fixes are imo invalid :-|

Are you saying, one of the implementations may not be standards-compliant? I can see, how results of cosine or even sqrt() may differ slightly between implementations (and platforms), but fabs?

> real problem here: it's just that unordered_map must not include cmath

I see. Maybe...

> https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=182657

Possible. I'll try to come up with a simpler test case and ask around...

~0018803

Kloot (developer)

the current clang build succeeds, whether it also does on freebsd should be retested.
+Notes

-Issue History
Date Modified Username Field Change
2015-04-08 19:53 UnitedMarsupials New Issue
2015-04-08 19:59 abma Severity block => major
2015-04-08 20:04 abma Note Added: 0014279
2015-04-08 20:09 abma Note Added: 0014281
2015-04-08 20:15 UnitedMarsupials Note Added: 0014282
2015-04-08 20:16 UnitedMarsupials Note Edited: 0014282 View Revisions
2015-04-08 20:17 abma Relationship added related to 0004731
2015-04-08 20:23 abma Note Added: 0014284
2015-04-08 20:26 UnitedMarsupials Note Added: 0014287
2015-04-08 20:34 abma Note Added: 0014288
2015-04-08 20:37 abma Note Edited: 0014288 View Revisions
2015-04-08 20:37 UnitedMarsupials Note Added: 0014289
2015-04-08 20:38 abma Note Added: 0014290
2015-04-08 20:55 UnitedMarsupials Note Added: 0014294
2015-04-08 20:58 abma Note Added: 0014296
2015-04-08 21:13 UnitedMarsupials Note Added: 0014297
2015-04-09 01:34 UnitedMarsupials File Added: patch-include-cmath
2015-04-09 01:35 UnitedMarsupials File Added: patch-rts-Sim-Path-IPathController.cpp
2015-04-09 01:35 UnitedMarsupials File Added: patch-rts-Sim-Projectiles-Unsynced-BitmapMuzzleFlame.cpp
2015-04-09 11:34 abma Note Added: 0014320
2015-04-09 11:40 abma Note Edited: 0014320 View Revisions
2015-04-09 12:05 abma Note Added: 0014323
2015-04-09 12:07 abma Note Edited: 0014323 View Revisions
2015-04-09 12:20 abma Note Added: 0014324
2015-04-09 15:29 UnitedMarsupials Note Added: 0014325
2015-04-09 15:32 UnitedMarsupials Note Edited: 0014325 View Revisions
2018-02-13 01:27 Kloot Status new => resolved
2018-02-13 01:27 Kloot Resolution open => fixed
2018-02-13 01:27 Kloot Note Added: 0018803
+Issue History