Patch: Fix libgomp linking on IA64 HP-UX

Steve Ellcey sje@cup.hp.com
Tue Mar 7 23:20:00 GMT 2006


Using -fopenmp does not work on ia64-hp-hpux11.23 because the HP linker
cannot find the gomp library.  Currently GCC generates the following
link line:

collect2 -z +Accept TypeMismatch -u main -o x -lgomp -L/proj/opensrc/sje/reg/gcc-ia64-hp-hpux11.23-trunk/lib/gcc/ia64-hp-hpux11.23/4.2.0 -L/usr/ccs/lib -L/proj/opensrc/sje/reg/gcc-ia64-hp-hpux11.23-trunk/lib/gcc/ia64-hp-hpux11.23/4.2.0/../../.. /var/tmp//cccVg0Zu.o -lgcc -lgcc_eh -lunwind -lpthread -lc -lgcc -lgcc_eh -lunwind

Notice that '-lgomp' comes before all the -L options.  This means that the
HP linker will not search any of those directories for libgomp.  With my
patch I now get:

collect2 -z +Accept TypeMismatch -u main -o x -L/proj/opensrc/sje/reg/gcc-ia64-hp-hpux11.23-trunk/lib/gcc/ia64-hp-hpux11.23/4.2.0 -L/usr/ccs/lib -L/proj/opensrc/sje/reg/gcc-ia64-hp-hpux11.23-trunk/lib/gcc/ia64-hp-hpux11.23/4.2.0/../../.. -lgomp /var/tmp//ccyHTwBs.o -lgcc -lgcc_eh -lunwind -lpthread -lc -lgcc -lgcc_eh -lunwind

The -lgomp now comes after the -L options and the linker can find
libgomp.

The change is to put -lgomp after %(link_libgcc) instead of before it.
Note that %(link_libgcc) does not generate the -lgcc entry, just the
-L flags that tell the linker where libgcc is.

Tested on ia64-hp-hpux11.23 with no regressions.

OK for checkin?

Steve Ellcey
sje@cup.hp.com



2006-03-07  Steve Ellcey  <sje@cup.hp.com>

	* gcc.c (LINK_COMMAND_SPEC): Change ordering.


Index: gcc.c
===================================================================
--- gcc.c	(revision 111807)
+++ gcc.c	(working copy)
@@ -703,8 +703,8 @@ proper position among the other output f
 %{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\
     %(linker) %l " LINK_PIE_SPEC "%X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r}\
     %{s} %{t} %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}}\
-    %{static:} %{L*} %(mfwrap) %{fopenmp:%:include(libgomp.spec)%(link_gomp)}\
-    %(link_libgcc) %o %(mflib)\
+    %{static:} %{L*} %(mfwrap) %(link_libgcc)\
+    %{fopenmp:%:include(libgomp.spec)%(link_gomp)} %o %(mflib)\
     %{fprofile-arcs|fprofile-generate|coverage:-lgcov}\
     %{!nostdlib:%{!nodefaultlibs:%(link_gcc_math) %(link_ssp) %(link_gcc_c_sequence)}}\
     %{!A:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} }}}}}}"



More information about the Gcc-patches mailing list