Subject: pkg/20225: Fix libtool -no-undefined on Solaris
To: None <gnats-bugs@gnats.netbsd.org>
From: Jonathan Perkin <sketch@rd.bbc.co.uk>
List: netbsd-bugs
Date: 02/06/2003 18:33:27
>Number:         20225
>Category:       pkg
>Synopsis:       libtool passes incorrect flag to Sun ld
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Feb 06 10:34:00 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     Jonathan Perkin
>Release:        NetBSD 1.6M
>Organization:
	British Broadcasting Corporation
>Environment:
System: NetBSD munkeh.intra.nut 1.6M NetBSD 1.6M (GENERIC) #0: Tue Jan 21 11:42:54 GMT 2003 sketch@munkeh.intra.nut:/usr/src/sys/arch/sparc64/compile/GENERIC sparc64
Architecture: sparc64
Machine: sparc64
>Description:
	While attempting to build graphics/imlib2 on Solaris/pkgsrc, I ran
	into a problem using Sun ld and trying to compile one of the libraries
	without failing due to unresolved symbols.  After a bit of digging, I
	found that libtool uses the wrong ld flag to specify this option.

		[-z defs]       disallow undefined symbol references
		[-z nodefs]     allow undefined symbol references
		
	Now, after a bit of googling, I've seen a few small discussions where
	this may actually be the correct intent, but these seem to be GCC
	specific, ignoring the fact someone may be using Sun Workshop cc.

	The below fix works for me, although I'm no linker guru so I have no
	idea what the fallout might be.  Given it's Solaris only, I'd like
	to hear of other reports (and whether anyone else has this problem),
	and it'd be good to get it committed if it fixes immediate problems,
	if not being the "correct" fix (which would probably be to get GCC
	3.2+ as main compiler on Solaris/pkgsrc)

>How-To-Repeat:
	Try to build graphics/imlib2 on Solaris, and it'll fail trying to
	build filters/.libs/testfilter.so
>Fix:
Index: distinfo
===================================================================
RCS file: /cvsroot/pkgsrc/devel/libtool/distinfo,v
retrieving revision 1.24
diff -u -u -r1.24 distinfo
--- distinfo	2003/01/31 20:33:51	1.24
+++ distinfo	2003/02/06 18:18:06
@@ -14,5 +14,5 @@
 SHA1 (patch-aj) = 5382fc0a6a58687da5523c596118a4eeb948f675
 SHA1 (patch-ak) = 7e7c6a515361863b683bbc8be24c8146501ca864
 SHA1 (patch-al) = 22f1b7289d9ba477255e66364ae23af24a298dd0
-SHA1 (patch-am) = 0057a15d9bdb5a70d4964df49aa3e905ff7d9cf5
+SHA1 (patch-am) = 14c6373669d69e55845d0e5fb0731bb2c7260ebc
 SHA1 (patch-ao) = 4e115e9d6ddde556205dc786cde471bfee5a5e9e
Index: patches/patch-am
===================================================================
RCS file: /cvsroot/pkgsrc/devel/libtool/patches/patch-am,v
retrieving revision 1.5
diff -u -u -r1.5 patch-am
--- patches/patch-am	2003/01/31 20:33:52	1.5
+++ patches/patch-am	2003/02/06 18:18:06
@@ -1,8 +1,8 @@
 $NetBSD: patch-am,v 1.5 2003/01/31 20:33:52 skrll Exp $
 
---- ltcf-c.sh.orig	2001-04-25 04:05:02.000000000 +0000
-+++ ltcf-c.sh
-@@ -173,23 +173,13 @@ EOF
+--- ltcf-c.sh.orig	Wed Apr 25 05:05:02 2001
++++ ltcf-c.sh	Thu Feb  6 18:14:40 2003
+@@ -173,23 +173,13 @@
        $CC $output_objdir/$soname-exp '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags'
      ;;
  
@@ -28,7 +28,7 @@
      fi
      ;;
  
-@@ -379,6 +369,23 @@ else
+@@ -379,6 +369,23 @@
      fix_srcfile_path='`cygpath -w "$srcfile"`'
      ;;
  
@@ -52,7 +52,16 @@
    freebsd1*)
      ld_shlibs=no
      ;;
-@@ -644,7 +651,7 @@ else
+@@ -505,7 +512,7 @@
+     ;;
+ 
+   solaris*)
+-    no_undefined_flag=' -z defs'
++    no_undefined_flag=' -z nodefs'
+     # $CC -shared without GNU ld will not create a library from C++
+     # object files and a static libstdc++, better avoid it by now
+     archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+@@ -644,7 +651,7 @@
      darwin* | rhapsody*)
        # PIC is the default on this platform
        # Common symbols not allowed in MH_DYLIB files
>Release-Note:
>Audit-Trail:
>Unformatted: