[committed] Fix linking with libm on hppa-hpux.

John David Anglin dave@hiauly1.hia.nrc.ca
Thu Jan 17 09:49:00 GMT 2008


The enclosed patch is a partial fix for PR libgfortran/34699.  I
noticed in debugging this PR that fortran applications on hpux10
were in effect linked with two different versions of libm.  It turns
out the test fails on the 4.2 branch with the 1.0 version of libm
and passes with the 1.1 version.

There are PA 1.0 shared and archive versions in /lib (and /usr/lib).
There is a PA 1.1 archive version in /lib/pa1.1 (and /usr/lib/pa1.1).
In a shared link, the linker only uses an archive version if it
can't find a shared version in the entire search path.  However,
when linking an executable, the linker will select an archive version
if it occurs earlier in the list of directories searched for libraries.
Since the directory /lib/pa1.1 was being searched before /lib, the
linker always selected the PA 1.1 archive version when linking a
PA 1.1 or 2.0 executable.

There is some difference in the rounding behavior of the PA 1.0
and 1.1 versions.  I believe that linking with two versions may affect
the handling of math errors.

So, I've change LINK_SPEC for hpux10 and earlier to only search
/lib/pa1.1 and /usr/lib/pa1.1 in static links.  While it is still
possible for a user to link in a shared library, it takes some
special linker magic to do it.

In hpux11, the directories /lib/pa1.1 and /usr/lib/pa1.1 don't
contain any useful libraries (the PA 1.1 version of libm has been
moved to /lib and it is the default).  So, I've removed the code
to search these directories on hpux11.

Tested on hppa1.1-hp-hpux11.11, hppa2.0w-hp-hpux11.11 and
hppa64-hp-hpux11.11.  Committed to all active branches.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

2008-01-16  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>

	PR libgfortran/34699
	* pa-hpux.h (LINK_SPEC): Only search /lib/pa1.1 and /usr/lib/pa1.1 on
	static links.
	* pa-hpux10.h (LINK_SPEC): Likewise.
	* pa-hpux11.h (LINK_SPEC): Don't search /lib/pa1.1 and /usr/lib/pa1.1.

Index: config/pa/pa-hpux.h
===================================================================
--- config/pa/pa-hpux.h	(revision 131440)
+++ config/pa/pa-hpux.h	(working copy)
@@ -97,7 +97,7 @@
 #undef LINK_SPEC
 #if ((TARGET_DEFAULT | TARGET_CPU_DEFAULT) & MASK_PA_11)
 #define LINK_SPEC \
-  "%{!mpa-risc-1-0:%{!march=1.0:%{!shared:-L/lib/pa1.1 -L/usr/lib/pa1.1 }}}%{mlinker-opt:-O} %{!shared:-u main} %{static:-a archive} %{g*:-a archive} %{shared:-b}"
+  "%{!mpa-risc-1-0:%{!march=1.0:%{static:-L/lib/pa1.1 -L/usr/lib/pa1.1 }}}%{mlinker-opt:-O} %{!shared:-u main} %{static:-a archive} %{g*:-a archive} %{shared:-b}"
 #else
 #define LINK_SPEC \
   "%{mlinker-opt:-O} %{!shared:-u main} %{static:-a archive} %{g*:-a archive} %{shared:-b}"
Index: config/pa/pa-hpux10.h
===================================================================
--- config/pa/pa-hpux10.h	(revision 131440)
+++ config/pa/pa-hpux10.h	(working copy)
@@ -84,7 +84,7 @@
 #undef LINK_SPEC
 #if ((TARGET_DEFAULT | TARGET_CPU_DEFAULT) & MASK_PA_11)
 #define LINK_SPEC \
-  "%{!mpa-risc-1-0:%{!march=1.0:%{!shared:-L/lib/pa1.1 -L/usr/lib/pa1.1 }}}\
+  "%{!mpa-risc-1-0:%{!march=1.0:%{static:-L/lib/pa1.1 -L/usr/lib/pa1.1 }}}\
    %{!shared:%{p:-L/lib/libp %{!static:\
      %nWarning: consider linking with `-static' as system libraries with\n\
      %n  profiling support are only provided in archive format}}}\
Index: config/pa/pa-hpux11.h
===================================================================
--- config/pa/pa-hpux11.h	(revision 131440)
+++ config/pa/pa-hpux11.h	(working copy)
@@ -105,19 +105,7 @@
 /* We can debug dynamically linked executables on hpux11; we also
    want dereferencing of a NULL pointer to cause a SEGV.  */
 #undef LINK_SPEC
-#if ((TARGET_DEFAULT | TARGET_CPU_DEFAULT) & MASK_PA_11)
 #define LINK_SPEC \
-  "%{!mpa-risc-1-0:%{!march=1.0:%{!shared:-L/lib/pa1.1 -L/usr/lib/pa1.1 }}}\
-   %{!shared:%{p:-L/lib/libp -L/usr/lib/libp %{!static:\
-     %nWarning: consider linking with `-static' as system libraries with\n\
-     %n  profiling support are only provided in archive format}}}\
-   %{!shared:%{pg:-L/lib/libp -L/usr/lib/libp %{!static:\
-     %nWarning: consider linking with `-static' as system libraries with\n\
-     %n  profiling support are only provided in archive format}}}\
-   -z %{mlinker-opt:-O} %{!shared:-u main -u __gcc_plt_call}\
-   %{static:-a archive} %{shared:-b}"
-#else
-#define LINK_SPEC \
   "%{!shared:%{p:-L/lib/libp -L/usr/lib/libp %{!static:\
      %nWarning: consider linking with `-static' as system libraries with\n\
      %n  profiling support are only provided in archive format}}}\
@@ -126,7 +114,6 @@
      %n  profiling support are only provided in archive format}}}\
    -z %{mlinker-opt:-O} %{!shared:-u main -u __gcc_plt_call}\
    %{static:-a archive} %{shared:-b}"
-#endif
 
 /* HP-UX 11 has posix threads.  HP libc contains pthread stubs so that
    non-threaded applications can be linked with a thread-safe libc



More information about the Gcc-patches mailing list