[Unison-hackers] Compiling under Mac OS X
Benjamin Pierce
bcpierce at cis.upenn.edu
Tue Jul 21 15:17:21 EDT 2009
> First thing, I think you can remove the dependency on unison-blob.o
> from target macexecutable in Makefile.OCaml. At the moment, the Caml
> files are compiled twice! Replace the line:
>
> macexecutable: $(NAME)-blob.o
>
> by just
>
> macexecutable:
>
OK, done.
> Then, the patch had zero chance of working: the problem seems to
> happen at an earlier stage, when the Caml code is linked, not when the
> GUI is built. Can you try this, then:
>
>> make clean
>> export ZERO_LINK=NO
>> make
Same failure. :-(
>
> If this still does not work, we have to investigate a bit more. The
> compilation process fails at the final step when linking everything
> together. The reason is that the two symbols below are not found:
>
>> Undefined symbols:
>> "_caml_apply2", referenced from:
>> _caml_callback2_exn in libasmrun.a(i386.o)
>> "_caml_apply3", referenced from:
>> _caml_callback3_exn in libasmrun.a(i386.o)
>
> These symbols should come from file unison-blob.o . You can check
> they are indeed defined there with the following command:
>
>> nm unison-blob.o | grep caml_apply2
> 0000000000005000 T caml_apply2
> 0000000000003ef0 T caml_apply21
> 0000000000003b70 T caml_apply23
> 00000000000037c0 T caml_apply24
Output is a little different from yours:
~/current/unison/trunk/src> nm unison-blob.o | grep caml_apply2
000024b0 t _caml_apply2
But it looks like the one that the loader can't find is defined, at
least.
> If the symbols are not defined, we need to find out at which point
> they disappear. You need to change this rule:
>
> $(NAME)-blob.o: $(CAMLOBJS) $(COBJS)
> @echo Linking $@
> $(CAMLC) -output-obj -verbose $(CAMLFLAGS) ...
> $(LD) -r -o $@ u-b.o $(COBJS)
> $(RM) u-b.o
>
> into:
>
> $(NAME)-blob.o: $(CAMLOBJS) $(COBJS)
> @echo Linking $@
> $(CAMLC) -dstartup -output-obj -verbose $
> (CAMLFLAGS) ...
> $(LD) -r -o $@ u-b.o $(COBJS)
>
> (Add a "-dstartup" option to ocamlopt and remove the "rm" command.)
>
> Then, if you recompile, you should get two files u-b.o.startup.s and
> u-b.o in the build directory. Then, again, you can use "nm u-b.o" to
> find out whether caml_apply2 is defined in u-b.o. In the assembly
> file, there should be some lines that look like this:
>
> [...]
> .text
> .align 16
> .globl caml_apply2
> caml_apply2:
> subq $8, %rsp
> [...]
>
> Tell me the last point where you could find caml_apply2 defined (the
> corresponding output could be useful too).
>
> Now, if the symbols are actually defined in unison-blob.o, this may be
> a problem with the order in which the files are given to gcc for
> linking. So, in the following command (that should be a single line),
> you can try to move unison-blob.o before -lasmrun. (Under Linux, I
> have to put it before all the -lxxx, but this may different under
> Mac OS X.)
>
>> /Developer/usr/bin/gcc-4.0 -arch i386 -isysroot /Developer/SDKs/
>> MacOSX10.5.sdk -L/Users/bcpierce/current/unison/trunk/src/uimacnew/
>> build/Default -F/Users/bcpierce/current/unison/trunk/src/uimacnew/
>> build/Default -F/Users/bcpierce/current/unison/trunk/src/uimacnew -
>> filelist /Users/bcpierce/current/unison/trunk/src/uimacnew/build/
>> uimacnew.build/Default/uimac.build/Objects-normal/i386/
>> Unison.LinkFileList -mmacosx-version-min=10.5 -L/usr/local/lib/
>> ocaml -
>> lunix -lthreadsnat -lstr -lbigarray -lasmrun -framework Cocoa -
>> framework Security -framework Growl -framework ExceptionHandling /
>> Users/bcpierce/current/unison/trunk/src/uimacnew/../unison-blob.o -
>> o /
>> Users/bcpierce/current/unison/trunk/src/uimacnew/build/Default/
>> Unison.app/Contents/MacOS/Unison
Moving it earlier doesn't seem to help, unfortunately.
~/current/unison/trunk/src> /Developer/usr/bin/gcc-4.0 -arch i386 -
isysroot /Developer/SDKs/MacOSX10.5.sdk -L/Users/bcpierce/current/
unison/trunk/src/uimacnew/build/Default -F/Users/bcpierce/current/
unison/trunk/src/uimacnew/build/Default -F/Users/bcpierce/current/
unison/trunk/src/uimacnew -filelist /Users/bcpierce/current/unison/
trunk/src/uimacnew/build/uimacnew.build/Default/uimac.build/Objects-
normal/i386/Unison.LinkFileList -mmacosx-version-min=10.5 -L/usr/local/
lib/ocaml /Users/bcpierce/current/unison/trunk/src/uimacnew/../unison-
blob.o -lunix -lthreadsnat -lstr -lbigarray -lasmrun -framework Cocoa -
framework Security -framework Growl -framework ExceptionHandling -o /
Users/bcpierce/current/unison/trunk/src/uimacnew/build/Default/
Unison.app/Contents/MacOS/Unison
Undefined symbols:
"_caml_apply2", referenced from:
_caml_callback2_exn in libasmrun.a(i386.o)
"_caml_apply3", referenced from:
_caml_callback3_exn in libasmrun.a(i386.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
~/current/unison/trunk/src> /Developer/usr/bin/gcc-4.0 -arch i386 -
isysroot /Developer/SDKs/MacOSX10.5.sdk -L/Users/bcpierce/current/
unison/trunk/src/uimacnew/build/Default -F/Users/bcpierce/current/
unison/trunk/src/uimacnew/build/Default -F/Users/bcpierce/current/
unison/trunk/src/uimacnew /Users/bcpierce/current/unison/trunk/src/
uimacnew/../unison-blob.o -filelist /Users/bcpierce/current/unison/
trunk/src/uimacnew/build/uimacnew.build/Default/uimac.build/Objects-
normal/i386/Unison.LinkFileList -mmacosx-version-min=10.5 -L/usr/local/
lib/ocaml -lunix -lthreadsnat -lstr -lbigarray -lasmrun -framework
Cocoa -framework Security -framework Growl -framework
ExceptionHandling -o /Users/bcpierce/current/unison/trunk/src/
uimacnew/build/Default/Unison.app/Contents/MacOS/Unison
Undefined symbols:
"_caml_apply2", referenced from:
_caml_callback2_exn in libasmrun.a(i386.o)
"_caml_apply3", referenced from:
_caml_callback3_exn in libasmrun.a(i386.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
Any more thoughts?
- B
More information about the Unison-hackers
mailing list