Subject: "libtool" problems under Mac OS X Leopard
To: None <tech-pkg@NetBSD.org>
From: Matthias Scheler <tron@zhadum.org.uk>
List: tech-pkg
Date: 12/02/2007 16:50:03
	Hello,

I'm trying to build "graphics/glitz" under Mac OS X Leopard which
fails like this:

*** [buildlink3] Warning: libtool replaced -lglitz with ../../src/libglitz.la
gcc -dynamiclib  -o .libs/libglitz-glx.1.0.0.dylib  .libs/glitz_glx_drawable.o .libs/glitz_glx_format.o .libs/glitz_glx_info.o .libs/glitz_glx_extension.o .libs/glitz_glx_context.o .libs/glitz_glx_pbuffer.o  -L/Users/tron/obj/graphics/glitz/work.rotarran/.buildlink/lib -L/Users/tron/obj/graphics/glitz/work.rotarran/.x11-buildlink/lib -L/Users/tron/obj/graphics/glitz/work.rotarran/glitz-0.5.6/src ../../src/.libs/libglitz.dylib /Users/tron/obj/graphics/glitz/work.rotarran/.buildlink/lib/libXext.dylib -lX11 -lGL -lpthread -lXext  -install_name  /usr/pkg/lib/libglitz-glx.1.dylib -compatibility_version 2 -current_version 2.0
ld: cycle in dylib re-exports with /Users/tron/obj/graphics/glitz/work.rotarran/.buildlink/lib/libGL.dylib
collect2: ld returned 1 exit status

This is apparently a well known "improvement" in Leopard:

	http://developer.apple.com/qa/qa2007/qa1567.html

The fix is to use "-dylib_file /long/path/libGL.dylib:/long/path/libGL.dylib".
But that doesn't work unfortunately:

/bin/sh ../../libtool --tag=CC --mode=link gcc  -pipe -O2 -I/usr/pkg/include -DGLX_GLXEXT_LEGACY -I/usr/X11R6/include -I/usr/include -Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -fno-strict-aliasing   -L/usr/pkg/lib -L/usr/X11R6/lib -L/usr/lib -o libglitz-glx.la -rpath  /usr/pkg/lib -version-info 1:0:0 -no-undefined glitz_glx_drawable.lo  glitz_glx_format.lo  glitz_glx_info.lo  glitz_glx_extension.lo  glitz_glx_context.lo  glitz_glx_pbuffer.lo -L../../src -lglitz -L/usr/X11R6/lib -lX11 -lGL -dylib_file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib -lpthread -lXext
*** [buildlink3] Warning: libtool replaced -lglitz with ../../src/libglitz.la
gcc -dynamiclib  -o .libs/libglitz-glx.1.0.0.dylib  .libs/glitz_glx_drawable.o .libs/glitz_glx_format.o .libs/glitz_glx_info.o .libs/glitz_glx_extension.o .libs/glitz_glx_context.o .libs/glitz_glx_pbuffer.o  -L/Users/tron/obj/graphics/glitz/work.rotarran/.buildlink/lib -L/Users/tron/obj/graphics/glitz/work.rotarran/.x11-buildlink/lib -L/Users/tron/obj/graphics/glitz/work.rotarran/glitz-0.5.6/src ../../src/.libs/libglitz.dylib /Users/tron/obj/graphics/glitz/work.rotarran/.buildlink/lib/libXext.dylib -lX11 -lGL -lpthread -lXext  -install_name  /usr/pkg/lib/libglitz-glx.1.dylib -compatibility_version 2 -current_version 2.0
ld: cycle in dylib re-exports with /Users/tron/obj/graphics/glitz/work.rotarran/.buildlink/lib/libGL.dylib
collect2: ld returned 1 exit status

Note that the option is present when "libtool" is run but not when
"gcc" is run. I've made sure that it is not the buildink wrapper which
filters it out. My conclusion is that "libtool" from "libtool-base"
is removing that option. Apple's "libtool" doesn't do that. From
its manual page:

       link editor flags
              For  a  dynamic  shared  library  the  following ld(1) flags are
              accepted and passed through: -lx, -weak-lx,  -search_paths_first
[...]
              -all_load.   -arch_errors_fatal,  -dylib_file, -run_init_lazily,
[...]
              -no_uuid.   See  the  ld(1) man page for details on these flags.
              The flag -image_base is a synonym for -seg1addr.

How do I convince our "libtool" to do the same?

	Kind regards

-- 
Matthias Scheler                                  http://zhadum.org.uk/