[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#641102: unison: FTBFS with ld that defaults to --as-needed: bad link order



Package: unison
Version: 2.32.52-3
Severity: important
Tags: patch
User: ubuntu-devel@lists.ubuntu.com
Usertags: origin-ubuntu ubuntu-patch oneiric

unison fails to build with a linker that defaults to --as-needed:

  Linking unison
  ocamlopt -verbose -I lwt -I ubase -o unison   unix.cmxa str.cmxa bigarray.cmxa -cclib -lutil ubase/projectInfo.cmx ubase/myMap.cmx ubase/safelist.cmx ubase/uprintf.cmx ubase/util.cmx ubase/rx.cmx ubase/uarg.cmx ubase/prefs.cmx ubase/trace.cmx lwt/pqueue.cmx lwt/lwt.cmx lwt/lwt_util.cmx lwt/lwt_unix.cmx bytearray.cmx case.cmx pred.cmx uutil.cmx fileutil.cmx name.cmx path.cmx fspath.cmx fingerprint.cmx abort.cmx osx.cmx external.cmx props.cmx fileinfo.cmx os.cmx lock.cmx clroot.cmx common.cmx tree.cmx checksum.cmx terminal.cmx transfer.cmx xferhint.cmx remote.cmx globals.cmx copy.cmx stasher.cmx update.cmx files.cmx sortri.cmx recon.cmx transport.cmx strings.cmx uicommon.cmx uitext.cmx test.cmx main.cmx linktext.cmx osxsupport.o pty.o bytearray_stubs.o
  + as -o '/tmp/camlstartup999a84.o' '/tmp/camlstartup832abc.s'
  + gcc -o 'unison'   '-Llwt' '-Lubase' '-L/usr/lib/ocaml'  '/tmp/camlstartup999a84.o' '/usr/lib/ocaml/std_exit.o' 'linktext.o' 'main.o' 'test.o' 'uitext.o' 'uicommon.o' 'strings.o' 'transport.o' 'recon.o' 'sortri.o' 'files.o' 'update.o' 'stasher.o' 'copy.o' 'globals.o' 'remote.o' 'xferhint.o' 'transfer.o' 'terminal.o' 'checksum.o' 'tree.o' 'common.o' 'clroot.o' 'lock.o' 'os.o' 'fileinfo.o' 'props.o' 'external.o' 'osx.o' 'abort.o' 'fingerprint.o' 'fspath.o' 'path.o' 'name.o' 'fileutil.o' 'uutil.o' 'pred.o' 'case.o' 'bytearray.o' 'lwt/lwt_unix.o' 'lwt/lwt_util.o' 'lwt/lwt.o' 'lwt/pqueue.o' 'ubase/trace.o' 'ubase/prefs.o' 'ubase/uarg.o' 'ubase/rx.o' 'ubase/util.o' 'ubase/uprintf.o' 'ubase/safelist.o' 'ubase/myMap.o' 'ubase/projectInfo.o' '/usr/lib/ocaml/bigarray.a' '/usr/lib/ocaml/str.a' '/usr/lib/ocaml/unix.a' '/usr/lib/ocaml/stdlib.a' '-lbigarray' '-lcamlstr' '-lunix' '-lutil' 'osxsupport.o' 'pty.o' 'bytearray_stubs.o' '/usr/lib/ocaml/libasmrun.a' -lm  -ldl
  pty.o: In function `c_openpty':
  pty.c:(.text+0x74): undefined reference to `openpty'
  collect2: ld returned 1 exit status
  File "caml_startup", line 1, characters 0-1:
  Error: Error during linking
  make[1]: *** [unison] Error 2

This is because its link line order is wrong, putting libraries before
the objects that use them rather than after.  See:

  http://wiki.debian.org/ToolChain/DSOLinking#Only_link_with_needed_libraries

The following patch fixes this.

  * Fix link order to list C objects before the libraries they require.

diff -Nru unison-2.32.52/debian/patches/link-order.patch unison-2.32.52/debian/patches/link-order.patch
--- unison-2.32.52/debian/patches/link-order.patch	1970-01-01 01:00:00.000000000 +0100
+++ unison-2.32.52/debian/patches/link-order.patch	2011-09-10 12:17:34.000000000 +0100
@@ -0,0 +1,18 @@
+Description: Fix link order to list C objects before the libraries they require
+Author: Colin Watson <cjwatson@ubuntu.com>
+Forwarded: no
+Last-Update: 2011-09-10
+
+Index: b/Makefile.OCaml
+===================================================================
+--- a/Makefile.OCaml
++++ b/Makefile.OCaml
+@@ -366,7 +366,7 @@
+ 
+ $(NAME)$(EXEC_EXT): $(CAMLOBJS) $(COBJS)
+ 	@echo Linking $@
+-	$(CAMLC) -verbose $(CAMLFLAGS) -o $@ $(CFLAGS) $(CAMLLIBS) $(CLIBS) $^
++	$(CAMLC) -verbose $(CAMLFLAGS) -o $@ $(CFLAGS) $(CAMLLIBS) $^ $(CLIBS)
+ 
+ # Unfortunately -output-obj does not put .o files into the output, only .cmx
+ # files, so we have to use $(LD) to take care of COBJS.
diff -Nru unison-2.32.52/debian/patches/series unison-2.32.52/debian/patches/series
--- unison-2.32.52/debian/patches/series	2011-04-03 12:21:58.000000000 +0100
+++ unison-2.32.52/debian/patches/series	2011-09-10 12:09:12.000000000 +0100
@@ -5,3 +5,4 @@
 0005-Fix-build-with-OCaml-3.12.patch
 0006-Fix-bad-interaction-with-OpenSSH-5.6.patch
 debian-changes-2.32.52-3
+link-order.patch

Thanks,

-- 
Colin Watson                                       [cjwatson@ubuntu.com]



Reply to: