Patchwork [v3] Link libstdc++.so with -pthread on Tru64 UNIX (PR target/45693)

login
register
mail settings
Submitter Rainer Orth
Date Nov. 2, 2010, 4:20 p.m.
Message ID <ydd39rj7l4u.fsf@manam.CeBiTec.Uni-Bielefeld.DE>
Download mbox | patch
Permalink /patch/69906/
State New
Headers show

Comments

Rainer Orth - Nov. 2, 2010, 4:20 p.m.
Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes:

> As indicated in the PR, all C++ EH tests on Tru64 UNIX were failing
> since TLS (emutls in this case) was enabled by an unrelated patch.  The
> problem is the same as in PR PR target/46131: emutls relies on a couple
> of libpthread functions.  While there are dummy implementations in
> libgcc, of course we need the real thing here.  The proper solution is
> to link libstdc++.so with -pthread here (instead of, e.g., linking with
> -lpthread in g++), so EH doesn't always work, even if linked with
> another driver or in a mixed-language problem.  Manual testing indicated
> that this fixes the problem as expected.  alpha-dec-osf5.1b testing in
> progress, will commit once completed successfully.

While the idea was sound, actual testing revealed two problems:

* The osf* case also needs to set os_include_dir.

* Cannot use -pthread in OPT_LDFLAGS: libtool swallows that,
  -Wl,-pthread doesn't work (it's not a linker option), and -Wc,-pthread
  doesn't work either (seems to be ignored with -shared), so I had to
  fall back to using -lpthread instead.

This fixed all the EH related C++ failures.

Installed.

	Rainer


2010-10-28  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	PR target/45693
	* configure.host (osf*): Set os_include_dir to os/generic.
	Add -lpthread to OPT_LDFLAGS.
Andreas Schwab - Nov. 2, 2010, 4:30 p.m.
Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes:

> * Cannot use -pthread in OPT_LDFLAGS: libtool swallows that,
>   -Wl,-pthread doesn't work (it's not a linker option), and -Wc,-pthread
>   doesn't work either (seems to be ignored with -shared), so I had to
>   fall back to using -lpthread instead.

Shouldn't that be put in LIBADD?

Andreas.
Rainer Orth - Nov. 2, 2010, 4:46 p.m.
Andreas Schwab <schwab@redhat.com> writes:

> Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes:
>
>> * Cannot use -pthread in OPT_LDFLAGS: libtool swallows that,
>>   -Wl,-pthread doesn't work (it's not a linker option), and -Wc,-pthread
>>   doesn't work either (seems to be ignored with -shared), so I had to
>>   fall back to using -lpthread instead.
>
> Shouldn't that be put in LIBADD?

I see no direct way of doing so.  One might use GLIBCXX_LIBS, no idea if
this could safely be done in configure.host.

	Rainer
Ralf Wildenhues - Nov. 2, 2010, 6:51 p.m.
Hello Rainer,

* Rainer Orth wrote on Tue, Nov 02, 2010 at 05:20:17PM CET:
> > As indicated in the PR, all C++ EH tests on Tru64 UNIX were failing
> > since TLS (emutls in this case) was enabled by an unrelated patch.  The
> > problem is the same as in PR PR target/46131: emutls relies on a couple
> > of libpthread functions.  While there are dummy implementations in
> > libgcc, of course we need the real thing here.  The proper solution is
> > to link libstdc++.so with -pthread here (instead of, e.g., linking with
> > -lpthread in g++), so EH doesn't always work, even if linked with
> > another driver or in a mixed-language problem.  Manual testing indicated
> > that this fixes the problem as expected.  alpha-dec-osf5.1b testing in
> > progress, will commit once completed successfully.
> 
> While the idea was sound, actual testing revealed two problems:
> 
> * The osf* case also needs to set os_include_dir.
> 
> * Cannot use -pthread in OPT_LDFLAGS: libtool swallows that,
>   -Wl,-pthread doesn't work (it's not a linker option), and -Wc,-pthread
>   doesn't work either (seems to be ignored with -shared), so I had to
>   fall back to using -lpthread instead.

Both -pthread and -Wc,-pthread should have worked.  Please show logs
that indicate that it was swallowed.  libtool has specific code to
allow through -pthread, I'm not aware of bugs in that area.

Thanks,
Ralf

> 2010-10-28  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
> 
> 	PR target/45693
> 	* configure.host (osf*): Set os_include_dir to os/generic.
> 	Add -lpthread to OPT_LDFLAGS.
> 
> diff -r 3048db040dd6 libstdc++-v3/configure.host
> --- a/libstdc++-v3/configure.host	Fri Oct 29 17:12:46 2010 +0000
> +++ b/libstdc++-v3/configure.host	Sat Oct 30 11:43:36 2010 +0200
> @@ -261,6 +261,13 @@
>    netbsd*)
>      os_include_dir="os/bsd/netbsd"
>      ;;
> +  osf*)
> +    os_include_dir="os/generic"
> +    # libstdc++.so relies on emutls on Tru64 UNIX, which only works with the
> +    # real functions implemented in libpthread.so, not with the dummies in
> +    # libgcc, so always pass -lpthread.
> +    OPT_LDFLAGS="${OPT_LDFLAGS} -lpthread"
> +    ;;
>    qnx6.[12]*)
>      os_include_dir="os/qnx/qnx6.1"

Patch

diff -r 3048db040dd6 libstdc++-v3/configure.host
--- a/libstdc++-v3/configure.host	Fri Oct 29 17:12:46 2010 +0000
+++ b/libstdc++-v3/configure.host	Sat Oct 30 11:43:36 2010 +0200
@@ -261,6 +261,13 @@ 
   netbsd*)
     os_include_dir="os/bsd/netbsd"
     ;;
+  osf*)
+    os_include_dir="os/generic"
+    # libstdc++.so relies on emutls on Tru64 UNIX, which only works with the
+    # real functions implemented in libpthread.so, not with the dummies in
+    # libgcc, so always pass -lpthread.
+    OPT_LDFLAGS="${OPT_LDFLAGS} -lpthread"
+    ;;
   qnx6.[12]*)
     os_include_dir="os/qnx/qnx6.1"
     c_model=c