This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH]: Fix target/6428 for hppa*-hp-hpux*


This patch adds a warning when linking with -pg or -p without -static.
HP only provides libraries for profiling in archive format.  On the
32-bit port, shared library dependences are usually hardcoded.  As
a result, you can end up with a wonderful mix of libc/libm routines,
some from non-profiling libraries and some from profiling libraries.
This is particularly a problem using the g++ driver which defaults
to linking with libgcc_s.

I also moved the location for emitting the -L locations for the profiling
libraries as I noted that otherwise the profiling version of libm
under hpux10.20 wouldn't be selected.

Three tests that use -p or -pg have been updated to add -static to
the test options under hppa*-*-hpux*.

Installed on trunk.

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

2003-05-21  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>

	PR target/6428
	* pa-hpux10.h (LINK_SPEC, LIB_SPEC): Move -L options for profiling
	directories from LIB_SPEC to LINK_SPEC.  Emit warning if `-p' or `-pg'
	option is used without `-static'.
	* pa-hpux11.h (LINK_SPEC, LIB_SPEC): Likewise.
	* pa64-hpux.h (LINK_SPEC, LIB_SPEC): Likewise.

	* g++.old-deja/g++.law/profile1.C (dg-options): Add -static to options
	for hppa*-hp-hpux*.
	* gcc.dg/20021014-1.c (dg-options): Likewise.
	* gcc.dg/nest.c (dg-options): Likewise.

Index: config/pa/pa-hpux10.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/pa/pa-hpux10.h,v
retrieving revision 1.14
diff -u -3 -p -r1.14 pa-hpux10.h
--- config/pa/pa-hpux10.h	11 Apr 2003 18:30:50 -0000	1.14
+++ config/pa/pa-hpux10.h	19 May 2003 17:30:09 -0000
@@ -69,12 +69,27 @@ Boston, MA 02111-1307, USA.  */
 /* We can debug dynamically linked executables on hpux9; we also want
    dereferencing of a NULL pointer to cause a SEGV.  */
 #undef LINK_SPEC
-#if ((TARGET_DEFAULT | TARGET_CPU_DEFAULT) &  MASK_PA_11)
+#if ((TARGET_DEFAULT | TARGET_CPU_DEFAULT) & MASK_PA_11)
 #define LINK_SPEC \
-  "%{!mpa-risc-1-0:%{!shared:-L/lib/pa1.1 -L/usr/lib/pa1.1 }} -z %{mlinker-opt:-O} %{!shared:-u main} %{static:-a archive} %{shared:-b}"
+  "%{!mpa-risc-1-0:%{!shared:-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}}}\
+   %{!shared:%{pg:-L/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}\
+   %{static:-a archive} %{shared:-b}"
 #else
 #define LINK_SPEC \
-  "-z %{mlinker-opt:-O} %{!shared:-u main} %{static:-a archive} %{shared:-b}"
+  "%{!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}}}\
+   %{!shared:%{pg:-L/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}\
+   %{static:-a archive} %{shared:-b}"
 #endif
 
 /* Like the default, except no -lg.  */
@@ -84,10 +99,8 @@ Boston, MA 02111-1307, USA.  */
      %{!p:%{!pg:\
        %{!threads:-lc %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}\
        %{threads:-lcma -lc_r}}}\
-     %{p: -L/lib/libp/ -lc\
-       %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}\
-     %{pg: -L/lib/libp/ -lc\
-       %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}"
+     %{p:%{!pg:-lc %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}\
+     %{pg:-lc %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}"
 
 #undef THREAD_MODEL_SPEC
 #define THREAD_MODEL_SPEC "%{!threads:single}%{threads:dce}"
Index: config/pa/pa-hpux11.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/pa/pa-hpux11.h,v
retrieving revision 1.8
diff -u -3 -p -r1.8 pa-hpux11.h
--- config/pa/pa-hpux11.h	11 Apr 2003 18:30:50 -0000	1.8
+++ config/pa/pa-hpux11.h	19 May 2003 17:30:10 -0000
@@ -70,14 +70,26 @@ Boston, MA 02111-1307, USA.  */
 /* 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) & 1)
+#if ((TARGET_DEFAULT | TARGET_CPU_DEFAULT) & MASK_PA_11)
 #define LINK_SPEC \
-  "%{!mpa-risc-1-0:%{!shared:-L/lib/pa1.1 -L/usr/lib/pa1.1 }} -z\
-   %{mlinker-opt:-O} %{!shared:-u main -u __gcc_plt_call}\
+  "%{!mpa-risc-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 \
-  "-z %{mlinker-opt:-O} %{!shared:-u main -u __gcc_plt_call}\
+  "%{!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}"
 #endif
 
@@ -88,10 +100,8 @@ Boston, MA 02111-1307, USA.  */
      %{!p:%{!pg:\
        %{!threads:-lc %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}\
        %{threads:-lcma -lc_r}}}\
-     %{p: -L/lib/libp/ -lc\
-       %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}\
-     %{pg: -L/lib/libp/ -lc\
-       %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}"
+     %{p:%{!pg:-lc %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}\
+     %{pg:-lc %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}"
 
 /* Under hpux11, the normal location of the `ld' and `as' programs is the
    /usr/ccs/bin directory.  */
Index: config/pa/pa64-hpux.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/pa/pa64-hpux.h,v
retrieving revision 1.25
diff -u -3 -p -r1.25 pa64-hpux.h
--- config/pa/pa64-hpux.h	12 May 2003 17:40:07 -0000	1.25
+++ config/pa/pa64-hpux.h	19 May 2003 17:30:10 -0000
@@ -37,10 +37,24 @@ Boston, MA 02111-1307, USA.  */
 #undef LINK_SPEC
 #if ((TARGET_DEFAULT | TARGET_CPU_DEFAULT) & MASK_GNU_LD)
 #define LINK_SPEC \
-  "%{mhp-ld:+Accept TypeMismatch} -E %{mlinker-opt:-O} %{!shared:-u main} %{static:-a archive} %{shared:%{mhp-ld:-b}%{!mhp-ld:-shared}}"
+  "%{!shared:%{p:-L/lib/pa20_64/libp -L/usr/lib/pa20_64/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/pa20_64/libp -L/usr/lib/pa20_64/libp %{!static:\
+     %nWarning: consider linking with `-static' as system libraries with\n\
+     %n  profiling support are only provided in archive format}}}\
+   %{mhp-ld:+Accept TypeMismatch} -E %{mlinker-opt:-O} %{!shared:-u main}\
+   %{static:-a archive} %{shared:%{mhp-ld:-b}%{!mhp-ld:-shared}}"
 #else
 #define LINK_SPEC \
-  "%{!mgnu-ld:+Accept TypeMismatch} -E %{mlinker-opt:-O} %{!shared:-u main} %{static:-a archive} %{shared:%{mgnu-ld:-shared}%{!mgnu-ld:-b}}"
+  "%{!shared:%{p:-L/lib/pa20_64/libp -L/usr/lib/pa20_64/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/pa20_64/libp -L/usr/lib/pa20_64/libp %{!static:\
+     %nWarning: consider linking with `-static' as system libraries with\n\
+     %n  profiling support are only provided in archive format}}}\
+   %{!mgnu-ld:+Accept TypeMismatch} -E %{mlinker-opt:-O} %{!shared:-u main}\
+   %{static:-a archive} %{shared:%{mgnu-ld:-shared}%{!mgnu-ld:-b}}"
 #endif
 
 /* Like the default, except no -lg.  */
@@ -48,9 +62,9 @@ Boston, MA 02111-1307, USA.  */
 #define LIB_SPEC \
   "%{!shared:\
      %{!p:%{!pg: -lc %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}\
-     %{pg: -L/usr/lib/pa20_64/libp/ -lgprof -lc\
-       %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}\
-     %{p: -L/usr/lib/pa20_64/libp/ -lprof -lc\
+     %{p:%{!pg:-lprof -lc\
+       %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}\
+     %{pg:-lgprof -lc\
        %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}\
    /usr/lib/pa20_64/milli.a"
 
Index: testsuite/g++.old-deja/g++.law/profile1.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.old-deja/g++.law/profile1.C,v
retrieving revision 1.5
diff -u -3 -p -r1.5 profile1.C
--- testsuite/g++.old-deja/g++.law/profile1.C	1 May 2003 02:02:43 -0000	1.5
+++ testsuite/g++.old-deja/g++.law/profile1.C	19 May 2003 17:30:10 -0000
@@ -1,5 +1,6 @@
 // { dg-do run { xfail m68k-motorola-sysv m88k-motorola-sysv3 mips*-*-* i[3456]86-*-sco3.2v5* } }
 // { dg-options "-pg" }
+// { dg-options "-pg -static" { target hppa*-*-hpux* } }
 // GROUPS passed profiling
 #include <stdio.h>
 main()
Index: testsuite/gcc.dg/20021014-1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/20021014-1.c,v
retrieving revision 1.6
diff -u -3 -p -r1.6 20021014-1.c
--- testsuite/gcc.dg/20021014-1.c	6 May 2003 22:47:03 -0000	1.6
+++ testsuite/gcc.dg/20021014-1.c	19 May 2003 17:30:10 -0000
@@ -1,5 +1,6 @@
 /* { dg-do run } */
 /* { dg-options "-O2 -p" } */
+/* { dg-options "-O2 -p -static" { target hppa*-*-hpux* } } */
 /* { dg-error "profiler" "No profiler support" { target mmix-*-* xstormy16-*-* } 0 } */
 /* { dg-error "" "consider using `-pg' instead of `-p' with gprof(1)" { target *-*-freebsd* } 0 } */
 /* Support for -p on solaris2 relies on mcrt1.o which comes with the
Index: testsuite/gcc.dg/nest.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/nest.c,v
retrieving revision 1.7
diff -u -3 -p -r1.7 nest.c
--- testsuite/gcc.dg/nest.c	6 May 2003 22:47:03 -0000	1.7
+++ testsuite/gcc.dg/nest.c	21 May 2003 02:09:44 -0000
@@ -1,6 +1,7 @@
 /* PR 5967, PR 7114 */
 /* { dg-do run } */
 /* { dg-options "-O2 -pg" } */
+/* { dg-options "-O2 -pg -static" { target hppa*-*-hpux* } } */
 /* { dg-error "profiler" "No profiler support" { target mmix-*-* xstormy16-*-* } 0 } */
 /* Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
    See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]