Looking for help in compiling unison on mac OS Catalina


I would like to build unison. To get an interoperable version with what I have on other systems, I build it from pkgsrc. (unison is using a data structure on the wire that depends on the ocaml used to build it).

ocaml itself builds fine on mac OS. There are some patches and some flags (see the Makefile and patches below https://github.com/NetBSD/pkgsrc/blob/trunk/lang/ocaml/). ocaml with these patches/flags builds and works fine on NetBSD and at least builds on CentOS 7 (haven’t tried it there).

unison in pkgsrc also has some patches and flags (see Makefile and patches below https://github.com/NetBSD/pkgsrc/blob/trunk/net/unison2.51/). It works fine with these on NetBSD.

When I try to build unison on mac OS, it looks good until the end when it stops with:

Linking unison
ocamlc -verbose -g -unsafe-string -I lwt -I ubase -I system -I fsmonitor -I fsmonitor/linux -I fsmonitor/windows -I system/generic -I lwt/generic -ccopt -mmacosx-version-min=10.5 -custom -g -o unison  unix.cma str.cma bigarray.cma ubase/rx.cmo unicode_tables.cmo unicode.cmo bytearray.cmo system/system_generic.cmo system/generic/system_impl.cmo system.cmo ubase/projectInfo.cmo ubase/myMap.cmo ubase/safelist.cmo ubase/util.cmo ubase/uarg.cmo ubase/prefs.cmo ubase/trace.cmo ubase/proplist.cmo lwt/pqueue.cmo lwt/lwt.cmo lwt/lwt_util.cmo lwt/generic/lwt_unix_impl.cmo lwt/lwt_unix.cmo uutil.cmo case.cmo pred.cmo fileutil.cmo name.cmo path.cmo fspath.cmo fs.cmo fingerprint.cmo abort.cmo osx.cmo external.cmo fswatch.cmo props.cmo fileinfo.cmo os.cmo lock.cmo clroot.cmo common.cmo tree.cmo checksum.cmo terminal.cmo transfer.cmo xferhint.cmo remote.cmo globals.cmo fswatchold.cmo fpcache.cmo update.cmo copy.cmo stasher.cmo files.cmo sortri.cmo recon.cmo transport.cmo strings.cmo uicommon.cmo uitext.cmo test.cmo main.cmo linktext.cmo osxsupport.o pty.o bytearray_stubs.o 
+ clang -O2 -fno-strict-aliasing -fwrapv -Wall  -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE   -Wl,-no_compact_unwind -o 'unison'  '-Llwt' '-Lubase' '-Lsystem' '-Lfsmonitor' '-Lfsmonitor/linux' '-Lfsmonitor/windows' '-Lsystem/generic' '-Llwt/generic' '-L/opt/pkg/lib/ocaml' -pipe -I/opt/pkg/include -L/opt/pkg/lib -L/usr/lib -mmacosx-version-min=10.5 '-fdebug-prefix-map=/var/folders/23/zvf0q1xx5f76gty6flk516200000z8/T/camlprimde5fc5.c=camlprim.c' '/var/folders/23/zvf0q1xx5f76gty6flk516200000z8/T/camlprimde5fc5.c' '-lcamlstr' '-lunix' 'osxsupport.o' 'pty.o' 'bytearray_stubs.o' '-lcamlrun' -I'/opt/pkg/lib/ocaml' -lm  -lpthread 
0  0x104e0e998  __assert_rtn + 127
1  0x104e17d69  ld::passes::stubs::arm::StubHelperAtom::StubHelperAtom(ld::passes::stubs::Pass&, ld::Atom const&, ld::Atom const*, bool) (.cold.1) + 0
2  0x104dcb1ba  ld::passes::stubs::x86_64::classic::StubHelperAtom::StubHelperAtom(ld::passes::stubs::Pass&, ld::Atom const&, ld::Atom const&, bool) + 168
3  0x104dcb0a5  ld::passes::stubs::x86_64::classic::LazyPointerAtom::LazyPointerAtom(ld::passes::stubs::Pass&, ld::Atom const&, bool, bool) + 135
4  0x104dcafda  ld::passes::stubs::x86_64::classic::StubAtom::StubAtom(ld::passes::stubs::Pass&, ld::Atom const&, bool, bool) + 92
5  0x104dc9200  ld::passes::stubs::Pass::makeStub(ld::Atom const&, bool) + 1776
6  0x104dc990b  ld::passes::stubs::Pass::process(ld::Internal&) + 1215
7  0x104dc9cb9  ld::passes::stubs::doPass(Options const&, ld::Internal&) + 105
8  0x104cef4ec  main + 892
9  0x7fff6cefccc9  start + 1
A linker snapshot was created at:
ld: Assertion failed: (targetAtom != NULL), function Fixup, file /Library/Caches/com.apple.xbs/Sources/ld64/ld64-556.5/src/ld/ld.hpp, line 785.
clang: error: linker command failed with exit code 1 (use -v to see invocation)
File "_none_", line 1:
Error: Error while building custom runtime system
gnumake: *** [unison] Error 2
*** Error code 2

I have no idea what the problem is here. Can anyone please help?


Well, this looks like an internal failure in the linker (ld). So in theory it’s not caused by anything any of the other tools is doing wrong. The usual thing to do in such cases (IMHO) is to try leaving off various linker options until it works, then try adding back the ones you really need one at a time. In essence, you’re trying to eliminate the edge case that didn’t show up while testing the linker.