Subject: libtool parse of nagfor -Wl,-Wl,, gives incorrect result

From: Thomas Jahns <[email-masked]>
Date: Wed, 29 Aug 2012 13:56:10 +0200

Hello,

I'm using an MPI library for nagfor that has the -rpath already correctly hidden
inside $wl, unfortunately since it starts with the same letters as the
corresponding libtool option, I'm getting erroneous results:

excerpt from make output:
============8<=======================================================================
/bin/bash ../libtool --tag=FC   --mode=link nagfor    -g -o show_ieee_emulation
show_ieee_emulation.o ../src/libtestdata.la ../src/libscalesppm.la
-I/home/tjahns/opt/mpich2-1.4.1-nag52-i386-linux/include
-I/home/tjahns/opt/parmetis-3.1.1-mpich2-1.4.1-nag52-i386-linux/include
-L/sw/etch-ia32/netcdf-3.6.2-nag/lib -lnetcdf
-Wl,-Wl,,-rpath,,/home/tjahns/opt/mpich2-1.4.1-nag52-i386-linux/lib
-I/home/tjahns/opt/mpich2-1.4.1-nag52-i386-linux/include
-I/home/tjahns/opt/mpich2-1.4.1-nag52-i386-linux/include
-L/home/tjahns/opt/mpich2-1.4.1-nag52-i386-linux/lib -lmpichf90 -lmpichf90
-lmpich -lopa -lmpl -lrt -lpthread  -lcrypto
libtool: link: nagfor -g -o .libs/show_ieee_emulation show_ieee_emulation.o
-I/home/tjahns/opt/mpich2-1.4.1-nag52-i386-linux/include
-I/home/tjahns/opt/parmetis-3.1.1-mpich2-1.4.1-nag52-i386-linux/include
-Wl,-Wl,,-Wl -Wl,-Wl,,"" -Wl,-Wl,,-rpath -Wl,-Wl,,""
-Wl,-Wl,,/home/tjahns/opt/mpich2-1.4.1-nag52-i386-linux/lib
-I/home/tjahns/opt/mpich2-1.4.1-nag52-i386-linux/include
-I/home/tjahns/opt/mpich2-1.4.1-nag52-i386-linux/include
../src/.libs/libtestdata.a ../src/.libs/libscalesppm.so
-L/sw/etch-ia32/netcdf-3.6.2-nag/lib
/sw/etch-ia32/netcdf-3.6.2-nag/lib/libnetcdf.a
-L/home/tjahns/opt/mpich2-1.4.1-nag52-i386-linux/lib -lmpichf90 -lmpich
/home/tjahns/opt/mpich2-1.4.1-nag52-i386-linux/lib/libopa.so
/home/tjahns/opt/mpich2-1.4.1-nag52-i386-linux/lib/libmpl.so -lrt -lpthread
-lcrypto -Wl,-Wl,,-rpath
-Wl,-Wl,,/home/tjahns/opt/scales-ppm-0.0.1-i386-linux-nag52-mpich2-1.4.1-noomp/lib
-Wl,-Wl,,-rpath -Wl,-Wl,,/home/tjahns/opt/mpich2-1.4.1-nag52-i386-linux/lib
============8<=======================================================================

Thus in this example

-Wl,-Wl,,-rpath,,/home/tjahns/opt/mpich2-1.4.1-nag52-i386-linux/lib

is replaced with

-Wl,-Wl,,-Wl -Wl,-Wl,,"" -Wl,-Wl,,-rpath -Wl,-Wl,,""
-Wl,-Wl,,/home/tjahns/opt/mpich2-1.4.1-nag52-i386-linux/lib

I'm not sure of the best way to address this unfortunate coincidence of compiler
and libtool flags. My, perhaps naïve, idea would be to test whether an argument
starting with -Wl, also matches $wl and, in case $wl does not equal "-Wl," pass
the flag argument on to the linker unaltered.

I'm using libtool 2.4.2 and nagfor 5.2.721. I can provide further information on
the software environment if desired.

Regards, Thomas Jahns
-- 
Thomas Jahns
DKRZ GmbH, Department: Application software

Deutsches Klimarechenzentrum
Bundesstraße 45a
D-20146 Hamburg

Phone: +49-40-460094-151
Fax: +49-40-460094-270
Email: Thomas Jahns <[email-masked]>