Skip to content
Tcl Source Code View Ticket
Login

View Ticket

NetBSD ELF shared libraries are not supported

Closed / Fixed219017ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 01:09:25
OriginalBugID: 3959 Bug
Version: 8.2.3
SubmitDate: '1999-12-29'
LastModified: '2000-01-03'
Severity: CRIT
Status: Released
Submitter: techsupp
ChangedBy: hobbs
OS: BSD
OSVersion: NetBSD/SPARC 1.4, NetBSD/i386 1.4P
Machine: Generic AMD K6-2 PC, Sun SPARCstation IPX
FixedDate: '2000-01-03'
FixedInVersion: 8.3b2
ClosedDate: '2000-10-25'


Name: Andreas Gustafsson

Comments:
Some versions of NetBSD use the a.out object format and have a
SunOS 4 style naming scheme for shared libraries, for example,
"libtcl82.so.1.0".  These versions are currently supported by the
Tcl/Tk shared library build mechanisms.

However, recent versions of NetBSD use the ELF object format and omit
the version number extension from the shared library file name, as in
"libtcl82.so".  Attempting to build Tcl/Tk on such a system will fail.

The enclosed patch fixes the problem by probing for the object format
and choosing the appropriate version numbering scheme.  It also adds a
definition of LD_SEARCH_FLAGS for all NetBSD systems.  This is
necessary so that the shared libraries can be found at runtime without
any need for editing /etc/ld.so.conf or setting LD_LIBRARY_PATH.

The patch needs to be applied separately to Tcl and Tk.
Unfortunately, the aclocal.m4 file that needs to be patched is missing
from the Tk distribution (as was reported in a separate bug report).
Note that "autoconf" needs to be rerun after applying the patch.

The patch has been tested on NetBSD/SPARC 1.4 (a.out) and
NetBSD/i386 1.4P (ELF).

ReproducibleScript:
configure --enable-shared
make

ObservedBehavior:
Normal configure and make output, then:

ld -Bshareable -x -o libtcl82.so.1.0 regcomp.o [...]  tclLoadDl.o
: libtcl82.so.1.0
c -c -g -fpic -I./../generic -I.  -DHAVE_UNISTD_H=1 -DHAVE_LIMITS_H=1
-DHAVE_GETCWD=1 -DHAVE_OPENDIR=1 -DHAVE_STRSTR=1 -DHAVE_STRTOL=1
-DHAVE_TMPNAM=1 -DHAVE_WAITPID=1 -DNO_VALUES_H=1 -DHAVE_UNISTD_H=1
-DHAVE_SYS_PARAM_H=1 -DUSE_TERMIOS=1 -DHAVE_SYS_TIME_H=1
-DTIME_WITH_SYS_TIME=1 -DHAVE_TM_ZONE=1 -DHAVE_TM_GMTOFF=1
-DHAVE_ST_BLKSIZE=1 -DSTDC_HEADERS=1 -DNEED_MATHERR=1
-DRETSIGTYPE=void -DHAVE_SIGNED_CHAR=1 -DHAVE_SYS_IOCTL_H=1
-DHAVE_SYS_FILIO_H=1 -DTCL_SHLIB_EXT=\".so\" ./../unix/tclAppInit.c cc
tclAppInit.o -L/usr/x/itcl/tcl8.2.3/unix -ltcl82 -lm -lc -o tclsh
/usr/bin/ld: cannot open -ltcl82: No such file or directory
collect2: ld returned 1 exit status

DesiredBehavior:
Successful linking.

Patch:
--- /x/tcl.clean/tcl8.2.3/unix/aclocal.m4       Tue Dec 14 19:59:18 1999
+++ ./aclocal.m4        Thu Dec 23 22:10:45 1999
@@ -736,8 +736,18 @@
                DL_OBJS="tclLoadDl.o"
                DL_LIBS=""
                LDFLAGS=""
-               LD_SEARCH_FLAGS=""
-               SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so.1.0'
+               LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
+               AC_MSG_CHECKING(for ELF)
+               AC_EGREP_CPP(yes, [
+#ifdef __ELF__
+               yes
+#endif
+               ],
+                   AC_MSG_RESULT(yes)
+                   SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so',
+                   AC_MSG_RESULT(no)
+                   SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so.1.0'
+               )
            ], [
                SHLIB_CFLAGS=""
                SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r"

PatchFiles:
aclocal.m4



Fixed in 8.3b2 tcl.m4. 
-- 01/03/2000 hobbs
welch Closed ticket [219017ffff]. [History diff]2000-10-26 08:33:09
dgp Ticket [219017ffff]: 3 changes [History diff]2001-04-05 06:52:48
Log in (anonymous is fine) to add a comment.