Bug #47416 Build failure on OS X 10.6: duplicate symbol _timed_mutexes
Submitted: 17 Sep 2009 14:19 Modified: 29 Jun 2010 6:55
Reporter: Jon Olav Hauglid Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Embedded Library ( libmysqld ) Severity:S2 (Serious)
Version:6.0.14-alpha, mysql-pe OS:MacOS (10.6)
Assigned to: Georgi Kodinov CPU Architecture:Any

[17 Sep 2009 14:19] Jon Olav Hauglid
Description:
Trying to build the current version of mysql-6.0-codebase-bugfixing on OS X 10.6 (Snow Leopard) results in the following error message:

ld: duplicate symbol _timed_mutexes in ../../libmysqld/libmysqld.a(my_static.o) and ../../libmysqld/libmysqld.a(my_static.o)
collect2: ld returned 1 exit status
make[4]: *** [mysql] Error 1
make[4]: *** Waiting for unfinished jobs....
ld: duplicate symbol _timed_mutexes in ../../libmysqld/libmysqld.a(my_static.o) and ../../libmysqld/libmysqld.a(my_static.o)
collect2: ld returned 1 exit status
make[4]: *** [mysqltest_embedded] Error 1
mv -f .deps/mysql_client_test.Tpo .deps/mysql_client_test.Po
make[3]: *** [all] Error 2
make[2]: *** [all-recursive] Error 1
make[1]: *** [all] Error 2
make: *** [all-recursive] Error 1

Verified on two separate installations.

How to repeat:
BUILD/compile-pentium-valgrind-max
[9 Oct 2009 13:51] Jon Olav Hauglid
It turns out that the BUILD/ scripts are not actively maintained and are planned for eventual removal.

A work-around is to use configure & make.
Therefore setting this bug to "Won't fix"
[16 Oct 2009 7:04] Georgi Kodinov
Happens in mysql-pe-stage as well. I don't think we can easily leave BUILD/* scripts unmaintained. This is how most of the mysql developers compile, they bring better uniformity over configure and it's easier to type than long configure lines. And it ultimately saves time. Let's leave this bug to open. I'll find out what the problem is (if you haven't done so already).
[16 Oct 2009 7:36] Georgi Kodinov
it's not true that the configure works : configure (with no options) doesn't build the embedded server. And this is an embedded server compilation problem.
[21 Jan 2010 15:14] Valeriy Kravchuk
Bug #50405  was marked as a duplicate of this one.
[2 Feb 2010 13:07] Bernd Ocklin
in Xcode 3.2 (used in darwin10, Snow Leopard) Apple have introduced a bug (radar 6320843 "duplicate symbols from static libraries not properly ignored")
[9 Feb 2010 14:04] Georgi Kodinov
Not repeatable with xcode 3.2.1 on 5.1-bugteam. mysql-pe and mysql-6.0-codebase-bugfixing affected.
[12 Feb 2010 14:37] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/100140

3902 Georgi Kodinov	2010-02-12
      Bug #47416: Build failure on OS X 10.6: duplicate symbol _timed_mutexes
      
      my_static.o is included in both ndbclient lib and the mysys lib. As a
      result it gets added twice into libmysqld.a.
      As a result all the global symbols defined in it are defined twice.
      This is not a problem for the most of the linkers, but gcc on MacOSX 10.6
      has been changed to consider this a problem (radar 6320843).
      Fixed by adding an option to ranlib to generate a library that doesn't have
      the symbols from my_static (and others) defined twice.
     @ configure.in
        Add a branch for Snow Leopard and define the ranlib compatibility flag
     @ libmysqld/Makefile.am
        use the ranlib compatibility flag
[12 Feb 2010 14:56] Daniel Fischer
Looks like it might work.
[2 Mar 2010 14:34] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100302142746-u1gxdf5yk2bjrq3e) (version source revid:alik@sun.com-20100225090938-2j5ybqoau570mytu) (merge vers: 6.0.14-alpha) (pib:16)
[3 Mar 2010 1:51] Paul DuBois
Noted in 6.0.14 changelog.

my_static.o was included twice into libmysqld, resulting in
duplicate-symbol errors on Mac OS X 10.6.

Setting report to Need Merge pending push to Celosia.
[29 Jun 2010 6:55] Jon Olav Hauglid
I can now build all trees I've tried without problems,
and 6.0 trees for which this bug existed, have been abandoned.
After discussing with Joro, we've decided to close this bug.
[29 Jan 2011 9:52] Martin Zaun
Ran into the 'link error duplicate symbol' problem on 5.1-telco-7.1 in
client/ (see below), after my upgrade to MacOS 10.6.

I tried to apply this bug's patch: to call ranlib (which actually is a
symbolic link to libtool on MacOS) with '-c'.  But no effect!

Saw that others had solved this by doing the opposite: to supress '-c'
flag on darwin10:
    http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42554
    http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41180 

The workaround/solution I found is calling: ./configure --with-pic ... 

Regards, Martin

...
Making all in client
make  all-am
/bin/sh ../libtool --preserve-dup-deps  --tag=CC   --mode=link /usr/bin/gcc-4.2 -DTHREAD -UUNDEF_THREADS_HACK -g -DSAFE_MUTEX -DSAFEMALLOC -g -m64   -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT  -DDONT_DECLARE_CXA_PURE_VIRTUAL   -o mysqlimport mysqlimport-mysqlimport.o   -all-static ../libmysql_r/libmysqlclient_r.la ../mysys/libmysyslt.la -lm   -lz
libtool: link: warning: complete static linking is impossible in this configuration
libtool: link: /usr/bin/gcc-4.2 -DTHREAD -UUNDEF_THREADS_HACK -g -DSAFE_MUTEX -DSAFEMALLOC -g -m64 -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL -o mysqlimport mysqlimport-mysqlimport.o  ../libmysql_r/.libs/libmysqlclient_r.a ../mysys/.libs/libmysyslt.a -lm -lz
ld: duplicate symbol _timed_mutexes in ../mysys/.libs/libmysyslt.a(my_static.o) and ../libmysql_r/.libs/libmysqlclient_r.a(my_static.o)
collect2: ld returned 1 exit status
make[2]: *** [mysqlimport] Error 1
make[1]: *** [all] Error 2
make: *** [all-recursive] Error 1