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]

[gomp] Fix -fopenmp -static


Hi!

As reported in http://www.openmp.org/pipermail/omp/2006/000435.html
-static -fopenmp doesn't work, as -lgomp -lrt (in Linux case) comes
before the user objects.  Say gcc -static -fopenmp -v -o a a.c results in:
/usr/libexec/gcc/x86_64-redhat-linux/4.1.0/collect2 -m elf_x86_64 -static \
-o a /usr/lib/gcc/x86_64-redhat-linux/4.1.0/../../../../lib64/crt1.o \
/usr/lib/gcc/x86_64-redhat-linux/4.1.0/../../../../lib64/crti.o \
/usr/lib/gcc/x86_64-redhat-linux/4.1.0/crtbeginT.o -lgomp -lrt \
-L/usr/lib/gcc/x86_64-redhat-linux/4.1.0 -L/usr/lib/gcc/x86_64-redhat-linux/4.1.0 \
-L/usr/lib/gcc/x86_64-redhat-linux/4.1.0/../../../../lib64 -L/lib/../lib64 \
-L/usr/lib/../lib64 /tmp/cckutU0e.o --start-group -lgcc -lgcc_eh -lpthread \
-lc --end-group /usr/lib/gcc/x86_64-redhat-linux/4.1.0/crtend.o \
/usr/lib/gcc/x86_64-redhat-linux/4.1.0/../../../../lib64/crtn.o
(that's on redhat/gcc-4_1-branch, but trunk behaves exactly the same).
The following patch moves %(link_gomp) later into LINK_COMMAND_SPEC,
so in the above example -lgomp -lrt comes in between /tmp/cckutU0e.o
and --start-group.  Ok for trunk?

2006-04-10  Jakub Jelinek  <jakub@redhat.com>

	* gcc.c (LINK_COMMAND_SPEC): Move link_gomp after %o.

--- gcc/gcc.c.jj	2006-01-31 13:52:32.000000000 +0100
+++ gcc/gcc.c	2006-04-10 13:36:15.000000000 +0200
@@ -698,8 +698,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) %o\
+    %{fopenmp:%:include(libgomp.spec)%(link_gomp)} %(mflib)\
     %{fprofile-arcs|fprofile-generate|coverage:-lgcov}\
     %{!nostdlib:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}\
     %{!A:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} }}}}}}"

	Jakub


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