Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Aug 2013 20:13:34 +0200
From:      Dimitry Andric <dim@FreeBSD.org>
To:        Dmitry Morozovsky <marck@rinet.ru>
Cc:        "freebsd-current@freebsd.org CURRENT" <freebsd-current@FreeBSD.org>, Peter Wemm <peter@wemm.org>
Subject:   Re: building i386 world on amd64 host: failed @svn
Message-ID:  <17A40261-A0DA-4070-990F-0D0777A5BE44@FreeBSD.org>
In-Reply-To: <alpine.BSF.2.00.1307281713160.55051@woozle.rinet.ru>
References:  <alpine.BSF.2.00.1307281713160.55051@woozle.rinet.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
On Jul 28, 2013, at 15:15, Dmitry Morozovsky <marck@rinet.ru> wrote:
...
> on my builder I have consistent error:
>=20
> =
/usr/obj/i386.i386/FreeBSD/pristine/src.current/usr.bin/svn/svn/../lib/lib=
svn_subr/libsvn_subr.a(named_atomic.o):=20
> In function `svn_named_atomic__cmpxchg':
> named_atomic.c:(.text+0xed): undefined reference to=20
> `__sync_val_compare_and_swap_8'
> =
/usr/obj/i386.i386/FreeBSD/pristine/src.current/usr.bin/svn/svn/../lib/lib=
svn_subr/libsvn_subr.a(named_atomic.o):=20
> In function `svn_named_atomic__add':
> named_atomic.c:(.text+0x193): undefined reference to =
`__sync_add_and_fetch_8'
> =
/usr/obj/i386.i386/FreeBSD/pristine/src.current/usr.bin/svn/svn/../lib/lib=
svn_subr/libsvn_subr.a(named_atomic.o):=20
> In function `svn_named_atomic__write':
> named_atomic.c:(.text+0x1f3): undefined reference to=20
> `__sync_lock_test_and_set_8'

After a bit of private conversation with Dmitry, it turned out he was
building using WITHOUT_CLANG, e.g. gcc is used for everything.  Now,
this is *not* a problem specific to cross-building: head will not build
on i386 with gcc at all!  It results in exactly the same error shown
above.

This is because Subversion has a few wrapper routines for atomic
operations, and these are implemented in terms of the __sync_xxx
compiler builtins, since usr.bin/svn/svn_private_config.h has
SVN_HAS_ATOMIC_BUILTINS defined.  On i386, gcc apparently cannot inline
the 64 bit versions of these builtins, so it inserts a call to an
external function instead, leading to a link error.

Eventually, we could put such functions in libc, but for now it might be
better to turn off the SVN_HAS_ATOMIC_BUILTINS define in case of !clang
&& i386, e.g.:

Index: usr.bin/svn/svn_private_config.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- usr.bin/svn/svn_private_config.h    (revision 254300)
+++ usr.bin/svn/svn_private_config.h    (working copy)
@@ -153,7 +153,9 @@
 #define SVN_FS_WANT_DB_PATCH 14

 /* Define if compiler provides atomic builtins */
+#if defined(__i386__) && !defined(__clang__)
 #define SVN_HAS_ATOMIC_BUILTINS 1
+#endif

 /* Is GNOME Keyring support enabled? */
 /* #undef SVN_HAVE_GNOME_KEYRING */

Alternatively, we could attempt to figure out why gcc doesn't want to
inline those 64 bit builtins on FreeBSD.  It seems to have no problem
doing so on the first Linux box I tried...

-Dimitry




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?17A40261-A0DA-4070-990F-0D0777A5BE44>