Patchwork Default to --enable-libstdcxx-time=auto

login
register
mail settings
Submitter Rainer Orth
Date May 22, 2013, 2:05 p.m.
Message ID <yddip2brtxf.fsf@lokon.CeBiTec.Uni-Bielefeld.DE>
Download mbox | patch
Permalink /patch/245626/
State New
Headers show

Comments

Rainer Orth - May 22, 2013, 2:05 p.m.
Jonathan Wakely <jwakely.gcc@gmail.com> writes:

> This alters the configure script to enable C++11 thread library
> features based on targets that are known to support the features,
> rather than based on link tests which are disabled by default.  With
> Glibc 2.17 this enables a nanosecond resolution std::system_clock in
> the default configuration, yay!
>
> I've tested this on two versions of Fedora and Debian, but would be
> grateful for test results on Solaris, Cygwin and BSD targets, and for
> cross-compilers to any of those targets.

Apart from the abi_check failure already reported, I get the following
testsuite regressions on Solaris 10/x86:

FAIL: 30_threads/async/54297.cc (test for excess errors)
WARNING: 30_threads/async/54297.cc compilation failed to produce executable
FAIL: 30_threads/condition_variable_any/53830.cc (test for excess errors)
WARNING: 30_threads/condition_variable_any/53830.cc compilation failed to produ
e executable
FAIL: 30_threads/this_thread/3.cc (test for excess errors)
WARNING: 30_threads/this_thread/3.cc compilation failed to produce executable
FAIL: 30_threads/this_thread/4.cc (test for excess errors)
WARNING: 30_threads/this_thread/4.cc compilation failed to produce executable
FAIL: 30_threads/thread/native_handle/cancel.cc (test for excess errors)
WARNING: 30_threads/thread/native_handle/cancel.cc compilation failed to produc
e executable

All of them have the same root cause:

Excess errors:
Undefined                       first referenced
 symbol                             in file
nanosleep                           /var/tmp//ccQhmiwd.o  (symbol belongs to implicit dependency /lib/librt.so.1)
ld: fatal: symbol referencing errors. No output written to ./54297.exe
collect2: error: ld returned 1 exit status

It seems that now every single C++ program needs to be linked with -lrt,
not only libstdc++.so.  This will also happen on Solaris 9 (bootstrap
still running), while on Solaris 11 nanosleep and the others were
integrated into libc.so.1.

Speaking of Solaris 9, there's another caveat: unlike Solaris 10 and up,
CLOCK_MONOTONIC isn't defined, while the equivalent non-standard
CLOCK_HIGHRES is.  Instead of handling this in
libstdc++-v3/src/c++11/chrono.cc directly, I've chosen the following
route which allows libstdc++ to build on Solaris 9:

2013-05-22  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* config/os/solaris/solaris2.9/os_defines.h [!CLOCK_MONOTONIC]
	(CLOCK_MONOTONIC): Define.
Rainer
Jonathan Wakely - May 22, 2013, 2:44 p.m.
On 22 May 2013 15:05, Rainer Orth wrote:
> Jonathan Wakely <jwakely.gcc@gmail.com> writes:
>
>> This alters the configure script to enable C++11 thread library
>> features based on targets that are known to support the features,
>> rather than based on link tests which are disabled by default.  With
>> Glibc 2.17 this enables a nanosecond resolution std::system_clock in
>> the default configuration, yay!
>>
>> I've tested this on two versions of Fedora and Debian, but would be
>> grateful for test results on Solaris, Cygwin and BSD targets, and for
>> cross-compilers to any of those targets.
>
> Apart from the abi_check failure already reported, I get the following
> testsuite regressions on Solaris 10/x86:

Thanks for checking it.

> FAIL: 30_threads/async/54297.cc (test for excess errors)
> WARNING: 30_threads/async/54297.cc compilation failed to produce executable
> FAIL: 30_threads/condition_variable_any/53830.cc (test for excess errors)
> WARNING: 30_threads/condition_variable_any/53830.cc compilation failed to produ
> e executable
> FAIL: 30_threads/this_thread/3.cc (test for excess errors)
> WARNING: 30_threads/this_thread/3.cc compilation failed to produce executable
> FAIL: 30_threads/this_thread/4.cc (test for excess errors)
> WARNING: 30_threads/this_thread/4.cc compilation failed to produce executable
> FAIL: 30_threads/thread/native_handle/cancel.cc (test for excess errors)
> WARNING: 30_threads/thread/native_handle/cancel.cc compilation failed to produc
> e executable
>
> All of them have the same root cause:
>
> Excess errors:
> Undefined                       first referenced
>  symbol                             in file
> nanosleep                           /var/tmp//ccQhmiwd.o  (symbol belongs to implicit dependency /lib/librt.so.1)
> ld: fatal: symbol referencing errors. No output written to ./54297.exe
> collect2: error: ld returned 1 exit status
>
> It seems that now every single C++ program needs to be linked with -lrt,
> not only libstdc++.so.  This will also happen on Solaris 9 (bootstrap
> still running), while on Solaris 11 nanosleep and the others were
> integrated into libc.so.1.

I see.  Would you prefer to disable use of nanosleep on Solaris 9 and
10, or to keep using it and link to librt?
Rainer Orth - May 22, 2013, 2:52 p.m.
Jonathan Wakely <jwakely.gcc@gmail.com> writes:

>> All of them have the same root cause:
>>
>> Excess errors:
>> Undefined                       first referenced
>>  symbol                             in file
>> nanosleep /var/tmp//ccQhmiwd.o (symbol belongs to implicit dependency
>> /lib/librt.so.1)
>> ld: fatal: symbol referencing errors. No output written to ./54297.exe
>> collect2: error: ld returned 1 exit status
>>
>> It seems that now every single C++ program needs to be linked with -lrt,
>> not only libstdc++.so.  This will also happen on Solaris 9 (bootstrap
>> still running), while on Solaris 11 nanosleep and the others were
>> integrated into libc.so.1.
>
> I see.  Would you prefer to disable use of nanosleep on Solaris 9 and
> 10, or to keep using it and link to librt?

I think it's fine for both C++11 programs and libstdc++.so to depend
on librt.  Maybe one could restrict linking with -lrt to C++11 mode?
But I doubt that: you can probably link both C++99 and C++11 objects
into a single executable, and with libstdc++.so already depending on
librt, there's not much point in the added complexity.

	Rainer
Rainer Orth - May 23, 2013, 10:05 a.m.
Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes:

> Jonathan Wakely <jwakely.gcc@gmail.com> writes:
>
>> This alters the configure script to enable C++11 thread library
>> features based on targets that are known to support the features,
>> rather than based on link tests which are disabled by default.  With
>> Glibc 2.17 this enables a nanosecond resolution std::system_clock in
>> the default configuration, yay!
>>
>> I've tested this on two versions of Fedora and Debian, but would be
>> grateful for test results on Solaris, Cygwin and BSD targets, and for
>> cross-compilers to any of those targets.
>
> Apart from the abi_check failure already reported, I get the following
> testsuite regressions on Solaris 10/x86:
>
> FAIL: 30_threads/async/54297.cc (test for excess errors)
> WARNING: 30_threads/async/54297.cc compilation failed to produce executable
> FAIL: 30_threads/condition_variable_any/53830.cc (test for excess errors)
> WARNING: 30_threads/condition_variable_any/53830.cc compilation failed to produ
> e executable
> FAIL: 30_threads/this_thread/3.cc (test for excess errors)
> WARNING: 30_threads/this_thread/3.cc compilation failed to produce executable
> FAIL: 30_threads/this_thread/4.cc (test for excess errors)
> WARNING: 30_threads/this_thread/4.cc compilation failed to produce executable
> FAIL: 30_threads/thread/native_handle/cancel.cc (test for excess errors)
> WARNING: 30_threads/thread/native_handle/cancel.cc compilation failed to produc
> e executable
>
> All of them have the same root cause:
>
> Excess errors:
> Undefined                       first referenced
>  symbol                             in file
> nanosleep                           /var/tmp//ccQhmiwd.o  (symbol belongs to implicit dependency /lib/librt.so.1)
> ld: fatal: symbol referencing errors. No output written to ./54297.exe
> collect2: error: ld returned 1 exit status
>
> It seems that now every single C++ program needs to be linked with -lrt,
> not only libstdc++.so.  This will also happen on Solaris 9 (bootstrap
> still running), while on Solaris 11 nanosleep and the others were
> integrated into libc.so.1.
>
> Speaking of Solaris 9, there's another caveat: unlike Solaris 10 and up,
> CLOCK_MONOTONIC isn't defined, while the equivalent non-standard
> CLOCK_HIGHRES is.  Instead of handling this in
> libstdc++-v3/src/c++11/chrono.cc directly, I've chosen the following
> route which allows libstdc++ to build on Solaris 9:
>
> 2013-05-22  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
>
> 	* config/os/solaris/solaris2.9/os_defines.h [!CLOCK_MONOTONIC]
> 	(CLOCK_MONOTONIC): Define.

The Solaris 9 (i386-pc-solaris2.9) bootstrap has now completed
successfully, so the patch above seems to be sound.  Ok for mainline?

Astonishingly, the only failure I see is abi_check.  The nanosleep error
above seems to be linker version dependent.

	Rainer
Benjamin Kosnik - May 24, 2013, 8:23 p.m.
>> I get the
> > following testsuite regressions on Solaris 10/x86:
> >
> > FAIL: 30_threads/async/54297.cc (test for excess errors)
> > WARNING: 30_threads/async/54297.cc compilation failed to produce
> > executable FAIL: 30_threads/condition_variable_any/53830.cc (test
> > for excess errors) WARNING:
> > 30_threads/condition_variable_any/53830.cc compilation failed to
> > produ e executable FAIL: 30_threads/this_thread/3.cc (test for
> > excess errors) WARNING: 30_threads/this_thread/3.cc compilation
> > failed to produce executable FAIL: 30_threads/this_thread/4.cc
> > (test for excess errors) WARNING: 30_threads/this_thread/4.cc
> > compilation failed to produce executable FAIL:
> > 30_threads/thread/native_handle/cancel.cc (test for excess errors)
> > WARNING: 30_threads/thread/native_handle/cancel.cc compilation
> > failed to produc e executable
> >
> > All of them have the same root cause:
> >
> > Excess errors:
> > Undefined                       first referenced
> >  symbol                             in file
> > nanosleep                           /var/tmp//ccQhmiwd.o  (symbol
> > belongs to implicit dependency /lib/librt.so.1) ld: fatal: symbol
> > referencing errors. No output written to ./54297.exe collect2:
> > error: ld returned 1 exit status
> >
> > It seems that now every single C++ program needs to be linked with
> > -lrt, not only libstdc++.so.  This will also happen on Solaris 9
> > (bootstrap still running), while on Solaris 11 nanosleep and the
> > others were integrated into libc.so.1.

So you'll need conditional LDFLAGS for solaris 9 and 10 only?

> > Speaking of Solaris 9, there's another caveat: unlike Solaris 10
> > and up, CLOCK_MONOTONIC isn't defined, while the equivalent
> > non-standard CLOCK_HIGHRES is.  Instead of handling this in
> > libstdc++-v3/src/c++11/chrono.cc directly, I've chosen the following
> > route which allows libstdc++ to build on Solaris 9:
> >
> > 2013-05-22  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
> >
> > 	* config/os/solaris/solaris2.9/os_defines.h
> > [!CLOCK_MONOTONIC] (CLOCK_MONOTONIC): Define.
> 
> The Solaris 9 (i386-pc-solaris2.9) bootstrap has now completed
> successfully, so the patch above seems to be sound.  Ok for mainline?

This is ok.Thanks!

-benjamin
Rainer Orth - May 24, 2013, 9:21 p.m.
Benjamin De Kosnik <bkoz@redhat.com> writes:

>>> I get the
>> > following testsuite regressions on Solaris 10/x86:
>> >
>> > FAIL: 30_threads/async/54297.cc (test for excess errors)
>> > WARNING: 30_threads/async/54297.cc compilation failed to produce
>> > executable FAIL: 30_threads/condition_variable_any/53830.cc (test
>> > for excess errors) WARNING:
>> > 30_threads/condition_variable_any/53830.cc compilation failed to
>> > produ e executable FAIL: 30_threads/this_thread/3.cc (test for
>> > excess errors) WARNING: 30_threads/this_thread/3.cc compilation
>> > failed to produce executable FAIL: 30_threads/this_thread/4.cc
>> > (test for excess errors) WARNING: 30_threads/this_thread/4.cc
>> > compilation failed to produce executable FAIL:
>> > 30_threads/thread/native_handle/cancel.cc (test for excess errors)
>> > WARNING: 30_threads/thread/native_handle/cancel.cc compilation
>> > failed to produc e executable
>> >
>> > All of them have the same root cause:
>> >
>> > Excess errors:
>> > Undefined                       first referenced
>> >  symbol                             in file
>> > nanosleep                           /var/tmp//ccQhmiwd.o  (symbol
>> > belongs to implicit dependency /lib/librt.so.1) ld: fatal: symbol
>> > referencing errors. No output written to ./54297.exe collect2:
>> > error: ld returned 1 exit status
>> >
>> > It seems that now every single C++ program needs to be linked with
>> > -lrt, not only libstdc++.so.  This will also happen on Solaris 9
>> > (bootstrap still running), while on Solaris 11 nanosleep and the
>> > others were integrated into libc.so.1.
>
> So you'll need conditional LDFLAGS for solaris 9 and 10 only?

Strictly speaking, yes.  In Solaris 11, the librt functions were moved
to libc, but librt is left behind as a filter on libc.  It were best to
wrap -lrt in -z ignore/-z record (the Solaris equivalents of
--as-needed/--no-as-needed) when linking C++ programs, which is one
reason I think this is best handled with a new libstdc++.spec since most
of the configury is already present in libstdc++, along the lines of
libgfortran.spec.

acinclude.m4 would have to be amended to use AC_SEARCH_LIBS rather than
hardcoding the addition of -lrt to GLIBCXX_LIBS.

For the moment, this patch

	http://gcc.gnu.org/ml/gcc-patches/2013-05/msg01488.html

does the job which is far less intrusive than adding libstdc++.spec, but
is certainly suboptimal.

	Rainer

Patch

# HG changeset patch
# Parent 079c0691568d1b9ef88a62ebf89ea19d3a8272ab
Use CLOCK_HIGHRES on Solaris 9

	libstdc++-v3:
	* config/os/solaris/solaris2.9/os_defines.h [!CLOCK_MONOTONIC]
	(CLOCK_MONOTONIC): Define.

diff --git a/libstdc++-v3/config/os/solaris/solaris2.9/os_defines.h b/libstdc++-v3/config/os/solaris/solaris2.9/os_defines.h
--- a/libstdc++-v3/config/os/solaris/solaris2.9/os_defines.h
+++ b/libstdc++-v3/config/os/solaris/solaris2.9/os_defines.h
@@ -35,5 +35,10 @@ 
 #define __CORRECT_ISO_CPP_WCHAR_H_PROTO
 #endif
 
+/* Solaris 9 uses the non-standard CLOCK_HIGHRES instead.  */
+#ifndef CLOCK_MONOTONIC
+#define CLOCK_MONOTONIC CLOCK_HIGHRES
 #endif
 
+#endif
+