On Fri, Apr 14, 2000 at 08:57:12AM -0300, Alexandre Oliva wrote:
> On Apr 14, 2000, Jakub Jelinek <[EMAIL PROTECTED]> wrote:
> 
> > The following patch tries to solve it partly by using double quotes arround
> > $(*LD) argument to ltconfig, so that ltconfig takes the whole
> > gcc -m32
> > or whatever as one argument.
> 
> This won't do The Right Thing (TM) in general.  On many platforms,
> libtool bypasses the compiler at link time, so you lose.  The right
> solution is to use the multi-language libtool, that records which
> compiler(s) you're using (including -B and -m switches, if present in
> CC when libtool is configured), and uses them or the corresponding
> options at link time.
> 
> Meanwhile, the closer you can get to being right is to ``quote'' any
> compiler flags with libtool's `-Xcompiler' (or `-Wc,') flag.

Ok, what about this libtool patch?
ltconfig records for gcc any options from gcc -print-multi-lib and if it
sees them during --mode link, it passes them into compiler_flags (and thus
into gcc -shared options). In addition to this, it handles -B, -b and -V gcc
options.

2000-04-27  Jakub Jelinek  <[EMAIL PROTECTED]>

        * ltconfig.in (extra_compiler_flags, extra_compiler_flags_value):
        New variables. Set for gcc using -print-multi-lib. Export them
        to libtool.
        (sparc64-*-linux-gnu*): Use libsuff 64 for search paths.
        * ltmain.in (B|b|V): Don't throw away gcc's -B, -b and -V options
        for -shared links.
        (extra_compiler_flags_value, extra_compiler_flags): Check these
        for extra compiler options which need to be passed down in
        compiler_flags.

--- libtool/ltmain.in.jj        Mon Apr 10 20:39:30 2000
+++ libtool/ltmain.in   Thu Apr 27 14:47:48 2000
@@ -923,6 +923,13 @@ compiler."
          finalize_command="$finalize_command $wl$qarg"
          continue
          ;;
+       B|b|V)
+         compiler_flags="$compiler_flags -$prev$qarg"
+         prev=
+         compile_command="$compile_command -$prev$qarg"
+         finalize_command="$finalize_command -$prev$qarg"
+         continue
+         ;;
        *)
          eval "$prev=\"\$arg\""
          prev=
@@ -1166,6 +1173,17 @@ compiler."
 
       # Some other compiler flag.
       -* | +*)
+       if test "X$extra_compiler_flags_value" != "X"; then
+           is_extra_compiler_flag=
+           eval "case \"\$arg\" in \
+             $extra_compiler_flags_value) \
+               is_extra_compiler_flag=yes ;; \
+             esac"
+           if test "$is_extra_compiler_flag"; then
+             prev=`echo "X$arg" | $Xsed -e 's/^-//'`
+             continue
+           fi
+       fi
        # Unknown arguments in both finalize_command and compile_command need
        # to be aesthetically quoted because they are evaled later.
        arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
@@ -1174,6 +1192,16 @@ compiler."
          arg="\"$arg\""
          ;;
        esac
+       if test "X$extra_compiler_flags" != "X"; then
+           is_extra_compiler_flag=
+           eval "case \"\$arg\" in \
+             $extra_compiler_flags) \
+               is_extra_compiler_flag=yes ;; \
+             esac"
+           if test "$is_extra_compiler_flag"; then
+             compiler_flags="$compiler_flags $arg"
+           fi
+       fi
        ;;
 
       *.$objext)
--- libtool/ltconfig.in.jj      Mon Apr 10 20:39:30 2000
+++ libtool/ltconfig.in Thu Apr 27 16:00:03 2000
@@ -910,6 +910,29 @@ if test "$with_gcc" = yes; then
 
 fi
 
+extra_compiler_flags=
+extra_compiler_flags_value=
+if test "$with_gcc" = yes; then
+  extra_compiler_flags_value="-B|-b|-V"
+  extra_compiler_flags="-B*|-b*|-V*"
+  # Check to see what are the possible multilibing options
+  echo $ac_n "checking what multilib options $compiler supports ... $ac_c" 1>&6
+  multilibopts=
+  if ${CC-cc} -print-multi-lib >/dev/null 2>&1; then
+    for dir in `${CC-cc} -print-multi-lib 2>/dev/null`; do
+      multilibopts="$multilibopts`echo $dir | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`"
+    done
+  fi
+  # Kill any whitespace at the beginning and end
+  multilibopts=`echo $multilibopts`
+  if test -n "$multilibopts"; then
+    extra_compiler_flags="$extra_compiler_flags`echo $multilibopts | sed -e 's/ 
+-/|-/g' -e 's/^-/|-/'`"
+    echo "$ac_t$multilibopts" 1>&6
+  else
+    echo "$ac_t"none 1>&6
+  fi
+fi
+
 # See if the linker supports building shared libraries.
 echo $ac_n "checking whether the linker ($LD) supports shared libraries... $ac_c" 1>&6
 
@@ -1666,6 +1689,13 @@ linux-gnu*)
     *) dynamic_linker='Linux ld.so' ;;
     esac
   fi
+  case "$host_cpu" in
+  sparc64)
+    libsuff=64
+    sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} 
+/usr/local/lib${libsuff}"
+    sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff}"
+    ;;
+  esac
   ;;
 
 netbsd*)
@@ -2490,7 +2520,8 @@ case "$ltmain" in
     finish_cmds finish_eval global_symbol_pipe global_symbol_to_cdecl \
     hardcode_libdir_flag_spec hardcode_libdir_separator  \
     sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
-    compiler_c_o compiler_o_lo need_locks exclude_expsyms include_expsyms; do
+    compiler_c_o compiler_o_lo need_locks exclude_expsyms include_expsyms \
+    extra_compiler_flags extra_compiler_flags_value; do
 
     case "$var" in
     reload_cmds | old_archive_cmds | old_archive_from_new_cmds | \
@@ -2738,6 +2769,10 @@ archive_cmds=$archive_cmds
 archive_expsym_cmds=$archive_expsym_cmds
 postinstall_cmds=$postinstall_cmds
 postuninstall_cmds=$postuninstall_cmds
+
+# Case patterns for extra compiler flags needed for linking
+extra_compiler_flags=$extra_compiler_flags
+extra_compiler_flags_value=$extra_compiler_flags_value
 
 # Commands to strip libraries.
 old_striplib=$old_striplib


        Jakub

Reply via email to