View Issue Details

IDProjectCategoryView StatusLast Update
0004729Spring engineGeneralpublic2018-02-13 01:27
ReporterUnitedMarsupials Assigned To 
PrioritynormalSeveritymajorReproducibilityhave not tried
Status resolvedResolutionfixed 
Product Version98.0 
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.
Attached Files
patch-include-cmath (Attachment missing)
patch-rts-Sim-Path-IPathController.cpp (Attachment missing)
patch-rts-Sim-Projectiles-Unsynced-BitmapMuzzleFlame.cpp (Attachment missing)
Checked infolog.txt for Errors

Relationships

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

Activities

abma

2015-04-08 20:04

administrator   ~0014279

> 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.

abma

2015-04-08 20:09

administrator   ~0014281

reordering includes in Button.cpp could fix this, too

UnitedMarsupials

2015-04-08 20:15

reporter   ~0014282

Last edited: 2015-04-08 20:16

> 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...

abma

2015-04-08 20:23

administrator   ~0014284

> 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.

UnitedMarsupials

2015-04-08 20:26

reporter   ~0014287

> 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?

abma

2015-04-08 20:34

administrator   ~0014288

Last edited: 2015-04-08 20:37

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.

UnitedMarsupials

2015-04-08 20:37

reporter   ~0014289

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?

abma

2015-04-08 20:38

administrator   ~0014290

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

thats wrong, sorry.

UnitedMarsupials

2015-04-08 20:55

reporter   ~0014294

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...

abma

2015-04-08 20:58

administrator   ~0014296

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

UnitedMarsupials

2015-04-08 21:13

reporter   ~0014297

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>

abma

2015-04-09 11:34

administrator   ~0014320

Last edited: 2015-04-09 11:40

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

but this needs testing...

abma

2015-04-09 12:05

administrator   ~0014323

Last edited: 2015-04-09 12:07

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!

abma

2015-04-09 12:20

administrator   ~0014324

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

UnitedMarsupials

2015-04-09 15:29

reporter   ~0014325

Last edited: 2015-04-09 15:32

> 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...

Kloot

2018-02-13 01:27

developer   ~0018803

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

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
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
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
2015-04-09 12:05 abma Note Added: 0014323
2015-04-09 12:07 abma Note Edited: 0014323
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
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