This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: PATCH: LDFLAGS handling in V3
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: Mark Mitchell <mark at codesourcery dot com>
- Cc: libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Tue, 04 Oct 2005 17:03:09 -0300
- Subject: Re: PATCH: LDFLAGS handling in V3
- References: <200507272135.j6RLZHH2024117@sethra.codesourcery.com><or8xzrgaze.fsf@livre.redhat.lsd.ic.unicamp.br><42E806F0.4050704@codesourcery.com><42E81D58.5000108@codesourcery.com><or64uuai3x.fsf@livre.redhat.lsd.ic.unicamp.br><42E927F8.2090004@codesourcery.com><orpst29142.fsf@livre.redhat.lsd.ic.unicamp.br><42E98339.2070803@codesourcery.com><42E9AD58.5020809@codesourcery.com>
On Jul 29, 2005, Mark Mitchell <mark@codesourcery.com> wrote:
> 2005-07-28 Mark Mitchell <mark@codesourcery.com>
> * libtool-ldflags: New script.
> 2005-07-27 Mark Mitchell <mark@codesourcery.com>
> * src/Makefile.am (LTLDFLAGS): New variable.
> (CXXLINK): Use it.
> * libsupc++/Makefile.am (LLDFLAGS): New variable.
> (CXXLINK): Use it.
> * src/Makefile.in: Regenerated.
> * libsupc++/Makefile.in: Likewise.
Apologies for the huge delay. It does look good, but there are some
minor tweaks I have to suggest:
> Index: libtool-ldflags
> + for arg; do
This construct is not portable. To make it portable, some shells barf
at `for var;', but work fine if you replace the `;' with a line break.
> + # Quote the argument, using single quotes -- after replacing any
> + # embedded single quotes with:
[...]
> + quoted_arg="'`echo "$arg" | sed -e "$sed_script"`'"
I suggest only going through the quoting if you actually find any
single quotes in the argument, something like the snippet below.
Also, some shells match the quote right after the assignment operator
with the quote after the echo, and then complain about the unmatched
backtick.
Fortunately, you don't need the double quotes around the entire
assignment.
Also, beware echo commands that try to be smart and accept arguments
starting with `-'. Prepending something to $arg and removing that in
the sed script fixes that.
sed_script="1s,^X,,;s|'|'\"'\"'|g"
case $arg in
*"'"*) quoted_arg=`echo "X$arg" | sed -e "$sed_script"` ;;
*) quoted_arg=$arg ;;
esac
quoted_arg="'"$quoted_arg"'"
There's another solution that avoids adding single quotes to all
arguments, that involves using double quotes when any characters that
need quoting are preset. This is what libtool actually does, but I
don't know whether it would actually be advantageous in this case.
One thing that got me a bit confused is that you're quoting every
single argument with -Xcompiler here. Is this really what you mean?
This will render libtool unable to recognize some arguments that it is
supposed to handle itself; -Ldir, -lib, -static, -all-static, -rpath
dir and -Rdir come to mind. -rpath is probably the most difficult to
handle correctly, because you must not only leave itself alone, but
also the subsequent argument.
--
Alexandre Oliva http://www.lsd.ic.unicamp.br/~oliva/
Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org}