Bug 196288 - graphics/graphviz: (cmd/smyrna) links libm too early
Summary: graphics/graphviz: (cmd/smyrna) links libm too early
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Only Me
Assignee: Dirk Meyer
URL: arch
Keywords: easy, needs-qa, patch
Depends on:
Blocks:
 
Reported: 2014-12-27 00:33 UTC by Trond.Endrestol
Modified: 2014-12-28 18:25 UTC (History)
1 user (show)

See Also:
dinoex: maintainer-feedback-


Attachments
Using the pre-build target to append LIBS += -lm to ${WRKSRC}/cmd/smyrna/Makefile (69 bytes, text/plain)
2014-12-27 00:33 UTC, Trond.Endrestol
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Trond.Endrestol 2014-12-27 00:33:30 UTC
Created attachment 150979 [details]
Using the pre-build target to append LIBS += -lm to ${WRKSRC}/cmd/smyrna/Makefile

I had to save the attachment as graphics/graphviz/Makefile.local to get smyrna to link. The problem is that -lm is specified too early during linkage. Adding -lm towards the end of the link command resolves the missing cos().
Comment 1 Dirk Meyer freebsd_committer 2014-12-27 10:01:08 UTC
Sorry, I can not reproduce the problem.

What FreeBSD version are you running?
Comment 2 Trond.Endrestol 2014-12-27 21:17:27 UTC
(In reply to Dirk Meyer from comment #1)
> Sorry, I can not reproduce the problem.
> 
> What FreeBSD version are you running?

My laptop was running stable/10 amd64 r276201 and the ports tree was at the time updated on Dec 25th.
My system was running stable/9 a couple of days ago, but I made the transition to stable/10 on Boxing Day.
Both the source and ports trees are up to date, and I now run stable/10 r276312.

I enforce the use of clang as the compiler using these lines in /etc/make.conf:

CC=clang
CXX=clang++
CPP=clang-cpp

Clang is the system compiler for stable/10 and shouldn't be the cause of this.
I even tried with USE_GCC=yes to enforce the use of GCC 4.8. The link problem persisted.

Here's how the link problem manifest itself on my system:

  CC       topviewsettings.o
  CC       glutrender.o
  CCLD     smyrna
/usr/bin/ld: undefined reference to symbol `cos@@FBSD_1.0' (try adding -lm)
//lib/libm.so.5: could not read symbols: Bad value
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Makefile:724: recipe for target 'smyrna' failed
gmake[6]: *** [smyrna] Error 1
gmake[6]: Leaving directory '/usr/ports/workdirs/usr/ports/graphics/graphviz/work/graphviz-2.38.0/cmd/smyrna'
Makefile:531: recipe for target 'all-recursive' failed
gmake[5]: *** [all-recursive] Error 1
gmake[5]: Leaving directory '/usr/ports/workdirs/usr/ports/graphics/graphviz/work/graphviz-2.38.0/cmd'
Makefile:774: recipe for target 'all-recursive' failed
gmake[4]: *** [all-recursive] Error 1
gmake[4]: Leaving directory '/usr/ports/workdirs/usr/ports/graphics/graphviz/work/graphviz-2.38.0'
Makefile:583: recipe for target 'all' failed
gmake[3]: *** [all] Error 2
gmake[3]: Leaving directory '/usr/ports/workdirs/usr/ports/graphics/graphviz/work/graphviz-2.38.0'
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1

Stop.
make[2]: stopped in /usr/ports/graphics/graphviz
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/graphics/graphviz
*** Error code 1

Stop.
make: stopped in /usr/ports/graphics/graphviz
Comment 3 Dirk Meyer freebsd_committer 2014-12-28 09:54:06 UTC
still no error on FreeBSD 10.0 amd64:

[...]
/bin/sh ../../libtool  --tag=CC   --mode=link cc  -O2 -pipe -DLIBICONV_PLUG -fstack-protector -fno-s
trict-aliasing -Wstrict-prototypes -Wpointer-arith -Wall -ffast-math  -L/usr/local/lib -fstack-prote
ctor -L/usr/local/lib -o smyrna arcball.o draw.o glexpose.o glmotion.o gltemplate.o appmouse.o callb
acks.o gvprpipe.o hier.o hotkeymap.o main.o md5.o polytess.o selectionfuncs.o smyrna_utils.o topfish
eyeview.o topviewfuncs.o trackball.o tvnodes.o viewport.o viewportcamera.o datalistcallbacks.o frmob
jectui.o glcompui.o gui.o menucallbacks.o toolboxcallbacks.o topviewsettings.o glutrender.o ../../li
b/cgraph/libcgraph_C.la ../../lib/cdt/libcdt_C.la ../../lib/xdot/libxdot_C.la ../../lib/glcomp/libgl
comp_C.la ../../lib/topfish/libtopfish_C.la ../../lib/common/libcommon_C.la ../../lib/gvpr/libgvpr_C
.la ../../lib/expr/libexpr_C.la ../../lib/ingraphs/libingraphs_C.la ../../lib/neatogen/libneatogen_C
.la -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -pthread -lgdk_pixbuf-2.0 -lgio-2
.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lintl -lfontconfig -L/usr/local/lib -lfreety
pe   -lglut -lgtkglext-x11-1.0 -lgdkglext-x11-1.0 -lGLU -lGL -lXmu -lXt -lSM -lICE -lpangox-1.0  -lX
11 -Wl,--export-dynamic -lgmodule-2.0 -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo
 -pthread -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lintl -lfo
ntconfig -L/usr/local/lib -lfreetype   -lglade-2.0 -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -lat
k-1.0 -lcairo -pthread -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.
0 -lintl -lfontconfig -lfreetype -L/usr/local/lib -lxml2   -lexpat -lgts -lgthread-2.0 -Wl,--export-
dynamic -lgmodule-2.0 -pthread -L/usr/local/lib -lglib-2.0 -lintl    
libtool: link: cc -O2 -pipe -DLIBICONV_PLUG -fstack-protector -fno-strict-aliasing -Wstrict-prototyp
es -Wpointer-arith -Wall -ffast-math -fstack-protector -o .libs/smyrna arcball.o draw.o glexpose.o g
lmotion.o gltemplate.o appmouse.o callbacks.o gvprpipe.o hier.o hotkeymap.o main.o md5.o polytess.o 
selectionfuncs.o smyrna_utils.o topfisheyeview.o topviewfuncs.o trackball.o tvnodes.o viewport.o vie
wportcamera.o datalistcallbacks.o frmobjectui.o glcompui.o gui.o menucallbacks.o toolboxcallbacks.o 
topviewsettings.o glutrender.o -pthread -Wl,--export-dynamic -pthread -pthread -Wl,--export-dynamic 
-pthread  -L/usr/local/lib ../../lib/cgraph/.libs/libcgraph_C.a ../../lib/cdt/.libs/libcdt_C.a ../..
/lib/xdot/.libs/libxdot_C.a ../../lib/glcomp/.libs/libglcomp_C.a ../../lib/topfish/.libs/libtopfish_
C.a ../../lib/common/.libs/libcommon_C.a ../../lib/gvpr/.libs/libgvpr_C.a ../../lib/expr/.libs/libex
pr_C.a /data/image/usr/ports/current/graphviz-smyrna/work/graphviz-2.38.0/lib/cdt/.libs/libcdt.so ..
/../lib/ingraphs/.libs/libingraphs_C.a ../../lib/neatogen/.libs/libneatogen_C.a /usr/local/lib/libgl
ut.so -lgtkglext-x11-1.0 -lgdkglext-x11-1.0 -lGLU -lGL /usr/local/lib/libXmu.so /usr/local/lib/libXt
.so /usr/local/lib/libSM.so /usr/local/lib/libICE.so -lpangox-1.0 /usr/local/lib/libX11.so /usr/loca
l/lib/libglade-2.0.so -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.
0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lfontconfig -lfreetype -lxml2 -lexpat -lgts -l
gthread-2.0 -lgmodule-2.0 -lglib-2.0 -lintl -pthread -Wl,-rpath -Wl,/usr/local/lib/graphviz -Wl,-rpa
th -Wl,/usr/local/lib
gmake[5]: Leaving directory '/data/image/usr/ports/current/graphviz-smyrna/work/graphviz-2.38.0/cmd/
smyrna'
Comment 4 Dirk Meyer freebsd_committer 2014-12-28 10:09:45 UTC
  -lm  is already added 3 times in the Makefile

Check:

/usr/ports/current/graphviz-smyrna$ grep .-lm `make -V WRKSRC`/cmd/smyrna/Makefile
GD_LIBS = -L/usr/local/lib -fstack-protector -L/usr/local/lib -lgd -lgd -ljpeg -lz -lm -L/usr/local/lib -lpng16 -L/usr/local/lib -lfreetype -lfontconfig -L/usr/local/lib -lfreetype -lfontconfig -L/usr/local/lib -ltiff
GTS_LIBS =  -lgts -lm -lgthread-2.0 -Wl,--export-dynamic -lgmodule-2.0 -pthread -L/usr/local/lib -lglib-2.0 -lintl
MATH_LIBS = -lm

Which entries are missing in your side?
Comment 5 Trond.Endrestol 2014-12-28 11:07:58 UTC
(In reply to Dirk Meyer from comment #4)
>   -lm  is already added 3 times in the Makefile

But is -lm added in the right order at the right time?

> Check:
> 
> /usr/ports/current/graphviz-smyrna$ grep .-lm `make -V
> WRKSRC`/cmd/smyrna/Makefile
> GD_LIBS = -L/usr/local/lib -fstack-protector -L/usr/local/lib -lgd -lgd
> -ljpeg -lz -lm -L/usr/local/lib -lpng16 -L/usr/local/lib -lfreetype
> -lfontconfig -L/usr/local/lib -lfreetype -lfontconfig -L/usr/local/lib -ltiff
> GTS_LIBS =  -lgts -lm -lgthread-2.0 -Wl,--export-dynamic -lgmodule-2.0
> -pthread -L/usr/local/lib -lglib-2.0 -lintl
> MATH_LIBS = -lm
> 
> Which entries are missing in your side?

/usr/ports/graphics/graphviz# grep -e -lm `make -V WRKSRC`/cmd/smyrna/Makefile produced:

GD_LIBS = -L/usr/local/lib -fstack-protector -L/usr/local/lib -lgd -lgd -ljpeg -lz -lm -L/usr/local/lib -lpng16 -L/usr/local/lib -lfreetype -lfontconfig -L/usr/local/lib -lfreetype -lfontconfig -lXpm -L/usr/local/lib -lX11 -L/usr/local/lib -lvpx -lm -L/usr/local/lib -ltiff
MATH_LIBS = -lm
RSVG_LIBS = -lrsvg-2 -lm -lgio-2.0 -lgdk_pixbuf-2.0 -lgobject-2.0 -lglib-2.0 -lintl -L/usr/local/lib -lcairo -pthread  

For some reason I'm missing GTS_LIBS, but have gained RSVG_LIBS. Strange.
Comment 6 Trond.Endrestol 2014-12-28 11:10:52 UTC
This is how graphviz is configured on my laptop, in case this is helpful:

/usr/ports/graphics/graphviz# make showconfig
===> The following configuration options are available for graphviz-2.38.0_6:
     XPM=on: XPM pixmap image format support
     DIGCOLA=on: neato layout engine wiwth DIGCOLA features
     IPSEPCOLA=on: neato layout engine wiwth IPSEPCOLA features
     ICONV=on: Encoding conversion support via iconv
     NLS=off: Native Language Support
     PANGOCAIRO=on: pangocairo support
     LIBRSVG2=on: SVG vector graphics support via librsvg2
     POPPLER=on: PDF and PS file support via poppler
     ANN=off: ANN edge bundling support
     GTS=on: GNU Triangulated Surface Library support
     GTK2=on: gtk2 plugin (requires PANGOCAIRO)
     GDK=on: gdk library support (requires GTK2)
     GDK_PIXBUF=on: gdk pixbuf support (requires GDK)
     GNOMEUI=off: libgnomeui support
     SMYRNA=on: SMYRNA graph viewer (requires GTK2)
     GVEDIT=off: gvedit (requires qt)
     MING=off: ming plugin
     DEVIL=off: devil plugin
     GHOSTSCRIPT=off: ghostscript plugin (requires PANGOCAIRO)
     PERL=off: Perl bindings (swig)
     PHP=off: PHP bindings (swig)
     PYTHON=off: Python bindings (swig)
     RUBY=off: Ruby bindings (swig)
     LUA=off: Lua bindings (swig)
     TCL=off: TCL bindings (swig)
     TK=off: TK toolkit support
     GUILE=off: Guile bindings (swig)
     NVTHREADS=off: Link with threads (needed for nvidia)
     DOCS=on: Build and/or install documentation
     EXAMPLES=off: Build and/or install examples
===> Use 'make config' to modify these settings
Comment 7 commit-hook freebsd_committer 2014-12-28 18:02:21 UTC
A commit references this bug:

Author: dinoex
Date: Sun Dec 28 18:01:44 UTC 2014
New revision: 375732
URL: https://svnweb.freebsd.org/changeset/ports/375732

Log:
  - fix linker problems with smyrna
  PR:		195676
  PR:		196288

Changes:
  head/graphics/graphviz/Makefile