when linking on Solaris 64bit shared object using cc, -m64 should be used

Petr Sumbera <[email protected]>
Newsgroups gmane.comp.gnu.libtool.patches
Message-ID <[email protected]>
Hi,

I'm often getting following error:

/usr/apr/1.5/build/sparcv9/libtool --silent --mode=link cc -o 
mod_dtrace.la
-rpath /usr/apache2/2.2/libexec/sparcv9 -module -avoid-version
mod_dtrace.lo
ld: fatal: file .libs/mod_dtrace.o: wrong ELF class: ELFCLASS64
apxs:Error: Command failed with rc=131072

Attached patch fixes the issue.

Note that I'm not libtool expert. Any feedback is welcomed.

Thanks,

Petr
libtool.m4.patch (text/plain, 2.2 KB)
--- build/libtool.m4
+++ build/libtool.m4
@@ -5432,11 +5445,16 @@
 
     solaris*)
       _LT_TAGVAR(no_undefined_flag, $1)=' -z defs'
+      for i in $LTCFLAGS; do
+        case $i in
+          -m32|-m64) _LT_TAGVAR(addressing_model, $1)="$i";;
+        esac
+      done
       if test "$GCC" = yes; then
 	wlarc='${wl}'
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_cmds, $1)='$CC ${addressing_model} -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
 	_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+	  $CC ${addressing_model} -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
       else
 	case `$CC -V 2>&1` in
 	*"Compilers 5.0"*)
@@ -5447,9 +5465,9 @@
 	  ;;
 	*)
 	  wlarc='${wl}'
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC ${addressing_model} -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
 	  _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+	  $CC ${addressing_model} -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
 	  ;;
 	esac
       fi
@@ -5719,6 +5737,8 @@
     [Commands necessary for finishing linking programs])
 _LT_TAGDECL([], [file_list_spec], [1],
     [Specify filename containing input files])
+_LT_TAGDECL([], [addressing_model], [1],
+    [Set 32-bit or 64-bit addressing model])
 dnl FIXME: Not yet implemented
 dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1],
 dnl    [Compiler flag to generate thread safe objects])
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.