Tcl Source Code

View Ticket
Login
Ticket UUID: 1921166
Title: won't build 64bit version on Solaris with cc
Type: Bug Version: obsolete: 8.4.18
Submitter: psum Created on: 2008-03-20 15:10:47
Subsystem: 53. Configuration and Build Tools Assigned To: das
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2008-03-27 20:52:34
Resolution: Fixed Closed By: das
    Closed on: 2008-03-27 13:51:15
Description:
Tcl and/or Tk won't build on Solaris (tested with Solaris 11[b76] and 9) with "--enable-64bit" (tested on sparcv9 but should be the same for amd64) when compiling with Sun Studio compiler (cc):

cc -G -z text -o libtcl8.4.so regcomp.o regexec.o regfree.o regerror.o tclAlloc.o  tclAsync.o tclBasic.o tclBinary.o  tclCkalloc.o tclClock.o tclCmdAH.o tclCmdIL.o tclCmdMZ.o  tclCompCmds.o tclCompExpr.o tclCompile.o tclDate.o tclEncoding.o  tclEnv.o tclEvent.o tclExecute.o tclFCmd.o tclFileName.o tclGet.o  tclHash.o tclHistory.o tclIndexObj.o tclInterp.o tclIO.o tclIOCmd.o  tclIOGT.o tclIOSock.o tclIOUtil.o tclLink.o tclListObj.o  tclLiteral.o tclLoad.o tclMain.o tclNamesp.o tclNotify.o  tclObj.o tclPanic.o tclParse.o tclParseExpr.o tclPipe.o  tclPkg.o tclPosixStr.o tclPreserve.o tclProc.o tclRegexp.o  tclResolve.o tclResult.o tclScan.o tclStringObj.o tclThread.o  tclThreadAlloc.o tclThreadJoin.o tclStubInit.o tclStubLib.o  tclTimer.o tclUtf.o tclUtil.o tclVar.o tclUnixChan.o tclUnixEvent.o tclUnixFCmd.o  tclUnixFile.o tclUnixPipe.o tclUnixSock.o  tclUnixTime.o tclUnixInit.o tclUnixThrd.o  tclUnixCompat.o tclUnixNotfy.o   tclLoadDl.o -ldl  -lsocket -lnsl -lm -lc   -R /usr/local/lib
ld: fatal: file regcomp.o: wrong ELF class: ELFCLASS64
ld: fatal: File processing errors. No output written to libtcl8.4.so

This is probably regression after:

Sat Sep 15 06:00:49 2007 UTC (6 months ago) by das 

(SunOS-5.1x):replace direct use of '/usr/ccs/bin/ld' in SHLIB_LD by
'cc' compiler driver.

3870c3997,4002
<               SHLIB_LD="/usr/ccs/bin/ld -G -z text"
---
>               case $system in
>                   SunOS-5.[1-9][0-9]*)
>                       SHLIB_LD='${CC} -G -z text';;
>                   *)
>                       SHLIB_LD="/usr/ccs/bin/ld -G -z text";;
>               esac

Where ${CC} is missing -xarch parameter. Please note that xarch is set in LDFLAGS. Therefore something like this need to be added (see also attached patch):

SHLIB_LD="$SHLIB_LD $LDFLAGS"

This should be applicable also for 8.5 version.
User Comments: das added on 2008-03-27 20:52:34:
Logged In: YES 
user_id=90580
Originator: NO

eh, meant to say "the tcl/unix/dltest/Makefile.in fix"

das added on 2008-03-27 20:51:15:
Logged In: YES 
user_id=90580
Originator: NO

fix committed to Tcl & Tk HEAD and core-8-4-branch and both branches of TEA.

the tcl/unix/Makefile.in fix was already present on HEAD but had not been backported to core-8-4-branch, fixed.

psum added on 2008-03-25 22:57:29:
Logged In: YES 
user_id=1544880
Originator: YES

Ops, this also affects make test:

cc -G -z text  -o pkga.so pkga.o -L/builds/ps156622/sfwnv/usr/src/lib/tcl/tcl8.4.18-64/unix -ltclstub8.4 -ldl  -lsocket -lnsl -lpthread -lm
ld: fatal: file pkga.o: wrong ELF class: ELFCLASS64
ld: fatal: File processing errors. No output written to pkga.so

Therefore something like this is needed:

--- tcl8.4.18/unix/dltest/Makefile.in.orig      Tue Mar 25 08:16:31 2008
+++ tcl8.4.18/unix/dltest/Makefile.in   Tue Mar 25 08:18:59 2008
@@ -7,6 +7,7 @@
 CC = @CC@
 LIBS =                 @TCL_BUILD_STUB_LIB_SPEC@ @DL_LIBS@ @LIBS@ @MATH_LIBS@
 AC_FLAGS =             @DEFS@
+LDFLAGS =              @LDFLAGS_DEFAULT@ @LDFLAGS@
 SHLIB_CFLAGS =         @SHLIB_CFLAGS@
 SHLIB_LD =             @SHLIB_LD@
 SHLIB_LD_LIBS =                @SHLIB_LD_LIBS@

psum added on 2008-03-21 19:04:52:
Logged In: YES 
user_id=1544880
Originator: YES

I can confirm that Tcl builds with --enable-dtrace and --enable-64bit just fine with your modified patch (tested on CVS HEAD). I verified this on Solaris Nevada (sparc and intel) and Solaris 10 8/07 (sparc).

I had problem to compile it on first version of Solaris 10 (s10_74L2a). Evidently there was some change in dtrace in Solaris updates (as it works with Solaris 10 8/07). The problem was following:

/usr/sbin/dtrace -G  -o tclDTrace.o -s /net/shaker/builds/ps156622/tcl/unix/../generic/tclDTrace.d regcomp.o regexec.o regfree.o regerror.o tclAlloc.o  tclAsync.o tclBasic.o tclBinary.o tclCkalloc.o tclClock.o  tclCmdAH.o tclCmdIL.o tclCmdMZ.o tclCompCmds.o tclCompExpr.o  tclCompile.o tclConfig.o tclDate.o tclDictObj.o tclEncoding.o  tclEnv.o tclEvent.o tclExecute.o tclFCmd.o tclFileName.o tclGet.o  tclHash.o tclHistory.o tclIndexObj.o tclInterp.o tclIO.o tclIOCmd.o  tclIORChan.o tclIOGT.o tclIOSock.o tclIOUtil.o tclLink.o tclListObj.o  tclLiteral.o tclLoad.o tclMain.o tclNamesp.o tclNotify.o  tclObj.o tclPanic.o tclParse.o tclPathObj.o tclPipe.o  tclPkg.o tclPkgConfig.o tclPosixStr.o  tclPreserve.o tclProc.o tclRegexp.o  tclResolve.o tclResult.o tclScan.o tclStringObj.o  tclStrToD.o tclThread.o  tclThreadAlloc.o tclThreadJoin.o tclThreadStorage.o tclStubInit.o  tclStubLib.o tclTimer.o tclTrace.o tclUtf.o tclUtil.o tclVar.o  tclTomMathInterface.o tclUnixChan.o tclUnixEvent.o tclUnixFCmd.o  tclUnixFile.o tclUnixPipe.o tclUnixSock.o  tclUnixTime.o tclUnixInit.o tclUnixThrd.o  tclUnixCompat.o tclUnixNotfy.o   tclLoadDl.o
dtrace: failed to link script /net/shaker/builds/ps156622/tcl/unix/../generic/tclDTrace.d: incorrect ELF class for object file regcomp.o

Problem is with missing dtrace option "-64".

But this is fixed in dtrace now so please go ahead with the change.

das added on 2008-03-20 23:35:49:
Logged In: YES 
user_id=90580
Originator: NO

this change was needed to get the DTrace support to compile with sun cc, can you verify that tcl builds correctly with '--enable-dtrace --enable-64bit' when you add LDFLAGS to SHLIB_LD? I don't have access to a 64bit Solaris box...

I would suggest that a better fix would be to add a make-time ref to LDFLAGS to the link line, same as we do on many other platforms. Could you verify that the HEAD builds correctly for 64bit with the following change?
what about the /usr/ccs/bin/ld case, is the -xarch flag not needed there?

Index: unix/tcl.m4
===================================================================
RCS file: /cvsroot/tcl/tcl/unix/tcl.m4,v
retrieving revision 1.192
diff -u -p -r1.192 tcl.m4
--- unix/tcl.m413 Mar 2008 17:44:22 -00001.192
+++ unix/tcl.m420 Mar 2008 16:25:36 -0000
@@ -1954,7 +1954,7 @@ dnl AC_CHECK_TOOL(AR, ar)
     ], [
 case $system in
     SunOS-5.[[1-9]][[0-9]]*)
-SHLIB_LD='${CC} -G -z text';;
+SHLIB_LD='${CC} -G -z text ${LDFLAGS}';;
     *)
 SHLIB_LD='/usr/ccs/bin/ld -G -z text';;
 esac

psum added on 2008-03-20 22:10:48:

File Added - 271195: tcl_m4.patch

Attachments: