Bug 193528 - [PATCH] lang/gcc5: c++11 support is broken
Summary: [PATCH] lang/gcc5: c++11 support is broken
Status: Closed Overcome By Events
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Some People
Assignee: Andreas Tobler
URL:
Keywords:
: 194929 (view as bug list)
Depends on: 219275
Blocks:
  Show dependency treegraph
 
Reported: 2014-09-10 16:22 UTC by Dmitry Marakasov
Modified: 2018-05-22 09:34 UTC (History)
10 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Marakasov 2014-09-10 16:22:10 UTC
C++11 support is broken in lang/gcc* from ports. The problem is that gcc doesn't define _GLIBCXX_USE_C99 macro, which unhides C++11 features.

Maybe that's related to the problem I've reported before, in which gcc disables whole C99 support after not detecting certain math functions in our math library - I don't remember details and status of that problem.

If this is too hard to properly fix in the compilers, we may instead just hardcode -D_GLIBCXX_USE_C99 into macros which gcc defines or into CXXFLAGS in compiler.mk.
This will enable most of c++11 on pre-clang FreeBSD versions.

Port maintainer (gerald@FreeBSD.org) is cc'd.

Generated with FreeBSD Port Tools 1.02 (mode: change, diff: SVN)

How-To-Repeat:
% cat test.cc
#include <string>

int main() {
        std::to_string(1);
        return 0;
}
% clang++ -std=c++11 test.cc
% g++47 -std=c++11 test.cc
test.cc: In function 'int main()'
test.cc:4:2: error: 'to_string' is not a member of 'std'
% g++47 -std=c++11 -D_GLIBCXX_USE_C99 test.cc
%
Comment 1 Steve Kargl freebsd_committer 2014-09-10 20:37:34 UTC
(In reply to amdmi3 from comment #0)

> Maybe that's related to the problem I've reported before, in which gcc
> disables whole C99 support after not detecting certain math functions in our
> math library - I don't remember details and status of that problem.

------------------------------------------------------------------------
r269758 | kargl | 2014-08-09 08:53:40 -0700 (Sat, 09 Aug 2014) | 9 lines

When r255294 was committed, it exposed the symbols lgammal, powl,
and tgammal in libm.  These functions are part of ISO/IEC 9899:1999
and their prototypes should have been moved into the appropriate
__ISO_C_VISIBLE >= 1999 section.  After moving the prototypes,
remnants of r236148 can be removed.

PR:             standards/191754
Reviewed by:    bde
------------------------------------------------------------------------

And before you ask.  I have no intentions of merging this into a 
stable branch.
Comment 2 Dmitry Marakasov freebsd_committer 2014-09-11 05:07:48 UTC
This is probably no longer related, at least of current. The mentioned test program doesn't build on current from Aug 24 with gcc48 built just now, while logs confirm that math issue in gcc was fixed:

10.0:

---
configure:18932: checking for ISO C99 support to TR1 in <math.h>
configure:19056:  /wrkdirs/usr/ports/lang/gcc48/work/build/./gcc/xgcc -shared-libgcc -B/wrkdirs/usr/ports/lang/gcc48/work/build/./gcc -nostdinc++ -L/wrkdirs/usr/ports/lang/gcc48/work/build/x86_64-portbld-freebsd10.0/libstdc++-v3/src -L/wrkdirs/usr/ports/lang/gcc48/work/build/x86_64-portbld-freebsd10.0/libstdc++-v3/src/.libs -B/usr/local/x86_64-portbld-freebsd10.0/bin/ -B/usr/local/x86_64-portbld-freebsd10.0/lib/ -isystem /usr/local/x86_64-portbld-freebsd10.0/include -isystem /usr/local/x86_64-portbld-freebsd10.0/sys-include    -c -g -O2 -pipe -fno-strict-aliasing -std=c++98  conftest.cpp >&5
conftest.cpp: In function 'int main()':
conftest.cpp:93:14: error: 'erfl' was not declared in this scope
     erfl(0.0l);
              ^
conftest.cpp:96:15: error: 'erfcl' was not declared in this scope
     erfcl(0.0l);
               ^
conftest.cpp:123:17: error: 'lgammal' was not declared in this scope
     lgammal(0.0l);
                 ^
conftest.cpp:177:17: error: 'tgammal' was not declared in this scope
     tgammal(0.0l);
                 ^
configure:19056: $? = 1
---

head:

---
configure:18932: checking for ISO C99 support to TR1 in <math.h>
configure:19056:  /wrkdirs/usr/ports/lang/gcc48/work/build/./gcc/xgcc -shared-libgcc -B/wrkdirs/usr/ports/lang/gcc48/work/build/./gcc -nostdinc++ -L/wrkdirs/usr/ports/lang/gcc48/work/build/x86_64-portbld-freebsd11.0/libstdc++-v3/src -L/wrkdirs/usr/ports/lang/gcc48/work/build/x86_64-portbld-freebsd11.0/libstdc++-v3/src/.libs -B/usr/local/x86_64-portbld-freebsd11.0/bin/ -B/usr/local/x86_64-portbld-freebsd11.0/lib/ -isystem /usr/local/x86_64-portbld-freebsd11.0/include -isystem /usr/local/x86_64-portbld-freebsd11.0/sys-include    -c -g -O2 -pipe -fno-strict-aliasing  -std=c++98  conftest.cpp >&5
configure:19056: $? = 0
configure:19065: result: yes
---
Comment 3 Matthias Vallentin 2014-11-14 21:43:32 UTC
*** Bug 194929 has been marked as a duplicate of this bug. ***
Comment 4 Yuri Victorovich freebsd_committer 2015-03-07 02:16:39 UTC
+1
I hit the same problem while trying to update port finance/bitcoin-armory to 0.93
No std::to_string() function.
Comment 5 Yuri Victorovich freebsd_committer 2015-03-07 20:48:23 UTC
+1 again
I tried to make the port for FreeFileSync (from sourceforge), and again clang compile breaks on it, and gcc doesn't support std::snprintf (added by c11)
Comment 6 Yuri Victorovich freebsd_committer 2015-03-29 09:34:45 UTC
Any progress on this one?
Comment 7 Gerald Pfeifer freebsd_committer 2015-05-01 22:27:44 UTC
Andreas, do you have an idea on how to best tackle this?
Comment 8 Ryan Steinmetz freebsd_committer freebsd_triage 2015-05-01 22:45:38 UTC
I've also run into this.  Broken.
Comment 9 Andreas Tobler freebsd_committer 2015-05-03 20:18:33 UTC
I'm looking into this. It is not a late evening project. Given the results of my studies it needs some work. On both sides, the gcc part needs to be improved regarding detection of functionality and on the FreeBSD part we're still lacking some complex functions in libm.
Comment 10 John Marino freebsd_committer 2015-07-09 11:00:03 UTC
IIUC, this bug report only applies to FreeBSD 8 and FreeBSD 9 these days.
Comment 11 Dmitry Marakasov freebsd_committer 2015-07-10 16:12:44 UTC
(In reply to John Marino from comment #10)
> IIUC, this bug report only applies to FreeBSD 8 and FreeBSD 9 these days.

Incorrect, it applies to all versions including -CURRENT.

You may try devel/sdl2pp with USE_GCC=yes and without -D_GLIBCXX_USE_C99.
Comment 12 John Marino freebsd_committer 2015-07-10 16:19:43 UTC
DragonFly has an identical libm and the libstdc++ os_defines now match.

C99/c++11 works on DragonFly.  what is preventing it from working on FreeBSD 10 and 11?
Comment 13 John Marino freebsd_committer 2015-07-10 16:21:06 UTC
Ah, wait, no it's not the same!

We pulled in several long double functions from NetBSD.  That's probably the difference.
Comment 14 Dmitry Marakasov freebsd_committer 2015-07-10 17:30:05 UTC
(In reply to John Marino from comment #13)
> Ah, wait, no it's not the same!
> 
> We pulled in several long double functions from NetBSD.  That's probably the
> difference.

Likely.
Comment 15 Andreas Tobler freebsd_committer 2015-09-27 21:06:08 UTC
Work is in progress. Results can be seen here:

https://gcc.gnu.org/ml/gcc-testresults/2015-09/msg02290.html

The delay is natural, we're contributors, not full time assignee's
Comment 16 Andreas Tobler freebsd_committer 2015-11-14 22:31:20 UTC
Some progress here, we added enhanced locale support for FreeBSD.
Also, we added a more fine grained distinction about C99 capabilities. Not only C99 or not.

This has been done on gcc-trunk, iow the next gcc release which will be 6.0. A backport is right now out of discussion. Later, in a few weeks, we might reconsider.

The progress covers much more than addressed in this ticket...

Curious parties might update in week or so the ports lang/gcc6-devel and test their needs.
Comment 17 commit-hook freebsd_committer 2017-01-07 15:26:37 UTC
A commit references this bug:

Author: sunpoet
Date: Sat Jan  7 15:26:08 UTC 2017
New revision: 430799
URL: https://svnweb.freebsd.org/changeset/ports/430799

Log:
  Fix build with GCC prior to 6.0

  PR:		193528
  Notified by:	jbeich

Changes:
  head/databases/rocksdb/Makefile
Comment 18 Gerald Pfeifer freebsd_committer 2017-05-14 14:01:09 UTC
lang/gcc6 (and later) indeed do not exhibit this issue any longer;
thanks Andreas!
Comment 19 Gerald Pfeifer freebsd_committer 2017-07-23 20:24:38 UTC
This has been fixed for GCC 6 and later, which we really should have
updated to by now (and which is only stalled for a number of not too
actively maintained ports, cf. PR 219275).

GCC 5 is going EOL in the next weeks probably, and backporting those
changes is not realistic.

Let's put any efforts into the upgrade via PR 219275.  Help appreciated!
Comment 20 A Grayson 2018-05-22 09:34:37 UTC
MARKED AS SPAM