Opened 12 years ago

Closed 11 years ago

Last modified 2 years ago

#36364 closed defect (fixed)

gcc47, gcc48: Missing support for std::this_thread::sleep_for/sleep_until

Reported by: l.digaspero@… Owned by: jeremyhu (Jeremy Huddleston Sequoia)
Priority: Normal Milestone:
Component: ports Version: 2.1.2
Keywords: Cc: jeremyhu (Jeremy Huddleston Sequoia), manphiz@…, cooljeanius (Eric Gallager)
Port: gcc47 gcc48

Description

In order to fully support c++11 threads for g++47/g++48, it is necessary to add the flag --enable-libstdccxx-time to ./configure in order to automatically define the _GLIBCXX_USE_NANOSLEEP macro and compile the support to sleep_for/sleep_until functions in threads.

Attachments (3)

gcc47_fix_nanosleep_test.diff (590 bytes) - added by howarth@… 12 years ago.
patch to fix libstdc++-v3's configure check for nanosleep()
gcc48_fix_nanosleep_test.diff (590 bytes) - added by howarth@… 12 years ago.
patch to fix libstdc++-v3's configure check for nanosleep()
enable_libstdcxx_time_yes.diff (516 bytes) - added by howarth@… 12 years ago.
backport of fix to default to --enable-libstdcxx-time=yes

Download all attachments as: .zip

Change History (25)

comment:1 Changed 12 years ago by l.digaspero@…

Cc: l.digaspero@… added

Cc Me!

comment:2 Changed 12 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: jeremyhu@… added; l.digaspero@… removed
Keywords: c++11 std::thread removed
Milestone: MacPorts Future
Owner: changed from macports-tickets@… to mww@…
Priority: HighNormal
Summary: Missing support for std::this_thread::sleep_for/sleep_untilgcc47, gcc48: Missing support for std::this_thread::sleep_for/sleep_until

comment:3 Changed 12 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Resolution: fixed
Status: newclosed

comment:4 Changed 12 years ago by howarth@…

Using --enable-libstdccxx-time without arguments doesn't do anything because that defaults to 'no'.
Furthermore, using --enable-libstdccxx-time=yes won't work because the configure tests for nanosleep
support in libstdc++-v3/configure ultimately fails on the test...

configure:19829: checking for nanosleep
configure:19851: /sw/src/fink.build/gcc47-4.7.2-1000/darwin_objdir/./gcc/xgcc -shared-libgcc -B/sw/src/fink.build/gcc47-4.7.2-1000/darwin_objdir/./gcc -nostdinc++ -L/sw/src/fink.build/gcc47-4.7.2-1000/darwin_objdir/x86_64-apple-darwin12.2.0/libstdc++-v3/src -L/sw/src/fink.build/gcc47-4.7.2-1000/darwin_objdir/x86_64-apple-darwin12.2.0/libstdc++-v3/src/.libs -B/sw/lib/gcc4.7/x86_64-apple-darwin12.2.0/bin/ -B/sw/lib/gcc4.7/x86_64-apple-darwin12.2.0/lib/ -isystem /sw/lib/gcc4.7/x86_64-apple-darwin12.2.0/include -isystem /sw/lib/gcc4.7/x86_64-apple-darwin12.2.0/sys-include -o conftest -g -O2 -fno-exceptions conftest.cpp >&5
conftest.cpp: In function 'int main()':
conftest.cpp:97:15: error: 'tp' was not declared in this scope

due to the test case....

| #include <unistd.h>
| #include <time.h>
| | int
| main ()
| {
| #if _POSIX_TIMERS > 0
| timespec tp;
| #endif
| nanosleep(&tp, 0);
|
| ;
| return 0;
| }

requiring posix timers which darwin doesn't support.

comment:5 Changed 12 years ago by howarth@…

Resolution: fixed
Status: closedreopened

comment:6 Changed 12 years ago by howarth@…

Also note that passing --enable-libstdccxx-time=yes causes libstdc++-v3/configure to check...

configure:19382: checking for clock_gettime, nanosleep and sched_yield

and darwin doesn't provide clock_gettime. It is unclear how important that is to the enable-libstdccxx-time option
functioning.

comment:7 in reply to:  4 Changed 12 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Replying to howarth@…:

Using --enable-libstdccxx-time without arguments doesn't do anything because that defaults to 'no'.

You seem to misunderstand how autoconf works.

Also, it is --enable-libstdcxx-time, not --enable-libstdccxx-time (you made the same copy-paste-o as above).

Furthermore, using --enable-libstdccxx-time=yes won't work because the configure tests for nanosleep
support in libstdc++-v3/configure ultimately fails on the test...

configure:19829: checking for nanosleep
configure:19851: /sw/src/fink.build/gcc47-4.7.2-1000/darwin_objdir/./gcc/xgcc -shared-libgcc -B/sw/src/fink.build/gcc47-4.7.2-1000/darwin_objdir/./gcc -nostdinc++ -L/sw/src/fink.build/gcc47-4.7.2-1000/darwin_objdir/x86_64-apple-darwin12.2.0/libstdc++-v3/src -L/sw/src/fink.build/gcc47-4.7.2-1000/darwin_objdir/x86_64-apple-darwin12.2.0/libstdc++-v3/src/.libs -B/sw/lib/gcc4.7/x86_64-apple-darwin12.2.0/bin/ -B/sw/lib/gcc4.7/x86_64-apple-darwin12.2.0/lib/ -isystem /sw/lib/gcc4.7/x86_64-apple-darwin12.2.0/include -isystem /sw/lib/gcc4.7/x86_64-apple-darwin12.2.0/sys-include -o conftest -g -O2 -fno-exceptions conftest.cpp >&5
conftest.cpp: In function 'int main()':
conftest.cpp:97:15: error: 'tp' was not declared in this scope

due to the test case....

| #include <unistd.h>
| #include <time.h>
| | int
| main ()
| {
| #if _POSIX_TIMERS > 0
| timespec tp;
| #endif
| nanosleep(&tp, 0);
|
| ;
| return 0;
| }

requiring posix timers which darwin doesn't support.

Why do they need _POSIX_TIMERS? That's not needed for nanosleep.

comment:8 Changed 12 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Resolution: fixed
Status: reopenedclosed

If there is a new issue, please open a new ticket.

comment:9 Changed 12 years ago by howarth@…

This isn't a new issue because the changes proposed and added in r98265 never worked in the first place.
The documentation of the configure options in libstdc++-v3/configure

--enable-libstdcxx-time[=KIND]

use KIND for check type [default=no]


clearly show the current usage is faulty. Also a cursory check of the libstdc++-v3/config.log would have
shown that --enable-libstdcxx-time=yes also is broken on darwin because this option is currently linux-centric
and depends on the presence of posix timers.

comment:10 Changed 12 years ago by howarth@…

Resolution: fixed
Status: closedreopened

comment:11 Changed 12 years ago by jeremyhu (Jeremy Huddleston Sequoia)

--enable-<blah> is equivalent to --enable-<blah>=yes in autoconf. Similarly, --disable-<blah> is equivalent to --enable-<blah>=yes.

As for the option being broken, that's not something that I can fix as gcc is GPL3. It should be straight forward, though. I don't see why they check for posix timers for nanosleep. We should be able to just remove that #if _POSIX_TIMERS > 0

If you can provide such a patch, I'll include it.

Changed 12 years ago by howarth@…

patch to fix libstdc++-v3's configure check for nanosleep()

Changed 12 years ago by howarth@…

patch to fix libstdc++-v3's configure check for nanosleep()

comment:12 Changed 12 years ago by howarth@…

The gcc47_fix_nanosleep_test.diff and gcc48_fix_nanosleep_test.diff patches need to be used in concert with passing --enable-libstdcxx-time=yes to configure.
Can be confirmed by checking the installed c++ headers with grep to show...

./c++/4.8.0/x86_64-apple-darwin12.2.0/bits/c++config.h:#define _GLIBCXX_USE_NANOSLEEP 1
./c++/4.8.0/x86_64-apple-darwin12.2.0/i386/bits/c++config.h:#define _GLIBCXX_USE_NANOSLEEP 1

comment:13 Changed 12 years ago by manphiz@…

Cc: manphiz@… added

Cc Me!

comment:14 Changed 12 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Updated gcc48 in r98534

comment:15 Changed 12 years ago by howarth@…

Fixed upstream for gcc 4.8.0 by effectively defaulting to --enable-libstdcxx-time=yes on darwin.

http://gcc.gnu.org/ml/libstdc++-cvs/2012-q4/msg00045.html

comment:16 Changed 12 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Thanks, Jack. Can you please attach the final patch that was used to this ticket, so I can use it for gcc47? Thanks.

Changed 12 years ago by howarth@…

backport of fix to default to --enable-libstdcxx-time=yes

comment:17 Changed 11 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Owner: changed from mww@… to jeremyhu@…
Status: reopenednew

I'll fix this when I bump gcc46 and gcc47 for #38814

comment:18 Changed 11 years ago by jeremyhu (Jeremy Huddleston Sequoia)

comment:19 Changed 11 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Resolution: fixed
Status: newclosed

comment:20 Changed 2 years ago by cooljeanius (Eric Gallager)

Is this still necessary nowadays? I'm wondering if the configure line for the gcc ports can be simplified at all...

comment:21 Changed 2 years ago by cooljeanius (Eric Gallager)

Cc: cooljeanius added

comment:22 in reply to:  15 Changed 2 years ago by cooljeanius (Eric Gallager)

Replying to howarth@…:

Fixed upstream for gcc 4.8.0 by effectively defaulting to --enable-libstdcxx-time=yes on darwin.

http://gcc.gnu.org/ml/libstdc++-cvs/2012-q4/msg00045.html

Actually wait, if this went into gcc 4.8.0, then I guess the answer to my previous question is a "no"? If that's the case, then why have we been carrying around that configure flag in all successive gcc versions after this?

Note: See TracTickets for help on using tickets.