From nobody@FreeBSD.org  Fri Jan  4 08:18:07 2013
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115])
	by hub.freebsd.org (Postfix) with ESMTP id E2C682CA
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  4 Jan 2013 08:18:07 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id D360E35C
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  4 Jan 2013 08:18:07 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.5/8.14.5) with ESMTP id r048I5Z5023702
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 4 Jan 2013 08:18:05 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.5/8.14.5/Submit) id r048I5nX023701;
	Fri, 4 Jan 2013 08:18:05 GMT
	(envelope-from nobody)
Message-Id: <201301040818.r048I5nX023701@red.freebsd.org>
Date: Fri, 4 Jan 2013 08:18:05 GMT
From: "Matthew X. Economou" <xenophon+freebsd@irtnog.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: lang/lua should link liblua against libm
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         174964
>Category:       ports
>Synopsis:       lang/lua should link liblua against libm
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    lua
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jan 04 08:20:00 UTC 2013
>Closed-Date:    Sat Jan 05 22:52:04 UTC 2013
>Last-Modified:  Sun Jan  6 00:00:00 UTC 2013
>Originator:     Matthew X. Economou
>Release:        9.0-RELEASE
>Organization:
IRTNOG
>Environment:
FreeBSD cinep001bsdgw.irtnog.net 9.0-RELEASE-p4 FreeBSD 9.0-RELEASE-p4 #10 r242510M: Sat Nov  3 15:07:27 EDT 2012     root@cinep001bsdgw.irtnog.net:/usr/obj/usr/src/sys/FIREWALL  amd64

>Description:
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)

>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

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

portmaster -m LDFLAGS="-lm" lang/lua


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->lua 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Fri Jan 4 08:20:08 UTC 2013 
Responsible-Changed-Why:  
Over to maintainer (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=174964 

From: Matthias Andree <mandree@FreeBSD.org>
To: bug-followup@FreeBSD.org, xenophon+freebsd@irtnog.org
Cc: lua@FreeBSD.ORG
Subject: Re: ports/174964: lang/lua should link liblua against libm
Date: Sat, 05 Jan 2013 23:01:06 +0100

 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).

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/174964: commit references a PR
Date: Sat,  5 Jan 2013 22:47:11 +0000 (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"
 
State-Changed-From-To: open->closed 
State-Changed-By: mandree 
State-Changed-When: Sat Jan 5 22:52:03 UTC 2013 
State-Changed-Why:  
lang/lua now adds -lm to LDFLAGS (as of PORTREVISION 5). Thank you! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=174964 

From: Matthias Andree <mandree@FreeBSD.org>
To: bug-followup@FreeBSD.org, xenophon+freebsd@irtnog.org
Cc:  
Subject: Re: ports/174964: lang/lua should link liblua against libm
Date: Sat, 05 Jan 2013 23:51:07 +0100

 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

From: "xenophon\\+freebsd" <xenophon+freebsd@irtnog.org>
To: "Matthias Andree" <mandree@FreeBSD.org>,
	<bug-followup@FreeBSD.org>
Cc:  
Subject: RE: ports/174964: lang/lua should link liblua against libm
Date: Sat, 5 Jan 2013 18:46:48 -0500

 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
>Unformatted:
