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]

Re: gcc-64 20021111 broken on HP-UX 11.00


> ldd: "gengenrtl" is not a shared executable.
> collect2: /usr/ccs/bin/ldd returned 1 exit status

I have installed the patch below and it should fix the above problem.

However, we are back to the previous situation where global constructors
and destructors in dependent libraries are not executed.  This causes
a variety of regressions when the HP linker was being used.  For example,
objc is essentially unusable and g++ is compromised.  This of course
is also the state with GNU ld.

If you use the HP linker, LD_INIT_SWITCH and LD_FINI_SWITCH can be
defined as shown below and this results in GCC testsuite results
fairly comparable to that of the 32-bit ports.  You can even enable
the building of a shared libgcc in config.gcc.

Unfortunately, LD_INIT_SWITCH and LD_FINI_SWITCH can't be defined
with the GNU linker without other nasty things happening.  As far
as I can tell, there is no way to define these symbols without
making the GCC code linker dependent.  I don't think we want to
do this at this time, so I have disabled the above two macros.
Hopefully, the GNU ld bugs can be fixed in the near future and we
can use the above macros, or possibly .init and .fini sections.

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

2002-11-13  John David Anglin  <dave@hiauly1.hia.nrc.ca>

	* pa64-hpux.h (LINK_SPEC): Move "+Accept TypeMismatch" switch to the
	beginning of the spec.
	(LDD_SUFFIX, PARSE_LDD_OUTPUT): Delete.
	(LD_INIT_SWITCH, LD_FINI_SWITCH): Define but don't enable.  Add comment
	regarding problems with global constructors when using GNU ld.

Index: config/pa/pa64-hpux.h
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/config/pa/pa64-hpux.h,v
retrieving revision 1.18
diff -u -3 -p -r1.18 pa64-hpux.h
--- config/pa/pa64-hpux.h	10 Nov 2002 01:14:47 -0000	1.18
+++ config/pa/pa64-hpux.h	13 Nov 2002 17:12:03 -0000
@@ -31,14 +31,16 @@ Boston, MA 02111-1307, USA.  */
      N_("Assume code will be linked by HP ld") },
 
 /* We can debug dynamically linked executables on hpux11; we also
-   want dereferencing of a NULL pointer to cause a SEGV.  */
+   want dereferencing of a NULL pointer to cause a SEGV.  Do not move
+   the "+Accept TypeMismatch" switch.  We check for it in collect2
+   to determine which init/fini is needed.  */
 #undef LINK_SPEC
 #if ((TARGET_DEFAULT | TARGET_CPU_DEFAULT) & MASK_GNU_LD)
 #define LINK_SPEC \
-  "-E %{mlinker-opt:-O} %{!shared:-u main} %{static:-a archive} %{shared:%{mhp-ld:-b}%{!mhp-ld:-shared}} %{mhp-ld:+Accept TypeMismatch}"
+  "%{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 \
-  "-E %{mlinker-opt:-O} %{!shared:-u main} %{static:-a archive} %{shared:%{mgnu-ld:-shared}%{!mgnu-ld:-b}} %{!mgnu-ld:+Accept TypeMismatch}"
+  "%{!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.  */
@@ -252,19 +254,26 @@ do {								\
 
 /* Since we are not yet using .init and .fini sections, we need to
    explicitly arrange to run the global constructors and destructors.
-   HPUX 11 has ldd and we use it to determine the dependencies of
-   dynamic objects.  It might be possible to use the ld options for
-   running initializers and terminators and thereby avoid the necessity
-   of running ldd, but unfortunately the options are different for
-   the two linkers.  */
-#define LDD_SUFFIX "/usr/ccs/bin/ldd"
-
-/* Skip to first '>' then advance to '/' at the beginning of the filename.  */
-#define PARSE_LDD_OUTPUT(PTR)					\
-do {								\
-  while (*PTR != '>') PTR++;					\
-  while (*PTR != '/') PTR++;					\
-} while (0)
+   We could use ldd for this but it depends on LD_LIBRARY_PATH being
+   correctly set.  So, we use the ld init and fini switches. However,
+   we need to support different switches for the GNU and HP linkers.
+   We can't check TARGET_GNU_LD in collect2, so we need a different
+   test.  The +Accept switch is always the first switch when we are
+   using the HP linker (see define for LINK_SPEC).  Checking for it
+   is a somewhat fragile as it depends on internal details of the
+   collect2 program but it is better than testing ld_file_name.
+
+   FIXME: The GNU linker is broken.  The -init/-fini switches don't
+   work and ldd can't determine the dynamic dependences of executables
+   linked with GNU ld.  The init and fini routines are not executed
+   although DT_INIT and DT_FINI appear ok.  As a result, defining
+   LD_INIT_SWITCH and LD_FINI_SWITCH causes more harm than good when
+   using GNU ld.  However, the definitions appear to work fine with
+   the HP linker.  */
+#if 0
+#define LD_INIT_SWITCH (strcmp ("+Accept", ld2_argv[1]) ? "-init" : "+init")
+#define LD_FINI_SWITCH (strcmp ("+Accept", ld2_argv[1]) ? "-fini" : "+fini")
+#endif
 
 /* If using HP ld do not call pxdb.  Use size as a program that does nothing
    and returns 0.  /bin/true cannot be used because it is a script without


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