Bug 174964 - lang/lua should link liblua against libm
Summary: lang/lua should link liblua against libm
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: lua
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-04 08:20 UTC by xenophon+freebsd
Modified: 2013-01-06 00:00 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description xenophon+freebsd 2013-01-04 08:20:00 UTC
Ports configured to use Lua (e.g., Wireshark) will throw an error during "make config" about being unable to link against liblua.  Upon review of the port's "config.log" file, one will see linker error messages similar to the following:

configure:25468: checking for luaL_register in -llua
configure:25493: cc -o conftest -O2 -pipe -funit-at-a-time -fno-strict-aliasing -Wall -W -Wextra -Wdeclaration-after-statement -Wendif-labels -Wpointer-arith -Wno-pointer-sign -Wcast-align -Wformat-security -Wold-style-definition -I/usr/local/include/gtk-2.0 -I/usr/local/include/gio-unix-2.0/ -I/usr/local/include/atk-1.0 -I/usr/local/include/cairo -I/usr/local/include/pixman-1 -I/usr/local/include/drm -D_THREAD_SAFE -I/usr/local/include/gdk-pixbuf-2.0 -I/usr/local/include/libpng15 -I/usr/local/include/pango-1.0 -D_REENTRANT -I/usr/local/include/glib-2.0 -I/usr/local/include/freetype2 -I/usr/local/include   -DG_DISABLE_DEPRECATED -DG_DISABLE_SINGLE_INCLUDES -DGSEAL_ENABLE -DGTK_DISABLE_DEPRECATED -DGTK_DISABLE_SINGLE_INCLUDES -D_FORTIFY_SOURCE=2 -D_U_="__attribute__((unused))"  -I/usr/local/include -I/usr/local/include -I/usr/include/pcap -I/usr/local/include/lua51  -L/usr/local/lib -Wl,-rpath=/usr/local/lib -Wl,--as-needed -L/usr/local/lib -L/usr/local/lib -L/usr/local/lib conftest.c
  -llua  -lz  -pthread -pthread -L/usr/local/lib/lua51 -llua -lm  -lm >&5
conftest.c: In function 'main':
conftest.c:65: warning: old-style function definition
/usr/local/lib/lua51/liblua.so: undefined reference to `floor'
/usr/local/lib/lua51/liblua.so: undefined reference to `ceil'
/usr/local/lib/lua51/liblua.so: undefined reference to `cosh'
/usr/local/lib/lua51/liblua.so: undefined reference to `tan'
/usr/local/lib/lua51/liblua.so: undefined reference to `tanh'
/usr/local/lib/lua51/liblua.so: undefined reference to `asin'
/usr/local/lib/lua51/liblua.so: undefined reference to `log'
/usr/local/lib/lua51/liblua.so: undefined reference to `atan'
/usr/local/lib/lua51/liblua.so: undefined reference to `sinh'
/usr/local/lib/lua51/liblua.so: undefined reference to `fmod'
/usr/local/lib/lua51/liblua.so: undefined reference to `acos'
/usr/local/lib/lua51/liblua.so: undefined reference to `exp'
/usr/local/lib/lua51/liblua.so: undefined reference to `sin'
/usr/local/lib/lua51/liblua.so: undefined reference to `pow'
/usr/local/lib/lua51/liblua.so: undefined reference to `atan2'
/usr/local/lib/lua51/liblua.so: undefined reference to `cos'
/usr/local/lib/lua51/liblua.so: undefined reference to `log10'

This happens even though the configuration test program is being linked against libm (as shown in the arguments to the "cc" command above).  Liblua itself is not linked against libm, only libc:

cinep001bsdgw# ldd /usr/local/lib/lua51/liblua-5.1.so.1
lua51/liblua-5.1.so.1:
        libc.so.7 => /lib/libc.so.7 (0x80084a000)

Fix: 

Force the lang/lua port to link against libm by setting LDFLAGS.  For example:

portmaster -m LDFLAGS="-lm" lang/lua
How-To-Repeat: cd /usr/ports/lang/lua; make install
mkdir -p /var/db/ports/wireshark
echo "OPTIONS_FILE_SET+=LUA" > /var/db/ports/wireshark/options
cd /usr/ports/net/wireshark; make config BATCH=yes
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2013-01-04 08:20:08 UTC
Responsible Changed
From-To: freebsd-ports-bugs->lua

Over to maintainer (via the GNATS Auto Assign Tool)
Comment 2 Matthias Andree freebsd_committer freebsd_triage 2013-01-05 22:01:06 UTC
I cannot reproduce the problem.

Please check whence the -Wl,-rpath=/usr/local/lib -Wl,--as-needed in
your linker command line comes from, it is probably the culprit.

Please show your /etc/make.conf, /etc/src.conf, your exact command line
(or else confirm there was nothing else than you've reported).
Comment 3 dfilter service freebsd_committer freebsd_triage 2013-01-05 22:47:11 UTC
Author: mandree
Date: Sat Jan  5 22:47:04 2013
New Revision: 309971
URL: http://svnweb.freebsd.org/changeset/ports/309971

Log:
  Bugfix:
  - Record liblua's dependency on libm.so explicitly. [1]
  
  Assorted lint removals:
  - Convert to Options NG
  - Reduce old-style Makefile header
  - USE_GNOME=pkgconfig -> USE_PKGCONFIG=yes
  
  PR:		ports/174964
  Submitted by:	Matthew X. Economou

Modified:
  head/lang/lua/Makefile

Modified: head/lang/lua/Makefile
==============================================================================
--- head/lang/lua/Makefile	Sat Jan  5 21:34:25 2013	(r309970)
+++ head/lang/lua/Makefile	Sat Jan  5 22:47:04 2013	(r309971)
@@ -1,13 +1,9 @@
-# New ports collection makefile for: 	lua
-# Date created:				27 June 1999
-# Whom:					Richard Kiss
-#
+# Created by: Richard Kiss
 # $FreeBSD$
-#
 
 PORTNAME=	lua
 PORTVERSION=	5.1.5
-PORTREVISION=	4
+PORTREVISION=	5
 CATEGORIES=	lang
 MASTER_SITES=	http://www.lua.org/ftp/ \
 		ftp://ftp.ntua.gr/pub/lang/lua/ \
@@ -22,7 +18,7 @@ PATCH_WRKSRC=	${WRKSRC}/src
 USE_LUA=	5.1
 LUA_COMPS=	# only define variables
 ALL_TARGET=	freebsd
-USE_GNOME=	pkgconfig
+USE_PKGCONFIG=	yes
 USE_LDCONFIG=	yes
 MAKE_JOBS_SAFE=	yes
 MAKE_ENV=	LUA_SONAME="liblua-${LUA_VER}.so.${LUA_VER_SH}"
@@ -33,6 +29,9 @@ MAKE_ENV=	LUA_SONAME="liblua-${LUA_VER}.
 # have its settings when we get here.
 # See http://wiki.freebsd.org/MatthiasAndree/LuaLessonsLearnt
 MAKE_ARGS=	__MAKE_CONF=${NONEXISTENT}
+# liblua.so requires libm, so make sure it has an explicit dependency
+# so that applications need not second-guess lua's dependencies.
+LDFLAGS+=	-lm
 
 MAN1=		lua-${LUA_VER}.1 luac-${LUA_VER}.1
 DOCSDIR=	${PREFIX}/share/doc/${LUA_SUBDIR}
@@ -108,7 +107,7 @@ do-install:
 		${PREFIX}/man/man1/${f:C/.1$//}-${LUA_VER}.1
 .endfor
 # Documentation.
-.if !defined(NOPORTDOCS)
+.if ${PORT_OPTIONS:MDOCS}
 	${MKDIR} ${DOCSDIR}
 	${MKDIR} ${DOCSDIR}/etc
 	${MKDIR} ${DOCSDIR}/test
_______________________________________________
svn-ports-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-ports-all
To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
Comment 4 Matthias Andree freebsd_committer freebsd_triage 2013-01-05 22:51:07 UTC
Matthew,

on second thought, and after discussion on #bsdports (IRC), the
consensus is that all libraries should link their dependencies (-lm in
this case) explicitly, rather than letting applications second-guess
them, so I am committing the proposed lua change for the sake of
correctness, even though I consider the wireshark "make configure"
failure self-inflicted because no FreeBSD version sets --as-needed by
default.

Thank you for bringing this to our attention, writing a mostly complete
bug report, and offering the solution, it saved me a lot of time.

Best regards
Matthias
Comment 5 Matthias Andree freebsd_committer freebsd_triage 2013-01-05 22:52:03 UTC
State Changed
From-To: open->closed

lang/lua now adds -lm to LDFLAGS (as of PORTREVISION 5). Thank you!
Comment 6 xenophon+freebsd 2013-01-05 23:46:48 UTC
Matthias,

Thanks for handling this so quickly.  I'd still be happy to forward my
make.conf/src.conf/ports.conf/options files, if you're still interested.

Best wishes,
Matthew

--=20
I FIGHT FOR THE USERS


> -----Original Message-----
> From: Matthias Andree [mailto:mandree@FreeBSD.org]
> Sent: Saturday, January 05, 2013 5:51 PM
> To: bug-followup@FreeBSD.org; xenophon\+freebsd
> Subject: Re: ports/174964: lang/lua should link liblua against
> libm
>=20
> Matthew,
>=20
> on second thought, and after discussion on #bsdports (IRC), the
> consensus is that all libraries should link their dependencies (-
> lm in
> this case) explicitly, rather than letting applications second-
> guess
> them, so I am committing the proposed lua change for the sake of
> correctness, even though I consider the wireshark "make
> configure"
> failure self-inflicted because no FreeBSD version sets --as-
> needed by
> default.
>=20
> Thank you for bringing this to our attention, writing a mostly
> complete
> bug report, and offering the solution, it saved me a lot of time.
>=20
> Best regards
> Matthias