[build, libgo] Use librt on Solaris 2 if necessary

Rainer Orth ro@CeBiTec.Uni-Bielefeld.DE
Fri Jan 14 17:25:00 GMT 2011


On Solaris < 11, libgo.so contains unresolved references to a couple of
functions, notably sched_yield and sem_*.  They are only provided by
librt, but moved to libc in Solaris 11.

The following patch checks if it is necessary to link with -lrt to get
sched_yield, following the guidance of the Autoconf manual for
AC_CHECK_LIB vs. AC_SEARCH_LIBS and thus not introducing another
variable, but just adding it to LIBS.

Tested by running make configure-target-libgo on i386-pc-solaris2.10 and
i386-pc-solaris2.11 and noting that -lrt is added to LIBS for the
former, but LIBS is unchanged for the latter.

In a previous bootstrap, I'd manually added -lrt to libgo/Makefile on
Solaris 10/x86 and managed to complete the build and run the tests.

Ok for mainline?

	Rainer


2011-01-14  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	libgo:
	* configure.ac: Check if -lrt is required for sched_yield.
	* configure: Regenerate.

diff -r 6c184227ca86 libgo/configure.ac
--- a/libgo/configure.ac	Fri Jan 14 10:25:46 2011 +0100
+++ b/libgo/configure.ac	Fri Jan 14 17:55:14 2011 +0100
@@ -1,6 +1,6 @@
 # configure.ac -- Go library configure script.
 
-# Copyright 2009 The Go Authors. All rights reserved.
+# Copyright 2009, 2011 The Go Authors. All rights reserved.
 # Use of this source code is governed by a BSD-style
 # license that can be found in the LICENSE file.
 
@@ -274,6 +274,9 @@
 AC_CHECK_LIB([pthread], [pthread_create], PTHREAD_LIBS=-lpthread)
 AC_SUBST(PTHREAD_LIBS)
 
+dnl Test if -lrt is required for sched_yield.
+AC_SEARCH_LIBS([sched_yield], [rt])
+
 AC_C_BIGENDIAN
 
 GCC_CHECK_UNWIND_GETIPINFO

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University



More information about the Gcc-patches mailing list