Bug 219168

Summary: databases/libmemcached cannot build, undefined reference to symbol
Product: Ports & Packages Reporter: Miroslav Lachman <000.fbsd>
Component: Individual Port(s)Assignee: Matthew Seaman <matthew>
Status: Closed FIXED    
Severity: Affects Only Me CC: alex, de-freebsd, m.tsatsenko, matthew, ohartmann, ports
Priority: --- Flags: bugzilla: maintainer-feedback? (m.tsatsenko)
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
poudriere bulk build log
none
patch m.tsatsenko: maintainer-approval+

Description Miroslav Lachman 2017-05-09 13:55:50 UTC
Cannot build libmemcached from today  ports tree in Poudriere for FreeBSD 10.3 amd64:

libtool: link: c++ -std=c++0x -O2 -pipe -fstack-protector -isystem /usr/local/include -fno-strict-aliasing -D__STDC_CONSTANT_MACROS -isystem /usr/local/include -g -Wno-unknown-pragmas -Wall -Wextra -Wno-attributes -Wvarargs -Waddress -Warray-bounds -Wchar-subscripts -Wcomment -Wctor-dtor-privacy -Wfloat-equal -Wformat=2 -Wformat-y2k -Wmissing-field-initializers -Wnon-virtual-dtor -Woverloaded-virtual -Wpointer-arith -Wredundant-decls -Wshadow -Wshorten-64-to-32 -Wsign-compare -Wstrict-overflow=1 -Wswitch-enum -Wundef -Wc++11-compat -Wunused -Wunused-result -Wunused-variable -Wunused-parameter -Wwrite-strings -Wformat-security -fwrapv -fPIE -Wsizeof-pointer-memaccess -Wpacked -fstack-protector -o clients/.libs/memaslap clients/memaslap.o clients/ms_conn.o clients/ms_setting.o clients/ms_sigsegv.o clients/ms_stats.o clients/ms_task.o clients/ms_thread.o clients/generator.o clients/execute.o  -levent clients/.libs/libutilities.a -L/usr/local/lib libmemcached/.libs/libmemcached.so -lexecinfo -Wl,-rpath -Wl,/usr/local/lib
/usr/bin/ld: undefined reference to symbol `pthread_create@@FBSD_1.0' (try adding -lthr)
//lib/libthr.so.3: could not read symbols: Bad value
c++: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[2]: *** [Makefile:4719: clients/memaslap] Error 1
gmake[2]: Leaving directory '/wrkdirs/usr/ports/databases/libmemcached/work/libmemcached-1.0.18'
gmake[1]: *** [Makefile:3712: all] Error 2
gmake[1]: Leaving directory '/wrkdirs/usr/ports/databases/libmemcached/work/libmemcached-1.0.18'
*** Error code 1

Stop.
make: stopped in /usr/ports/databases/libmemcached
====>> Cleaning up wrkdir
===>  Cleaning for libmemcached-1.0.18_6
build of databases/libmemcached ended at Tue May  9 12:27:27 CEST 2017
build time: 00:02:19
!!! build failure encountered !!!



Relevant parts of Poudriere build log:

Poudriere version: 3.1.17
Host OSVERSION: 1003000
Jail OSVERSION: 1003000
Job Id: 01

---Begin Environment---
SHELL=/bin/csh
OSVERSION=1003000
UNAME_v=FreeBSD 10.3-RELEASE-p19
UNAME_r=10.3-RELEASE-p19
BLOCKSIZE=K
MAIL=/var/mail/root
STATUS=1
SAVED_TERM=screen
MASTERMNT=/vol0/poudriere/data/.m/10_3_amd64-default-global/ref
UID=0
FORCE_PACKAGE=yes
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/root/bin
POUDRIERE_BUILD_TYPE=bulk
PKGNAME=libmemcached-1.0.18_6
OLDPWD=/
PWD=/vol0/poudriere/data/.m/10_3_amd64-default-global/ref/.p/pool
MASTERNAME=10_3_amd64-default-global
SCRIPTPREFIX=/usr/local/share/poudriere
USER=root
HOME=/root
POUDRIERE_VERSION=3.1.17
SCRIPTPATH=/usr/local/share/poudriere/bulk.sh
GID=0
LIBEXECPREFIX=/usr/local/libexec/poudriere
LOCALBASE=/usr/local
PACKAGE_BUILDING=yes
POUDRIEREPATH=/usr/local/bin/poudriere
---End Environment---

---Begin OPTIONS List---
===> The following configuration options are available for libmemcached-1.0.18_6:
     DEBUG=off: Build with debugging support
     DTRACE=off: Enable DTrace support
     MEMASLAP=on: Load generation and benchmark tool
     SASL=off: SASL authentication support
====> Options available for the group HASH
     FNV64=on: Enable fnv64 hashing
     HSIEH=off: Enable hsieh hashing
     MURMUR=on: Enable murmur hashing
===> Use 'make config' to modify these settings
---End OPTIONS List---

--CONFIGURE_ARGS--
--without-memcached  --without-sphinx-build  --enable-libmemcachedprotocol --disable-debug --disable-dtrace --enable-memaslap --disable-sasl --enable-fnv64_hash --disable-hsieh_hash --enable-murmur_hash --prefix=/usr/local ${_LATE_CONFIGURE_ARGS}
--End CONFIGURE_ARGS--

--CONFIGURE_ENV--
MAKE=gmake PKG_CONFIG=pkgconf XDG_DATA_HOME=/wrkdirs/usr/ports/databases/libmemcached/work  XDG_CONFIG_HOME=/wrkdirs/usr/ports/databases/libmemcached/work  HOME=/wrkdirs/usr/ports/databases/libmemcached/work TMPDIR="/tmp" SHELL=/bin/sh CONFIG_SHELL=/bin/sh CMAKE_PREFIX_PATH="/usr/local" CONFIG_SITE=/usr/ports/Templates/config.site lt_cv_sys_max_cmd_len=262144
--End CONFIGURE_ENV--

--MAKE_ENV--
XDG_DATA_HOME=/wrkdirs/usr/ports/databases/libmemcached/work  XDG_CONFIG_HOME=/wrkdirs/usr/ports/databases/libmemcached/work  HOME=/wrkdirs/usr/ports/databases/libmemcached/work TMPDIR="/tmp" NO_PIE=yes WITHOUT_DEBUG_FILES=yes WITHOUT_KERNEL_SYMBOLS=yes SHELL=/bin/sh NO_LINT=YES PREFIX=/usr/local  LOCALBASE=/usr/local  LIBDIR="/usr/lib"  CC="cc" CFLAGS="-O2 -pipe  -fstack-protector -isystem /usr/local/include -fno-strict-aliasing"  CPP="cpp" CPPFLAGS="-isystem /usr/local/include"  LDFLAGS=" -fstack-protector" LIBS="-L/usr/local/lib -lexecinfo -L/usr/local/lib"  CXX="c++" CXXFLAGS="-O2 -pipe -fstack-protector -isystem /usr/local/include -fno-strict-aliasing  -D__STDC_CONSTANT_MACROS -isystem /usr/local/include"  MANPREFIX="/usr/local" BSD_INSTALL_PROGRAM="install  -s -m 555"  BSD_INSTALL_LIB="install  -s -m 0644"  BSD_INSTALL_SCRIPT="install  -m 555"  BSD_INSTALL_DATA="install  -m 0644"  BSD_INSTALL_MAN="install  -m 444"
--End MAKE_ENV--



---Begin make.conf---
USE_PACKAGE_DEPENDS=yes
BATCH=yes
WRKDIRPREFIX=/wrkdirs
PORTSDIR=/usr/ports
PACKAGES=/packages
DISTDIR=/distfiles

#### /usr/local/etc/poudriere.d/global-make.conf ####
## poudriere make.conf for SET name global

OPTIONS_UNSET= X11 GUI CUPS DOCS EXAMPLES NLS HAL

WITH_BDB_VER=5
WITH_GHOSTSCRIPT_VER=9

DEFAULT_VERSIONS=apache=2.4 perl5=5.24 mysql=10.1m php=5.6 python=2.7 python3=3.5 pgsql=9.4 ssl=openssl

DISABLE_LICENSES=yes
Comment 1 Miroslav Lachman 2017-05-09 19:31:56 UTC
FYI: I locally reverted the port back to 1.0.18_4 and build works.
Comment 2 m.tsatsenko 2017-05-09 21:57:03 UTC
Hello,
Thanks for reporting this!
At first could you please attach entire build log. Yes I could not reproduce the issue for now.
Also try adding -lthr to the LIBS and report if the problem persists.
Comment 3 Miroslav Lachman 2017-05-09 23:00:18 UTC
Created attachment 182454 [details]
poudriere bulk build log

requested build log from Poudriere
Comment 4 Alexander Kuznetsov 2017-05-10 00:29:29 UTC
(In reply to m.tsatsenko from comment #2)
Hello!

I have just added -lthr to the LIBS in Makefile and after that I built the port on FreeBSD 10.3 x64 successfully.
Comment 5 Krzysztof 2017-05-10 06:48:22 UTC
(In reply to Alexander Kuznetsov from comment #4)

I can confirm that works also on FreeBSD 11.0. You can check logs:

1. without lthr: http://uld.bsdserwis.com/pkg/data/11x64-default/2017-05-09_22h23m00s/logs/errors/libmemcached-1.0.18_6.log (error)

2. with lthr: http://uld.bsdserwis.com/pkg/data/11x64-default/2017-05-10_08h37m14s/logs/libmemcached-1.0.18_6.log (success)

So patch is very simple :-)
Comment 6 m.tsatsenko 2017-05-11 22:27:23 UTC
Created attachment 182520 [details]
patch

- Fix build by passing -lthr to linker
- Regenerate patches to make portlint happy

QA:
portlint OK
poudrierre 103amd64 OK
Comment 7 O. Hartmann 2017-05-16 13:16:17 UTC
(In reply to m.tsatsenko from comment #6)

I ran into this problem today on recent 12-CURRENT (as jail: Revision: 318336, same as host) and recent ports tree (revision 440997) within a recent poudriere environment. Host (and jail) has WITH_LLD_IS_LD=yes set.

I can not fathom from the thread here whether the problem has been fixed AND committed, nor did I apply the patch provided (since I though it has been committed within the past week).

[...]
c++ -std=c++0x -DHAVE_CONFIG_H -I.   -isystem /usr/local/include -fvisibility=hidden  -O2 -pipe -fstack-protector -isystem /usr/local/include -fno-strict-aliasing  -D__STDC_CONSTANT_MACROS -isystem /usr/local/include -g -Wno-unknown-pragmas -Wno-pragmas -Wall -Wextra -Wno-attributes -Wvarargs -Waddress -Warray-bounds -Wchar-subscripts -Wcomment -Wctor-dtor-privacy -Wfloat-equal -Wformat=2 -Wformat-y2k -Wmissing-field-initializers -Wnon-virtual-dtor -Woverloaded-virtual -Wpointer-arith -Wredundant-decls -Wshadow -Wshorten-64-to-32 -Wsign-compare -Wstrict-overflow=1 -Wswitch-enum -Wundef -Wc++11-compat -Wunused -Wunused-result -Wunused-variable -Wunused-parameter -Wunused-local-typedefs -Wwrite-strings -Wformat-security -fwrapv -fPIE -Wsizeof-pointer-memaccess -Wpacked -MT clients/execute.o -MD -MP -MF $depbase.Tpo -c -o clients/execute.o clients/execute.cc &&\
mv -f $depbase.Tpo $depbase.Po
/bin/sh ./libtool  --tag=CXX   --mode=link c++ -std=c++0x  -O2 -pipe -fstack-protector -isystem /usr/local/include -fno-strict-aliasing  -D__STDC_CONSTANT_MACROS -isystem /usr/local/include -g -Wno-unknown-pragmas -Wno-pragmas -Wall -Wextra -Wno-attributes -Wvarargs -Waddress -Warray-bounds -Wchar-subscripts -Wcomment -Wctor-dtor-privacy -Wfloat-equal -Wformat=2 -Wformat-y2k -Wmissing-field-initializers -Wnon-virtual-dtor -Woverloaded-virtual -Wpointer-arith -Wredundant-decls -Wshadow -Wshorten-64-to-32 -Wsign-compare -Wstrict-overflow=1 -Wswitch-enum -Wundef -Wc++11-compat -Wunused -Wunused-result -Wunused-variable -Wunused-parameter -Wunused-local-typedefs -Wwrite-strings -Wformat-security -fwrapv -fPIE -Wsizeof-pointer-memaccess -Wpacked  -fstack-protector -o clients/memaslap clients/memaslap.o clients/ms_conn.o clients/ms_setting.o clients/ms_sigsegv.o clients/ms_stats.o clients/ms_task.o clients/ms_thread.o clients/generator.o clients/execute.o -levent clients/libutilities.la libmemcached/libmemcached.la -L/usr/local/lib -lexecinfo -L/usr/local/lib
libtool: link: c++ -std=c++0x -O2 -pipe -fstack-protector -isystem /usr/local/include -fno-strict-aliasing -D__STDC_CONSTANT_MACROS -isystem /usr/local/include -g -Wno-unknown-pragmas -Wno-pragmas -Wall -Wextra -Wno-attributes -Wvarargs -Waddress -Warray-bounds -Wchar-subscripts -Wcomment -Wctor-dtor-privacy -Wfloat-equal -Wformat=2 -Wformat-y2k -Wmissing-field-initializers -Wnon-virtual-dtor -Woverloaded-virtual -Wpointer-arith -Wredundant-decls -Wshadow -Wshorten-64-to-32 -Wsign-compare -Wstrict-overflow=1 -Wswitch-enum -Wundef -Wc++11-compat -Wunused -Wunused-result -Wunused-variable -Wunused-parameter -Wunused-local-typedefs -Wwrite-strings -Wformat-security -fwrapv -fPIE -Wsizeof-pointer-memaccess -Wpacked -fstack-protector -o clients/.libs/memaslap clients/memaslap.o clients/ms_conn.o clients/ms_setting.o clients/ms_sigsegv.o clients/ms_stats.o clients/ms_task.o clients/ms_thread.o clients/generator.o clients/execute.o  -levent clients/.libs/libutilities.a -L/usr/local/lib libmemcached/.libs/libmemcached.so -lexecinfo -Wl,-rpath -Wl,/usr/local/lib
/usr/bin/ld: error: clients/ms_thread.c:291: undefined symbol 'pthread_create'
c++: error: linker command failed with exit code 1 (use -v to see invocation)
Comment 8 CTS - FreeBSD Team 2017-06-07 14:12:37 UTC
Today i was also hit by this. Added the -lthr to LIBS and it built just fine. I am on 10.3-RELEASE-p16
Comment 9 commit-hook freebsd_committer freebsd_triage 2017-06-09 16:46:07 UTC
A commit references this bug:

Author: matthew
Date: Fri Jun  9 16:45:35 UTC 2017
New revision: 443019
URL: https://svnweb.freebsd.org/changeset/ports/443019

Log:
  Fix the build of libmemcached: add -lthr to the libraries
  plus modifications to the autoconf files.

  PR:		219168
  Submitted by:	m.tsatsenko@gmail.com (maintainer)
  Reported by:	000.fbsd@quip.cz
  Approved by:	m.tsatsenko@gmail.com (maintainer)

Changes:
  head/databases/libmemcached/Makefile
  head/databases/libmemcached/files/patch-bug1245562
  head/databases/libmemcached/files/patch-bug1400560
  head/databases/libmemcached/files/patch-libmemcached_assert.hpp
  head/databases/libmemcached/files/patch-libtest_lite.h
  head/databases/libmemcached/files/patch-log.hpp
  head/databases/libmemcached/files/patch-m4_ax__debug.m4
  head/databases/libmemcached/files/patch-util_log.hpp
Comment 10 Matthew Seaman freebsd_committer freebsd_triage 2017-06-09 16:46:47 UTC
Committed, thanks!
Comment 11 Po-Chuan Hsieh freebsd_committer freebsd_triage 2017-06-09 17:20:56 UTC
With SASL disabled, could you try this one instead of pulling in libltr?

I've compared the build log of successful builds (SASL enabled) and failed builds (SASL disabled). The only difference is that "-pthread" is missing in the failing command. If you add it back, it builds fine.

Index: Makefile
===================================================================
--- Makefile    (revision 443022)
+++ Makefile    (working copy)
@@ -23,8 +23,8 @@
                --without-sphinx-build \
                --enable-libmemcachedprotocol

-LIBS+=         -L${LOCALBASE}/lib -lexecinfo -lthr
-CXXFLAGS+=     -D__STDC_CONSTANT_MACROS
+LIBS+=         -L${LOCALBASE}/lib -lexecinfo
+CXXFLAGS+=     -D__STDC_CONSTANT_MACROS -pthread

 OPTIONS_DEFINE=                DEBUG DTRACE MEMASLAP SASL
 OPTIONS_DEFAULT=       MEMASLAP SASL MURMUR FNV64
Comment 12 Matthew Seaman freebsd_committer freebsd_triage 2017-06-09 17:54:41 UTC
Thanks.  I'm just compile testing with each of the SASL option settings.
Comment 13 commit-hook freebsd_committer freebsd_triage 2017-06-09 19:07:19 UTC
A commit references this bug:

Author: matthew
Date: Fri Jun  9 19:06:42 UTC 2017
New revision: 443036
URL: https://svnweb.freebsd.org/changeset/ports/443036

Log:
  Fix the build in a better way -- this works irrespective of the SASL
  option setting

  PR:		219168
  Submitted by:	sunpoet

Changes:
  head/databases/libmemcached/Makefile
Comment 14 Po-Chuan Hsieh freebsd_committer freebsd_triage 2017-06-09 19:16:54 UTC
Thanks!