bug-libtool
[Top][All Lists]
Advanced

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

possible bug in libtool


From: Andrei Dorofeev
Subject: possible bug in libtool
Date: Tue, 27 Nov 2001 15:16:29 -0800 (PST)

Hi,

I was trying to compile the latest version of libxml2 which uses libtool,
and found one interesting problem in libtool which causes it to fail.
First of all, I am using Sun's 6.1 C compiler and standard Solaris linker
(/usr/ccs/bin/ld).

Among the CFLAGS that I use to build 64-bit version of libxml2 I am using
"-Wc,-Qiselect-regsym=0" option to disable register symbols (used to
detect conflicts between objects that use global registers).  When libtool
gets invoked with this option, it magically changes "-Wc" to "-Wl" and
passes the "-Qiselect-regsym=0" directly to linker instead of code
generator causing it to fail.

I don't understand the reason why libtool needs to do anything with "-Wc"
at all, because this option is very platform-specific and most of its
arguments aren't even documented.  The syntax is also different between
cc and gcc; for example Sun'c cc accepts more than just -Wl and -Wc.

     [from cc(1)]

     -Wc,arg
          Passes the argument arg to c.  Each  argument  must  be
          separated from the preceding by only a comma.  (A comma
          can be part of an argument by escaping it by an immedi-
          ately  preceding backslash (\) character; the backslash
          is removed from the resulting argument.)  All -W  argu-
          ments  are  passed after the regular command-line argu-
          ments.

          c can be one of the following:

               a    assembler: (fbe) (gas)
               c    C code generator: (cg)(SPARC), (codegen)(x86)
               l    link editor (ld)
               m    mcs
               p    preprocessor (cpp)
               0    compiler (acomp and ssbd)
               2    optimizer: (iropt) (SPARC); intermediate code
                    translator: (cg386) (x86)

while GNU cc only seems to accept -Wl:

     [from gcc(1)]

     -Wl,option
          Pass option as an option to the linker.  If option con-
          tains  commas, it is split into multiple options at the
          commas.

I think libtool should not do anything special with "-W?,*" type of
options and simply pass them directly to the compiler.

Regardless of that, the following piece of code from libtool seems
to suffer from advanced cut-n-pasting technology:

      -Wc,*)
        args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'`
        arg=
        IFS="${IFS=     }"; save_ifs="$IFS"; IFS=','
        for flag in $args; do
          IFS="$save_ifs"
          case $flag in
            *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \       ]*|*]*|"")
            flag="\"$flag\""
            ;;
          esac
(1) ->    arg="$arg $wl$flag"
          compiler_flags="$compiler_flags $flag"
        done
        IFS="$save_ifs"
        arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
        ;;

      -Wl,*)
        args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'`
        arg=
        IFS="${IFS=     }"; save_ifs="$IFS"; IFS=','
        for flag in $args; do
          IFS="$save_ifs"
          case $flag in
            *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \       ]*|*]*|"")
            flag="\"$flag\""
            ;;
          esac
(2) ->    arg="$arg $wl$flag"
          compiler_flags="$compiler_flags $wl$flag"
          linker_flags="$linker_flags $flag"
        done
        IFS="$save_ifs"
        arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
        ;;

Both (1) and (2) are using $wl string (set to "-Wl" in the beginning of
libtool) which causes "-Wc,foo" being converted to "-Wl,foo" as in the
following example:

 /bin/sh ./libtool --mode=link /opt/SUNWspro/SC6.1/bin/cc  -xO3
 -xarch=v9 -dalign   -Wc,-Qiselect-regsym=0 -xspace -W0,-Lt -Xa  -xildoff
                     ~~~~
 -xregs=no%appl -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -z defs -z text -z
 combreloc -o xmllint  xmllint.o ./libxml2.la -lpthread -lz -L/lib -lm -lsocket
 -lnsl

 /opt/SUNWspro/SC6.1/bin/cc -xO3 -xarch=v9 -dalign
 -Wl,-Qiselect-regsym=0 -xspace -W0,-Lt -Xa -xildoff -xregs=no%appl
 ~~~~
 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -z defs -z text -z combreloc -o
 .libs/xmllint xmllint.o  ./.libs/libxml2.so -L/lib -lpthread -lz -lm -lsocket
 -lnsl
 ld: fatal: option -Q has illegal argument `iselect-regsym=0'
 ld: fatal: Flags processing errors
 *** Error code 1
 make: Fatal error: Command failed for target `xmllint'

Also, since "-Wc,-Qiselect-regsym=0" is intended to be an option for cg, not
cc, I get warnings from cc every time libtool passes "-Qiselect-regsym=0":

/bin/sh ./libtool --mode=compile /opt/SUNWspro/SC6.1/bin/cc
-DHAVE_CONFIG_H -I. -I. -I. -I./include -I./include  -D_REENTRANT  -I/include
-xO3 -xarch=v9 -dalign   -Wc,-Qiselect-regsym=0 -xspace -W0,-Lt -Xa  -xildoff
-xregs=no%appl -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -c xmlIO.c
rm -f .libs/xmlIO.lo
/opt/SUNWspro/SC6.1/bin/cc -DHAVE_CONFIG_H -I. -I. -I. -I./include
-I./include -D_REENTRANT -I/include -xO3 -xarch=v9 -Qiselect-regsym=0 -dalign
-xspace -W0,-Lt -Xa -xildoff -xregs=no%appl -D_FILE_OFFSET_BITS=64
-D_LARGEFILE_SOURCE -c xmlIO.c  -KPIC -DPIC -o xmlIO.o
cc: Warning: illegal option -Qiselect-regsym=0                  <--- *

Any comments?

- Andrei




reply via email to

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