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]

[committed] Fix linking of static openmp applications on hppa*-hp-hpux11*


Attempting to link an openmp as a static executable currently fails
on hppa*-hp-hpux11* because librt is not included in the link.  librt
is only available as a shared object, so it's technically not possible
to build a completely static openmp application.  However, it is still
useful to minimize the number of shared libraries when debugging openmp
applications.

There are also link order issues with libpthread and libc, so I decided
to handle this case in LIB_SPEC.

Tested on hppa2.0w-hp-hpux11.11 and hppa64-hp-hpux11.11.  Committed to trunk.

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

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

	* pa64-hpux.h (LIB_SPEC): Link against librt when building static
	openmp applications.
	* pa-hpux11.h (LIB_SPEC): Likewise.

Index: config/pa/pa64-hpux.h
===================================================================
--- config/pa/pa64-hpux.h	(revision 139820)
+++ config/pa/pa64-hpux.h	(working copy)
@@ -57,25 +57,35 @@
 #if ((TARGET_DEFAULT | TARGET_CPU_DEFAULT) & MASK_GNU_LD)
 #define LIB_SPEC \
   "%{!shared:\
-     %{!p:%{!pg: %{static|mt|pthread:-lpthread} -lc\
+     %{!p:%{!pg:%{static|mt|pthread:%{fopenmp:%{static:-a shared} -lrt\
+		  %{static:-a archive}} -lpthread} -lc\
 	    %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}\
      %{p:%{!pg:%{static:%{!mhp-ld:-a shared}%{mhp-ld:-a archive_shared}}\
-	   -lprof %{static:-a archive} %{static|mt|pthread:-lpthread} -lc\
+	   -lprof %{static:-a archive}\
+	   %{static|mt|pthread:%{fopenmp:%{static:-a shared} -lrt\
+	     %{static:-a archive}} -lpthread} -lc\
 	   %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}\
      %{pg:%{static:%{!mhp-ld:-a shared}%{mhp-ld:-a archive_shared}}\
-       -lgprof %{static:-a archive} %{static|mt|pthread:-lpthread} -lc\
+       -lgprof %{static:-a archive}\
+       %{static|mt|pthread:%{fopenmp:%{static:-a shared} -lrt\
+	 %{static:-a archive}} -lpthread} -lc\
        %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}\
    %{shared:%{mt|pthread:-lpthread}}"
 #else
 #define LIB_SPEC \
   "%{!shared:\
-     %{!p:%{!pg: %{static|mt|pthread:-lpthread} -lc\
+     %{!p:%{!pg:%{static|mt|pthread:%{fopenmp:%{static:-a shared} -lrt\
+		  %{static:-a archive}} -lpthread} -lc\
 	    %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}\
      %{p:%{!pg:%{static:%{mgnu-ld:-a shared}%{!mgnu-ld:-a archive_shared}}\
-	   -lprof %{static:-a archive} %{static|mt|pthread:-lpthread} -lc\
+	   -lprof %{static:-a archive}\
+	   %{static|mt|pthread:%{fopenmp:%{static:-a shared} -lrt\
+	     %{static:-a archive}} -lpthread} -lc\
 	   %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}\
      %{pg:%{static:%{mgnu-ld:-a shared}%{!mgnu-ld:-a archive_shared}}\
-       -lgprof %{static:-a archive} %{static|mt|pthread:-lpthread} -lc\
+       -lgprof %{static:-a archive}\
+       %{static|mt|pthread:%{fopenmp:%{static:-a shared} -lrt\
+	 %{static:-a archive}} -lpthread} -lc\
        %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}\
    %{shared:%{mt|pthread:-lpthread}}"
 #endif
Index: config/pa/pa-hpux11.h
===================================================================
--- config/pa/pa-hpux11.h	(revision 139820)
+++ config/pa/pa-hpux11.h	(working copy)
@@ -122,8 +122,9 @@
 #undef LIB_SPEC
 #define LIB_SPEC \
   "%{!shared:\
-     %{mt|pthread:-lpthread} -lc \
-     %{static:%{!nolibdld:-a shared -ldld -a archive -lpthread -lc}}}\
+     %{static|mt|pthread:%{fopenmp:%{static:-a archive_shared} -lrt\
+       %{static:-a archive}} -lpthread} -lc\
+     %{static:%{!nolibdld:-a archive_shared -ldld -a archive -lc}}}\
    %{shared:%{mt|pthread:-lpthread}}"
 
 #undef STARTFILE_SPEC


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