Patchwork libgo patch committed: Link against -lm

login
register
mail settings
Submitter Ian Taylor
Date Dec. 8, 2010, 2:09 a.m.
Message ID <mcrhbepm2vr.fsf@google.com>
Download mbox | patch
Permalink /patch/74622/
State New
Headers show

Comments

Ian Taylor - Dec. 8, 2010, 2:09 a.m.
This patch links libgo against -lm if appropriate.  This is for PR
46840.  Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian

Patch

diff -r 47fef7574d60 libgo/Makefile.am
--- a/libgo/Makefile.am	Tue Dec 07 16:13:14 2010 -0800
+++ b/libgo/Makefile.am	Tue Dec 07 18:05:51 2010 -0800
@@ -1267,7 +1267,7 @@ 
 
 libgo_la_SOURCES = $(runtime_files)
 
-libgo_la_LIBADD = $(libgo_go_objs) $(LIBFFI) $(PTHREAD_LIBS)
+libgo_la_LIBADD = $(libgo_go_objs) $(LIBFFI) $(PTHREAD_LIBS) $(MATH_LIBS)
 
 libgobegin_a_SOURCES = \
 	runtime/go-main.c
@@ -1283,7 +1283,7 @@ 
 
 GOLINK = $(LIBTOOL) --tag GO --mode-link $(GOC) \
 	$(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_GOCFLAGS) $(LTLDFLAGS) \
-	$(PTHREAD_LIBS) -o $@
+	$(PTHREAD_LIBS) $(MATH_LIBS) -o $@
 
 # Build a package.
 BUILDARCHIVE = \
diff -r 47fef7574d60 libgo/configure.ac
--- a/libgo/configure.ac	Tue Dec 07 16:13:14 2010 -0800
+++ b/libgo/configure.ac	Tue Dec 07 18:05:51 2010 -0800
@@ -187,6 +187,11 @@ 
 	    [Define if the linker support split stack adjustments])
 fi
 
+dnl Test for the -lm library.
+MATH_LIBS=
+AC_CHECK_LIB([m], [sqrt], MATH_LIBS=-lm)
+AC_SUBST(MATH_LIBS)
+
 dnl Test whether the compiler supports the -pthread option.
 AC_CACHE_CHECK([whether -pthread is supported],
 [ac_cv_libgo_pthread_supported],