Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Mar 2014 00:33:14 -0600
From:      "James R. Van Artsdalen" <james-freebsd-ports@jrv.org>
To:        freebsd-ports@freebsd.org
Subject:   net/samba36 does not build on stable10?
Message-ID:  <5326972A.5080400@jrv.org>

next in thread | raw e-mail | index | archive | help
FreeBSD STABLE10.housenet.jrv 10.0-STABLE FreeBSD 10.0-STABLE #0
r263107M: Sun Mar 16 17:52:42 UTC 2014    
root@STABLE10.housenet.jrv:/usr/obj/usr/src/sys/GENERIC  amd64

Samba 3.6 doesn't compile for me on stable10, yet internet searches
don't reveal any other cases similar to this?

The symptom is that compilations fail due to a linkage error: undefined
reference to `__unsafe_string_function_usage_here__'.

These seem to be the result of this code in
work/samba-3.6.23/source3/include/safe_string.h

#ifdef HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS
...
#define safe_strcpy_fn2(fn_name, fn_line, d, s, max_len) \
    (CHECK_STRING_SIZE(d, max_len+1) \
    ? __unsafe_string_function_usage_here__() \
    : safe_strcpy_fn(fn_name, fn_line, (d), (s), (max_len)))
...

HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS is a configuration-time item set in
work/samba-3.6.23/source3/wscript:

    # Check if the compiler will optimize out functions
    conf.CHECK_CODE('''
if (0) {
    this_function_does_not_exist();
} else {
    return 1;
}''', 'HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS',
        msg="Checking if the compiler will optimize out functions")

A manual #undef of HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS fixes the
problem.  It appears that samba assumes such dead code removal always
happens, whereas perhaps there are cases clang does not remove.  Or
perhaps the CHECK_STRING_SIZE test is finding a real bug.  Either way it
appears to be a samba issue that is exposed by stable10's usage of clang.

Compilation output:
...
Linking bin/smbstatus
locking/locking.o: In function `rename_share_filename':
/usr/ports/net/samba36/work/samba-3.6.23/source3/locking/locking.c:1100:
undefined reference to `__unsafe_string_function_usage_here__'
/usr/ports/net/samba36/work/samba-3.6.23/source3/locking/locking.c:1101:
undefined reference to `__unsafe_string_function_usage_here__'
/usr/ports/net/samba36/work/samba-3.6.23/source3/locking/locking.c:1102:
undefined reference to `__unsafe_string_function_usage_here__'
locking/locking.o: In function `unparse_share_modes':
/usr/ports/net/samba36/work/samba-3.6.23/source3/locking/locking.c:851:
undefined reference to `__unsafe_string_function_usage_here__'
/usr/ports/net/samba36/work/samba-3.6.23/source3/locking/locking.c:854:
undefined reference to `__unsafe_string_function_usage_here__'
locking/locking.o:/usr/ports/net/samba36/work/samba-3.6.23/source3/locking/locking.c:857:
more undefined references to `__unsafe_string_function_usage_here__' follow
lib/util_str.o: In function `string_append':
/usr/ports/net/samba36/work/samba-3.6.23/source3/lib/util_str.c:2101:
undefined reference to `__unsafe_string_function_usage_here__'
cc: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[2]: *** [bin/testparm] Error 1
gmake[2]: *** Waiting for unfinished jobs....
cc: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[2]: *** [bin/smbstatus] Error 1
gmake[2]: Leaving directory
`/usr/ports/net/samba36/work/samba-3.6.23/source3'
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/net/samba36
*** Error code 1

Stop.
make: stopped in /usr/ports/net/samba36
STABLE10:/usr/ports/net/samba36# svnlite info
...
Repository UUID: 35697150-7ecd-e111-bb59-0022644237b5
Revision: 348319
Node Kind: directory
Schedule: normal
Last Changed Author: delphij
Last Changed Rev: 347949
Last Changed Date: 2014-03-12 01:07:30 +0000 (Wed, 12 Mar 2014)

STABLE10:/usr/ports/net/samba36# cc -v
FreeBSD clang version 3.3 (tags/RELEASE_33/final 183502) 20130610
Target: x86_64-unknown-freebsd10.0
Thread model: posix
STABLE10:/usr/ports/net/samba36# cat /etc/make.conf
WITH_DEBUG=1
WITHOUT_X11=1
OPTIONS_UNSET=X11
WITHOUT_PKGNG=1
NO_WARNING_PKG_INSTALL_EOL=yes
STABLE10:/usr/ports/net/samba36#




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5326972A.5080400>