Subject: pkg/6935: pkglibtool should include /usr/lib/c++rt0.o to shared libs
To: None <gnats-bugs@gnats.netbsd.org>
From: Jaromir Dolecek <dolecek@ics.muni.cz>
List: netbsd-bugs
Date: 02/03/1999 19:52:09
>Number:         6935
>Category:       pkg
>Synopsis:       pkglibtool should include /usr/lib/c++rt0.o to shared libs
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Wed Feb  3 11:05:01 1999
>Last-Modified:
>Originator:     Jaromir Dolecek
>Organization:
	Per4mance, Brno, Czech Republic
>Release:        NetBSD-19990118 or so
>Environment:
	
System: NetBSD jdolecek.per4mance.cz 1.3I NetBSD 1.3I (JDOLECEK) #0: Sun Jan 31 21:02:09 MET 1999 dolecek@jdolecek.per4mance.cz:/home/dolecek/tmp/kern-19990116/src/sys/arch/i386/compile/JDOLECEK i386


>Description:
	Some C++ libraries uses static constructors. On a.out systems,
	they require to link /usr/lib/c++rt0.o into the library
	to actually run the constructors when the shared lib is mapped.
	While it's possible to do it manually for each individual
	package, it's much more convenient to link it in
	automatically. It's only 500B or so big (i386 arch)
	and doesn't hurt even when it's not needed, so it can be safely
	linked into each library pkglibtool is creating. As we
	are moving to ELF anyway, this solution is probly
	better than modifying each and every C++ library around
	to explicitely link in that c++rt0.o file on NetBSD a.out systems.

	Wouldn't it be better if ld would link in the c++rt0.o
	into each created shared library directly ? Maybe.
>How-To-Repeat:
>Fix:
	This patch replaces patch-aa in current pkglibtool package.
	The changed part pretty much makes the same as the code
	for FreeBSD 2.2.X.

--- ltconfig.orig	Fri Mar 20 09:00:29 1998
+++ ltconfig	Wed Feb  3 19:28:46 1999
@@ -808,7 +808,17 @@
 
   netbsd*)
     # Tested with NetBSD 1.2 ld
-    archive_cmds='$LD -Bshareable -o $lib$libobjs'
+    if $CC -E - -dM </dev/null | grep -q __ELF__; then
+      archive_cmds='$LD -shared -o $lib$libobjs'	# ELF
+    else
+      archive_cmds='$LD -Bshareable -o $lib$libobjs'	# a.out
+      if [ -f /usr/lib/c++rt0.o ]; then
+  	# include c++rt0.o to get C++ constructor support; even for C libs, it
+	# doesn't break anything and help significantly (at cost of little
+	# extra space -- 523B on NetBSD 1.3I/i386)
+	archive_cmds="$archive_cmds /usr/lib/c++rt0.o"
+      fi
+    fi
     hardcode_libdir_flag_spec='-R$libdir'
     hardcode_direct=yes
     hardcode_shlibpath_var=no
@@ -1181,8 +1191,15 @@
 
 netbsd* | openbsd*)
   version_type=sunos
-  library_names_spec='${libname}${release}.so.$versuffix'
-  finish_cmds='PATH="$PATH:/sbin" ldconfig -m $libdir'
+  if $CC -E - -dM </dev/null | grep -q __ELF__; then
+    library_names_spec='${libname}${release}.so.$versuffix ${libname}${release}.so.$major ${libname}${release}.so'
+    soname_spec='${libname}${release}.so.$major'
+    dynamic_linker='NetBSD ld.elf_so'
+  else
+    library_names_spec='${libname}${release}.so.$versuffix'
+    finish_cmds='PATH="$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD/OpenBSD (a.out) ld.so'
+  fi
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
>Audit-Trail:
>Unformatted: