Bug 374685 - Won't Build on Mac OS X 10.11 (El Capitan) - undefined symbol ___bzero
Summary: Won't Build on Mac OS X 10.11 (El Capitan) - undefined symbol ___bzero
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: 3.12.0
Platform: unspecified macOS
: NOR major
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
: 377550 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-01-07 11:17 UTC by chris
Modified: 2017-04-01 22:27 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description chris 2017-01-07 11:17:27 UTC
When I build Valgrind on Mac OS X 10.11 via:

1. Download Valgrind 3.12.0 source code tarball
2. cd to extracted source directory
3. Run ./configure
4. Run make

I get this error (truncated output):

link_tool_exe_darwin: /usr/bin/ld -static -arch x86_64 -macosx_version_min 10.6 -o memcheck-amd64-darwin -u __start -e __start -image_base 0x138000000 -stack_addr 0x134000000 -stack_size 0x800000 memcheck_amd64_darwin-mc_leakcheck.o memcheck_amd64_darwin-mc_malloc_wrappers.o memcheck_amd64_darwin-mc_main.o memcheck_amd64_darwin-mc_translate.o memcheck_amd64_darwin-mc_machine.o memcheck_amd64_darwin-mc_errors.o ../coregrind/libcoregrind-amd64-darwin.a ../VEX/libvex-amd64-darwin.a
Undefined symbols for architecture x86_64:
  "___bzero", referenced from:
      _hijack_thread_state in libcoregrind-amd64-darwin.a(libcoregrind_amd64_darwin_a-syswrap-amd64-darwin.o)
      _RRegUniverse__init in libvex-amd64-darwin.a(libvex_amd64_darwin_a-host_generic_regs.o)
ld: symbol(s) not found for architecture x86_64
make[3]: *** [memcheck-amd64-darwin] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
Comment 1 Philippe Waroquiers 2017-01-07 15:44:58 UTC
This problem was already discussed on the user mailing list.
The below solution was proposed by John Reiser.


> Undefined symbols for architecture x86_64:
>
>   "___bzero", referenced from:
>
>       _hijack_thread_state in libcoregrind-amd64-darwin.a(libcoregrind_amd64_darwin_a-syswrap-amd64-darwin.o)
>
>       _RRegUniverse__init in libvex-amd64-darwin.a(libvex_amd64_darwin_a-host_generic_regs.o)

$ grep -r __bzero valgrind-3.12

===== coregrind/m_main.c
#if defined(VGO_darwin) && DARWIN_VERS == DARWIN_10_10

/* This might also be needed for > DARWIN_10_10, but I have no way
    to test for that.  Hence '==' rather than '>=' in the version
    test above. */
void __bzero ( void* s, UWord n );
void __bzero ( void* s, UWord n )
{
    (void) VG_(memset)( s, 0, n );
}

#endif
=====

So a timid developer chose "not functional" versus
"works, but perhaps a few microseconds slower".

Just change it to
	#if defined(VGO_darwin)
omitting the test of DARWIN_VERS.
Comment 2 Philippe Waroquiers 2017-01-07 15:57:25 UTC
Note that this was fixed in SVN, effectively by always defining __bzero.
So, 3.13../SVN should build out of the box

r16103 | rhyskidd | 2016-10-23 23:31:16 +0200 (Sun, 23 Oct 2016) | 1 line

bzero is non-POSIX (deprecated), accordingly __bzero template required for all macOS versions. n-i-bz.
------------------------------------------------------------------------
Comment 3 chris 2017-01-08 04:55:31 UTC
Thanks Philippe! I can confirm it builds and installs using the latest SVN commit.
Comment 4 Jeffrey Walton 2017-01-21 04:25:37 UTC
The issue surfaced on a 2012 Intel Core2 Duo MacBook running OS X 10.9.

Working from Master, the issue was resolved on OS X 10.9, also.
Comment 5 Rhys Kidd 2017-04-01 22:27:13 UTC
*** Bug 377550 has been marked as a duplicate of this bug. ***