Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Building of head on HPUX is broken when using the native CC

Closed / Fixed2502365fffffffffffffffffffffffffffffffffCreated 18 years agoUpdated 18 years ago
Descriptionplain2009-01-12 20:08:49
Using the native C compiler on HPUX the configure script generates a Makefile which is broken.
The SHLIB_LD variable is set to 'cc -Wl,-b'. This is wrong. It has to be 'cc -b'.
The flag is properly forwarded to the native linker in this form. In the -Wl form some handling in cc itself is bypassed.

The error caused by using -Wl,-b is

/usr/ccs/bin/ld: CODE_ONE_SYM fixup to non-code subspace in file /opt/langtools/lib/crt0.o - shared library must be position independent. Use +z or +Z to recompile.
make: *** [libtcl8.6.sl] Error 1

This has to be fixed somewhere in the configure  and/or tcl.m4. The last to modify the HP sections was Jan IIRC, hence the assigning it to him.

./unix/configure:7128:        SHLIB_LD="${CC} -Wl,-b"
./unix/tcl.m4:1283:             SHLIB_LD="${CC} -Wl,-b"

Tk is broken in the same manner.

./unix/configure:5013:          SHLIB_LD="${CC} -Wl,-b"
./unix/tcl.m4:1283:             SHLIB_LD="${CC} -Wl,-b"
andreas_kupriesplain2009-01-13 03:14:32
Side note: TEA does _not_ seem to be broken in this manner :)
nijtmansplain2009-01-13 16:41:14
It appears that HP-UX behaves different on IA64 than on a PA-risc
machine. I'm OK with changing "-Wl,-b" to "-b", but I don't
have access to a IA64 machine any more to check if it works
there as well.
[email protected]plain2009-01-14 00:43:17
Well, I have a IA64 box running under HPUX here. I can't confirm my fix yet because the build of this night reported

    "ld: Can't find library or mismatched ABI for -ldld"

when trying to link the "libtcl8.6.so". It does this for both -b and -Wl,-b so this is likely a separate problem. There is no -L in that command line, so I am not fully sure where it takes the libdld.so from. I found one under /lib, that one is identified as an s800 library, which would explain the mismatch if this was taken ...

Yes, adding -L/lib/hpux64 to the link-line I get the correct library and the libtcl8.6.so is linked ok.

Now trying the -Wl,-b and -b I find that for IA64 both work. On PA-RISC definitely only the -b works, and the -Wl,-b doesn't. So, let us go with -b, that one looks universal.

And for IA64 we additionally need some fix to set the -L path to find all the proper 64bit libraries. Once more into the breach to see where this is in tcl.m4/configure.
andreas_kupriesplain2009-01-14 00:44:20
Meh, the nobody of the last comment was me.
andreas_kupriesplain2009-01-14 04:57:56
I added the following to tcl.m4, line 1309 (*)


    # 64bit not requested or not, may still be a 64bit platform.
    AS_IF([test "`uname -m`" = ia64], [
        SHLIB_LD_LIBS="-L/lib/hpux64 ${SHLIB_LD_LIBS}"
    ])

(*) Section: HP-UX-*.11.*, end of the section.

This seems to have done it regarding the library paths for our box.
nijtmansplain2009-01-14 05:53:20
OK, checked in the "-Wl,-b" to "-b" change, but cannot
test it any more, because I don't have access to a IA64
machine any more. I'm a little bit reluctant about the
second suggested change: I successfully compiled it on IA64
without this. But if it helps, than that's OK.

Assigning back to Andreas, it's difficult for me to do
anything more about it while not being able to test it....
andreas_kupriesplain2009-01-14 06:31:40
Ok. I will not commit the -L change yet. I have it locally, check if it works, and then I will delay a bit more so that I can compare to 8.5 and 8.4 branches to see how they are different. As they are working without change from my side since forever.
andreas_kupries Ticket [2502365fff]: 1 change [History diff]2009-01-14 06:34:05
nijtmansplain2009-01-14 16:06:37
In fact, I agree with the -L change, but I'm afraid it might break
a 32-bit build on HP-UX IA64. The current HP-UX section currently
only works for the native compiler. Looking at it, I don't think
it will work for gcc in all cases.

After HP-UX-11 is fixed for all known cases, I recommend to
'backport' this to TEA as well. I purposely didn't do that
yet, because TEA is more wide-spread than Tcl8.6. And
Bug 2073255 is not _that_ crucial.
andreas_kupriesplain2009-01-23 06:22:07
I have to ask a bit more.
Mainly. what changes were made for HPUX between 8.5 and 8.6, and why ?

The problem which I fixed locally with -L/lib/hpux64 seems to be tied to a
cc/ld change which was made for 8.6.

Thusly:
* I compiled 8.5 and 8.6 and compared.
* Both there head of their branches.
* Both were configured the same: Use the native HPUX cc, and --enable-64bit.

Results
* Tcl 8.5 core uses 'ld -b ... +s +b xxx-path:.' to link the libtcl.so. This works.
* Tcl 8.6 core uses 'cc -b ... -Wl,+s,+b,xxx-path:.' to link the libtcl.so. This FAILS.
* The reported failure is "ld: Can't find library or mismatched ABI for -ldld".
* Adding -L/lib/hpux64 fixes the issue for 8.6. that is what I did for the ActiveTcl builds to keep going.
* Using the 8.5 link line for 8.6, instead of adding -L... fixes the problem as well.

I am now suspecting that using the 'cc' as linker is ill-advised, it seems to play with the search paths to use, whixch can be compensated for with an explicit -L.

Given that I would really like to know the motivations behind the changes made for HPUX.
Looking through the file annotations it seems that this was introduced by rev 1.199.
http://tcl.cvs.sourceforge.net/viewvc/tcl/tcl/unix/tcl.m4?r1=1.198&r2=1.199

The relevant comment for the patch is 'fix for bug [2073255]'.
And the bug in question is about having to add a +z somewhere.

The change ld -> cc is not documented and seems to have no relation to the bug.
I.e. it comes a bit out of left field.

Actually, looking at the referenced bug and original patch ... The comment says we need to a "+z" option to CFLAGS, and the proposed patch than add "-z" instead (plus vs minus!).
Then it gets restructured to handle GCC, and at that point the ld -> cc change is made as well.

Oh, and we still have the "-z" floating around, although a few lines later "+z" is actually added as well. That explains another difference I saw in the make log of 8.5 vs 8.6.

Tcl 85: cc     +DD64 +z
Tcl 86: cc -z +DD64 +z

The -z is added to CFLAGS, the +z added to SHLIB_CFLAGS.
Lines 1282 and 1285 in the HEAD
nijtmansplain2009-02-10 19:31:57
Giving some answers:
The comment in [Bug 2073255] was wrong, I meant "-z" in
stead of "+z". I didn't expect those problems, the
restructuring was means as a start attempt to make
the gcc configuration work (the way it is now, it
certainly will not work. However, it's not worth
the trouble if that breaks a lot of other things.

I will revert the changes, except from the addition
of "-z" in CFLAGS.
nijtmans Ticket [2502365fff]: 1 change [History diff]2009-02-10 19:32:03
nijtmansplain2009-02-11 06:35:39
allow_comments - 1

changes reverted, except for the addition of "-z" in CFLAGS
Log in (anonymous is fine) to add a comment.