libtool-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Make -Wc,foo behave like -Xcompiler foo in link mode.


From: Peter Rosin
Subject: Make -Wc,foo behave like -Xcompiler foo in link mode.
Date: Fri, 04 Sep 2009 12:38:48 +0200
User-agent: Thunderbird 2.0.0.23 (Windows/20090812)

Hello!

I noticed something that appears strange:

$ echo "int main(void) { return 0; }" > foo.c
$ ./libtool --tag=CC   --mode=compile gcc -o foo.lo -c foo.c
libtool: compile:  gcc -c foo.c  -DDLL_EXPORT -DPIC -o .libs/foo.o
libtool: compile:  gcc -c foo.c -o foo.o >/dev/null 2>&1
$ ./libtool --tag=CC   --mode=link gcc -o foo foo.lo
libtool: link: gcc -o .libs/foo .libs/foo.o

The above went fine, now try to pass a silly arg (-time) to gcc:

$ ./libtool --tag=CC   --mode=link gcc -time -o foo foo.lo
libtool: link: gcc -time -o .libs/foo .libs/foo.o

Fine, gcc didn't complain. So pass -time with -Xcompiler instead:

$ ./libtool --tag=CC   --mode=link gcc -Xcompiler -time -o foo foo.lo
libtool: link: gcc -time -o .libs/foo .libs/foo.o

As expected. So try to pass -time with -Wc, instead:

$ ./libtool --tag=CC   --mode=link gcc -Wc,-time -o foo foo.lo
libtool: link: gcc -Wl,-time -o .libs/foo .libs/foo.o
c:/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: bad 
-rpath option
collect2: ld returned 1 exit status

Crash boom bang. How did -Wl end up in there?

Excerpt from "./libtool --mode=link --help":

  -weak LIBNAME     declare that the target provides the LIBNAME interface
  -Wc,FLAG
  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
  -Wl,FLAG
  -Xlinker FLAG     pass linker-specific FLAG directly to the linker

I interpret that as: -Wc,FLAG is equivalent to -Xcompiler FLAG but
distinctly different from what -Wl,FLAG is doing in gcc.

So, proposing this patch:

2009-09-04  Peter Rosin  <address@hidden>

        Make -Wc,foo behave like -Xcompiler foo in link mode.
        * libltdl/config/ltmain.m4sh (func_mode_link): Remove "-Wc,"
        instead of replacing it with "$wl".


Cheers,
Peter
diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh
index 9e4cfdb..4633ff2 100644
--- a/libltdl/config/ltmain.m4sh
+++ b/libltdl/config/ltmain.m4sh
@@ -4299,7 +4299,7 @@ func_mode_link ()
        for flag in $args; do
          IFS="$save_ifs"
           func_quote_for_eval "$flag"
-         arg="$arg $wl$func_quote_for_eval_result"
+         arg="$arg $func_quote_for_eval_result"
          compiler_flags="$compiler_flags $func_quote_for_eval_result"
        done
        IFS="$save_ifs"

reply via email to

[Prev in Thread] Current Thread [Next in Thread]